Browse Source

bugfix:2248评价列表展示修改

刘云鑫 3 months ago
parent
commit
ef39143d6e

+ 1 - 1
alien-entity/src/main/java/shop/alien/mapper/CommonRatingMapper.java

@@ -46,7 +46,7 @@ public interface CommonRatingMapper extends BaseMapper<CommonRating> {
 //            "    -- 1. 总评论数(当前门店、根评论、未删除)\n" +
 //            "    COUNT(1) AS totalCount,\n" +
             "    -- 2. 有图评论数(image_urls 不为 null 且不为空字符串)\n" +
-            "    SUM(CASE WHEN image_urls IS NOT NULL AND image_urls != '' THEN 1 ELSE 0 END) AS imageCount,\n" +
+            "    SUM(CASE WHEN image_urls IS NOT NULL AND image_urls != '' AND TRIM(image_urls) <> '' THEN 1 ELSE 0 END) AS imageCount,\n" +
             "    -- 3. 好评数(score >= 4.5)\n" +
             "    SUM(CASE WHEN score >= 4.5 THEN 1 ELSE 0 END) AS goodCount,\n" +
             "    -- 4. 中评数(score >= 3.0 AND score <= 4.0)\n" +

+ 14 - 0
alien-store/src/main/java/shop/alien/store/controller/CommonRatingController.java

@@ -94,6 +94,20 @@ public class CommonRatingController {
         return R.data(commonRatingService.getRatingDetail(ratingId, userId));
     }
 
+    /**删除评价
+     * @param ratingId 评价id
+     * @return 0:成功, 1:失败
+     */
+    @ApiOperation(value = "删除评价", notes = "0:成功, 1:失败")
+    @GetMapping("/deleteRating")
+    public R deleteRating(@RequestParam Long ratingId) {
+        boolean b = commonRatingService.removeById(ratingId);
+        if (b) {
+            return R.success("删除评价成功");
+        }
+        return R.fail("删除评价失败");
+    }
+
 //
 //    @ApiOperation("更新评价")
 //    @PutMapping("/update")

+ 8 - 3
alien-store/src/main/java/shop/alien/store/service/impl/CommonRatingServiceImpl.java

@@ -172,14 +172,19 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                 wrapper.ge(CommonRating::getScore, 4.5);
             }else if(searchScore == 2){
                 // 2-中评
-                wrapper.ge(CommonRating::getScore, 3.5);
-                wrapper.lt(CommonRating::getScore, 4.5);
+                wrapper.ge(CommonRating::getScore, 3.0);
+                wrapper.le(CommonRating::getScore, 4.0);
             }else if(searchScore == 3){
                 // 3-差评
-                wrapper.lt(CommonRating::getScore, 3.5);
+                wrapper.ge(CommonRating::getScore, 0.5);
+                wrapper.le(CommonRating::getScore, 2.5);
             }else if(searchScore == 4){
                 // 4-有图
                 wrapper.isNotNull(CommonRating::getImageUrls);
+                // 2. 排除 空字符串 ""
+                wrapper.ne(CommonRating::getImageUrls, "");
+                // 3. 排除 纯空格字符串(如"   ")—— 用 TRIM 函数去掉首尾空格后判断非空
+                wrapper.apply("TRIM({0}) <> ''", "image_urls");
             }
         }