Kaynağa Gözat

feat(app): 添加消息通知功能- 新增消息通知列表和详情查询接口
- 实现微信登录功能
- 优化首页轮播图查询接口

SheepHy 3 hafta önce
ebeveyn
işleme
22e8e0594c

+ 31 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/AppHomeController.java

@@ -1,13 +1,18 @@
 package org.jeecg.modules.app.controller;
 
 import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.app.service.IAppBannerService;
+import org.jeecg.modules.app.service.IUserService;
 import org.jeecg.modules.app.vo.AppBannerVO;
+import org.jeecg.modules.app.vo.MsgInfoVO;
+import org.jeecg.modules.app.vo.MsgVO;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
@@ -20,10 +25,36 @@ import java.util.List;
 public class AppHomeController {
     @Resource
     private IAppBannerService appBannerService;
+    @Resource
+    private IUserService userService;
 
     @GetMapping("/queryBanner")
     @Operation(summary = "查询首页轮播图")
     public Result<List<AppBannerVO>> queryBanner() {
         return Result.ok(appBannerService.queryBanner());
     }
+    /**
+     * @Author SheepHy
+     * @Description 查询消息通知列表(简略)
+     * @Date 17:13 2025/7/3
+     * @return List<MsgVO> {@link List<MsgVO>}
+     **/
+    @GetMapping("/getMsg")
+    @Operation(summary = "查询消息通知列表(简略)")
+    public Result<List<MsgVO>> getMsg(){
+        return Result.ok(userService.getMsg());
+    }
+
+    /**
+     * @Author SheepHy
+     * @Description 查询消息详情
+     * @Date 17:29 2025/7/3
+     * @Param id 消息ID
+     * @return MsgInfoVO {@link MsgInfoVO}
+     **/
+    @GetMapping("/getMsgInfo")
+    @Operation(summary = "查询消息详情")
+    public Result<MsgInfoVO> getMsgInfo(@RequestParam(required = false) @Schema(description = "消息ID") String id){
+        return Result.ok(userService.getMsgInfo(id));
+    }
 }

+ 26 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/IUserService.java

@@ -1,11 +1,36 @@
 package org.jeecg.modules.app.service;
 
 import org.jeecg.modules.app.vo.LoginUserVO;
+import org.jeecg.modules.app.vo.MsgInfoVO;
 import org.jeecg.modules.app.vo.MsgVO;
 
+import java.util.List;
+
 public interface IUserService {
 
+    /**
+     * @Description 微信登录
+     * @Author SheepHy
+     * @Date 17:14 2025/7/3
+     * @Param code 微信登录返回的code
+     * @return LoginUserVO {@link LoginUserVO}
+     **/
     LoginUserVO wechatLogin(String code);
 
-    MsgVO getMsg();
+    /**
+     * @Author SheepHy
+     * @Description 查询消息通知列表(简略)
+     * @Date 17:13 2025/7/3
+     * @return List<MsgVO> {@link List<MsgVO>}
+     **/
+    List<MsgVO> getMsg();
+
+    /**
+     * @Author SheepHy
+     * @Description 查询消息详情
+     * @Date 17:29 2025/7/3
+     * @Param id 消息ID
+     * @return MsgInfoVO {@link MsgInfoVO}
+     **/
+    MsgInfoVO getMsgInfo(String id);
 }

+ 22 - 3
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/UserServiceImpl.java

@@ -13,16 +13,21 @@ import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.RedisUtil;
 import org.jeecg.modules.app.service.IUserService;
 import org.jeecg.modules.app.vo.LoginUserVO;
+import org.jeecg.modules.app.vo.MsgInfoVO;
 import org.jeecg.modules.app.vo.MsgVO;
+import org.jeecg.modules.system.entity.SysAnnouncement;
 import org.jeecg.modules.system.entity.SysAnnouncementSend;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.mapper.SysAnnouncementMapper;
 import org.jeecg.modules.system.mapper.SysAnnouncementSendMapper;
 import org.jeecg.modules.system.mapper.SysUserMapper;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
 
 import static org.jeecg.common.constant.CommonConstant.PREFIX_USER_TOKEN;
 import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
@@ -72,14 +77,28 @@ public class UserServiceImpl implements IUserService {
     }
 
     @Override
-    public MsgVO getMsg() {
+    public List<MsgVO> getMsg() {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        List<MsgVO> msgVOList = new ArrayList<>();
         sysAnnouncementSendMapper.selectList(Wrappers.<SysAnnouncementSend>lambdaQuery()
                 .eq(SysAnnouncementSend::getUserId, user.getId())).forEach(sysAnnouncementSend -> {
-
+            SysAnnouncement sysAnnouncement = sysAnnouncementMapper.selectById(sysAnnouncementSend.getAnntId());
+            MsgVO msgVO = new MsgVO()
+                    .setReadFlag(sysAnnouncementSend.getReadFlag())
+                    .setTitile(sysAnnouncement.getTitile())
+                    .setSendTime(sysAnnouncement.getSendTime())
+                    .setImgUrl(sysAnnouncement.getImgUrl()).setSender(sysAnnouncement.getSender());
+            msgVOList.add(msgVO);
         });
+        return msgVOList;
+    }
 
-        return null;
+    @Override
+    public MsgInfoVO getMsgInfo(String id) {
+        SysAnnouncement sysAnnouncement = sysAnnouncementMapper.selectById(id);
+        MsgInfoVO msgInfoVO = new MsgInfoVO();
+        BeanUtils.copyProperties(sysAnnouncement, msgInfoVO);
+        return msgInfoVO;
     }
 
     private LoginUserVO generateLoginUserVO(SysUser user) {

+ 24 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/MsgInfoVO.java

@@ -0,0 +1,24 @@
+package org.jeecg.modules.app.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description="公告消息详情返回参数")
+public class MsgInfoVO {
+    @Schema(description = "消息id")
+    private String id;
+    @Schema(description = "标题")
+    private String titile;
+    @Schema(description = "发布人")
+    private String sender;
+    @Schema(description = "发布人")
+    private String msgContent;
+    @Schema(description = "发布时间")
+    private java.util.Date sendTime;
+    private String imgUrl;
+}