package cn.huge.module.knowledge.controller.web;
|
|
import cn.huge.base.common.utils.ReturnFailUtils;
|
import cn.huge.base.common.utils.ReturnSucUtils;
|
import cn.huge.module.knowledge.domain.po.CauseMapping;
|
import cn.huge.module.knowledge.service.CauseMappingService;
|
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: huangh
|
* @time: 2024年12月22日
|
* @version: 1.0.0
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/api/web/causeMapping")
|
public class CauseMappingWebController {
|
|
@Autowired(required = false)
|
private HttpServletRequest request;
|
|
@Autowired
|
private CauseMappingService service;
|
|
/**
|
* 获取请求URL参数
|
* @return Map<String, Object>
|
*/
|
private Map<String, Object> getParameter() {
|
Map<String, Object> terms = Maps.newHashMap();
|
|
// 映射表 ID
|
String causeMapId = request.getParameter("causeMapId");
|
if (StringUtils.isNotBlank(causeMapId)) {
|
terms.put("causeMapId", causeMapId);
|
}
|
|
// 裁判文书网案由信息表的案由 ID
|
String cpwsCauseId = request.getParameter("cpwsCauseId");
|
if (StringUtils.isNotBlank(cpwsCauseId)) {
|
terms.put("cpwsCauseId", cpwsCauseId);
|
}
|
|
// 业务系统案由表的案由标识符
|
String dyhCauseId = request.getParameter("dyhCauseId");
|
if (StringUtils.isNotBlank(dyhCauseId)) {
|
terms.put("dyhCauseId", dyhCauseId);
|
}
|
|
// 创建时间区间
|
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/causeMapping/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/causeMapping/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<CauseMapping> causeMappingPage = service.pageQuery(pageRequest, terms);
|
return ReturnSucUtils.getRepInfo("处理成功", causeMappingPage);
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 根据编号查询单个
|
* @url {ctx}/api/web/causeMapping/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/causeMapping/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/causeMapping/saveCauseMapping
|
* @param causeMapping 实体对象
|
* @return Object
|
*/
|
@PostMapping("/saveCauseMapping")
|
public Object saveCauseMapping(@RequestBody CauseMapping causeMapping) {
|
try {
|
service.saveCauseMapping(causeMapping);
|
return ReturnSucUtils.getRepInfo();
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
}
|