Explorar o código

优化举报接口,加入通知

zhangchen hai 3 semanas
pai
achega
4168d43c22

+ 4 - 1
alien-entity/src/main/java/shop/alien/entity/store/vo/LawyerUserViolationVo.java

@@ -23,9 +23,12 @@ public class LawyerUserViolationVo extends LawyerUserViolation {
     //举报结果通知
     private String reportResultNotification;
 
-    
     private String phone;
 
     private String nickName;
+
+    private String reportUserName;
+
+    private String reportedUserName;
 }
 

+ 29 - 3
alien-lawyer/src/main/java/shop/alien/lawyer/controller/LawyerUserViolationController.java

@@ -10,6 +10,7 @@ import shop.alien.entity.result.R;
 import shop.alien.entity.store.LawyerUserViolation;
 import shop.alien.entity.store.StoreDictionary;
 import shop.alien.entity.store.dto.LawyerUserViolationDto;
+import shop.alien.entity.store.vo.LawyerUserViolationVo;
 import shop.alien.lawyer.service.LawyerUserViolationService;
 
 import java.util.List;
@@ -104,11 +105,36 @@ public class LawyerUserViolationController {
         return R.data(lawyerUserViolationService.reportListByUserId(userId));
     }
 
-    @ApiOperation("举报结果详细信息")
+    /**
+     * 根据ID查询举报详情
+     * <p>
+     * 根据举报ID查询举报详细信息,包括被举报人信息、举报原因、举报凭证等
+     * </p>
+     *
+     * @param id 举报记录ID
+     * @return 统一响应结果,包含举报详情VO对象
+     * @author system
+     * @since 2025-01-XX
+     */
+    @ApiOperation(value = "举报详细信息", notes = "根据举报ID查询举报详细信息")
     @ApiOperationSupport(order = 3)
     @GetMapping("/reportListById")
-    public R<Map<String, Object>> reportListById(@RequestParam(value = "id") String id) {
-        return R.data(lawyerUserViolationService.reportListById(id));
+    public R<LawyerUserViolationVo> reportListById(@RequestParam(value = "id") String id) {
+        log.info("查询举报详情请求,ID:{}", id);
+        try {
+            LawyerUserViolationVo violationVo = lawyerUserViolationService.reportListById(id);
+            if (violationVo == null) {
+                log.warn("举报记录不存在,ID:{}", id);
+                return R.fail("举报记录不存在");
+            }
+            return R.data(violationVo);
+        } catch (RuntimeException e) {
+            log.warn("查询举报详情业务异常,ID:{},异常信息:{}", id, e.getMessage());
+            return R.fail(e.getMessage());
+        } catch (Exception e) {
+            log.error("查询举报详情异常,ID:{},异常信息:{}", id, e.getMessage(), e);
+            return R.fail("查询举报详情失败,请稍后重试");
+        }
     }
 
     @ApiOperation("举报分页")

+ 14 - 1
alien-lawyer/src/main/java/shop/alien/lawyer/service/LawyerUserViolationService.java

@@ -6,6 +6,7 @@ import shop.alien.entity.store.LawyerUserViolation;
 import shop.alien.entity.store.StoreDictionary;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.dto.LawyerUserViolationDto;
+import shop.alien.entity.store.vo.LawyerUserViolationVo;
 
 import java.io.IOException;
 import java.util.List;
@@ -31,7 +32,19 @@ public interface LawyerUserViolationService extends IService<LawyerUserViolation
 
     Map<String, Object> reportListByUserId(String userId);
 
-    Map<String, Object> reportListById(String id);
+    /**
+     * 根据ID查询举报详情
+     * <p>
+     * 根据举报ID查询举报详细信息,包括被举报人信息、举报原因、举报凭证等
+     * </p>
+     *
+     * @param id 举报记录ID,不能为空
+     * @return 举报详情VO对象,如果记录不存在返回null
+     * @throws RuntimeException 当参数无效或查询异常时抛出
+     * @author system
+     * @since 2025-01-XX
+     */
+    LawyerUserViolationVo reportListById(String id);
 
     IPage<LawyerUserViolationDto> getViolationPage(int page, int size, String orderId, String processingStatus);
 

+ 71 - 26
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/LawyerUserViolationServiceImpl.java

@@ -456,6 +456,32 @@ public class LawyerUserViolationServiceImpl extends ServiceImpl<LawyerUserViolat
     }
 
     /**
+     * 获取举报用户名称
+     *
+     * @param lawyerUserViolation 举报信息对象
+     * @return 举报用户名称
+     */
+    private String getReportingUserName(LawyerUserViolation lawyerUserViolation) {
+        String reportingUserType = lawyerUserViolation.getReportingUserType();
+        String reportingUserId = lawyerUserViolation.getReportingUserId();
+
+        if (StringUtils.isEmpty(reportingUserId)) {
+            return null;
+        }
+
+        if (USER_TYPE_LAWYER.equals(reportingUserType)) {
+            LawyerUser lawyerUser = lawyerUserMapper.selectById(reportingUserId);
+            return lawyerUser != null ? lawyerUser.getName() : null;
+        } else if (USER_TYPE_STORE.equals(reportingUserType)) {
+            StoreUser storeUser = storeUserMapper.selectById(reportingUserId);
+            return storeUser != null ? storeUser.getNickName() : null;
+        } else {
+            LifeUser lifeUser = lifeUserMapper.selectById(reportingUserId);
+            return lifeUser != null ? lifeUser.getUserName() : null;
+        }
+    }
+
+    /**
      * 生成被举报人通知消息
      *
      * @param lawyerUserViolation 举报信息对象
@@ -601,34 +627,53 @@ public class LawyerUserViolationServiceImpl extends ServiceImpl<LawyerUserViolat
         return resultMap;
     }
 
+    /**
+     * 根据ID查询举报详情
+     * <p>
+     * 根据举报ID查询举报详细信息,包括被举报人信息、举报原因、举报凭证等
+     * </p>
+     *
+     * @param id 举报记录ID,不能为空
+     * @return 举报详情VO对象,如果记录不存在返回null
+     * @throws RuntimeException 当参数无效或查询异常时抛出
+     * @author system
+     * @since 2025-01-XX
+     */
     @Override
-    public Map<String, Object> reportListById(String id) {
-        Map<String, Object> resultMap = new HashMap<String, Object>();
-        LawyerUserViolationVo lawyerUserViolationVo = new LawyerUserViolationVo();
-        LawyerUserViolation lawyerUserViolation = lawyerUserViolationMapper.selectById(id);
-        //商户或者用户名称
-        String reportedUserName;
-        if ("3".equals(lawyerUserViolation.getReportedUserType())) {
-            LawyerUser lawyerUser = lawyerUserMapper.selectById(lawyerUserViolation.getReportedUserId());
-            reportedUserName = lawyerUser.getName();
-        } else if ("1".equals(lawyerUserViolation.getReportedUserType())) {
-            StoreUser storeUser = storeUserMapper.selectById(lawyerUserViolation.getReportedUserId());
-            reportedUserName = storeUser.getName();
-        } else {
-            LifeUser lifeUser = lifeUserMapper.selectById(lawyerUserViolation.getReportedUserId());
-            reportedUserName = lifeUser.getUserName();
+    public LawyerUserViolationVo reportListById(String id) {
+        // 参数校验
+        if (StringUtils.isEmpty(id)) {
+            log.warn("查询举报详情参数为空,ID:{}", id);
+            throw new RuntimeException("举报ID不能为空");
+        }
+
+        try {
+            // 查询举报记录
+            LawyerUserViolation lawyerUserViolation = lawyerUserViolationMapper.selectById(id);
+            if (lawyerUserViolation == null) {
+                log.warn("举报记录不存在,ID:{}", id);
+                return null;
+            }
+
+            // 构建VO对象
+            LawyerUserViolationVo violationVo = new LawyerUserViolationVo();
+            BeanUtils.copyProperties(lawyerUserViolation, violationVo);
+
+            // 获取被举报用户名称
+            String reportedUserName = getReportedUserName(lawyerUserViolation);
+            violationVo.setReportedUserName(reportedUserName);
+
+            // 获取举报用户名称
+            String reportingUserName = getReportingUserName(lawyerUserViolation);
+            violationVo.setReportUserName(reportingUserName);
+
+            log.info("查询举报详情成功,ID:{}", id);
+            return violationVo;
+
+        } catch (Exception e) {
+            log.error("查询举报详情异常,ID:{},异常信息:{}", id, e.getMessage(), e);
+            throw new RuntimeException("查询举报详情失败:" + e.getMessage(), e);
         }
-        resultMap.put("message", lawyerUserViolation.getProcessingStatus() != null ? lawyerUserViolation.getProcessingStatus() : "");
-        lawyerUserViolationVo.setReportObject(reportedUserName);
-        lawyerUserViolationVo.setViolationReason(lawyerUserViolation.getViolationReason());
-        lawyerUserViolationVo.setReportEvidenceImg(lawyerUserViolation.getReportEvidenceImg());
-        lawyerUserViolationVo.setCreatedTime(lawyerUserViolation.getCreatedTime());
-        resultMap.put("reportDetail", lawyerUserViolationVo);
-        LawyerUserViolationVo lawyerUserViolationVo2 = new LawyerUserViolationVo();
-        lawyerUserViolationVo2.setProcessingStatus(lawyerUserViolation.getProcessingStatus());
-        lawyerUserViolationVo2.setProcessingTime(lawyerUserViolation.getProcessingTime());
-        resultMap.put("processStatus", lawyerUserViolationVo);
-        return resultMap;
     }
 
     @Override