package cn.huge.module.kind.controller.web;
|
|
import cn.huge.base.common.utils.ReturnFailUtils;
|
import cn.huge.base.common.utils.ReturnSucUtils;
|
import cn.huge.module.kind.domain.po.ThirdCause;
|
import cn.huge.module.kind.service.ThirdCauseService;
|
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.Map;
|
|
/**
|
* @title: 第三方纠纷类型映射表接口api-web端
|
* @description: 第三方纠纷类型映射表接口api-web端
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2024-09-09 14:31:22
|
* @version: 1.0.0
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/api/web/syCauseThird")
|
public class ThirdCauseWebController {
|
|
@Autowired(required = false)
|
private HttpServletRequest request;
|
|
@Autowired
|
private ThirdCauseService service;
|
|
/**
|
* 获取请求URL参数
|
* @return Map<String, Object>
|
*/
|
private Map<String, Object> getParameter(){
|
Map<String, Object> terms = Maps.newHashMap();
|
// 主键编号
|
String id = request.getParameter("id");
|
if (StringUtils.isNotBlank(id)){
|
terms.put("id", id);
|
}
|
// 第三方平台编号
|
String thirdSysId = request.getParameter("thirdSysId");
|
if (StringUtils.isNotBlank(thirdSysId)){
|
terms.put("thirdSysId", thirdSysId);
|
}
|
// 第三方平台名称
|
String thirdSysName = request.getParameter("thirdSysName");
|
if (StringUtils.isNotBlank(thirdSysName)){
|
terms.put("thirdSysName", thirdSysName);
|
}
|
// 第三方纠纷类型代码
|
String thirdCode = request.getParameter("thirdCode");
|
if (StringUtils.isNotBlank(thirdCode)){
|
terms.put("thirdCode", thirdCode);
|
}
|
// 第三方纠纷类型名称
|
String thirdName = request.getParameter("thirdName");
|
if (StringUtils.isNotBlank(thirdName)){
|
terms.put("thirdName", thirdName);
|
}
|
// 第三方纠纷类型父级代码
|
String thirdParentCode = request.getParameter("thirdParentCode");
|
if (StringUtils.isNotBlank(thirdParentCode)){
|
terms.put("thirdParentCode", thirdParentCode);
|
}
|
// 本平台纠纷类型代码
|
String causeCode = request.getParameter("causeCode");
|
if (StringUtils.isNotBlank(causeCode)){
|
terms.put("causeCode", causeCode);
|
}
|
// 层级
|
String level = request.getParameter("level");
|
if (StringUtils.isNotBlank(level)){
|
terms.put("level", level);
|
}
|
// 创建时间区间
|
String createStart = request.getParameter("createStart");
|
String createEnd = request.getParameter("createEnd");
|
if(StringUtils.isNotBlank(createStart) && StringUtils.isNotBlank(createEnd)) {
|
terms.put("createStart", createStart);
|
terms.put("createEnd", createEnd);
|
}
|
// 更新时间区间
|
String updateStart = request.getParameter("updateStart");
|
String updateEnd = request.getParameter("updateEnd");
|
if(StringUtils.isNotBlank(updateStart) && StringUtils.isNotBlank(updateEnd)) {
|
terms.put("updateStart", updateStart);
|
terms.put("updateEnd", updateEnd);
|
}
|
return terms;
|
}
|
|
/**
|
* 条件查询多个
|
* @url {ctx}/api/web/syCauseThird/listQuery
|
* @return Object
|
*/
|
@GetMapping("/listQuery")
|
public Object listQuery() {
|
try {
|
Map<String, Object> terms = getParameter();
|
return ReturnSucUtils.getRepInfo(service.listTerms(terms));
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 条件分页查询
|
* @url {ctx}/api/web/syCauseThird/pageQuery
|
* @param page 页码
|
* @param size 每页数量
|
* @return Object
|
*/
|
@GetMapping("/pageQuery")
|
public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
|
try {
|
Map<String, Object> terms = getParameter();
|
Sort sort = Sort.by(Sort.Direction.DESC, "create_time");
|
PageRequest pageRequest = PageRequest.of(page-1, size, sort);
|
Page<ThirdCause> syCauseThirdPage = service.pageQuery(pageRequest, terms);
|
return ReturnSucUtils.getRepInfo( "处理成功", syCauseThirdPage);
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 根据编号查询单个
|
* @url {ctx}/api/web/syCauseThird/getById
|
* @param id 主键编号
|
* @return Object
|
*/
|
@GetMapping("/getById")
|
public Object getById(@RequestParam(value = "id") String id) {
|
try {
|
return ReturnSucUtils.getRepInfo(service.getById(id));
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 根据主键单个
|
* @url {ctx}/api/web/syCauseThird/deleteById
|
* @param id 主键编号
|
* @return Object
|
*/
|
@GetMapping("/deleteById")
|
public Object deleteById(@RequestParam(value = "id") String id) {
|
try {
|
service.removeById(id);
|
return ReturnSucUtils.getRepInfo();
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 新增或更新对象
|
* @url {ctx}/api/web/syCauseThird/saveSyCauseThird
|
* @param thirdCause 实体对象
|
* @return Object
|
*/
|
@PostMapping("/saveSyCauseThird")
|
public Object saveSyCauseThird(@RequestBody ThirdCause thirdCause) {
|
try {
|
service.saveSyCauseThird(thirdCause);
|
return ReturnSucUtils.getRepInfo();
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
}
|