|
@@ -0,0 +1,95 @@
|
|
|
+package cn.iocoder.yudao.module.system.controller.admin.notify;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
|
|
|
+import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
|
|
|
+import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
+
|
|
|
+@Api(tags = "管理后台 - 我的站内信")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/system/notify-message")
|
|
|
+@Validated
|
|
|
+public class NotifyMessageController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private NotifyMessageService notifyMessageService;
|
|
|
+
|
|
|
+ // ========== 管理所有的站内信 ==========
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @ApiOperation("获得站内信")
|
|
|
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:notify-message:query')")
|
|
|
+ public CommonResult<NotifyMessageRespVO> getNotifyMessage(@RequestParam("id") Long id) {
|
|
|
+ NotifyMessageDO notifyMessage = notifyMessageService.getNotifyMessage(id);
|
|
|
+ return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @ApiOperation("获得站内信分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:notify-message:query')")
|
|
|
+ public CommonResult<PageResult<NotifyMessageRespVO>> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
|
|
|
+ PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
|
|
|
+ return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
|
|
|
+ }
|
|
|
+
|
|
|
+ // ========== 查看自己的站内信 ==========
|
|
|
+
|
|
|
+ @GetMapping("/my-page")
|
|
|
+ @ApiOperation("获得我的站内信分页")
|
|
|
+ public CommonResult<PageResult<NotifyMessageRespVO>> getMyMyNotifyMessagePage(@Valid NotifyMessageMyPageReqVO pageVO) {
|
|
|
+ PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(pageVO,
|
|
|
+ getLoginUserId(), UserTypeEnum.ADMIN.getValue());
|
|
|
+ return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update-read")
|
|
|
+ @ApiOperation("标记站内信为已读")
|
|
|
+ @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
|
|
+ public CommonResult<Boolean> updateNotifyMessageRead(@RequestParam("ids") List<Long> ids) {
|
|
|
+ notifyMessageService.updateNotifyMessageRead(ids, getLoginUserId(), UserTypeEnum.ADMIN.getValue());
|
|
|
+ return success(Boolean.TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update-all-read")
|
|
|
+ @ApiOperation("标记所有站内信为已读")
|
|
|
+ public CommonResult<Boolean> updateAllNotifyMessageRead() {
|
|
|
+ notifyMessageService.updateAllNotifyMessageRead(getLoginUserId(), UserTypeEnum.ADMIN.getValue());
|
|
|
+ return success(Boolean.TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get-unread-list")
|
|
|
+ @ApiOperation("获取当前用户的最新站内信列表,默认 10 条")
|
|
|
+ @ApiImplicitParam(name = "size", value = "10", defaultValue = "10", dataTypeClass = Integer.class)
|
|
|
+ public CommonResult<List<NotifyMessageRespVO>> getUnreadNotifyMessageList(
|
|
|
+ @RequestParam(name = "size", defaultValue = "10") Integer size) {
|
|
|
+ List<NotifyMessageDO> list = notifyMessageService.getUnreadNotifyMessageList(
|
|
|
+ getLoginUserId(), UserTypeEnum.ADMIN.getValue(), size);
|
|
|
+ return success(NotifyMessageConvert.INSTANCE.convertList(list));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get-unread-count")
|
|
|
+ @ApiOperation("获得当前用户的未读站内信数量")
|
|
|
+ public CommonResult<Long> getUnreadNotifyMessageCount() {
|
|
|
+ return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|