From db036f2bd4b6a24c0621ce796fd737499b782d5a Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 28 Mar 2023 15:12:37 +0800 Subject: [PATCH] =?UTF-8?q?notify=20=E4=BB=A3=E7=A0=81=20userId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java | 12 ++++++++++++ .../java/com/ningdatech/pmapi/sys/manage/NotifyManage.java | 4 +++- .../com/ningdatech/pmapi/sys/model/req/NotifyListReq.java | 3 --- .../java/com/ningdatech/pmapi/sys/model/vo/NotifyVO.java | 10 ++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java index a315501..2d4ec7e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java @@ -51,6 +51,18 @@ public enum MsgTypeEnum { return StringUtils.EMPTY; } + public static String getDescByName(String name) { + if (StringUtils.isBlank(name)) { + return StringUtils.EMPTY; + } + for (MsgTypeEnum t : MsgTypeEnum.values()) { + if (name.equals(t.name())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + public boolean eq(String val) { return this.name().equals(val); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NotifyManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NotifyManage.java index 9125b26..0ca8fa0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NotifyManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NotifyManage.java @@ -10,6 +10,7 @@ import com.ningdatech.pmapi.sys.model.entity.Notify; import com.ningdatech.pmapi.sys.model.req.NotifyListReq; import com.ningdatech.pmapi.sys.model.vo.NotifyVO; import com.ningdatech.pmapi.sys.service.INotifyService; +import com.ningdatech.pmapi.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -32,10 +33,11 @@ public class NotifyManage { private final INotifyService notifyService; public PageVo page(NotifyListReq notifyListReq) { + Long userId = LoginUserUtil.getUserId(); Page page = notifyListReq.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Notify.class) .eq(Objects.nonNull(notifyListReq.getReaded()), Notify::getReaded, notifyListReq.getReaded()) - .eq(Objects.nonNull(notifyListReq.getUserId()), Notify::getUserId, notifyListReq.getUserId()) + .eq(Notify::getUserId, userId) .like(Objects.nonNull(notifyListReq.getTitle()), Notify::getTitle, notifyListReq.getTitle()) .eq(Objects.nonNull(notifyListReq.getType()), Notify::getType, notifyListReq.getType()); notifyService.page(page,wrapper); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/NotifyListReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/NotifyListReq.java index c08e22b..a9b6266 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/NotifyListReq.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/NotifyListReq.java @@ -19,9 +19,6 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) public class NotifyListReq extends PagePo { - @ApiModelProperty("用户ID") - private Integer userId; - @ApiModelProperty("是否已读") private Boolean readed; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NotifyVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NotifyVO.java index 7197588..e25a92c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NotifyVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NotifyVO.java @@ -2,11 +2,15 @@ package com.ningdatech.pmapi.sys.model.vo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; +import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; import java.time.LocalDateTime; +import java.util.Objects; /** *

@@ -50,4 +54,10 @@ public class NotifyVO implements Serializable { @ApiModelProperty("创建时间") private LocalDateTime createTime; + public String getTypeName(){ + if(Objects.nonNull(this.type)){ + return MsgTypeEnum.getDescByName(this.type); + } + return StringUtils.EMPTY; + } }