Browse Source

知识库

master
yanyan 3 years ago
parent
commit
b44015674f
  1. 28
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/add.html
  2. 30
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/detail.html
  3. 26
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/edit.html
  4. 44
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/view.html
  5. 121
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/KnowledgeLibraryController.java
  6. 1
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/KnowledgeLibraryServiceImpl.java

28
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/add.html

@ -21,21 +21,21 @@
<input class="form-control" type="text" name="subTitle" id="subTitle" required>
</div>
</div>
<!-- <div class="form-group">-->
<!-- <label class="col-sm-2 control-label is-required">标签:</label>-->
<!-- <div class="col-sm-10">-->
<!-- <select id="flag" class="form-control select2-multiple" multiple>-->
<!-- <option th:each="f:${dicts}" th:value="${f.dictValue}" th:text="${f.dictLabel}" th:disabled="${f.status == '1'}"></option>-->
<!-- </select>-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group">
<label class="col-sm-2 control-label is-required">标签:</label>
<div class="col-sm-10">
<select id="flag" class="form-control select2-multiple" multiple>
<option th:each="f:${dicts}" th:value="${f.dictValue}" th:text="${f.dictLabel}" th:disabled="${f.status == '1'}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">类型:</label>
<div class="col-sm-4">
<select name="type" class="form-control m-b" th:with="type=${@dict.getType('knowledge_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
<!-- <label class="col-sm-2 control-label is-required">类型:</label>-->
<!-- <div class="col-sm-4">-->
<!-- <select name="type" class="form-control m-b" th:with="type=${@dict.getType('knowledge_type')}">-->
<!-- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!-- </select>-->
<!-- </div>-->
<label class="col-sm-2 control-label is-required">置顶:</label>
<div class="col-sm-4">
<select name="pinned" class="form-control m-b" th:with="type=${@dict.getType('is_pinned')}">

30
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/detail.html

@ -28,22 +28,22 @@
<input class="form-control" type="text" name="subTitle" id="subTitle" th:field="*{subTitle}" disabled required>
</div>
</div>
<!-- <div class="form-group">-->
<!-- <label class="col-sm-2 control-label is-required">标签:</label>-->
<!-- <div class="col-sm-10">-->
<!-- <select id="flag" class="form-control select2-multiple" multiple>-->
<!-- <option th:each="f:${dicts}" th:value="${f.dictValue}" th:text="${f.dictLabel}" th:selected="${f.isDefault} eq 'Y'" th:disabled="${f.status == '1'}"></option>-->
<!-- &lt;!&ndash; <option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>&ndash;&gt;-->
<!-- </select>-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group">
<label class="col-sm-2 control-label is-required">标签:</label>
<div class="col-sm-10">
<select id="flag" class="form-control select2-multiple" multiple>
<option th:each="f:${dicts}" th:value="${f.dictValue}" th:text="${f.dictLabel}" th:selected="${f.isDefault} eq 'Y'" th:disabled="${f.status == '1'}"></option>
<!-- <option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>-->
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">类型:</label>
<div class="col-sm-4">
<select name="type" class="form-control m-b" th:with="type=${@dict.getType('knowledge_type')}" disabled>
<option th:field="*{type}" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
<!-- <label class="col-sm-2 control-label is-required">类型:</label>-->
<!-- <div class="col-sm-4">-->
<!-- <select name="type" class="form-control m-b" th:with="type=${@dict.getType('knowledge_type')}" disabled>-->
<!-- <option th:field="*{type}" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!-- </select>-->
<!-- </div>-->
<label class="col-sm-2 control-label is-required">置顶:</label>
<div class="col-sm-4">
<select id="pinned" name="pinned" class="form-control m-b" th:with="type=${@dict.getType('is_pinned')}" disabled>

26
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/edit.html

@ -23,21 +23,21 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">标签:</label>
<div class="col-sm-10">
<select id="flag" class="form-control select2-multiple" multiple>
<option th:each="f:${dicts}" th:value="${f.dictValue}" th:text="${f.dictLabel}" th:selected="${f.isDefault} eq 'Y'" th:disabled="${f.status == '1'}"></option>
<!-- <option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>-->
</select>
</div>
<!-- <label class="col-sm-2 control-label is-required">标签:</label>-->
<!-- <div class="col-sm-10">-->
<!-- <select id="flag" class="form-control select2-multiple" multiple>-->
<!-- <option th:each="f:${dicts}" th:value="${f.dictValue}" th:text="${f.dictLabel}" th:selected="${f.isDefault} eq 'Y'" th:disabled="${f.status == '1'}"></option>-->
<!--&lt;!&ndash; <option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>&ndash;&gt;-->
<!-- </select>-->
<!-- </div>-->
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">类型:</label>
<div class="col-sm-4">
<select name="type" class="form-control m-b" th:with="type=${@dict.getType('knowledge_type')}">
<option th:field="*{type}" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
<!-- <label class="col-sm-2 control-label is-required">类型:</label>-->
<!-- <div class="col-sm-4">-->
<!-- <select name="type" class="form-control m-b" th:with="type=${@dict.getType('knowledge_type')}">-->
<!-- <option th:field="*{type}" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!-- </select>-->
<!-- </div>-->
<label class="col-sm-2 control-label is-required">置顶:</label>
<div class="col-sm-4">
<select id="pinned" name="pinned" class="form-control m-b" th:with="type=${@dict.getType('is_pinned')}">

44
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/view.html

@ -111,21 +111,21 @@
field: 'title',
title: '标题'
},
{
field: 'flag',
title: '标签',
align: 'center',
formatter: function (value, row, index) {
var tmp = "";
for(var i=0; i<knowledgeFlags.length; i++) {
if(value.indexOf(knowledgeFlags[i].dictValue) > -1) {
tmp += knowledgeFlags[i].dictLabel+",";
}
}
return tmp.slice(0, tmp.length-1);
// return $.table.selectDictLabel(knowledgeFlags, value);
}
},
// {
// field: 'flag',
// title: '标签',
// align: 'center',
// formatter: function (value, row, index) {
// var tmp = "";
// for(var i=0; i<knowledgeFlags.length; i++) {
// if(value.indexOf(knowledgeFlags[i].dictValue) > -1) {
// tmp += knowledgeFlags[i].dictLabel+",";
// }
// }
// return tmp.slice(0, tmp.length-1);
// // return $.table.selectDictLabel(knowledgeFlags, value);
// }
// },
{
field : 'status',
title : '状态',
@ -134,13 +134,13 @@
return $.table.selectDictLabel(statuss, value);
}
},
{
field : 'type',
title : '类型',
formatter : function (value, row, index) {
return $.table.selectDictLabel(types, value);
}
},
// {
// field : 'type',
// title : '类型',
// formatter : function (value, row, index) {
// return $.table.selectDictLabel(types, value);
// }
// },
{
field : 'pinned',
title : '置顶',

121
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/KnowledgeLibraryController.java

@ -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);
}
}

1
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/KnowledgeLibraryServiceImpl.java

@ -77,7 +77,6 @@ public class KnowledgeLibraryServiceImpl implements IKnowledgeLibraryService
// 上传文件,并在附件表中添加记录
if (resNum > 0 && ObjectUtil.isNotEmpty(files)) {
for (MultipartFile file : files) {
// todo 将原有关联附件删除在重新上传比较好
zdxtFileCommonApi.insertZdxtFile(file, knowledgeLibrary.getGuid(), fileUploadApi.upload(file));
}
}

Loading…
Cancel
Save