Ver código fonte

功能添加注释

zjy 1 mês atrás
pai
commit
1666bdaf14

+ 8 - 1
alien-entity/src/main/java/shop/alien/mapper/second/SecondUserCreditMapper.java

@@ -8,11 +8,18 @@ import shop.alien.entity.second.SecondUserCredit;
 
 
 /**
- * 二手商品映射器
+ * 用户积分Mapper接口
+ * 提供用户积分的数据库操作方法
  */
 @Mapper
 public interface SecondUserCreditMapper extends BaseMapper<SecondUserCredit> {
 
+    /**
+     * 根据用户ID更新用户积分
+     *
+     * @param userId 用户ID
+     * @param points 要增加的积分值
+     */
     @Select("update second_user_credit set user_points = user_points + #{points} " +
             "where user_id = #{userId} and delete_flag = 0 ")
     void updatePointsByUserId(@Param("userId") int userId, @Param("points") int points);

+ 18 - 1
alien-second/src/main/java/shop/alien/second/controller/SecondGoodsReportingController.java

@@ -11,6 +11,10 @@ import shop.alien.entity.second.vo.SecondReportingVo;
 import shop.alien.entity.second.vo.SecondUserViolationVo;
 import shop.alien.second.service.SecondGoodsReportingService;
 
+/**
+ * 二手平台举报详情控制器
+ * 提供举报详情查询和商品举报功能
+ */
 @Slf4j
 @Api(tags = {"二手平台-举报详情"})
 @ApiSort(9)
@@ -22,6 +26,12 @@ public class SecondGoodsReportingController {
 
     private final SecondGoodsReportingService service;
 
+    /**
+     * 查询举报详情
+     *
+     * @param id 举报记录ID
+     * @return 举报详情信息
+     */
     @ApiOperation("举报详情")
     @PostMapping("/queryReportingDetail")
     public R<SecondReportingVo> queryReportingDetail(@RequestParam(value = "id", required = false) Integer id) {
@@ -29,6 +39,13 @@ public class SecondGoodsReportingController {
         return R.data(service.queryReportingDetail(id), "查询成功");
     }
 
+    /**
+     * 商品举报
+     *
+     * @param lifeuserViolation 举报信息对象
+     * @return 举报结果,成功返回"举报成功",失败返回"举报失败"
+     * @throws Exception 举报过程中可能发生的异常
+     */
     @ApiOperation("举报")
     @PostMapping("/addReport")
     public R<String> reporting(@RequestBody SecondUserViolationVo lifeuserViolation) throws Exception {
@@ -40,4 +57,4 @@ public class SecondGoodsReportingController {
         return R.data("举报成功");
     }
 
-}
+}

+ 16 - 1
alien-second/src/main/java/shop/alien/second/controller/SecondShieldController.java

@@ -17,6 +17,10 @@ import shop.alien.util.common.JwtUtil;
 
 import java.util.Date;
 
+/**
+ * 二手平台拉黑控制器
+ * 提供商品拉黑和取消拉黑功能
+ */
 @Slf4j
 @Api(tags = {"二手平台-拉黑"})
 @ApiSort(9)
@@ -28,6 +32,13 @@ public class SecondShieldController {
 
     private final SecondShieldMapper mapper;
 
+    /**
+     * 商品拉黑
+     * 将指定商品加入黑名单
+     *
+     * @param shieldId 要拉黑的商品ID
+     * @return 操作结果,成功返回"拉黑成功",失败返回"拉黑失败"
+     */
     @ApiOperation("商品拉黑")
     @PostMapping("/saveGoodsShield")
     public R<T> saveGoodsShield(
@@ -60,6 +71,10 @@ public class SecondShieldController {
 
     /**
      * 取消拉黑
+     * 将指定商品从黑名单中移除
+     *
+     * @param secondGoods 包含要取消拉黑商品信息的对象
+     * @return 操作结果,成功返回"取消拉黑成功"
      */
     @PostMapping("/deleteGoodsShield")
     @ApiOperation("取消拉黑")
@@ -69,4 +84,4 @@ public class SecondShieldController {
         return R.success("取消拉黑成功");
     }
 
-}
+}

+ 34 - 0
alien-second/src/main/java/shop/alien/second/controller/SecondUserCreditController.java

@@ -12,6 +12,7 @@ import shop.alien.second.service.SecondUserCreditService;
 
 /**
  * 二手平台用户积分控制器
+ * 提供用户积分查询、更新、创建积分记录、身份认证加分等功能
  */
 @Slf4j
 @Api(tags = {"二期-用户积分"})
@@ -23,6 +24,12 @@ public class SecondUserCreditController {
     
     private final SecondUserCreditService secondUserCreditService;
     
+    /**
+     * 根据用户ID获取用户积分信息
+     *
+     * @param userId 用户ID
+     * @return 用户积分信息
+     */
     @ApiOperation("获取用户积分")
     @ApiOperationSupport(order = 1)
     @ApiImplicitParams({
@@ -40,6 +47,12 @@ public class SecondUserCreditController {
         }
     }
     
+    /**
+     * 更新用户积分
+     *
+     * @param credit 用户积分信息对象
+     * @return 更新结果,成功返回true,失败返回false
+     */
     @ApiOperation("更新用户积分")
     @ApiOperationSupport(order = 2)
     @PostMapping("/update/credit")
@@ -58,6 +71,13 @@ public class SecondUserCreditController {
         }
     }
     
+    /**
+     * 新建用户积分记录
+     *
+     * @param userId 用户ID
+     * @param initialPoints 初始积分值
+     * @param pointsType 积分类型
+     */
     @ApiOperation("新建用户积分记录")
     @ApiOperationSupport(order = 3)
     @ApiImplicitParams({
@@ -77,6 +97,13 @@ public class SecondUserCreditController {
         }
     }
 
+    /**
+     * 用户身份认证成功后增加信用分
+     *
+     * @param userId 用户ID
+     * @return 增加信用分结果
+     * @throws Exception 处理过程中可能发生的异常
+     */
     @ApiOperation("用户身份认证成功后增加信用分")
     @ApiOperationSupport(order = 4)
     @ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户ID", dataType = "Integer", required = true)})
@@ -86,6 +113,13 @@ public class SecondUserCreditController {
         return R.data(secondUserCreditService.addIdInfoPoints(userId));
     }
 
+    /**
+     * 检查用户信用分是否达标
+     *
+     * @param userId 用户ID
+     * @return 检查结果,包含是否达标和相关信息的JSON对象
+     * @throws Exception 处理过程中可能发生的异常
+     */
     @ApiOperation("信用分是否达标")
     @ApiOperationSupport(order = 5)
     @ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户ID", dataType = "Integer", required = true)})

+ 13 - 0
alien-second/src/main/java/shop/alien/second/controller/SecondUserCreditRecordController.java

@@ -12,6 +12,7 @@ import java.util.List;
 
 /**
  * 二手平台用户积分记录控制器
+ * 提供用户积分记录查询和创建积分记录功能
  */
 @Slf4j
 @Api(tags = {"二期-用户积分记录"})
@@ -23,6 +24,12 @@ public class SecondUserCreditRecordController {
     
     private final SecondUserCreditRecordService secondUserPointsRecordService;
     
+    /**
+     * 根据用户ID获取用户积分记录列表
+     *
+     * @param userId 用户ID
+     * @return 用户积分记录列表
+     */
     @ApiOperation("获取用户积分记录列表")
     @ApiOperationSupport(order = 1)
     @ApiImplicitParams({
@@ -40,6 +47,12 @@ public class SecondUserCreditRecordController {
         }
     }
     
+    /**
+     * 创建积分记录
+     *
+     * @param record 积分记录对象
+     * @return 创建结果,成功返回true,失败返回false
+     */
     @ApiOperation("创建积分记录")
     @ApiOperationSupport(order = 2)
     @PostMapping("/create")

+ 13 - 4
alien-second/src/main/java/shop/alien/second/service/SecondGoodsReportingService.java

@@ -6,19 +6,28 @@ import shop.alien.entity.second.vo.SecondUserViolationVo;
 
 
 /**
- * 二手商品服务接口
+ * 二手商品举报服务接口
+ * 提供举报详情查询和商品举报等核心业务功能
  */
 public interface SecondGoodsReportingService {
 
 
     /**
-     * 查询商品详情信息
-     * @param id ID
-     * @return 举报详情
+     * 查询举报详情信息
+     *
+     * @param id 举报记录ID
+     * @return 举报详情信息
      */
     SecondReportingVo queryReportingDetail(Integer id);
 
 
+    /**
+     * 商品举报
+     *
+     * @param lifeuserViolation 举报信息对象
+     * @return 举报结果,大于0表示举报成功
+     * @throws Exception 举报过程中可能发生的异常
+     */
     int reporting(SecondUserViolationVo lifeuserViolation) throws Exception;
 
 

+ 3 - 0
alien-second/src/main/java/shop/alien/second/service/SecondUserCreditRecordService.java

@@ -5,11 +5,13 @@ import shop.alien.entity.second.SecondUserCreditRecord;
 
 /**
  * 二手平台用户积分记录服务接口
+ * 提供用户积分记录查询和创建积分记录等核心业务功能
  */
 public interface SecondUserCreditRecordService extends IService<SecondUserCreditRecord> {
     
     /**
      * 根据用户ID获取积分记录列表
+     *
      * @param userId 用户ID
      * @return 积分记录列表
      */
@@ -17,6 +19,7 @@ public interface SecondUserCreditRecordService extends IService<SecondUserCredit
     
     /**
      * 创建积分记录
+     *
      * @param record 积分记录信息
      * @return 是否创建成功
      */

+ 20 - 1
alien-second/src/main/java/shop/alien/second/service/SecondUserCreditService.java

@@ -7,11 +7,13 @@ import shop.alien.entity.second.vo.SecondUserCreditVo;
 
 /**
  * 二手平台用户积分服务接口
+ * 提供用户积分查询、更新、创建积分记录、身份认证加分等核心业务功能
  */
 public interface SecondUserCreditService extends IService<SecondUserCredit> {
     
     /**
      * 根据用户ID获取用户积分信息
+     *
      * @param userId 用户ID
      * @return 用户积分信息
      */
@@ -19,20 +21,37 @@ public interface SecondUserCreditService extends IService<SecondUserCredit> {
     
     /**
      * 更新用户积分
-     * @param credit
+     *
+     * @param credit 用户积分信息对象
      * @return 是否更新成功
      */
     boolean updatePoints(SecondUserCreditVo credit);
     
     /**
      * 新建用户积分记录
+     *
      * @param userId 用户ID
      * @param initialPoints 初始积分值
+     * @param pointsType 积分类型
      * @return 是否创建成功
      */
     boolean createPointsRecord(Integer userId, Integer initialPoints, Integer pointsType);
 
+    /**
+     * 用户身份认证成功后增加信用分
+     *
+     * @param userId 用户ID
+     * @return 是否增加成功
+     * @throws Exception 处理过程中可能发生的异常
+     */
     boolean addIdInfoPoints(Integer userId) throws Exception;
 
+    /**
+     * 检查用户信用分是否达标
+     *
+     * @param userId 用户ID
+     * @return 检查结果,包含是否达标和相关信息的JSON对象
+     * @throws Exception 处理过程中可能发生的异常
+     */
     JSONObject isFree(Integer userId) throws Exception;
 }

+ 30 - 4
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsReportingServiceImpl.java

@@ -34,13 +34,17 @@ import java.util.*;
 import java.util.stream.Collectors;
 
 /**
- * 二手商品服务实现类
+ * 二手商品举报服务实现类
+ * 实现举报详情查询和商品举报等核心业务逻辑
  */
 @Slf4j
 @Service
 @RequiredArgsConstructor
 public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingService {
 
+    /**
+     * 视频文件类型列表
+     */
     List<String> videoFileType = Arrays.asList("mp4", "avi", "flv", "mkv", "rmvb", "wmv", "3gp", "mov");
 
     @Autowired
@@ -63,6 +67,13 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
     @Autowired
     private final StoreImgMapper storeImgMapper;
 
+    /**
+     * 查询举报详情信息
+     * 根据举报ID获取举报详情,包括举报内容、举报类型、举报时间等信息
+     *
+     * @param id 举报记录ID
+     * @return 举报详情信息
+     */
     @Override
     public SecondReportingVo queryReportingDetail (Integer id) {
         SecondReportingVo secondReportingVo = new SecondReportingVo();
@@ -179,6 +190,14 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
 
     }
 
+    /**
+     * 商品举报
+     * 处理用户对商品或用户的举报请求,保存举报信息并发送通知
+     *
+     * @param lifeuserViolation 举报信息对象
+     * @return 举报结果,大于0表示举报成功
+     * @throws Exception 举报过程中可能发生的异常
+     */
     @Override
     public int reporting(SecondUserViolationVo lifeuserViolation) throws Exception  {
         try {
@@ -221,6 +240,12 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
         return 0;
     }
 
+    /**
+     * 创建举报通知
+     *
+     * @param lifeuserViolation 举报信息对象
+     * @return 举报通知对象
+     */
     private static LifeNotice getLifeNotice(LifeUserViolation lifeuserViolation)  {
         JSONObject data = JwtUtil.getCurrentUserInfo();
         String phoneId = null;
@@ -241,10 +266,11 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
     }
 
     /**
-     * 保存商品图片信息
+     * 保存举报图片信息
+     *
      * @param id 举报ID
-     * @param goods .getimgUrl 图片URL列表
-     * @return 保存结果
+     * @param goods 举报信息对象,包含图片URL列表
+     * @return 保存结果,始终返回true
      */
     private boolean saveStoreImages(Integer id, SecondUserViolationVo goods ) {
         if (CollectionUtil.isEmpty(goods.getImgUrl())) {

+ 5 - 0
alien-second/src/main/java/shop/alien/second/service/impl/SecondUserCreditRecordServiceImpl.java

@@ -14,6 +14,7 @@ import java.util.List;
 
 /**
  * 二手平台用户积分记录服务实现类
+ * 实现用户积分记录查询和创建积分记录等核心业务逻辑
  */
 @Slf4j
 @Service
@@ -24,6 +25,8 @@ public class SecondUserCreditRecordServiceImpl extends ServiceImpl<SecondUserCre
     
     /**
      * 根据用户ID获取积分记录列表
+     * 按创建时间倒序排列,只查询未删除的记录
+     *
      * @param userId 用户ID
      * @return 积分记录列表
      */
@@ -39,6 +42,8 @@ public class SecondUserCreditRecordServiceImpl extends ServiceImpl<SecondUserCre
     
     /**
      * 创建积分记录
+     * 设置删除标志为0,创建时间和更新时间为当前时间
+     *
      * @param record 积分记录信息
      * @return 是否创建成功
      */

+ 33 - 1
alien-second/src/main/java/shop/alien/second/service/impl/SecondUserCreditServiceImpl.java

@@ -20,6 +20,7 @@ import java.util.Date;
 
 /**
  * 二手平台用户积分服务实现类
+ * 实现用户积分查询、更新、创建积分记录、身份认证加分等核心业务逻辑
  */
 @Slf4j
 @Service
@@ -37,6 +38,7 @@ public class SecondUserCreditServiceImpl extends ServiceImpl<SecondUserCreditMap
 
     /**
      * 根据用户ID获取用户积分信息
+     *
      * @param userId 用户ID
      * @return 用户积分信息
      */
@@ -50,7 +52,9 @@ public class SecondUserCreditServiceImpl extends ServiceImpl<SecondUserCreditMap
     
     /**
      * 更新用户积分
-     * @param credit
+     * 如果用户没有积分记录则创建新记录,否则更新现有积分
+     *
+     * @param credit 用户积分信息对象
      * @return 是否更新成功
      */
     @Override
@@ -87,8 +91,11 @@ public class SecondUserCreditServiceImpl extends ServiceImpl<SecondUserCreditMap
     
     /**
      * 新建用户积分记录
+     * 如果用户已有积分记录则更新,否则创建新的积分记录
+     *
      * @param userId 用户ID
      * @param initialPoints 初始积分值
+     * @param pointsType 积分类型
      * @return 是否创建成功
      */
     @Override
@@ -130,6 +137,14 @@ public class SecondUserCreditServiceImpl extends ServiceImpl<SecondUserCreditMap
         }
     }
 
+    /**
+     * 用户身份认证成功后增加信用分
+     * 每个用户只能增加一次身份认证积分(200分)
+     *
+     * @param userId 用户ID
+     * @return 是否增加成功
+     * @throws Exception 处理过程中可能发生的异常
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean addIdInfoPoints(Integer userId) throws Exception {
@@ -163,6 +178,14 @@ public class SecondUserCreditServiceImpl extends ServiceImpl<SecondUserCreditMap
         }
     }
 
+    /**
+     * 检查用户信用分是否达标
+     * 判断用户是否被冻结以及积分是否达到500分
+     *
+     * @param userId 用户ID
+     * @return 检查结果,包含是否达标和相关信息的JSON对象
+     * @throws Exception 处理过程中可能发生的异常
+     */
     @Override
     public JSONObject isFree(Integer userId) throws Exception {
         try {
@@ -188,6 +211,15 @@ public class SecondUserCreditServiceImpl extends ServiceImpl<SecondUserCreditMap
         }
     }
 
+    /**
+     * 添加用户积分记录
+     * 创建新的用户积分记录和积分变更历史记录
+     *
+     * @param userId 用户ID
+     * @param points 积分值
+     * @param pointsType 积分类型
+     * @return 是否添加成功
+     */
     public boolean addPointsRecord(Integer userId, Integer points, Integer pointsType) {
         try {
             // 创建新的积分记录