package cn.huge.module.flow.controller.web;
|
|
import cn.huge.base.common.utils.ReturnFailUtils;
|
import cn.huge.base.common.utils.ReturnSucUtils;
|
import cn.huge.module.flow.domain.po.FlowInfo;
|
import cn.huge.module.flow.service.FlowInfoService;
|
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;
|
import java.util.stream.Collectors;
|
import java.util.stream.Stream;
|
|
/**
|
* @title: 业务流程信息表接口api-web端
|
* @description: 业务流程信息表接口api-web端
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2024-09-06 15:50:06
|
* @version: 1.0.0
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/api/web/flowInfo")
|
public class FlowInfoWebController {
|
|
@Autowired(required = false)
|
private HttpServletRequest request;
|
|
@Autowired
|
private FlowInfoService 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 flowableId = request.getParameter("flowableId");
|
if (StringUtils.isNotBlank(flowableId)){
|
terms.put("flowableId", flowableId);
|
}
|
// 工作流流程名称
|
String flowableName = request.getParameter("flowableName");
|
if (StringUtils.isNotBlank(flowableName)){
|
terms.put("flowableName", flowableName);
|
}
|
// 流程类型,1:主流程
|
String flowType = request.getParameter("flowType");
|
if (StringUtils.isNotBlank(flowType)){
|
terms.put("flowType", flowType);
|
}
|
// 调解类型
|
String mediType = request.getParameter("mediType");
|
if (StringUtils.isNotBlank(mediType)){
|
terms.put("mediType", mediType);
|
}
|
// 纠纷类型(最小级)
|
String caseType = request.getParameter("caseType");
|
if (StringUtils.isNotBlank(caseType)){
|
terms.put("caseType", caseType);
|
}
|
// 流程处理时限,以天为单位
|
String expire = request.getParameter("expire");
|
if (StringUtils.isNotBlank(expire)){
|
terms.put("expire", expire);
|
}
|
// 所属组织编号
|
String unitId = request.getParameter("unitId");
|
if (StringUtils.isNotBlank(unitId)){
|
terms.put("unitId", unitId);
|
}
|
// 描述
|
String flowDes = request.getParameter("flowDes");
|
if (StringUtils.isNotBlank(flowDes)){
|
terms.put("flowDes", flowDes);
|
}
|
// 操作人编号
|
String userId = request.getParameter("userId");
|
if (StringUtils.isNotBlank(userId)){
|
terms.put("userId", userId);
|
}
|
// 删除状态,0:未删除,1:已删除
|
String deleteStatus = request.getParameter("deleteStatus");
|
if (StringUtils.isNotBlank(deleteStatus)){
|
terms.put("deleteStatus", deleteStatus);
|
}
|
// 客户编号
|
String custId = request.getParameter("custId");
|
if (StringUtils.isNotBlank(custId)){
|
terms.put("custId", custId);
|
}
|
// 创建时间区间
|
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/flowInfo/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/flowInfo/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<FlowInfo> flowInfoPage = service.pageQuery(pageRequest, terms);
|
return ReturnSucUtils.getRepInfo( "处理成功", flowInfoPage);
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 根据编号查询单个
|
* @url {ctx}/api/web/flowInfo/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/flowInfo/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/flowInfo/saveFlowInfo
|
* @param flowInfo 实体对象
|
* @return Object
|
*/
|
@PostMapping("/saveFlowInfo")
|
public Object saveFlowInfo(@RequestBody FlowInfo flowInfo) {
|
try {
|
service.saveFlowInfo(flowInfo);
|
return ReturnSucUtils.getRepInfo();
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
}
|