提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.controller.admin.notify; |
H |
2 |
|
|
3 |
import com.iailab.framework.apilog.core.annotation.ApiAccessLog; |
|
4 |
import com.iailab.framework.common.enums.UserTypeEnum; |
|
5 |
import com.iailab.framework.common.pojo.CommonResult; |
|
6 |
import com.iailab.framework.common.pojo.PageResult; |
|
7 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
8 |
import com.iailab.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO; |
|
9 |
import com.iailab.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO; |
|
10 |
import com.iailab.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO; |
|
11 |
import com.iailab.module.system.dal.dataobject.notify.NotifyMessageDO; |
|
12 |
import com.iailab.module.system.service.notify.NotifyMessageService; |
|
13 |
import io.swagger.v3.oas.annotations.Operation; |
|
14 |
import io.swagger.v3.oas.annotations.Parameter; |
|
15 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
16 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
17 |
import org.springframework.validation.annotation.Validated; |
|
18 |
import org.springframework.web.bind.annotation.*; |
|
19 |
|
|
20 |
import javax.annotation.Resource; |
|
21 |
import javax.validation.Valid; |
|
22 |
import java.util.List; |
|
23 |
|
|
24 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
25 |
import static com.iailab.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
|
26 |
|
|
27 |
@Tag(name = "管理后台 - 我的站内信") |
|
28 |
@RestController |
|
29 |
@RequestMapping("/system/notify-message") |
|
30 |
@Validated |
|
31 |
public class NotifyMessageController { |
|
32 |
|
|
33 |
@Resource |
|
34 |
private NotifyMessageService notifyMessageService; |
|
35 |
|
|
36 |
// ========== 管理所有的站内信 ========== |
|
37 |
|
|
38 |
@GetMapping("/get") |
|
39 |
@Operation(summary = "获得站内信") |
|
40 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
41 |
@PreAuthorize("@ss.hasPermission('system:notify-message:query')") |
|
42 |
public CommonResult<NotifyMessageRespVO> getNotifyMessage(@RequestParam("id") Long id) { |
|
43 |
NotifyMessageDO message = notifyMessageService.getNotifyMessage(id); |
|
44 |
return success(BeanUtils.toBean(message, NotifyMessageRespVO.class)); |
|
45 |
} |
|
46 |
|
|
47 |
@GetMapping("/page") |
|
48 |
@Operation(summary = "获得站内信分页") |
|
49 |
@PreAuthorize("@ss.hasPermission('system:notify-message:query')") |
|
50 |
public CommonResult<PageResult<NotifyMessageRespVO>> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) { |
|
51 |
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(pageVO); |
|
52 |
return success(BeanUtils.toBean(pageResult, NotifyMessageRespVO.class)); |
|
53 |
} |
|
54 |
|
|
55 |
// ========== 查看自己的站内信 ========== |
|
56 |
|
|
57 |
@GetMapping("/my-page") |
|
58 |
@Operation(summary = "获得我的站内信分页") |
|
59 |
public CommonResult<PageResult<NotifyMessageRespVO>> getMyMyNotifyMessagePage(@Valid NotifyMessageMyPageReqVO pageVO) { |
|
60 |
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(pageVO, |
|
61 |
getLoginUserId(), UserTypeEnum.ADMIN.getValue()); |
|
62 |
return success(BeanUtils.toBean(pageResult, NotifyMessageRespVO.class)); |
|
63 |
} |
|
64 |
|
|
65 |
@PutMapping("/update-read") |
|
66 |
@Operation(summary = "标记站内信为已读") |
|
67 |
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") |
|
68 |
public CommonResult<Boolean> updateNotifyMessageRead(@RequestParam("ids") List<Long> ids) { |
|
69 |
notifyMessageService.updateNotifyMessageRead(ids, getLoginUserId(), UserTypeEnum.ADMIN.getValue()); |
|
70 |
return success(Boolean.TRUE); |
|
71 |
} |
|
72 |
|
|
73 |
@PutMapping("/update-all-read") |
|
74 |
@Operation(summary = "标记所有站内信为已读") |
|
75 |
public CommonResult<Boolean> updateAllNotifyMessageRead() { |
|
76 |
notifyMessageService.updateAllNotifyMessageRead(getLoginUserId(), UserTypeEnum.ADMIN.getValue()); |
|
77 |
return success(Boolean.TRUE); |
|
78 |
} |
|
79 |
|
|
80 |
@GetMapping("/get-unread-list") |
|
81 |
@Operation(summary = "获取当前用户的最新站内信列表,默认 10 条") |
|
82 |
@Parameter(name = "size", description = "10") |
|
83 |
public CommonResult<List<NotifyMessageRespVO>> getUnreadNotifyMessageList( |
|
84 |
@RequestParam(name = "size", defaultValue = "10") Integer size) { |
|
85 |
List<NotifyMessageDO> list = notifyMessageService.getUnreadNotifyMessageList( |
|
86 |
getLoginUserId(), UserTypeEnum.ADMIN.getValue(), size); |
|
87 |
return success(BeanUtils.toBean(list, NotifyMessageRespVO.class)); |
|
88 |
} |
|
89 |
|
|
90 |
@GetMapping("/get-unread-count") |
|
91 |
@Operation(summary = "获得当前用户的未读站内信数量") |
|
92 |
@ApiAccessLog(enable = false) // 由于前端会不断轮询该接口,记录日志没有意义 |
|
93 |
public CommonResult<Long> getUnreadNotifyMessageCount() { |
|
94 |
return success(notifyMessageService.getUnreadNotifyMessageCount( |
|
95 |
getLoginUserId(), UserTypeEnum.ADMIN.getValue())); |
|
96 |
} |
|
97 |
|
|
98 |
} |