广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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());
        }
    }
 
}