puzhibing
2023-06-13 7860e5cb6db60aeb82c640651998f8294635df5b
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
package com.dsh.course.controller;
 
import com.dsh.course.model.vo.SystemNoticeAddReq;
import com.dsh.course.model.vo.SystemNoticeListReq;
import com.dsh.course.model.vo.SystemNoticeListWarpper;
import com.dsh.course.model.vo.SystemNoticeWarpper;
import com.dsh.course.service.ISystemNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
 
@RestController
@RequestMapping("/systemNotice")
public class SystemNoticeController {
 
    @Autowired
    private ISystemNoticeService systemNoticeService;
 
 
    /**
     * 远程调用
     * @throws Exception
     */
    @PostMapping("/addSystemNotice")
    public void addSystemNotice(SystemNoticeAddReq req) {
        try {
            systemNoticeService.addSystemNotice(req.getUserType(), req.getContent(), req.getUserId(), req.getNoticeType());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
 
 
    /**
     * 获取未读消息数量
     * @return
     */
    @PostMapping("/queryNoReadNoticeNum")
    public int queryNoReadNoticeNum(SystemNoticeListReq req){
        try {
            return systemNoticeService.queryNoReadNoticeNum(req.getUid(), req.getUserType());
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }
    }
 
    /**
     * 获取消息列表
     * @param req
     * @return
     */
    @PostMapping("/querySystemNoticeListV2")
    public List<SystemNoticeWarpper> querySystemNoticeListV2(@RequestBody SystemNoticeListReq req){
        try {
            List<Map<String, Object>> list = systemNoticeService.queryList(req.getType(), req.getPageNum(), req.getSize(), req.getUid(), req.getUserType(),req.getLanguage());
            List<SystemNoticeWarpper> systemNoticeWarpper = SystemNoticeWarpper.getSystemNoticeWarpper(list);
            return systemNoticeWarpper;
        }catch (Exception e){
            e.printStackTrace();
            return new ArrayList<>();
        }
    }
 
 
    /**
     * 获取消息列表
     * @param req
     * @return
     */
    @PostMapping("/querySystemNoticeList")
    public SystemNoticeListWarpper querySystemNoticeList(SystemNoticeListReq req){
        try {
            List<Map<String, Object>> list = systemNoticeService.queryList(req.getType(), req.getPageNum(), req.getSize(), req.getUid(), req.getUserType(),req.getLanguage());
            List<SystemNoticeWarpper> systemNoticeWarpper = SystemNoticeWarpper.getSystemNoticeWarpper(list);
            SystemNoticeListWarpper listWarpper = new SystemNoticeListWarpper();
            listWarpper.setList(systemNoticeWarpper);
            return listWarpper;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
 
    /**
     * 阅读系统消息
     * @param req
     */
    @PostMapping("/readSystemNotice")
    public void readSystemNotice(SystemNoticeListReq req){
        try {
            systemNoticeService.readSystemNotice(req.getId(), req.getUid(), req.getUserType());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
 
 
    /**
     * 删除系统消息
     * @param req
     */
    @PostMapping("/delSystemNotice")
    public void delSystemNotice(SystemNoticeListReq req){
        try {
            systemNoticeService.delSystemNotice(req.getId(), req.getUid(), req.getUserType());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
 
 
    /**
     * 清空系统消息
     */
    @PostMapping("/clearSystemNotice")
    public void clearSystemNotice(SystemNoticeListReq req){
        try {
            systemNoticeService.clearSystemNotice(req.getUid(), req.getUserType());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}