package cn.huge.module.notice.controller.wechat;
|
|
import cn.huge.base.common.utils.ReturnFailUtils;
|
import cn.huge.base.common.utils.ReturnSucUtils;
|
import cn.huge.base.config.CurrentUser;
|
import cn.huge.module.mediate.constant.NoticeBaseConsts;
|
import cn.huge.module.notice.domain.po.NoticeParty;
|
import cn.huge.module.notice.service.NoticePartyService;
|
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.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.Date;
|
import java.util.Map;
|
|
/**
|
* @title: 当事人消息通知表接口api
|
* @description: 当事人消息通知表接口api
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2022-11-24 10:34:34
|
* @version: 1.0.0
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/api/wechat/noticeParty")
|
public class NoticePartyWechatController {
|
|
@Autowired(required = false)
|
private HttpServletRequest request;
|
|
@Autowired
|
private NoticePartyService 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 caseId = request.getParameter("caseId");
|
if (StringUtils.isNotBlank(caseId)){
|
terms.put("caseId", caseId);
|
}
|
// 消息类型,1:系统通知,2:平台公告
|
String noticeType = request.getParameter("noticeType");
|
if (StringUtils.isNotBlank(noticeType)){
|
terms.put("noticeType", noticeType);
|
}
|
// 标题
|
String title = request.getParameter("title");
|
if (StringUtils.isNotBlank(title)){
|
terms.put("title", title);
|
}
|
// 消息内容
|
String content = request.getParameter("content");
|
if (StringUtils.isNotBlank(content)){
|
terms.put("content", content);
|
}
|
// 接收人编号
|
String userId = request.getParameter("userId");
|
if (StringUtils.isNotBlank(userId)){
|
terms.put("userId", userId);
|
}
|
// 接收人名称
|
String userName = request.getParameter("userName");
|
if (StringUtils.isNotBlank(userName)){
|
terms.put("userName", userName);
|
}
|
// 跳转url
|
String visitUrl = request.getParameter("visitUrl");
|
if (StringUtils.isNotBlank(visitUrl)){
|
terms.put("visitUrl", visitUrl);
|
}
|
// 已读状态,1:未读(默认值),2:已读
|
String readStatus = request.getParameter("readStatus");
|
if (StringUtils.isNotBlank(readStatus)){
|
terms.put("readStatus", readStatus);
|
}
|
// 阅读时间
|
String readTime = request.getParameter("readTime");
|
if (StringUtils.isNotBlank(readTime)){
|
terms.put("readTime", readTime);
|
}
|
// 删除状态,1:未删除(默认值),99:已删除
|
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/weChat/noticeParty/pageMyNotice
|
* @param page 页码
|
* @param size 每页数量
|
* @param readStatus 每页数量
|
* @return Object
|
*/
|
@GetMapping("/pageMyNotice")
|
public Object pageMyNotice(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size,
|
@RequestParam(value = "readStatus") String readStatus, @CurrentUser String userId) {
|
try {
|
Map<String, Object> terms = getParameter();
|
terms.put("userId", userId);
|
terms.put("readStatus", readStatus);
|
Sort sort = Sort.by(Sort.Direction.DESC, "create_time");
|
PageRequest pageRequest = PageRequest.of(page-1, size, sort);
|
Page<NoticeParty> noticePartyPage = service.pageQuery(pageRequest, terms);
|
return ReturnSucUtils.getRepInfo( "处理成功", noticePartyPage);
|
} catch (Exception e) {
|
log.error("Controller接口[NoticePartyController.pageMyNotice]请求异常:"+e, e);
|
return ReturnFailUtils.getRepInfo(e.getMessage());
|
}
|
}
|
|
|
/**
|
* 我的消息-阅读消息
|
* @url {ctx}/api/weChat/noticeParty/readNotice
|
* @param id 消息编号
|
* @param userId
|
* @return
|
*/
|
@GetMapping("/readNotice")
|
public Object readNotice(@RequestParam(value = "id") String id, @CurrentUser String userId) {
|
try {
|
Date nowDate = new Date();
|
NoticeParty noticeParty = new NoticeParty();
|
noticeParty.setReadStatus(NoticeBaseConsts.READ_STATUS_2);
|
noticeParty.setReadTime(nowDate);
|
noticeParty.setUpdateTime(nowDate);
|
noticeParty.setId(id);
|
service.updateNoticeParty(noticeParty);
|
return ReturnSucUtils.getRepInfo( );
|
} catch (Exception e) {
|
log.error("Controller接口[NoticePartyController.readNotice]请求异常:"+e, e);
|
return ReturnFailUtils.getRepInfo(e.getMessage());
|
}
|
}
|
|
}
|