浏览代码

律师申诉

qxy 3 周之前
父节点
当前提交
985a72de5a

+ 75 - 0
alien-entity/src/main/java/shop/alien/entity/store/CommentAppeal.java

@@ -0,0 +1,75 @@
+package shop.alien.entity.store;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 评论申诉表
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Data
+@JsonInclude
+@EqualsAndHashCode(callSuper = false)
+@TableName("comment_appeals")
+@ApiModel(value = "CommentAppeal对象", description = "评论申诉表")
+public class CommentAppeal extends Model<CommentAppeal> {
+
+    @ApiModelProperty(value = "主键id")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "评论id")
+    @TableField("comment_id")
+    private Integer commentId;
+
+    @ApiModelProperty(value = "评论内容")
+    @TableField("comment_info")
+    private String commentInfo;
+
+    @ApiModelProperty(value = "申诉理由")
+    @TableField("appeal_reason")
+    private String appealReason;
+
+    @ApiModelProperty(value = "申诉处理状态, 0:待处理, 1:已通过, 2:已驳回")
+    @TableField("status")
+    private Integer status;
+
+    @ApiModelProperty(value = "删除标记, 0:未删除, 1:已删除")
+    @TableField("delete_flag")
+    @TableLogic
+    private Integer deleteFlag;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(value = "created_time", fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createdTime;
+
+    @ApiModelProperty(value = "创建人ID")
+    @TableField(value = "created_user_id", fill = FieldFill.INSERT)
+    private Integer createdUserId;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updatedTime;
+
+    @ApiModelProperty(value = "更新人ID")
+    @TableField(value = "updated_user_id", fill = FieldFill.INSERT_UPDATE)
+    private Integer updatedUserId;
+
+    @ApiModelProperty(value = "申诉时间")
+    @TableField(value = "appeal_time", fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date appealTime;
+}
+

+ 16 - 0
alien-entity/src/main/java/shop/alien/mapper/CommentAppealMapper.java

@@ -0,0 +1,16 @@
+package shop.alien.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import shop.alien.entity.store.CommentAppeal;
+
+/**
+ * 评论申诉表 Mapper 接口
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Mapper
+public interface CommentAppealMapper extends BaseMapper<CommentAppeal> {
+}
+

+ 21 - 0
alien-entity/src/main/resources/mapper/CommentAppealMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="shop.alien.mapper.CommentAppealMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="shop.alien.entity.store.CommentAppeal">
+        <id column="id" property="id" />
+        <result column="comment_id" property="commentId" />
+        <result column="comment_info" property="commentInfo" />
+        <result column="appeal_reason" property="appealReason" />
+        <result column="status" property="status" />
+        <result column="delete_flag" property="deleteFlag" />
+        <result column="created_time" property="createdTime" />
+        <result column="created_user_id" property="createdUserId" />
+        <result column="updated_time" property="updatedTime" />
+        <result column="updated_user_id" property="updatedUserId" />
+        <result column="appeal_time" property="appealTime" />
+    </resultMap>
+
+</mapper>
+

+ 86 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/controller/CommentAppealController.java

@@ -0,0 +1,86 @@
+package shop.alien.lawyer.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import io.swagger.annotations.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.CommentAppeal;
+import shop.alien.lawyer.service.CommentAppealService;
+
+/**
+ * 评论申诉表 前端控制器
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Slf4j
+@Api(tags = {"评论申诉管理"})
+@ApiSort(20)
+@CrossOrigin
+@RestController
+@RequestMapping("/commentAppeal")
+@RequiredArgsConstructor
+public class CommentAppealController {
+
+    private final CommentAppealService commentAppealService;
+
+    @ApiOperation(value = "提交申诉", notes = "用户提交评论申诉")
+    @ApiOperationSupport(order = 1)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "commentAppeal", value = "申诉信息", dataType = "CommentAppeal", paramType = "body", required = true)
+    })
+    @PostMapping("/submit")
+    public R<CommentAppeal> submitAppeal(@RequestBody CommentAppeal commentAppeal) {
+        log.info("CommentAppealController.submitAppeal?commentAppeal={}", commentAppeal);
+        return commentAppealService.submitAppeal(commentAppeal);
+    }
+
+    @ApiOperation(value = "审核申诉", notes = "管理员审核申诉,状态:1-已通过,2-已驳回")
+    @ApiOperationSupport(order = 2)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "申诉ID", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "status", value = "审核状态:1-已通过,2-已驳回", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "userId", value = "审核人ID", dataType = "Integer", paramType = "query", required = true)
+    })
+    @PostMapping("/audit")
+    public R<Boolean> auditAppeal(
+            @RequestParam("id") Integer id,
+            @RequestParam("status") Integer status,
+            @RequestParam("userId") Integer userId) {
+        log.info("CommentAppealController.auditAppeal?id={}, status={}, userId={}", id, status, userId);
+        return commentAppealService.auditAppeal(id, status, userId);
+    }
+
+    @ApiOperation(value = "分页查询申诉列表", notes = "分页查询申诉列表,支持按状态和评论ID筛选")
+    @ApiOperationSupport(order = 3)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum", value = "页数(默认1)", dataType = "int", paramType = "query"),
+            @ApiImplicitParam(name = "pageSize", value = "页容(默认10)", dataType = "int", paramType = "query"),
+            @ApiImplicitParam(name = "status", value = "申诉状态:0-待处理,1-已通过,2-已驳回", dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "commentId", value = "评论ID", dataType = "Integer", paramType = "query")
+    })
+    @GetMapping("/getPage")
+    public R<IPage<CommentAppeal>> getAppealPage(
+            @RequestParam(defaultValue = "1") int pageNum,
+            @RequestParam(defaultValue = "10") int pageSize,
+            @RequestParam(required = false) Integer status,
+            @RequestParam(required = false) Integer commentId) {
+        log.info("CommentAppealController.getAppealPage?pageNum={}, pageSize={}, status={}, commentId={}", 
+                pageNum, pageSize, status, commentId);
+        return commentAppealService.getAppealPage(pageNum, pageSize, status, commentId);
+    }
+
+    @ApiOperation(value = "获取申诉详情", notes = "根据申诉ID获取申诉详情")
+    @ApiOperationSupport(order = 4)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "申诉ID", dataType = "Integer", paramType = "query", required = true)
+    })
+    @GetMapping("/getDetail")
+    public R<CommentAppeal> getAppealDetail(@RequestParam("id") Integer id) {
+        log.info("CommentAppealController.getAppealDetail?id={}", id);
+        return commentAppealService.getAppealDetail(id);
+    }
+}
+

+ 53 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/service/CommentAppealService.java

@@ -0,0 +1,53 @@
+package shop.alien.lawyer.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.CommentAppeal;
+
+/**
+ * 评论申诉表 服务类
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+public interface CommentAppealService extends IService<CommentAppeal> {
+
+    /**
+     * 提交申诉
+     *
+     * @param commentAppeal 申诉信息
+     * @return 操作结果
+     */
+    R<CommentAppeal> submitAppeal(CommentAppeal commentAppeal);
+
+    /**
+     * 审核申诉
+     *
+     * @param id     申诉ID
+     * @param status 审核状态 1:已通过, 2:已驳回
+     * @param userId 审核人ID
+     * @return 操作结果
+     */
+    R<Boolean> auditAppeal(Integer id, Integer status, Integer userId);
+
+    /**
+     * 分页查询申诉列表
+     *
+     * @param pageNum  页数
+     * @param pageSize 页容
+     * @param status   申诉状态 0:待处理, 1:已通过, 2:已驳回
+     * @param commentId 评论ID(可选)
+     * @return 分页结果
+     */
+    R<IPage<CommentAppeal>> getAppealPage(Integer pageNum, Integer pageSize, Integer status, Integer commentId);
+
+    /**
+     * 获取申诉详情
+     *
+     * @param id 申诉ID
+     * @return 申诉详情
+     */
+    R<CommentAppeal> getAppealDetail(Integer id);
+}
+

+ 147 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/CommentAppealServiceImpl.java

@@ -0,0 +1,147 @@
+package shop.alien.lawyer.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.CommentAppeal;
+import shop.alien.mapper.CommentAppealMapper;
+import shop.alien.lawyer.service.CommentAppealService;
+
+/**
+ * 评论申诉表 服务实现类
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Slf4j
+@Transactional
+@Service
+@RequiredArgsConstructor
+public class CommentAppealServiceImpl extends ServiceImpl<CommentAppealMapper, CommentAppeal> implements CommentAppealService {
+
+    @Override
+    public R<CommentAppeal> submitAppeal(CommentAppeal commentAppeal) {
+        log.info("CommentAppealServiceImpl.submitAppeal?commentAppeal={}", commentAppeal);
+
+        // 校验必填字段
+        if (commentAppeal.getCommentId() == null) {
+            return R.fail("评论ID不能为空");
+        }
+        if (!StringUtils.hasText(commentAppeal.getAppealReason())) {
+            return R.fail("申诉理由不能为空");
+        }
+
+        // 检查该评论是否已有待处理或已通过的申诉
+        LambdaQueryWrapper<CommentAppeal> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(CommentAppeal::getCommentId, commentAppeal.getCommentId());
+        wrapper.eq(CommentAppeal::getDeleteFlag, 0);
+        wrapper.in(CommentAppeal::getStatus, 0, 1); // 待处理或已通过
+        CommentAppeal existingAppeal = this.getOne(wrapper);
+        if (existingAppeal != null) {
+            return R.fail("该评论已有申诉记录,无法重复申诉");
+        }
+
+        // 设置默认值
+        commentAppeal.setStatus(0); // 待处理
+        if (commentAppeal.getDeleteFlag() == null) {
+            commentAppeal.setDeleteFlag(0);
+        }
+
+        // 保存申诉
+        boolean result = this.save(commentAppeal);
+        if (result) {
+            log.info("提交申诉成功,id={}", commentAppeal.getId());
+            return R.data(commentAppeal, "申诉提交成功");
+        } else {
+            return R.fail("申诉提交失败");
+        }
+    }
+
+    @Override
+    public R<Boolean> auditAppeal(Integer id, Integer status, Integer userId) {
+        log.info("CommentAppealServiceImpl.auditAppeal?id={}, status={}, userId={}", id, status, userId);
+
+        // 校验参数
+        if (id == null) {
+            return R.fail("申诉ID不能为空");
+        }
+        if (status == null || (status != 1 && status != 2)) {
+            return R.fail("审核状态不正确,必须是1(已通过)或2(已驳回)");
+        }
+        if (userId == null) {
+            return R.fail("审核人ID不能为空");
+        }
+
+        // 查询申诉记录
+        CommentAppeal appeal = this.getById(id);
+        if (appeal == null || appeal.getDeleteFlag() == 1) {
+            return R.fail("申诉记录不存在或已被删除");
+        }
+
+        // 检查状态
+        if (appeal.getStatus() != 0) {
+            return R.fail("该申诉已处理,无法重复审核");
+        }
+
+        // 更新状态
+        CommentAppeal updateAppeal = new CommentAppeal();
+        updateAppeal.setId(id);
+        updateAppeal.setStatus(status);
+        updateAppeal.setUpdatedUserId(userId);
+
+        boolean result = this.updateById(updateAppeal);
+        if (result) {
+            String statusText = status == 1 ? "已通过" : "已驳回";
+            log.info("审核申诉成功,id={}, status={}", id, statusText);
+            return R.success("审核成功,申诉" + statusText);
+        } else {
+            return R.fail("审核失败");
+        }
+    }
+
+    @Override
+    public R<IPage<CommentAppeal>> getAppealPage(Integer pageNum, Integer pageSize, Integer status, Integer commentId) {
+        log.info("CommentAppealServiceImpl.getAppealPage?pageNum={}, pageSize={}, status={}, commentId={}", 
+                pageNum, pageSize, status, commentId);
+
+        Page<CommentAppeal> page = new Page<>(pageNum, pageSize);
+        LambdaQueryWrapper<CommentAppeal> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(CommentAppeal::getDeleteFlag, 0);
+        
+        if (status != null) {
+            wrapper.eq(CommentAppeal::getStatus, status);
+        }
+        if (commentId != null) {
+            wrapper.eq(CommentAppeal::getCommentId, commentId);
+        }
+        
+        wrapper.orderByDesc(CommentAppeal::getCreatedTime);
+        
+        IPage<CommentAppeal> pageResult = this.page(page, wrapper);
+        return R.data(pageResult);
+    }
+
+    @Override
+    public R<CommentAppeal> getAppealDetail(Integer id) {
+        log.info("CommentAppealServiceImpl.getAppealDetail?id={}", id);
+
+        if (id == null) {
+            return R.fail("申诉ID不能为空");
+        }
+
+        CommentAppeal appeal = this.getById(id);
+        if (appeal == null || appeal.getDeleteFlag() == 1) {
+            return R.fail("申诉记录不存在或已被删除");
+        }
+
+        return R.data(appeal, "查询成功");
+    }
+}
+