| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | public class KnowledgeBaseController { |
| | | @Autowired |
| | | private KnowledgeBaseService knowledgeBaseService; |
| | | @Autowired |
| | | private KnowledgeBaseFileService knowledgeBaseFileService; |
| | | |
| | | /**、 |
| | | * 获取列表 |
| | |
| | | */ |
| | | @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)); |
| | | } |
| | | /** |
| | | * 删除 |
| | |
| | | @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)); |
| | | } |
| | | |