Commit 9fac5a95dd758ed4e4bad6cd4a10726ed631b518

Authored by wangqian
1 parent 399721bd

app增加站内消息查询

urbanops-module-system/src/main/java/com/zteits/urbanops/module/system/controller/app/notify/AppNotifyMessageController.java 0 → 100644
  1 +package com.zteits.urbanops.module.system.controller.app.notify;
  2 +
  3 +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;
  4 +import com.zteits.urbanops.framework.common.enums.UserTypeEnum;
  5 +import com.zteits.urbanops.framework.common.pojo.CommonResult;
  6 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  7 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  8 +import com.zteits.urbanops.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
  9 +import com.zteits.urbanops.module.system.controller.app.notify.vo.message.NotifyMessageRespVO;
  10 +import com.zteits.urbanops.module.system.dal.dataobject.notify.NotifyMessageDO;
  11 +import com.zteits.urbanops.module.system.service.notify.NotifyMessageService;
  12 +import io.swagger.v3.oas.annotations.Operation;
  13 +import io.swagger.v3.oas.annotations.Parameter;
  14 +import io.swagger.v3.oas.annotations.tags.Tag;
  15 +import jakarta.annotation.Resource;
  16 +import jakarta.validation.Valid;
  17 +import org.springframework.validation.annotation.Validated;
  18 +import org.springframework.web.bind.annotation.*;
  19 +
  20 +import java.util.List;
  21 +
  22 +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
  23 +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
  24 +
  25 +@Tag(name = "管理后台 - 我的站内信")
  26 +@RestController
  27 +@RequestMapping("/system/notify-message")
  28 +@Validated
  29 +public class AppNotifyMessageController {
  30 +
  31 + @Resource
  32 + private NotifyMessageService notifyMessageService;
  33 +
  34 + @GetMapping("/my-page")
  35 + @Operation(summary = "获得我的站内信分页")
  36 + public CommonResult<PageResult<NotifyMessageRespVO>> getMyMyNotifyMessagePage(@Valid NotifyMessageMyPageReqVO pageVO) {
  37 + PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(pageVO,
  38 + getLoginUserId(), UserTypeEnum.ADMIN.getValue());
  39 + return success(BeanUtils.toBean(pageResult, NotifyMessageRespVO.class));
  40 + }
  41 +
  42 + @PutMapping("/update-read")
  43 + @Operation(summary = "标记站内信为已读")
  44 + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
  45 + public CommonResult<Boolean> updateNotifyMessageRead(@RequestParam("ids") List<Long> ids) {
  46 + notifyMessageService.updateNotifyMessageRead(ids, getLoginUserId(), UserTypeEnum.ADMIN.getValue());
  47 + return success(Boolean.TRUE);
  48 + }
  49 +
  50 + @PutMapping("/update-all-read")
  51 + @Operation(summary = "标记所有站内信为已读")
  52 + public CommonResult<Boolean> updateAllNotifyMessageRead() {
  53 + notifyMessageService.updateAllNotifyMessageRead(getLoginUserId(), UserTypeEnum.ADMIN.getValue());
  54 + return success(Boolean.TRUE);
  55 + }
  56 +
  57 + @GetMapping("/get-unread-list")
  58 + @Operation(summary = "获取当前用户的最新站内信列表,默认 10 条")
  59 + @Parameter(name = "size", description = "10")
  60 + public CommonResult<List<NotifyMessageRespVO>> getUnreadNotifyMessageList(
  61 + @RequestParam(name = "size", defaultValue = "10") Integer size) {
  62 + List<NotifyMessageDO> list = notifyMessageService.getUnreadNotifyMessageList(
  63 + getLoginUserId(), UserTypeEnum.ADMIN.getValue(), size);
  64 + return success(BeanUtils.toBean(list, NotifyMessageRespVO.class));
  65 + }
  66 +
  67 + @GetMapping("/get-unread-count")
  68 + @Operation(summary = "获得当前用户的未读站内信数量")
  69 + @ApiAccessLog(enable = false) // 由于前端会不断轮询该接口,记录日志没有意义
  70 + public CommonResult<Long> getUnreadNotifyMessageCount() {
  71 + return success(notifyMessageService.getUnreadNotifyMessageCount(
  72 + getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
  73 + }
  74 +
  75 +}
... ...
urbanops-module-system/src/main/java/com/zteits/urbanops/module/system/controller/app/notify/vo/message/NotifyMessageRespVO.java 0 → 100644
  1 +package com.zteits.urbanops.module.system.controller.app.notify.vo.message;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import java.time.LocalDateTime;
  7 +import java.util.Map;
  8 +
  9 +@Schema(description = "管理后台 - 站内信 Response VO")
  10 +@Data
  11 +public class NotifyMessageRespVO {
  12 +
  13 + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  14 + private Long id;
  15 +
  16 + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25025")
  17 + private Long userId;
  18 +
  19 + @Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  20 + private Byte userType;
  21 +
  22 + @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13013")
  23 + private Long templateId;
  24 +
  25 + @Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "test_01")
  26 + private String templateCode;
  27 +
  28 + @Schema(description = "模版发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
  29 + private String templateNickname;
  30 +
  31 + @Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试内容")
  32 + private String templateContent;
  33 +
  34 + @Schema(description = "模版类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
  35 + private Integer templateType;
  36 +
  37 + @Schema(description = "模版参数", requiredMode = Schema.RequiredMode.REQUIRED)
  38 + private Map<String, Object> templateParams;
  39 +
  40 + @Schema(description = "是否已读", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
  41 + private Boolean readStatus;
  42 +
  43 + @Schema(description = "阅读时间")
  44 + private LocalDateTime readTime;
  45 +
  46 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  47 + private LocalDateTime createTime;
  48 +
  49 +}
... ...