package cn.huge.module.cases.controller.wechat; import cn.huge.base.common.utils.GuavaCacheUtils; import cn.huge.base.common.utils.ObjectUtils; import cn.huge.base.common.utils.ReturnFailUtils; import cn.huge.base.common.utils.ReturnSucUtils; import cn.huge.base.config.CurrentUser; import cn.huge.module.cases.domain.dto.CaseInfoWeChatDTO; import cn.huge.module.cases.domain.dto.RegisterSaveDTO; import cn.huge.module.cases.service.CaseInfoService; import cn.huge.module.client.api.impl.UtilsClientImpl; 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.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; /** * @title: 纠纷信息主表接口api-web端 * @description: 纠纷信息主表接口api-web端 * @company: hugeinfo * @author: wangwh * @time: 2024-08-27 10:00:57 * @version: 1.0.0 */ @Slf4j @RestController @RequestMapping("/api/wechat/caseInfo") public class CaseInfoWechatController { @Autowired(required = false) private HttpServletRequest request; @Autowired private CaseInfoService service; @Autowired private UtilsClientImpl utilsClient; /** * 获取请求URL参数 * @return Map */ private Map getParameter(){ Map terms = Maps.newHashMap(); // 人员类型,1:我是申请方,2:我是被申请方 String personType = request.getParameter("personType"); if (StringUtils.isNotBlank(personType)){ terms.put("personType", personType); } // 事项进度,1:来访登记,2:事件流转,3:办理反馈,4:结案申请,5:当事人评价,6:结案归档 String process = request.getParameter("process"); if (StringUtils.isNotBlank(process)){ terms.put("process", process); } // 办理进度,1:待受理,2:化解中,3:已结案,4:不予受理 String processStatus = request.getParameter("processStatus"); if (StringUtils.isNotBlank(processStatus)){ terms.put("infoProcess", processStatus); } return terms; } /** * 条件分页查询 * @url {ctx}/api/wechat/caseInfo/pageCard * @param page 页码 * @param size 每页数量 * @return Object * @CurrentUser String userId, */ @GetMapping("/pageCard") public Object pageCard( @CurrentUser String userId,@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) { try { Map terms = getParameter(); Sort sort = Sort.by(Sort.Direction.DESC, "create_time"); PageRequest pageRequest = PageRequest.of(page-1, size, sort); Page caseInfoPage = service.pageQueryWechat(userId,pageRequest, terms); return ReturnSucUtils.getRepInfo( "处理成功", caseInfoPage); } catch (Exception e) { log.error("Controller接口[CaseInfoWechatController.pageCard]请求异常:"+e, e); return ReturnFailUtils.getRepInfo(); } } /** * 小程序端-纠纷登记-保存纠纷信息-正常案件 * @url {ctx}/api/wechat/caseInfo/caseRegister * @param registerSaveDTO 实体对象 * @CurrentUser String userId, */ @PostMapping("/caseRegister") public Object caseRegister(@CurrentUser String userId, @RequestBody RegisterSaveDTO registerSaveDTO) { try { Object caseRegister = GuavaCacheUtils.getCache("caseRegister"+userId); if(ObjectUtils.isNotEmpty(caseRegister)){ log.info("caseRegister is exist {}",caseRegister); return ReturnSucUtils.getRepInfo(caseRegister); }else{ if(ObjectUtils.isEmpty(registerSaveDTO.getId())){ registerSaveDTO.setId(utilsClient.getNewTimeCaseId()); } GuavaCacheUtils.putCache("caseRegister"+userId,registerSaveDTO.getId()); } String caseId = service.caseRegisterWechat(registerSaveDTO, userId); return ReturnSucUtils.getRepInfo(caseId); } catch (Exception e) { log.error("Controller接口[CaseInfoWechatController.caseRegister]请求异常:"+e, e); return ReturnFailUtils.getRepInfo(e.getMessage()); } } /** * 小程序端-查看案件详情 * @url {ctx}/api/wechat/caseInfo/getCaseInfo */ @GetMapping("/getCaseInfo") public Object getCaseInfo(@RequestParam(value = "id") String id) { try { return ReturnSucUtils.getRepInfo(service.getCaseInfoWechat(id)); } catch (Exception e) { log.error("Controller接口[CaseInfoWechatController.caseInfo]请求异常:"+e, e); return ReturnFailUtils.getRepInfo(e.getMessage()); } } }