feat(file): 在文件预览界面添加评论功能

- 实现文件评论的前端展示界面,包括评论列表、输入框和交互功能
- 添加文件评论的API接口,支持查询和新增评论操作
- 设计并实现后端服务层、控制器、数据访问层等相关组件
- 集成评论功能到现有的文件预览页面,支持展开/收起评论区
- 实现评论数据的实时加载和提交功能,优化用户体验
This commit is contained in:
jhd
2026-07-04 10:02:52 +08:00
parent 5029d09f09
commit 09466ad4a7
10 changed files with 443 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package com.klp.system.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.klp.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 文件评论对象 sys_file_comment
*
* @author klp
* @date 2026-07-04
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_file_comment")
public class SysFileComment extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 主键ID
*/
@TableId(value = "comment_id")
private Long commentId;
/**
* 关联文件ID
*/
private Long fileId;
/**
* 评论内容
*/
private String content;
/**
* 所属部门
*/
private String dept;
}

View File

@@ -0,0 +1,42 @@
package com.klp.system.domain.bo;
import com.klp.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.*;
/**
* 文件评论业务对象 sys_file_comment
*
* @author klp
* @date 2026-07-04
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SysFileCommentBo extends BaseEntity {
/**
* 主键ID
*/
private Long commentId;
/**
* 关联文件ID
*/
@NotNull(message = "文件ID不能为空")
private Long fileId;
/**
* 评论内容
*/
@NotBlank(message = "评论内容不能为空")
private String content;
/**
* 所属部门
*/
private String dept;
}

View File

@@ -0,0 +1,40 @@
package com.klp.system.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.klp.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 文件评论视图对象 sys_file_comment
*
* @author klp
* @date 2026-07-04
*/
@Data
@ExcelIgnoreUnannotated
public class SysFileCommentVo extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Long commentId;
/**
* 关联文件ID
*/
private Long fileId;
/**
* 评论内容
*/
private String content;
/**
* 所属部门
*/
private String dept;
}

View File

@@ -0,0 +1,15 @@
package com.klp.system.mapper;
import com.klp.system.domain.SysFileComment;
import com.klp.system.domain.vo.SysFileCommentVo;
import com.klp.common.core.mapper.BaseMapperPlus;
/**
* 文件评论Mapper接口
*
* @author klp
* @date 2026-07-04
*/
public interface SysFileCommentMapper extends BaseMapperPlus<SysFileCommentMapper, SysFileComment, SysFileCommentVo> {
}

View File

@@ -0,0 +1,25 @@
package com.klp.system.service;
import com.klp.system.domain.vo.SysFileCommentVo;
import com.klp.system.domain.bo.SysFileCommentBo;
import java.util.List;
/**
* 文件评论Service接口
*
* @author klp
* @date 2026-07-04
*/
public interface ISysFileCommentService {
/**
* 查询文件评论列表
*/
List<SysFileCommentVo> queryListByFileId(Long fileId);
/**
* 新增文件评论
*/
Boolean insertByBo(SysFileCommentBo bo);
}

View File

@@ -0,0 +1,50 @@
package com.klp.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.klp.common.helper.LoginHelper;
import com.klp.system.domain.bo.SysFileCommentBo;
import com.klp.system.domain.vo.SysFileCommentVo;
import com.klp.system.domain.SysFileComment;
import com.klp.system.mapper.SysFileCommentMapper;
import com.klp.system.service.ISysFileCommentService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 文件评论Service业务层处理
*
* @author klp
* @date 2026-07-04
*/
@RequiredArgsConstructor
@Service
public class SysFileCommentServiceImpl implements ISysFileCommentService {
private final SysFileCommentMapper baseMapper;
/**
* 查询文件评论列表(按时间升序)
*/
@Override
public List<SysFileCommentVo> queryListByFileId(Long fileId) {
LambdaQueryWrapper<SysFileComment> lqw = Wrappers.lambdaQuery();
lqw.eq(SysFileComment::getFileId, fileId);
lqw.orderByAsc(SysFileComment::getCreateTime);
return baseMapper.selectVoList(lqw);
}
/**
* 新增文件评论
*/
@Override
public Boolean insertByBo(SysFileCommentBo bo) {
SysFileComment add = BeanUtil.toBean(bo, SysFileComment.class);
// 自动填充部门和评论人
add.setDept(LoginHelper.getLoginUser().getDeptName());
return baseMapper.insert(add) > 0;
}
}

View File

@@ -0,0 +1,16 @@
<?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="com.klp.system.mapper.SysFileCommentMapper">
<resultMap type="com.klp.system.domain.SysFileComment" id="SysFileCommentResult">
<result property="commentId" column="comment_id"/>
<result property="fileId" column="file_id"/>
<result property="content" column="content"/>
<result property="dept" column="dept"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
</mapper>