Mr.qian 2 veckor sedan
förälder
incheckning
631f8ff20a

+ 31 - 14
mall-service/src/main/java/com/txz/mall/controller/appcontroller/AppNoticeController.java

@@ -1,6 +1,8 @@
 package com.txz.mall.controller.appcontroller;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.txz.mall.core.AuthService;
@@ -30,8 +32,14 @@ public class AppNoticeController {
      */
     @GetMapping("unread")
     public Result unread() {
+        Long userId;
+        try {
+            userId = AuthService.getTokenUserId(null);
+        } catch (Exception e) {
+            return Result.success(0);
+        }
         return Result.success(noticeService.count(Wrappers.<Notice>lambdaQuery()
-                        .eq(Notice::getUid, AuthService.getTokenUserId(null))
+                        .eq(Notice::getUid, userId)
                         .eq(Notice::getUserDel, Boolean.FALSE)
                         .eq(Notice::getReadFlag, Boolean.FALSE)
                 )
@@ -44,12 +52,15 @@ public class AppNoticeController {
     @GetMapping("page")
     public Result<Page<Notice>> page(NoticeGroupEnum type, BasePageParam page) {
         Page queryPage = new Page(page.getPage(), page.getSize());
+        LambdaQueryWrapper<Notice> eq = Wrappers.<Notice>lambdaQuery()
+                // .likeRight(ObjectUtil.isNotEmpty(type), Notice::getNoticeType, type.getData())
+                .eq(Notice::getUid, AuthService.getTokenUserId(null))
+                .eq(Notice::getUserDel, Boolean.FALSE);
+        if (ObjectUtil.isNotEmpty(type)) {
+            eq.likeRight(Notice::getNoticeType, type.getData());
+        }
         return Result.success(
-                noticeService.page(queryPage, Wrappers.<Notice>lambdaQuery()
-                        .likeRight(ObjectUtil.isNotEmpty(type), Notice::getNoticeType, type.getData())
-                        .eq(Notice::getUid, AuthService.getTokenUserId(null))
-                        .eq(Notice::getUserDel, Boolean.FALSE)
-                )
+                noticeService.page(queryPage, eq)
         );
     }
     
@@ -76,13 +87,16 @@ public class AppNoticeController {
      */
     @PatchMapping("readAll")
     public Result readAll(NoticeGroupEnum type) {
-        noticeService.update(Wrappers.<Notice>lambdaUpdate()
+        LambdaUpdateWrapper<Notice> updateWrapper = Wrappers.<Notice>lambdaUpdate()
                 .eq(Notice::getUid, AuthService.getTokenUserId(null))
                 .eq(Notice::getUserDel, Boolean.FALSE)
                 .eq(Notice::getReadFlag, Boolean.FALSE)
-                .set(Notice::getReadFlag, Boolean.TRUE)
-                .likeRight(ObjectUtil.isNotEmpty(type), Notice::getNoticeType, type.getData())
-        );
+                .set(Notice::getReadFlag, Boolean.TRUE);
+        // .likeRight(ObjectUtil.isNotEmpty(type), Notice::getNoticeType, type.getData());
+        if (ObjectUtil.isNotEmpty(type)) {
+            updateWrapper.likeRight(Notice::getNoticeType, type.getData());
+        }
+        noticeService.update(updateWrapper);
         return Result.success();
     }
     
@@ -105,12 +119,15 @@ public class AppNoticeController {
      */
     @DeleteMapping("delete")
     public Result delete(NoticeGroupEnum type) {
-        noticeService.update(Wrappers.<Notice>lambdaUpdate()
-                .likeRight(ObjectUtil.isNotEmpty(type), Notice::getNoticeType, type.getData())
+        LambdaUpdateWrapper<Notice> updateWrapper = Wrappers.<Notice>lambdaUpdate()
+                // .likeRight(ObjectUtil.isNotEmpty(type), Notice::getNoticeType, type.getData())
                 .eq(Notice::getUid, AuthService.getTokenUserId(null))
                 .set(Notice::getUserDel, Boolean.TRUE)
-                .set(Notice::getReadFlag, Boolean.TRUE)
-        );
+                .set(Notice::getReadFlag, Boolean.TRUE);
+        if (ObjectUtil.isNotEmpty(type)) {
+            updateWrapper.likeRight(Notice::getNoticeType, type.getData());
+        }
+        noticeService.update(updateWrapper);
         return Result.success();
     }
     

+ 1 - 2
mall-service/src/main/java/com/txz/mall/dao/impl/StoreCombinationMapperImpl.java

@@ -23,8 +23,7 @@ public class StoreCombinationMapperImpl {
     }
     
     public String getIdByProductId(Long productId) {
-        String sql = "select id from m_store_combination where product_id = #{productId} and is_delete = 0 and start_time <= now() and stop_time >= now() and is_show = 1 order by start_time limit 1 ";
-        return sql;
+        return "select id from m_store_combination where product_id = #{productId} and is_delete = 0 and start_time <= now() and stop_time >= now() and is_show = 1 order by start_time limit 1 ";
     }
     
 }

+ 17 - 0
mall-service/src/main/java/dto/FavoriteDTO.java

@@ -0,0 +1,17 @@
+package dto;
+
+import lombok.Builder;
+import lombok.Data;
+
+/**
+ * @author: MTD®️
+ * @date: 2025/8/27
+ */
+@Data
+@Builder
+public class FavoriteDTO {
+    
+    private Long productId;
+    
+    private Long userId;
+}