package cn.huge.module.ctuser.controller.wechat;
|
|
import cn.huge.base.common.utils.ReturnFailUtils;
|
import cn.huge.base.common.utils.ReturnSucUtils;
|
import cn.huge.module.ctuser.domain.po.CtUnit;
|
import cn.huge.module.ctuser.service.CtUnitService;
|
import cn.huge.module.ctuser.service.CtUserService;
|
import com.google.common.collect.Lists;
|
import com.google.common.collect.Maps;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.Sort;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @title: 客户组织信息表接口api-微服务调用
|
* @description: 客户组织信息表接口api-微服务调用
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2024-08-19 20:04:19
|
* @version: 1.0.0
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/api/wechat/ctUnit")
|
public class CtUnitWechatController {
|
|
@Autowired(required = false)
|
private HttpServletRequest request;
|
|
@Autowired
|
private CtUnitService service;
|
|
/**
|
* 获取请求URL参数
|
* @return Map<String, Object>
|
*/
|
private Map<String, Object> getParameter() {
|
Map<String, Object> terms = Maps.newHashMap();
|
String keyword = request.getParameter("keyword");
|
if (StringUtils.isNotBlank(keyword)){
|
terms.put("keyword", keyword);
|
}
|
// 组织地址省
|
String prov = request.getParameter("prov");
|
if (StringUtils.isNotBlank(prov)){
|
terms.put("prov", prov);
|
}
|
// 组织地址省名称
|
String provName = request.getParameter("provName");
|
if (StringUtils.isNotBlank(provName)){
|
terms.put("provName", provName);
|
}
|
// 组织地址市
|
String city = request.getParameter("city");
|
if (StringUtils.isNotBlank(city)){
|
terms.put("city", city);
|
}
|
// 组织地址市名称
|
String cityName = request.getParameter("cityName");
|
if (StringUtils.isNotBlank(cityName)){
|
terms.put("cityName", cityName);
|
}
|
// 组织地址区
|
String area = request.getParameter("area");
|
if (StringUtils.isNotBlank(area)){
|
terms.put("area", area);
|
}
|
// 组织地址区名称
|
String areaName = request.getParameter("areaName");
|
if (StringUtils.isNotBlank(areaName)){
|
terms.put("areaName", areaName);
|
}
|
// 组织地址街道
|
String road = request.getParameter("road");
|
if (StringUtils.isNotBlank(road)){
|
terms.put("road", road);
|
}
|
// 组织地址街道名称
|
String roadName = request.getParameter("roadName");
|
if (StringUtils.isNotBlank(roadName)){
|
terms.put("roadName", roadName);
|
}
|
// 组织地址社区
|
String village = request.getParameter("village");
|
if (StringUtils.isNotBlank(village)){
|
terms.put("village", village);
|
}
|
// 组织地址社区名称
|
String villageName = request.getParameter("villageName");
|
if (StringUtils.isNotBlank(villageName)){
|
terms.put("villageName", villageName);
|
}
|
return terms;
|
}
|
|
/**
|
* 统计机构数量
|
* @url {ctx}/api/wechat/ctUnit/countUnit
|
* @return Object
|
*/
|
@GetMapping("/countUnit")
|
public Object countUnit() {
|
try {
|
return ReturnSucUtils.getRepInfo(service.wechatCountUnit());
|
} catch (Exception e) {
|
log.error("Controller接口[CtUnitWechatController.countUnit]请求异常:"+e, e);
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 综治中心查询
|
* @url {ctx}/api/wechat/ctUnit/pageZzQuery
|
* @return Object
|
*/
|
@GetMapping("/pageZzQuery")
|
public Object pageZzQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
|
try {
|
Map<String, Object> terms = getParameter();
|
terms.put("unitType",1);
|
Sort sort = Sort.by(Sort.Direction.DESC, "create_time");
|
PageRequest pageRequest = PageRequest.of(page-1, size, sort);
|
Page<CtUnit> ctUnitPage = service.pageQuery(pageRequest, terms);
|
return ReturnSucUtils.getRepInfo( "处理成功", ctUnitPage);
|
} catch (Exception e) {
|
log.error("Controller接口[CtUnitWechatController.pageZzQuery]请求异常:"+e, e);
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
|
/**
|
* 调解组织查询
|
* @url {ctx}/api/wechat/ctUnit/pageZzQuery
|
* @return Object
|
*/
|
@GetMapping("/pageTjQuery")
|
public Object pageTjQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
|
try {
|
Map<String, Object> terms = getParameter();
|
List<Integer> unitTypes = Arrays.asList(2,3,4,5);
|
terms.put("unitTypes",unitTypes);
|
Sort sort = Sort.by(Sort.Direction.DESC, "create_time");
|
PageRequest pageRequest = PageRequest.of(page-1, size, sort);
|
Page<CtUnit> ctUnitPage = service.pageQuery(pageRequest, terms);
|
return ReturnSucUtils.getRepInfo( "处理成功", ctUnitPage);
|
} catch (Exception e) {
|
log.error("Controller接口[CtUnitWechatController.pageTjQuery]请求异常:"+e, e);
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 组织详情
|
* @url {ctx}/api/wechat/ctUnit/getById
|
* @return Object
|
*/
|
@GetMapping("/getById")
|
public Object getById(@RequestParam(value = "id") String id) {
|
try {
|
return ReturnSucUtils.getRepInfo(service.getById(id));
|
} catch (Exception e) {
|
log.error("Controller接口[CtUnitWechatController.getById]请求异常:"+e, e);
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
}
|