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
package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.AuthLogin;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.qo.NotificationQo;
import com.tanpu.community.api.beans.qo.ThemeNotifyQo;
import com.tanpu.community.api.beans.req.notification.NotifyQueryReq;
import com.tanpu.community.manager.NotificationManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 消息通知
*/
@Slf4j
@RestController
@RequestMapping("/api/notification")
@Api(value = "圈子消息通知")
public class NotificationController {
@Autowired
private UserHolder userHolder;
@Autowired
private NotificationManager notificationManager;
@AuthLogin
@PostMapping("/query")
@ResponseBody
@ApiOperation(value = "查找用戶的消息通知列表")
public CommonResp<List<ThemeNotifyQo>> query(@RequestBody NotifyQueryReq req){
List<ThemeNotifyQo> query = notificationManager.queryList(req, userHolder.getUserId());
return CommonResp.success(query);
}
@AuthLogin
@GetMapping("/updateCount")
@ResponseBody
@ApiOperation(value = "更新推送")
public CommonResp<NotificationQo> query(){
NotificationQo notificationQO = notificationManager.queryBriefInfo(userHolder.getUserId());
return CommonResp.success(notificationQO);
}
@AuthLogin
@GetMapping("/init")
@ResponseBody
@ApiOperation(value = "初始化数据")
public CommonResp<Void> initData(){
if (!"admin".equals(userHolder.getUserId())){
return CommonResp.failed("权限不足");
}
notificationManager.initAllData();
return CommonResp.success();
}
}