فهرست منبع

fix:我的评价-店铺评价

刘云鑫 2 ماه پیش
والد
کامیت
07f9ad93f9

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

@@ -1,8 +1,11 @@
 package shop.alien.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -67,5 +70,7 @@ public interface CommonRatingMapper extends BaseMapper<CommonRating> {
      */
     @Update("UPDATE common_rating SET delete_flag = 1, updated_time = NOW() WHERE id = #{id}")
     int logicDeleteById(@Param("id") Integer id);
+
+    IPage<CommonRating> getMyRatingList(Page<CommonRating> page, @Param(Constants.WRAPPER) QueryWrapper<CommonRating> wrapper);
 }
 

+ 6 - 0
alien-entity/src/main/resources/mapper/CommonRatingMapper.xml

@@ -31,6 +31,12 @@
         is_anonymous, is_show, audit_status, like_count, score_one, score_two, score_three,
         delete_flag, created_user_id, updated_time, updated_user_id
     </sql>
+    <select id="getMyRatingList" resultType="shop.alien.entity.store.vo.CommonRatingVo">
+        select cr.*,si.store_name storeName
+        from common_rating cr
+        left join store_info si on cr.business_id = si.id
+        ${ew.customSqlSegment}
+    </select>
 
 </mapper>
 

+ 17 - 42
alien-store/src/main/java/shop/alien/store/controller/CommonRatingController.java

@@ -147,47 +147,22 @@ public class CommonRatingController {
         return R.fail("删除评价失败");
     }
 
-//
-//    @ApiOperation("更新评价")
-//    @PutMapping("/update")
-//    public R<Boolean> update(@RequestBody CommonRating commonRating) {
-//        log.info("CommonRatingController.update?commonRating={}", commonRating);
-//        return R.data(commonRatingService.updateById(commonRating));
-//    }
-//
-//    @ApiOperation("删除评价")
-//    @ApiImplicitParam(name = "id", value = "评价ID", dataType = "Long", paramType = "path", required = true)
-//    @DeleteMapping("/delete/{id}")
-//    public R<Boolean> delete(@PathVariable Long id) {
-//        log.info("CommonRatingController.delete?id={}", id);
-//        return R.data(commonRatingService.removeById(id));
-//    }
-//
-//    @ApiOperation("获取平均评分")
-//    @ApiImplicitParams({
-//            @ApiImplicitParam(name = "businessType", value = "业务类型", dataType = "Integer", paramType = "query", required = true),
-//            @ApiImplicitParam(name = "businessId", value = "业务ID", dataType = "Long", paramType = "query", required = true)
-//    })
-//    @GetMapping("/getAverageScore")
-//    public R<Double> getAverageScore(
-//            @RequestParam Integer businessType,
-//            @RequestParam Long businessId) {
-//        log.info("CommonRatingController.getAverageScore?businessType={}&businessId={}", businessType, businessId);
-//        return R.data(commonRatingService.getAverageScore(businessType, businessId));
-//    }
-//
-//    @ApiOperation("获取评价数量")
-//    @ApiImplicitParams({
-//            @ApiImplicitParam(name = "businessType", value = "业务类型", dataType = "Integer", paramType = "query", required = true),
-//            @ApiImplicitParam(name = "businessId", value = "业务ID", dataType = "Long", paramType = "query", required = true)
-//    })
-//    @GetMapping("/getRatingCount")
-//    public R<Long> getRatingCount(
-//            @RequestParam Integer businessType,
-//            @RequestParam Long businessId) {
-//        log.info("CommonRatingController.getRatingCount?businessType={}&businessId={}", businessType, businessId);
-//        return R.data(commonRatingService.getRatingCount(businessType, businessId));
-//    }
+    // 查询我自己的评价
+    @ApiOperation("查询我的评价")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "businessType", value = "业务类型", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "Long", paramType = "query", required = true),
+            @ApiImplicitParam(name = "auditStatus", value = "审核状态", dataType = "Integer", paramType = "query", required = true)})
+    @GetMapping("/getMyRatingList")
+    public R getMyRatingList(@RequestParam(defaultValue = "1") Integer pageNum,
+                             @RequestParam(defaultValue = "10") Integer pageSize,
+                             @RequestParam Integer businessType,
+                             @RequestParam Long userId,
+                             @RequestParam(required = false) Integer auditStatus) {
+        log.info("CommonRatingController.getMyRatingList?pageNum={}&pageSize={}&businessType={}&userId={}&auditStatus={}", pageNum, pageSize, businessType, userId, auditStatus);
+        return commonRatingService.getMyRatingList(pageNum, pageSize, businessType, userId, auditStatus);
+    }
 
 }
-

+ 11 - 0
alien-store/src/main/java/shop/alien/store/service/CommonRatingService.java

@@ -61,6 +61,17 @@ public interface CommonRatingService extends IService<CommonRating> {
      */
     void updateStoreScoreAfterDelete(Integer businessId);
 
+    /**
+     * 查询我的评价
+     * @param pageNum
+     * @param pageSize
+     * @param businessType
+     * @param userId
+     * @param auditStatus
+     * @return
+     */
+    R getMyRatingList(Integer pageNum, Integer pageSize, Integer businessType, Long userId, Integer auditStatus);
+
 
   /*  /**
      * 根据业务类型和业务ID获取平均评分

+ 16 - 0
alien-store/src/main/java/shop/alien/store/service/impl/CommonRatingServiceImpl.java

@@ -779,6 +779,22 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
         }
     }
 
+    @Override
+    public R getMyRatingList(Integer pageNum, Integer pageSize, Integer businessType, Long userId, Integer auditStatus) {
+        Page<CommonRating> page = new Page<>(pageNum, pageSize);
+        // 改成queryWrapper
+        QueryWrapper<CommonRating> wrapper = new QueryWrapper<>();
+        wrapper.eq(businessType!=null,"cr.business_type", businessType)
+                .eq(userId != null, "cr.user_id", userId)
+                .eq("cr.delete_flag", 0)
+                .eq(auditStatus != null,"cr.audit_status", auditStatus);
+        wrapper.eq("cr.is_show", 1);
+        wrapper.orderByDesc("cr.created_time");
+        IPage<CommonRating> page1 = commonRatingMapper.getMyRatingList(page, wrapper);
+        R<IPage<CommonRatingVo>> iPageR = doListBusinessWithType(page1, businessType, userId, null);
+        return iPageR;
+    }
+
 /*
     @Override
     public Double getAverageScore(Integer businessType, Long businessId) {