|
|
|
@ -1,16 +1,10 @@ |
|
|
|
package com.zdxt.knowledge.controller; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import com.zdxt.auth.dto.DictDataBean; |
|
|
|
import com.zdxt.auth.feign.DictDataApi; |
|
|
|
import com.zdxt.common.ZDResponse; |
|
|
|
import com.zdxt.common.controller.BaseController; |
|
|
|
import com.zdxt.common.util.TableDataInfo; |
|
|
|
import com.zdxt.flow.util.DateUtil; |
|
|
|
import com.zdxt.knowledge.domain.KnowledgeLibrary; |
|
|
|
import com.zdxt.knowledge.domain.KnowledgeLibrary; |
|
|
|
import com.zdxt.knowledge.service.IKnowledgeLibraryService; |
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions; |
|
|
|
@ -21,25 +15,29 @@ import org.springframework.validation.annotation.Validated; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* 知识库Controller |
|
|
|
* |
|
|
|
* |
|
|
|
* @author ruoyi |
|
|
|
* @date 2023-12-25 |
|
|
|
*/ |
|
|
|
@Controller |
|
|
|
@RequestMapping("/small/library") |
|
|
|
public class KnowledgeLibraryController extends BaseController |
|
|
|
{ |
|
|
|
public class KnowledgeLibraryController extends BaseController { |
|
|
|
private String prefix = "project/smallProgram/library"; |
|
|
|
|
|
|
|
@Autowired private IKnowledgeLibraryService knowledgeLibraryService; |
|
|
|
@Autowired private DictDataApi dictDataApi; |
|
|
|
@Autowired |
|
|
|
private IKnowledgeLibraryService knowledgeLibraryService; |
|
|
|
@Autowired |
|
|
|
private DictDataApi dictDataApi; |
|
|
|
|
|
|
|
@RequiresPermissions("small:library:view") |
|
|
|
@GetMapping() |
|
|
|
public String library() |
|
|
|
{ |
|
|
|
public String library() { |
|
|
|
return prefix + "/view"; |
|
|
|
} |
|
|
|
|
|
|
|
@ -49,19 +47,39 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
@RequiresPermissions("small:library:view") |
|
|
|
@PostMapping("/list") |
|
|
|
@ResponseBody |
|
|
|
public TableDataInfo list(KnowledgeLibrary knowledgeLibrary) |
|
|
|
{ |
|
|
|
public TableDataInfo list(KnowledgeLibrary knowledgeLibrary) { |
|
|
|
startPage(); |
|
|
|
List<KnowledgeLibrary> list = knowledgeLibraryService.selectKnowledgeLibraryList(knowledgeLibrary); |
|
|
|
return getDataTable(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询小程序 |
|
|
|
*/ |
|
|
|
@PostMapping("/listApp") |
|
|
|
@ResponseBody |
|
|
|
public TableDataInfo listApp(@RequestBody KnowledgeLibrary knowledgeLibrary) { |
|
|
|
startPage(); |
|
|
|
knowledgeLibrary.setPublishstate(1); |
|
|
|
List<KnowledgeLibrary> list = knowledgeLibraryService.selectKnowledgeLibraryList(knowledgeLibrary); |
|
|
|
return getDataTable(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询 |
|
|
|
*/ |
|
|
|
@PostMapping("/getById") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse getById(@RequestBody KnowledgeLibrary knowledgeLibrary) { |
|
|
|
KnowledgeLibrary library = knowledgeLibraryService.selectKnowledgeLibraryById(knowledgeLibrary.getGuid()); |
|
|
|
return ZDResponse.success("成功", library); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增知识库 |
|
|
|
*/ |
|
|
|
@GetMapping("/add") |
|
|
|
public String add(ModelMap mmap) |
|
|
|
{ |
|
|
|
public String add(ModelMap mmap) { |
|
|
|
DictDataBean dictBean = new DictDataBean(); |
|
|
|
dictBean.setDictType("knowledge_flag"); |
|
|
|
mmap.put("dicts", dictDataApi.getDictData(dictBean)); |
|
|
|
@ -74,18 +92,16 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
@RequiresPermissions("small:library:add") |
|
|
|
@PostMapping("/add") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse addSave(@RequestParam("file") MultipartFile[] files, @Validated KnowledgeLibrary knowledgeLibrary) |
|
|
|
{ |
|
|
|
public ZDResponse addSave(@RequestParam("file") MultipartFile[] files, @Validated KnowledgeLibrary knowledgeLibrary) { |
|
|
|
int resNum = knowledgeLibraryService.insertKnowledgeLibrary(knowledgeLibrary, files); |
|
|
|
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|
|
|
return resNum > 0 ? ZDResponse.success("操作成功", resNum) : ZDResponse.error("操作失败", resNum); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改知识库 |
|
|
|
*/ |
|
|
|
@GetMapping("/edit/{guid}") |
|
|
|
public String edit(@PathVariable("guid") String guid, ModelMap mmap) |
|
|
|
{ |
|
|
|
public String edit(@PathVariable("guid") String guid, ModelMap mmap) { |
|
|
|
KnowledgeLibrary knowledgeLibrary = knowledgeLibraryService.selectKnowledgeLibraryById(guid); |
|
|
|
mmap.put("knowledgeLibrary", knowledgeLibrary); |
|
|
|
|
|
|
|
@ -93,7 +109,7 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
dictBean.setDictType("knowledge_flag"); |
|
|
|
List<DictDataBean> dictDataBeans = dictDataApi.getDictData(dictBean); |
|
|
|
for (DictDataBean dictb : dictDataBeans) { |
|
|
|
if (knowledgeLibrary.getFlag().indexOf(dictb.getDictValue())>-1) { |
|
|
|
if (knowledgeLibrary.getFlag().indexOf(dictb.getDictValue()) > -1) { |
|
|
|
dictb.setIsDefault("Y"); |
|
|
|
} else { |
|
|
|
dictb.setIsDefault("N"); |
|
|
|
@ -109,18 +125,16 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
@RequiresPermissions("small:library:edit") |
|
|
|
@PostMapping("/edit") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse editSave(@RequestParam("file") MultipartFile[] files, KnowledgeLibrary knowledgeLibrary) |
|
|
|
{ |
|
|
|
public ZDResponse editSave(@RequestParam("file") MultipartFile[] files, KnowledgeLibrary knowledgeLibrary) { |
|
|
|
int resNum = knowledgeLibraryService.updateKnowledgeLibrary(knowledgeLibrary, files); |
|
|
|
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|
|
|
return resNum > 0 ? ZDResponse.success("操作成功", resNum) : ZDResponse.error("操作失败", resNum); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 知识库详情 |
|
|
|
*/ |
|
|
|
@GetMapping("/detail/{guid}") |
|
|
|
public String detail(@PathVariable("guid") String guid, ModelMap mmap) |
|
|
|
{ |
|
|
|
public String detail(@PathVariable("guid") String guid, ModelMap mmap) { |
|
|
|
KnowledgeLibrary knowledgeLibrary = knowledgeLibraryService.selectKnowledgeLibraryById(guid); |
|
|
|
mmap.put("knowledgeLibrary", knowledgeLibrary); |
|
|
|
|
|
|
|
@ -128,7 +142,7 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
dictBean.setDictType("knowledge_flag"); |
|
|
|
List<DictDataBean> dictDataBeans = dictDataApi.getDictData(dictBean); |
|
|
|
for (DictDataBean dictb : dictDataBeans) { |
|
|
|
if (knowledgeLibrary.getFlag().indexOf(dictb.getDictValue())>-1) { |
|
|
|
if (knowledgeLibrary.getFlag().indexOf(dictb.getDictValue()) > -1) { |
|
|
|
dictb.setIsDefault("Y"); |
|
|
|
} else { |
|
|
|
dictb.setIsDefault("N"); |
|
|
|
@ -142,12 +156,11 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
* 删除知识库 |
|
|
|
*/ |
|
|
|
@RequiresPermissions("small:library:remove") |
|
|
|
@PostMapping( "/remove") |
|
|
|
@PostMapping("/remove") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse remove(String ids) |
|
|
|
{ |
|
|
|
public ZDResponse remove(String ids) { |
|
|
|
int resNum = knowledgeLibraryService.deleteKnowledgeLibraryByIds(ids); |
|
|
|
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|
|
|
return resNum > 0 ? ZDResponse.success("操作成功", resNum) : ZDResponse.error("操作失败", resNum); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -156,10 +169,9 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
@RequiresPermissions("small:library:edit") |
|
|
|
@PostMapping("/toPublishState") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse toPublishState(String ids, String state) |
|
|
|
{ |
|
|
|
public ZDResponse toPublishState(String ids, String state) { |
|
|
|
int resNum = knowledgeLibraryService.updatePublishState(ids, state); |
|
|
|
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|
|
|
return resNum > 0 ? ZDResponse.success("操作成功", resNum) : ZDResponse.error("操作失败", resNum); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -168,14 +180,13 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
@RequiresPermissions("custom:image:edit") |
|
|
|
@PostMapping("/changeUp") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse changeUp(KnowledgeLibrary knowledge) |
|
|
|
{ |
|
|
|
int resNum = knowledgeLibraryService.updateSrot(knowledge.getSrot(), knowledge.getSrot()+1); |
|
|
|
public ZDResponse changeUp(KnowledgeLibrary knowledge) { |
|
|
|
int resNum = knowledgeLibraryService.updateSrot(knowledge.getSrot(), knowledge.getSrot() + 1); |
|
|
|
if (resNum > 0) { |
|
|
|
knowledge.setSrot(knowledge.getSrot()+1); |
|
|
|
knowledge.setSrot(knowledge.getSrot() + 1); |
|
|
|
resNum = knowledgeLibraryService.updateKnowledgeLibrary(knowledge); |
|
|
|
} |
|
|
|
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|
|
|
return resNum > 0 ? ZDResponse.success("操作成功", resNum) : ZDResponse.error("操作失败", resNum); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -184,44 +195,46 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
@RequiresPermissions("custom:image:edit") |
|
|
|
@PostMapping("/changeUnder") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse changeUnder(KnowledgeLibrary knowledge) |
|
|
|
{ |
|
|
|
int resNum = knowledgeLibraryService.updateSrot(knowledge.getSrot(), knowledge.getSrot()-1); |
|
|
|
public ZDResponse changeUnder(KnowledgeLibrary knowledge) { |
|
|
|
int resNum = knowledgeLibraryService.updateSrot(knowledge.getSrot(), knowledge.getSrot() - 1); |
|
|
|
if (resNum > 0) { |
|
|
|
knowledge.setSrot(knowledge.getSrot()-1); |
|
|
|
knowledge.setSrot(knowledge.getSrot() - 1); |
|
|
|
resNum = knowledgeLibraryService.updateKnowledgeLibrary(knowledge); |
|
|
|
} |
|
|
|
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|
|
|
return resNum > 0 ? ZDResponse.success("操作成功", resNum) : ZDResponse.error("操作失败", resNum); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询附件信息 |
|
|
|
* |
|
|
|
* @param key |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping( "/queryFiles/{key}") |
|
|
|
@GetMapping("/queryFiles/{key}") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse queryFiles(@PathVariable String key){ |
|
|
|
public ZDResponse queryFiles(@PathVariable String key) { |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
map.put("filePreview", knowledgeLibraryService.queryFiles(key)); |
|
|
|
return ZDResponse.success("获取成功",map); |
|
|
|
return ZDResponse.success("获取成功", map); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询附件信息 |
|
|
|
* |
|
|
|
* @param key |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping( "/queryFilesPost") |
|
|
|
@PostMapping("/queryFilesPost") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse queryFilesPost(String key){ |
|
|
|
public ZDResponse queryFilesPost(String key) { |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
map.put("filePreview", knowledgeLibraryService.queryFiles(key)); |
|
|
|
return ZDResponse.success("获取成功",map); |
|
|
|
return ZDResponse.success("获取成功", map); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除案例要素附件 |
|
|
|
* |
|
|
|
* @param key |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -252,8 +265,8 @@ public class KnowledgeLibraryController extends BaseController |
|
|
|
|
|
|
|
@GetMapping("/getFlowEP") |
|
|
|
@ResponseBody |
|
|
|
public ZDResponse getFlowEV(String id){ |
|
|
|
public ZDResponse getFlowEV(String id) { |
|
|
|
KnowledgeLibrary library = knowledgeLibraryService.selectKnowledgeLibraryById(id); |
|
|
|
return ZDResponse.success("",library); |
|
|
|
return ZDResponse.success("", library); |
|
|
|
} |
|
|
|
} |
|
|
|
|