src/main/java/com/ruoyi/approve/controller/KnowledgeBaseController.java
@@ -1,11 +1,17 @@ package com.ruoyi.approve.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.approve.mapper.KnowledgeBaseFileMapper; import com.ruoyi.approve.mapper.KnowledgeBaseMapper; import com.ruoyi.approve.pojo.KnowledgeBase; import com.ruoyi.approve.pojo.KnowledgeBaseFile; import com.ruoyi.approve.pojo.RpaProcessAutomation; import com.ruoyi.approve.service.KnowledgeBaseFileService; import com.ruoyi.approve.service.KnowledgeBaseService; import com.ruoyi.approve.vo.KnowledgeBaseVo; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.framework.web.domain.AjaxResult; import io.swagger.annotations.Api; @@ -13,6 +19,7 @@ import lombok.AllArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -24,6 +31,8 @@ public class KnowledgeBaseController { @Autowired private KnowledgeBaseService knowledgeBaseService; @Autowired private KnowledgeBaseFileService knowledgeBaseFileService; /**ã * è·åå表 @@ -31,25 +40,29 @@ */ @GetMapping("/getList") public AjaxResult getList(@RequestParam(defaultValue = "1") long current, @RequestParam(defaultValue = "10") long size, KnowledgeBase knowledgeBase) { @RequestParam(defaultValue = "10") long size, KnowledgeBaseVo knowledgeBase) { Page page = new Page(current, size); return AjaxResult.success(knowledgeBaseService.listpage(page,knowledgeBase)); IPage<KnowledgeBaseVo> listpage = knowledgeBaseService.listpage(page, knowledgeBase); listpage.getRecords().forEach(item -> { item.setFiles(knowledgeBaseFileService.list(new QueryWrapper<KnowledgeBaseFile>().lambda().eq(KnowledgeBaseFile::getKnowledgeBaseId, item.getId()))); }); return AjaxResult.success(listpage); } /**ã * 墿·» * @return */ @PostMapping("/add") public AjaxResult add(@RequestBody KnowledgeBase knowledgeBase){ return AjaxResult.success(knowledgeBaseService.save(knowledgeBase)); public AjaxResult add(@RequestBody KnowledgeBaseVo knowledgeBase){ return AjaxResult.success(knowledgeBaseService.add(knowledgeBase)); } /** * æ´æ° * @return */ @PostMapping("/update") public AjaxResult update(@RequestBody KnowledgeBase knowledgeBase){ return AjaxResult.success(knowledgeBaseService.updateById(knowledgeBase)); public AjaxResult update(@RequestBody KnowledgeBaseVo knowledgeBase){ return AjaxResult.success(knowledgeBaseService.updateKnowledgeBase(knowledgeBase)); } /** * å é¤ @@ -58,6 +71,7 @@ @DeleteMapping("/delete") public AjaxResult delete(@RequestBody List<Long> ids){ if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("è¯·ä¼ å ¥è¦å é¤çID"); knowledgeBaseFileService.remove(new QueryWrapper<KnowledgeBaseFile>().lambda().in(KnowledgeBaseFile::getKnowledgeBaseId, ids)); return AjaxResult.success(knowledgeBaseService.removeByIds(ids)); } src/main/java/com/ruoyi/approve/controller/KnowledgeBaseFileController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,72 @@ package com.ruoyi.approve.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.pojo.AccountFile; import com.ruoyi.account.service.AccountFileService; import com.ruoyi.approve.pojo.KnowledgeBaseFile; import com.ruoyi.approve.service.KnowledgeBaseFileService; import com.ruoyi.framework.web.domain.AjaxResult; import io.swagger.annotations.ApiOperation; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; /** * <p> * ç¥è¯åº--éä»¶ å端æ§å¶å¨ * </p> * * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå ¬å¸ * @since 2026-04-07 01:45:45 */ @RestController @RequestMapping("/knowledgeBaseFile") public class KnowledgeBaseFileController { @Resource private KnowledgeBaseFileService knowledgeBaseFileService; /** * æ°å¢ * @param accountFile * @return */ @PostMapping("/add") @ApiOperation("æ°å¢") public AjaxResult add(@RequestBody KnowledgeBaseFile accountFile) { return AjaxResult.success(knowledgeBaseFileService.save(accountFile)); } /** * å é¤ * @param ids * @return */ @DeleteMapping("/del") @ApiOperation("å é¤") public AjaxResult delAccountFile(@RequestBody List<Integer> ids) { if(CollectionUtils.isEmpty(ids)){ return AjaxResult.error("è¯·éæ©è³å°ä¸æ¡æ°æ®"); } //å 餿£éªéä»¶ return AjaxResult.success(knowledgeBaseFileService.removeBatchByIds(ids)); } /** *å页æ¥è¯¢ * @param page * @param accountFile * @return */ @GetMapping("/listPage") @ApiOperation("å页æ¥è¯¢") public AjaxResult accountFileListPage(Page page, KnowledgeBaseFile accountFile) { return AjaxResult.success(knowledgeBaseFileService.knowledgeBaseFileListPage(page, accountFile)); } } src/main/java/com/ruoyi/approve/mapper/KnowledgeBaseFileMapper.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,22 @@ package com.ruoyi.approve.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.approve.pojo.KnowledgeBaseFile; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; /** * <p> * ç¥è¯åº--éä»¶ Mapper æ¥å£ * </p> * * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå ¬å¸ * @since 2026-04-07 01:45:45 */ @Mapper public interface KnowledgeBaseFileMapper extends BaseMapper<KnowledgeBaseFile> { IPage<KnowledgeBaseFile> knowledgeBaseFileListPage(Page page,@Param("accountFile") KnowledgeBaseFile accountFile); } src/main/java/com/ruoyi/approve/mapper/KnowledgeBaseMapper.java
@@ -5,9 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.approve.pojo.KnowledgeBase; import com.ruoyi.approve.vo.KnowledgeBaseVo; import org.apache.ibatis.annotations.Mapper; @Mapper public interface KnowledgeBaseMapper extends BaseMapper<KnowledgeBase> { IPage<KnowledgeBase> listpage(Page page, KnowledgeBase knowledgeBase); IPage<KnowledgeBaseVo> listpage(Page page, KnowledgeBase knowledgeBase); } src/main/java/com/ruoyi/approve/pojo/KnowledgeBaseFile.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,55 @@ package com.ruoyi.approve.pojo; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import java.time.LocalDateTime; @Data public class KnowledgeBaseFile { /** * åºå· */ @TableId(type = IdType.AUTO) private Long id; @ApiModelProperty(value = "æä»¶åç§°") private String name; @ApiModelProperty(value = "æä»¶è·¯å¾") private String url; @ApiModelProperty(value = "æä»¶å¤§å°") private int fileSize; @ApiModelProperty(value = "ç¥è¯åºid") @NotBlank(message = "ç¥è¯åºidä¸è½ä¸ºç©º!") private Long knowledgeBaseId; @ApiModelProperty(value = "å建æ¶é´") @TableField(fill = FieldFill.INSERT) private LocalDateTime createTime; @ApiModelProperty(value = "ä¿®æ¹æ¶é´") @TableField(fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; @ApiModelProperty(value = "åå»ºç¨æ·") @TableField(fill = FieldFill.INSERT) private Integer createUser; @ApiModelProperty(value = "ä¿®æ¹ç¨æ·") @TableField(fill = FieldFill.INSERT_UPDATE) private Integer updateUser; @ApiModelProperty(value = "ç§æ·ID") @TableField(fill = FieldFill.INSERT) private Long tenantId; } src/main/java/com/ruoyi/approve/service/KnowledgeBaseFileService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,20 @@ package com.ruoyi.approve.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.pojo.AccountFile; import com.ruoyi.approve.pojo.KnowledgeBaseFile; import com.baomidou.mybatisplus.extension.service.IService; /** * <p> * ç¥è¯åº--éä»¶ æå¡ç±» * </p> * * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå ¬å¸ * @since 2026-04-07 01:45:45 */ public interface KnowledgeBaseFileService extends IService<KnowledgeBaseFile> { IPage<KnowledgeBaseFile> knowledgeBaseFileListPage(Page page, KnowledgeBaseFile accountFile); } src/main/java/com/ruoyi/approve/service/KnowledgeBaseService.java
@@ -4,7 +4,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.approve.pojo.KnowledgeBase; import com.ruoyi.approve.vo.KnowledgeBaseVo; public interface KnowledgeBaseService extends IService<KnowledgeBase> { IPage<KnowledgeBase> listpage(Page page, KnowledgeBase knowledgeBase); IPage<KnowledgeBaseVo> listpage(Page page, KnowledgeBaseVo knowledgeBase); Boolean add(KnowledgeBaseVo knowledgeBase); Boolean updateKnowledgeBase(KnowledgeBaseVo knowledgeBase); } src/main/java/com/ruoyi/approve/service/impl/KnowledgeBaseFileServiceImpl.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,31 @@ package com.ruoyi.approve.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.pojo.AccountFile; import com.ruoyi.approve.pojo.KnowledgeBaseFile; import com.ruoyi.approve.mapper.KnowledgeBaseFileMapper; import com.ruoyi.approve.service.KnowledgeBaseFileService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * <p> * ç¥è¯åº--éä»¶ æå¡å®ç°ç±» * </p> * * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå ¬å¸ * @since 2026-04-07 01:45:45 */ @Service public class KnowledgeBaseFileServiceImpl extends ServiceImpl<KnowledgeBaseFileMapper, KnowledgeBaseFile> implements KnowledgeBaseFileService { @Autowired private KnowledgeBaseFileMapper knowledgeBaseFileMapper; @Override public IPage<KnowledgeBaseFile> knowledgeBaseFileListPage(Page page, KnowledgeBaseFile accountFile) { return knowledgeBaseFileMapper.knowledgeBaseFileListPage(page,accountFile); } } src/main/java/com/ruoyi/approve/service/impl/KnowledgeBaseServiceImpl.java
@@ -3,19 +3,47 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.approve.mapper.KnowledgeBaseFileMapper; import com.ruoyi.approve.mapper.KnowledgeBaseMapper; import com.ruoyi.approve.pojo.KnowledgeBase; import com.ruoyi.approve.pojo.KnowledgeBaseFile; import com.ruoyi.approve.service.KnowledgeBaseService; import com.ruoyi.approve.vo.KnowledgeBaseVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @Service public class KnowledgeBaseServiceImpl extends ServiceImpl<KnowledgeBaseMapper, KnowledgeBase> implements KnowledgeBaseService { @Autowired private KnowledgeBaseMapper knowledgeBaseMapper; @Autowired private KnowledgeBaseFileMapper knowledgeBaseFileMapper; @Override public IPage<KnowledgeBase> listpage(Page page, KnowledgeBase knowledgeBase) { public IPage<KnowledgeBaseVo> listpage(Page page, KnowledgeBaseVo knowledgeBase) { return knowledgeBaseMapper.listpage(page,knowledgeBase); } @Override public Boolean add(KnowledgeBaseVo knowledgeBase) { this.save(knowledgeBase); for (KnowledgeBaseFile file : knowledgeBase.getFiles()) { file.setKnowledgeBaseId(knowledgeBase.getId()); knowledgeBaseFileMapper.insert(file); } return true; } @Override public Boolean updateKnowledgeBase(KnowledgeBaseVo knowledgeBase) { this.updateById(knowledgeBase); for (KnowledgeBaseFile file : knowledgeBase.getFiles()) { if (file.getId() == null) { file.setKnowledgeBaseId(knowledgeBase.getId()); knowledgeBaseFileMapper.insert(file); } } return true; } } src/main/java/com/ruoyi/approve/vo/KnowledgeBaseVo.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,14 @@ package com.ruoyi.approve.vo; import com.ruoyi.approve.pojo.KnowledgeBase; import com.ruoyi.approve.pojo.KnowledgeBaseFile; import lombok.Data; import org.springframework.web.multipart.MultipartFile; import java.util.List; @Data public class KnowledgeBaseVo extends KnowledgeBase { private List<KnowledgeBaseFile> files; } src/main/resources/mapper/approve/KnowledgeBaseFileMapper.xml
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,30 @@ <?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.ruoyi.approve.mapper.KnowledgeBaseFileMapper"> <!-- éç¨æ¥è¯¢æ å°ç»æ --> <resultMap id="BaseResultMap" type="com.ruoyi.approve.pojo.KnowledgeBaseFile"> <id column="id" property="id" /> <result column="name" property="name" /> <result column="url" property="url" /> <result column="file_size" property="fileSize" /> <result column="knowledge_base_id" property="knowledgeBaseId" /> <result column="create_time" property="createTime" /> <result column="create_user" property="createUser" /> <result column="update_time" property="updateTime" /> <result column="update_user" property="updateUser" /> <result column="tenant_id" property="tenantId" /> </resultMap> <select id="knowledgeBaseFileListPage" resultType="com.ruoyi.approve.pojo.KnowledgeBaseFile"> SELECT * FROM account_file where <if test="accountFile.knowledgeBaseId != null and accountFile.knowledgeBaseId != ''"> AND knowledge_base_id = #{accountFile.knowledgeBaseId} </if> <if test="accountFile.name != null and accountFile.name != '' "> AND name = #{accountFile.name} </if> </select> </mapper> src/main/resources/mapper/approve/KnowledgeBaseMapper.xml
@@ -5,7 +5,7 @@ <mapper namespace="com.ruoyi.approve.mapper.KnowledgeBaseMapper"> <select id="listpage" resultType="com.ruoyi.approve.pojo.KnowledgeBase"> <select id="listpage" resultType="com.ruoyi.approve.vo.KnowledgeBaseVo"> select * from knowledge_base <where> 1=1