Browse Source

知识库简单的基础功能弄完

master
蟑螂恶霸 3 years ago
parent
commit
99c4a0d366
  1. 4
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml
  2. 241
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/add.html
  3. 285
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/detail.html
  4. 285
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/edit.html
  5. 88
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/library/view.html
  6. 111
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/KnowledgeLibraryController.java
  7. 13
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/KnowledgeLibrary.java
  8. 20
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IKnowledgeLibraryService.java
  9. 66
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/KnowledgeLibraryServiceImpl.java
  10. 9
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/KnowledgeLibraryMapper.xml

4
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml

@ -9,8 +9,8 @@ ruoyi:
# 实例演示开关 # 实例演示开关
demoEnabled: true demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: E:/ruoyi/uploadPath # profile: E:/ruoyi/uploadPath
# profile: /home/ruoyi/uploadPath profile: /Users/kylin_stone/Workspaces/uploads
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: true addressEnabled: true

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

@ -0,0 +1,241 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="zdxtInclude :: header('新增知识点')" />
<th:block th:include="zdxtInclude :: select2-css" />
<th:block th:include="zdxtInclude :: summernote-css"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-item-add">
<div class="form-group">
<label class="col-sm-2 control-label is-required">标题:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="title" id="title" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">副标题:</label>
<div class="col-sm-10">
<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">内容:</label>
<div class="col-sm-10">
<input type="hidden" name="content" id="content" />
<div id="itemContentSummernote" class="summernote"></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">封面:</label>
<div class="col-sm-10">
<div id="fileIn">
<div class="file-loading">
<input id="fileInput" name="file" type="file" multiple>
</div>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer" />
<th:block th:include="zdxtInclude :: select2-js" />
<th:block th:include="zdxtInclude :: summernote-js"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/>
<script type="text/javascript">
var prefix = ctx + "small/library";
$(function() {
$('#post').select2({
placeholder: "请选择标签",
allowClear: true
});
$('#userType').val('3').trigger('change');
// 渲染要素信息
renderVersionAtt();
})
function submitHandler() {
if ($.validate.form()) {
$('#fileInput').fileinput('upload');
}
}
/** 富文本 */
$('.summernote').summernote({
// placeholder: '请输入公告内容',
height: 330,
lang: 'zh-CN',
followingToolbar: false,
callbacks: {
onImageUpload: function (files) {
PlanVersion.summernoteImgUpload(files[0], this);
}
},
toolbar: [
['operate', ['undo','redo']],
['magic',['style']],
['style', ['bold', 'italic', 'underline', 'clear']],
['para', ['height','fontsize','ul', 'ol', 'paragraph']],
['font', ['strikethrough', 'superscript', 'subscript']],
['color', ['color']],
['insert',['video','link','table','hr','attachment']],//自定义按钮展示
['layout',['codeview']],
],
buttons: {
attachment:AttachmentButton
},
});
var AttachmentButton = function (context) {
var ui = $.summernote.ui;
// create button
var button = ui.button({
contents: '<i class="fa fa-folder-open"/>', //按钮样式
tooltip: '上传文件',
click: function () {
$("#fileWord").click();
}
});
return button.render(); //按钮渲染
}
/** 附件相关 */
/** 渲染附件信息 */
function renderVersionAtt() {
$("#fileIn").show();
$("#fileOut").hide();
uploadFiles();
$("#fileInput").fileinput('clear')
}
/** 上传附件 */
function uploadFiles() {
var filePreview = { fileList: null, previewRespDTOS: null }
initFile("fileInput", prefix + "/add", filePreview);
}
/** 初始化文件 */
function initFile(elementId, url, filePreview) {
var preview = filePreview.previewRespDTOS;
if (preview != null) {
for (var i = 0; i < preview.length; i++) {
// 图片删除的地址
preview[i].url = prefix + "/removeFile"
}
}
$("#" + elementId).fileinput({
'theme': 'explorer',
initialPreviewAsData: true,
dropZoneEnabled: true,
dropZoneTitle: "上传图片或视频",
uploadUrl: url,
uploadAsync: false,//异步上传
enctype: 'multipart/form-data',
showClose: false,
showPreview: true,
showUpload: false,
uploadExtraData: function () {
var formData = $("#form-item-add").serialize();
formData = decodeURIComponent(formData, true);
var arr = formData.split("&");
var data = {};
for (var i=0; i<arr.length; i++) {
var item = arr[i].split('=');
var value = item[1].replace("+", " ");
data[item[0]] = value;
}
data.content = $('#itemContentSummernote').summernote('code');
data.flag = $.form.selectSelects("flag");
return data;
},
// showBrowse: false,
previewFileIcon: '<i class="fas fa-file"></i>',
preferIconicPreview: true,
previewFileIconSettings: { // configure your icon file extensions
'doc': '<i class="fa fa-file-word-o text-primary"></i>',
'xls': '<i class="fa fa-file-excel-o text-success"></i>',
'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
'txt': '<i class="fa fa-file-text-o text-info"></i>',
'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
'htm': '<i class="fa fa-file-code-o text-info"></i>',
'mov': '<i class="fa fa-file-movie-o text-warning"></i>',
'mp3': '<i class="fa fa-file-audio-o text-warning"></i>'
},
previewFileExtSettings: {
'doc': function (ext) {
return ext.match(/(doc|docx)$/i);
},
'xls': function (ext) {
return ext.match(/(xls|xlsx)$/i);
},
'ppt': function (ext) {
return ext.match(/(ppt|pptx)$/i);
},
'zip': function (ext) {
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
},
'htm': function (ext) {
return ext.match(/(htm|html)$/i);
},
'mov': function (ext) {
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
},
'mp3': function (ext) {
return ext.match(/(mp3|wav)$/i);
},
'txt': function (ext) {
return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
}
},
layoutTemplates: {
// actionDelete: ''//去掉删除按钮
actionUpload: '' // 去掉上传按钮
},
initialPreview: filePreview.fileList == null ? [] : filePreview.fileList,
initialPreviewConfig: preview == null ? [] : preview
});
// 同步上传成功回调
$("#fileInput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
// // 同步上传成功回调
// $("#fileOutput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
// fileUploadCallBack(data.response);
// })
};
/** 文件上传回调 */
function fileUploadCallBack(result) {
var parent = window.parent;
if (result.success) {
parent.$.modal.msgSuccess(result.message);
} else {
$.modal.alertError(result.message);
}
$.modal.close();
parent.$.table.refresh();
// $.modal.closeLoading();
// $.modal.msgReload(result.message, modal_status.SUCCESS);
}
</script>
</body>
</html>

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

@ -0,0 +1,285 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="zdxtInclude :: header('修改知识点')" />
<th:block th:include="zdxtInclude :: select2-css" />
<th:block th:include="zdxtInclude :: summernote-css"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-item-add" th:object="${knowledgeLibrary}">
<input id="guid" name="guid" th:value="${knowledgeLibrary.guid}" class="form-control" type="hidden">
<div class="form-group">
<label class="col-sm-2 control-label is-required">标题:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="title" id="title" th:field="*{title}" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">副标题:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="subTitle" id="subTitle" th:field="*{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: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">内容:</label>
<div class="col-sm-10">
<input type="hidden" name="content" id="content" th:field="*{content}"/>
<div id="itemContentSummernote" class="summernote"></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">封面:</label>
<div class="col-sm-10">
<div id="fileIn">
<div class="file-loading">
<input id="fileInput" name="file" type="file" multiple>
</div>
</div>
<div id="fileOut" style="display: none">
<div class="file-loading">
<input id="fileOutput" name="file" type="file" multiple>
</div>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer" />
<th:block th:include="zdxtInclude :: select2-js" />
<th:block th:include="zdxtInclude :: summernote-js"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/>
<script type="text/javascript">
var prefix = ctx + "small/library";
// 当前文件框id,是不是fileInput
var isFlieIn = true;
$(function() {
$('#itemContentSummernote').summernote('code', $('#content').val());
$('#post').select2({
placeholder: "请选择职务",
allowClear: true
});
$('#userType').val('3').trigger('change');
// 渲染要素信息
renderVersionAtt();
})
function submitHandler() {
if (isFlieIn) {
$('#fileInput').fileinput('upload');
} else {
$('#fileOutput').fileinput('upload');
}
}
/** 富文本 */
$('.summernote').summernote({
// placeholder: '请输入公告内容',
height: 330,
lang: 'zh-CN',
followingToolbar: false,
callbacks: {
onImageUpload: function (files) {
PlanVersion.summernoteImgUpload(files[0], this);
}
},
toolbar: [
['operate', ['undo','redo']],
['magic',['style']],
['style', ['bold', 'italic', 'underline', 'clear']],
['para', ['height','fontsize','ul', 'ol', 'paragraph']],
['font', ['strikethrough', 'superscript', 'subscript']],
['color', ['color']],
['insert',['video','link','table','hr','attachment']],//自定义按钮展示
['layout',['codeview']],
],
buttons: {
attachment:AttachmentButton
},
});
var AttachmentButton = function (context) {
var ui = $.summernote.ui;
// create button
var button = ui.button({
contents: '<i class="fa fa-folder-open"/>', //按钮样式
tooltip: '上传文件',
click: function () {
$("#fileWord").click();
}
});
return button.render(); //按钮渲染
}
/** 附件相关 */
/** 渲染附件信息 */
function renderVersionAtt() {
var key = $("#guid").val();
$.getJSON(prefix + "/queryFiles/" + key, function (result) {
if (result.data != null) {
$("#fileIn").hide();
$("#fileOut").show();
// 重置文件预览框
$("#fileOut").html("<div class=\"file-loading\"><input id=\"fileOutput\" name=\"file\" type=\"file\" multiple></div>");
queryFiles(key);
isFlieIn = false;
} else {
$("#fileIn").show();
$("#fileOut").hide();
uploadFiles();
isFlieIn = true;
$("#fileInput").fileinput('clear')
}
});
}
/** 预览附件 */
function queryFiles(key) {
$.ajax({
type: "POST",
url: prefix + "/queryFilesPost",
data: {"key": key},
dataType: 'json',
success: function (result) {
if (result.success == true) {
initFile("fileOutput", prefix + "/edit", result.data.filePreview);
}
},
error: function (error) {
$.modal.alertWarning("附件预览失败!");
}
});
}
/** 上传附件 */
function uploadFiles() {
var filePreview = { fileList: null, previewRespDTOS: null }
initFile("fileInput", prefix + "/edit", filePreview);
}
/** 初始化文件 */
function initFile(elementId, url, filePreview) {
var preview = filePreview.previewRespDTOS;
if (preview != null) {
for (var i = 0; i < preview.length; i++) {
// 图片删除的地址
preview[i].url = prefix + "/removeFile"
}
}
$("#" + elementId).fileinput({
'theme': 'explorer',
initialPreviewAsData: true,
dropZoneEnabled: true,
dropZoneTitle: "上传图片或视频",
uploadUrl: url,
uploadAsync: false,//异步上传
enctype: 'multipart/form-data',
showClose: false,
showPreview: true,
showUpload: false,
uploadExtraData: function () {
var formData = $("#form-item-add").serialize();
formData = decodeURIComponent(formData, true);
var arr = formData.split("&");
var data = {};
for (var i=0; i<arr.length; i++) {
var item = arr[i].split('=');
var value = item[1].replace("+", " ");
data[item[0]] = value;
}
data.content = $('#itemContentSummernote').summernote('code');
data.flag = $.form.selectSelects("flag");
return data;
},
// showBrowse: false,
previewFileIcon: '<i class="fas fa-file"></i>',
preferIconicPreview: true,
previewFileIconSettings: { // configure your icon file extensions
'doc': '<i class="fa fa-file-word-o text-primary"></i>',
'xls': '<i class="fa fa-file-excel-o text-success"></i>',
'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
'txt': '<i class="fa fa-file-text-o text-info"></i>',
'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
'htm': '<i class="fa fa-file-code-o text-info"></i>',
'mov': '<i class="fa fa-file-movie-o text-warning"></i>',
'mp3': '<i class="fa fa-file-audio-o text-warning"></i>'
},
previewFileExtSettings: {
'doc': function (ext) {
return ext.match(/(doc|docx)$/i);
},
'xls': function (ext) {
return ext.match(/(xls|xlsx)$/i);
},
'ppt': function (ext) {
return ext.match(/(ppt|pptx)$/i);
},
'zip': function (ext) {
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
},
'htm': function (ext) {
return ext.match(/(htm|html)$/i);
},
'mov': function (ext) {
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
},
'mp3': function (ext) {
return ext.match(/(mp3|wav)$/i);
},
'txt': function (ext) {
return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
}
},
layoutTemplates: {
// actionDelete: ''//去掉删除按钮
actionUpload: '' // 去掉上传按钮
},
initialPreview: filePreview.fileList == null ? [] : filePreview.fileList,
initialPreviewConfig: preview == null ? [] : preview
});
// 同步上传成功回调
$("#fileInput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
// 同步上传成功回调
$("#fileOutput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
};
function fileUploadCallBack(result) {
var parent = window.parent;
if (result.success) {
parent.$.modal.msgSuccess(result.message);
} else {
$.modal.alertError(result.message);
}
$.modal.close();
parent.$.table.refresh();
// $.modal.closeLoading();
// $.modal.msgReload(result.message, modal_status.SUCCESS);
}
</script>
</body>
</html>

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

@ -0,0 +1,285 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="zdxtInclude :: header('修改知识点')" />
<th:block th:include="zdxtInclude :: select2-css" />
<th:block th:include="zdxtInclude :: summernote-css"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-item-add" th:object="${knowledgeLibrary}">
<input id="guid" name="guid" th:value="${knowledgeLibrary.guid}" class="form-control" type="hidden">
<div class="form-group">
<label class="col-sm-2 control-label is-required">标题:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="title" id="title" th:field="*{title}" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">副标题:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="subTitle" id="subTitle" th:field="*{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: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">内容:</label>
<div class="col-sm-10">
<input type="hidden" name="content" id="content" th:field="*{content}"/>
<div id="itemContentSummernote" class="summernote"></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">封面:</label>
<div class="col-sm-10">
<div id="fileIn">
<div class="file-loading">
<input id="fileInput" name="file" type="file" multiple>
</div>
</div>
<div id="fileOut" style="display: none">
<div class="file-loading">
<input id="fileOutput" name="file" type="file" multiple>
</div>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer" />
<th:block th:include="zdxtInclude :: select2-js" />
<th:block th:include="zdxtInclude :: summernote-js"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/>
<script type="text/javascript">
var prefix = ctx + "small/library";
// 当前文件框id,是不是fileInput
var isFlieIn = true;
$(function() {
$('#itemContentSummernote').summernote('code', $('#content').val());
$('#post').select2({
placeholder: "请选择职务",
allowClear: true
});
$('#userType').val('3').trigger('change');
// 渲染要素信息
renderVersionAtt();
})
function submitHandler() {
if (isFlieIn) {
$('#fileInput').fileinput('upload');
} else {
$('#fileOutput').fileinput('upload');
}
}
/** 富文本 */
$('.summernote').summernote({
// placeholder: '请输入公告内容',
height: 330,
lang: 'zh-CN',
followingToolbar: false,
callbacks: {
onImageUpload: function (files) {
PlanVersion.summernoteImgUpload(files[0], this);
}
},
toolbar: [
['operate', ['undo','redo']],
['magic',['style']],
['style', ['bold', 'italic', 'underline', 'clear']],
['para', ['height','fontsize','ul', 'ol', 'paragraph']],
['font', ['strikethrough', 'superscript', 'subscript']],
['color', ['color']],
['insert',['video','link','table','hr','attachment']],//自定义按钮展示
['layout',['codeview']],
],
buttons: {
attachment:AttachmentButton
},
});
var AttachmentButton = function (context) {
var ui = $.summernote.ui;
// create button
var button = ui.button({
contents: '<i class="fa fa-folder-open"/>', //按钮样式
tooltip: '上传文件',
click: function () {
$("#fileWord").click();
}
});
return button.render(); //按钮渲染
}
/** 附件相关 */
/** 渲染附件信息 */
function renderVersionAtt() {
var key = $("#guid").val();
$.getJSON(prefix + "/queryFiles/" + key, function (result) {
if (result.data != null) {
$("#fileIn").hide();
$("#fileOut").show();
// 重置文件预览框
$("#fileOut").html("<div class=\"file-loading\"><input id=\"fileOutput\" name=\"file\" type=\"file\" multiple></div>");
queryFiles(key);
isFlieIn = false;
} else {
$("#fileIn").show();
$("#fileOut").hide();
uploadFiles();
isFlieIn = true;
$("#fileInput").fileinput('clear')
}
});
}
/** 预览附件 */
function queryFiles(key) {
$.ajax({
type: "POST",
url: prefix + "/queryFilesPost",
data: {"key": key},
dataType: 'json',
success: function (result) {
if (result.success == true) {
initFile("fileOutput", prefix + "/edit", result.data.filePreview);
}
},
error: function (error) {
$.modal.alertWarning("附件预览失败!");
}
});
}
/** 上传附件 */
function uploadFiles() {
var filePreview = { fileList: null, previewRespDTOS: null }
initFile("fileInput", prefix + "/edit", filePreview);
}
/** 初始化文件 */
function initFile(elementId, url, filePreview) {
var preview = filePreview.previewRespDTOS;
if (preview != null) {
for (var i = 0; i < preview.length; i++) {
// 图片删除的地址
preview[i].url = prefix + "/removeFile"
}
}
$("#" + elementId).fileinput({
'theme': 'explorer',
initialPreviewAsData: true,
dropZoneEnabled: true,
dropZoneTitle: "上传图片或视频",
uploadUrl: url,
uploadAsync: false,//异步上传
enctype: 'multipart/form-data',
showClose: false,
showPreview: true,
showUpload: false,
uploadExtraData: function () {
var formData = $("#form-item-add").serialize();
formData = decodeURIComponent(formData, true);
var arr = formData.split("&");
var data = {};
for (var i=0; i<arr.length; i++) {
var item = arr[i].split('=');
var value = item[1].replace("+", " ");
data[item[0]] = value;
}
data.content = $('#itemContentSummernote').summernote('code');
data.flag = $.form.selectSelects("flag");
return data;
},
// showBrowse: false,
previewFileIcon: '<i class="fas fa-file"></i>',
preferIconicPreview: true,
previewFileIconSettings: { // configure your icon file extensions
'doc': '<i class="fa fa-file-word-o text-primary"></i>',
'xls': '<i class="fa fa-file-excel-o text-success"></i>',
'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
'txt': '<i class="fa fa-file-text-o text-info"></i>',
'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
'htm': '<i class="fa fa-file-code-o text-info"></i>',
'mov': '<i class="fa fa-file-movie-o text-warning"></i>',
'mp3': '<i class="fa fa-file-audio-o text-warning"></i>'
},
previewFileExtSettings: {
'doc': function (ext) {
return ext.match(/(doc|docx)$/i);
},
'xls': function (ext) {
return ext.match(/(xls|xlsx)$/i);
},
'ppt': function (ext) {
return ext.match(/(ppt|pptx)$/i);
},
'zip': function (ext) {
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
},
'htm': function (ext) {
return ext.match(/(htm|html)$/i);
},
'mov': function (ext) {
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
},
'mp3': function (ext) {
return ext.match(/(mp3|wav)$/i);
},
'txt': function (ext) {
return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
}
},
layoutTemplates: {
// actionDelete: ''//去掉删除按钮
actionUpload: '' // 去掉上传按钮
},
initialPreview: filePreview.fileList == null ? [] : filePreview.fileList,
initialPreviewConfig: preview == null ? [] : preview
});
// 同步上传成功回调
$("#fileInput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
// 同步上传成功回调
$("#fileOutput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
};
function fileUploadCallBack(result) {
var parent = window.parent;
if (result.success) {
parent.$.modal.msgSuccess(result.message);
} else {
$.modal.alertError(result.message);
}
$.modal.close();
parent.$.table.refresh();
// $.modal.closeLoading();
// $.modal.msgReload(result.message, modal_status.SUCCESS);
}
</script>
</body>
</html>

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

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head> <head>
<th:block th:include="include :: header('知识列表')"/> <th:block th:include="zdxtInclude :: header('知识列表')"/>
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
<div class="container-div"> <div class="container-div">
@ -14,19 +14,19 @@
职务编码:<input type="text" name="postCode" placeholder="请输入职务编码"/> 职务编码:<input type="text" name="postCode" placeholder="请输入职务编码"/>
</li>--> </li>-->
<li> <li>
职务名称:<input type="text" name="postName" placeholder="请输入职务名称"/> 标题:<input type="text" name="title" placeholder="请输入标题"/>
</li>
<li>
职务状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}"></option>
</select>
</li>
<li class="select-time">
<p>创建时间:</p>
<input type="text" class="time-input" id="createTime" placeholder="年-月-日" name="createTime" style="width: 200px;"/>
</li> </li>
<!-- <li>-->
<!-- 职务状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">-->
<!-- <option value="">所有</option>-->
<!-- <option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
<!-- th:value="${dict.dictValue}"></option>-->
<!-- </select>-->
<!-- </li>-->
<!-- <li class="select-time">-->
<!-- <p>创建时间:</p>-->
<!-- <input type="text" class="time-input" id="createTime" placeholder="年-月-日" name="createTime" style="width: 200px;"/>-->
<!-- </li>-->
<li> <li>
<a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-reset btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a> <a class="btn btn-reset btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
@ -37,7 +37,7 @@
</div> </div>
<div class="btn-group-sm" id="toolbar" role="group"> <div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add(100,813,420)" shiro:hasPermission="system:post:add"> <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="small:library:add">
<i class="fa fa-plus"></i> 新增 <i class="fa fa-plus"></i> 新增
</a> </a>
<!--<a class="btn btn-primary single disabled" onclick="$.operate.edit(null,813,420)" <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit(null,813,420)"
@ -45,7 +45,7 @@
<i class="fa fa-edit"></i> 修改 <i class="fa fa-edit"></i> 修改
</a>--> </a>-->
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
shiro:hasPermission="system:post:remove"> shiro:hasPermission="small:library:remove">
<i class="fa fa-remove"></i> 全部删除 <i class="fa fa-remove"></i> 全部删除
</a> </a>
<!-- <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:post:export"> <!-- <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:post:export">
@ -58,11 +58,13 @@
</div> </div>
</div> </div>
</div> </div>
<th:block th:include="include :: footer"/> <th:block th:include="zdxtInclude :: footer"/>
<script th:inline="javascript"> <script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('system:post:edit')}]]; var editFlag = [[${@permission.hasPermi('small:library:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:post:remove')}]]; var removeFlag = [[${@permission.hasPermi('small:library:remove')}]];
var datas = [[${@dict.getType('sys_normal_disable')}]]; var knowledgeFlags = [[${@dict.getType('knowledge_flag')}]];
var publishStates = [[${@dict.getType('publish_state')}]];
var examineStates = [[${@dict.getType('examine_state')}]];
var prefix = ctx + "small/library"; var prefix = ctx + "small/library";
$(function () { $(function () {
@ -75,10 +77,9 @@
updateUrl: prefix + "/edit/{id}", updateUrl: prefix + "/edit/{id}",
detailUrl: prefix + "/detail/{id}", detailUrl: prefix + "/detail/{id}",
removeUrl: prefix + "/remove", removeUrl: prefix + "/remove",
exportUrl: prefix + "/export", sortName: "srot",
sortName: "postSort", modalName: "知识点",
modalName: "职务", uniqueId:"guid",
uniqueId:"postId",
showCustomExport:exportboolen, showCustomExport:exportboolen,
customExportFunction:function(){ customExportFunction:function(){
$.table.exportExcel(); $.table.exportExcel();
@ -94,26 +95,41 @@
} }
}, },
{ {
field: 'title', field: 'guid',
title: '标题', title: '主键',
visible: false visible: false
}, },
{ {
field: 'flag', field: 'title',
title: '标签', title: '标题'
sortable: true
}, },
{ {
field: 'state', field: 'flag',
title: '状态', title: '标签',
align: 'center', align: 'center',
formatter: function (value, row, index) { formatter: function (value, row, index) {
return $.table.selectDictLabel(datas, value); 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: 'state',
// title: '状态',
// align: 'center',
// formatter: function (value, row, index) {
// return $.table.selectDictLabel(datas, value);
// }
// },
{ {
field: 'publishdate', field: 'publishdate',
title: '发布时间', title: '发布时间',
align: 'center',
sortable: true sortable: true
}, },
{ {
@ -121,7 +137,7 @@
title: '发布状态', title: '发布状态',
align: 'center', align: 'center',
formatter: function (value, row, index) { formatter: function (value, row, index) {
return $.table.selectDictLabel(datas, value); return $.table.selectDictLabel(publishStates, value);
} }
}, },
{ {
@ -129,7 +145,7 @@
title: '审核状态', title: '审核状态',
align: 'center', align: 'center',
formatter: function (value, row, index) { formatter: function (value, row, index) {
return $.table.selectDictLabel(datas, value); return $.table.selectDictLabel(examineStates, value);
} }
}, },
{ {
@ -138,14 +154,16 @@
formatter: function (value, row, index) { formatter: function (value, row, index) {
var actions = []; var actions = [];
// actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.postId + '\',813,420)"><i class="fa fa-eye"></i> 查看</a> '); // actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.postId + '\',813,420)"><i class="fa fa-eye"></i> 查看</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.postId + '\',813,420)"><i class="fa fa-edit"></i> 编辑</a> '); actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.guid + '\')"><i class="fa fa-edit"></i> 详情</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.postId + '\')"><i class="fa fa-remove"></i> 删除</a>'); actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.guid + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.guid + '\')"><i class="fa fa-remove"></i> 删除</a>');
return actions.join(''); return actions.join('');
} }
}] }]
}; };
$.table.init(options); $.table.init(options);
}); });
</script> </script>
</body> </body>
</html> </html>

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

@ -1,21 +1,23 @@
package com.zdxt.knowledge.controller; package com.zdxt.knowledge.controller;
import java.util.HashMap;
import java.util.List; 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.ZDResponse;
import com.zdxt.common.controller.BaseController; import com.zdxt.common.controller.BaseController;
import com.zdxt.common.util.TableDataInfo; import com.zdxt.common.util.TableDataInfo;
import com.zdxt.domain.auth.Post;
import com.zdxt.knowledge.domain.KnowledgeLibrary; import com.zdxt.knowledge.domain.KnowledgeLibrary;
import com.zdxt.knowledge.service.IKnowledgeLibraryService; import com.zdxt.knowledge.service.IKnowledgeLibraryService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/** /**
* 知识库Controller * 知识库Controller
@ -29,8 +31,8 @@ public class KnowledgeLibraryController extends BaseController
{ {
private String prefix = "project/smallProgram/library"; private String prefix = "project/smallProgram/library";
@Autowired @Autowired private IKnowledgeLibraryService knowledgeLibraryService;
private IKnowledgeLibraryService knowledgeLibraryService; @Autowired private DictDataApi dictDataApi;
@RequiresPermissions("small:library:view") @RequiresPermissions("small:library:view")
@GetMapping() @GetMapping()
@ -56,8 +58,11 @@ public class KnowledgeLibraryController extends BaseController
* 新增知识库 * 新增知识库
*/ */
@GetMapping("/add") @GetMapping("/add")
public String add() public String add(ModelMap mmap)
{ {
DictDataBean dictBean = new DictDataBean();
dictBean.setDictType("knowledge_flag");
mmap.put("dicts", dictDataApi.getDictData(dictBean));
return prefix + "/add"; return prefix + "/add";
} }
@ -67,9 +72,10 @@ public class KnowledgeLibraryController extends BaseController
@RequiresPermissions("small:library:add") @RequiresPermissions("small:library:add")
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public ZDResponse addSave(KnowledgeLibrary knowledgeLibrary) public ZDResponse addSave(@RequestParam("file") MultipartFile[] files, @Validated KnowledgeLibrary knowledgeLibrary)
{ {
return ZDResponse.success("操作成功", knowledgeLibraryService.insertKnowledgeLibrary(knowledgeLibrary)); int resNum = knowledgeLibraryService.insertKnowledgeLibrary(knowledgeLibrary, files);
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum);
} }
/** /**
@ -80,6 +86,18 @@ public class KnowledgeLibraryController extends BaseController
{ {
KnowledgeLibrary knowledgeLibrary = knowledgeLibraryService.selectKnowledgeLibraryById(guid); KnowledgeLibrary knowledgeLibrary = knowledgeLibraryService.selectKnowledgeLibraryById(guid);
mmap.put("knowledgeLibrary", knowledgeLibrary); mmap.put("knowledgeLibrary", knowledgeLibrary);
DictDataBean dictBean = new DictDataBean();
dictBean.setDictType("knowledge_flag");
List<DictDataBean> dictDataBeans = dictDataApi.getDictData(dictBean);
for (DictDataBean dictb : dictDataBeans) {
if (knowledgeLibrary.getFlag().indexOf(dictb.getDictValue())>-1) {
dictb.setIsDefault("Y");
} else {
dictb.setIsDefault("N");
}
}
mmap.put("dicts", dictDataBeans);
return prefix + "/edit"; return prefix + "/edit";
} }
@ -89,9 +107,34 @@ public class KnowledgeLibraryController extends BaseController
@RequiresPermissions("small:library:edit") @RequiresPermissions("small:library:edit")
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public ZDResponse editSave(KnowledgeLibrary knowledgeLibrary) public ZDResponse editSave(@RequestParam("file") MultipartFile[] files, KnowledgeLibrary knowledgeLibrary)
{ {
return ZDResponse.success("操作成功", knowledgeLibraryService.updateKnowledgeLibrary(knowledgeLibrary)); int resNum = knowledgeLibraryService.updateKnowledgeLibrary(knowledgeLibrary, files);
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum);
}
/**
* 知识库详情
*/
@RequiresPermissions("small:library:view")
@GetMapping("/detail/{guid}")
public String detail(@PathVariable("guid") String guid, ModelMap mmap)
{
KnowledgeLibrary knowledgeLibrary = knowledgeLibraryService.selectKnowledgeLibraryById(guid);
mmap.put("knowledgeLibrary", knowledgeLibrary);
DictDataBean dictBean = new DictDataBean();
dictBean.setDictType("knowledge_flag");
List<DictDataBean> dictDataBeans = dictDataApi.getDictData(dictBean);
for (DictDataBean dictb : dictDataBeans) {
if (knowledgeLibrary.getFlag().indexOf(dictb.getDictValue())>-1) {
dictb.setIsDefault("Y");
} else {
dictb.setIsDefault("N");
}
}
mmap.put("dicts", dictDataBeans);
return prefix + "/detail";
} }
/** /**
@ -102,6 +145,48 @@ public class KnowledgeLibraryController extends BaseController
@ResponseBody @ResponseBody
public ZDResponse remove(String ids) public ZDResponse remove(String ids)
{ {
return ZDResponse.success("操作成功", knowledgeLibraryService.deleteKnowledgeLibraryByIds(ids)); int resNum = knowledgeLibraryService.deleteKnowledgeLibraryByIds(ids);
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum);
}
/**
* 查询附件信息
* @param key
* @return
*/
@GetMapping( "/queryFiles/{key}")
@ResponseBody
public ZDResponse queryFiles(@PathVariable String key){
HashMap<String, Object> map = new HashMap<>();
map.put("filePreview", knowledgeLibraryService.queryFiles(key));
return ZDResponse.success("获取成功",map);
}
/**
* 查询附件信息
* @param key
* @return
*/
@PostMapping( "/queryFilesPost")
@ResponseBody
public ZDResponse queryFilesPost(String key){
HashMap<String, Object> map = new HashMap<>();
map.put("filePreview", knowledgeLibraryService.queryFiles(key));
return ZDResponse.success("获取成功",map);
}
/**
* 删除案例要素附件
* @param key
* @return
*/
@PostMapping("/removeFile")
@ResponseBody
public ZDResponse removeFile(String key) {
if (knowledgeLibraryService.removeFile(key) > 0) {
return ZDResponse.success("操作成功");
} else {
return ZDResponse.error("操作失败");
}
} }
} }

13
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/KnowledgeLibrary.java

@ -21,6 +21,9 @@ public class KnowledgeLibrary extends BaseDomain
/** 标题 */ /** 标题 */
private String title; private String title;
/** 副标题 */
private String subTitle;
/** 内容 */ /** 内容 */
private String content; private String content;
@ -36,7 +39,7 @@ public class KnowledgeLibrary extends BaseDomain
/** 发布时间 */ /** 发布时间 */
private String publishdate; private String publishdate;
/** 发布状态(0:待发布,1:已发布,2:已上线,3已下线) */ /** 发布状态(0:待发布,1:已发布,2:已上线,3:已下线) */
private Integer publishstate; private Integer publishstate;
/** 审核状态(0:未审核,1:已审核) */ /** 审核状态(0:未审核,1:已审核) */
@ -58,6 +61,14 @@ public class KnowledgeLibrary extends BaseDomain
this.title = title; this.title = title;
} }
public String getSubTitle() {
return subTitle;
}
public void setSubTitle(String subTitle) {
this.subTitle = subTitle;
}
public String getContent() { public String getContent() {
return content; return content;
} }

20
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IKnowledgeLibraryService.java

@ -1,6 +1,8 @@
package com.zdxt.knowledge.service; package com.zdxt.knowledge.service;
import com.zdxt.common.zdxtFile.AttFileRespDTO;
import com.zdxt.knowledge.domain.KnowledgeLibrary; import com.zdxt.knowledge.domain.KnowledgeLibrary;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
@ -34,7 +36,7 @@ public interface IKnowledgeLibraryService
* @param knowledgeLibrary 知识库 * @param knowledgeLibrary 知识库
* @return 结果 * @return 结果
*/ */
public int insertKnowledgeLibrary(KnowledgeLibrary knowledgeLibrary); public int insertKnowledgeLibrary(KnowledgeLibrary knowledgeLibrary, MultipartFile[] files);
/** /**
* 修改知识库 * 修改知识库
@ -42,7 +44,7 @@ public interface IKnowledgeLibraryService
* @param knowledgeLibrary 知识库 * @param knowledgeLibrary 知识库
* @return 结果 * @return 结果
*/ */
public int updateKnowledgeLibrary(KnowledgeLibrary knowledgeLibrary); public int updateKnowledgeLibrary(KnowledgeLibrary knowledgeLibrary, MultipartFile[] files);
/** /**
* 批量删除知识库 * 批量删除知识库
@ -59,4 +61,18 @@ public interface IKnowledgeLibraryService
* @return 结果 * @return 结果
*/ */
public int deleteKnowledgeLibraryById(String guid); public int deleteKnowledgeLibraryById(String guid);
/**
* 查询附件
* @param key
* @return
*/
AttFileRespDTO queryFiles(String key);
/**
* 删除案例要素图片
* @param key 图片id
* @return
*/
public int removeFile(String key);
} }

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

@ -1,13 +1,24 @@
package com.zdxt.knowledge.service.impl; package com.zdxt.knowledge.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.zdxt.auth.dto.ZdxtFileBean;
import com.zdxt.auth.feign.FileUploadApi;
import com.zdxt.auth.feign.ZdxtFileCommonApi;
import com.zdxt.common.util.Convert; import com.zdxt.common.util.Convert;
import com.zdxt.common.util.StringUtils;
import com.zdxt.common.zdxtFile.AttFileRespDTO;
import com.zdxt.common.zdxtFile.FilePreviewUtilBean;
import com.zdxt.common.zdxtFile.ZdxtFileCommon;
import com.zdxt.knowledge.domain.KnowledgeLibrary; import com.zdxt.knowledge.domain.KnowledgeLibrary;
import com.zdxt.knowledge.mapper.KnowledgeLibraryMapper; import com.zdxt.knowledge.mapper.KnowledgeLibraryMapper;
import com.zdxt.knowledge.service.IKnowledgeLibraryService; import com.zdxt.knowledge.service.IKnowledgeLibraryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
/** /**
* 知识库Service业务层处理 * 知识库Service业务层处理
@ -18,8 +29,9 @@ import org.springframework.stereotype.Service;
@Service @Service
public class KnowledgeLibraryServiceImpl implements IKnowledgeLibraryService public class KnowledgeLibraryServiceImpl implements IKnowledgeLibraryService
{ {
@Autowired @Autowired private KnowledgeLibraryMapper knowledgeLibraryMapper;
private KnowledgeLibraryMapper knowledgeLibraryMapper; @Autowired private FileUploadApi fileUploadApi;
@Autowired private ZdxtFileCommonApi zdxtFileCommonApi;
/** /**
* 查询知识库 * 查询知识库
@ -52,9 +64,20 @@ public class KnowledgeLibraryServiceImpl implements IKnowledgeLibraryService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertKnowledgeLibrary(KnowledgeLibrary knowledgeLibrary) public int insertKnowledgeLibrary(KnowledgeLibrary knowledgeLibrary, MultipartFile[] files)
{ {
return knowledgeLibraryMapper.insertKnowledgeLibrary(knowledgeLibrary); knowledgeLibrary.setGuid(StringUtils.getUUID());
knowledgeLibrary.setSrot(0L);
int resNum = knowledgeLibraryMapper.insertKnowledgeLibrary(knowledgeLibrary);
// 上传文件,并在附件表中添加记录
if (resNum > 0 && ObjectUtil.isNotEmpty(files)) {
for (MultipartFile file : files) {
// todo 将原有关联附件删除在重新上传比较好
zdxtFileCommonApi.insertZdxtFile(file, knowledgeLibrary.getGuid(), fileUploadApi.upload(file));
}
}
return resNum;
} }
/** /**
@ -64,9 +87,18 @@ public class KnowledgeLibraryServiceImpl implements IKnowledgeLibraryService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateKnowledgeLibrary(KnowledgeLibrary knowledgeLibrary) public int updateKnowledgeLibrary(KnowledgeLibrary knowledgeLibrary, MultipartFile[] files)
{ {
return knowledgeLibraryMapper.updateKnowledgeLibrary(knowledgeLibrary); int resNum = knowledgeLibraryMapper.updateKnowledgeLibrary(knowledgeLibrary);
// 上传文件,并在附件表中添加记录
if (resNum > 0 && ObjectUtil.isNotEmpty(files)) {
for (MultipartFile file : files) {
// todo 将原有关联附件删除在重新上传比较好
zdxtFileCommonApi.insertZdxtFile(file, knowledgeLibrary.getGuid(), fileUploadApi.upload(file));
}
}
return resNum;
} }
/** /**
@ -92,4 +124,26 @@ public class KnowledgeLibraryServiceImpl implements IKnowledgeLibraryService
{ {
return knowledgeLibraryMapper.deleteKnowledgeLibraryById(guid); return knowledgeLibraryMapper.deleteKnowledgeLibraryById(guid);
} }
@Override
public AttFileRespDTO queryFiles(String key) {
ZdxtFileBean zdxtFileBeanCondition = new ZdxtFileBean();
zdxtFileBeanCondition.setBusinessId(key);
List<ZdxtFileBean> fileBeanList = zdxtFileCommonApi.selectZdxtFileList(zdxtFileBeanCondition);
ArrayList<ZdxtFileCommon> fileList = new ArrayList<>();
for (ZdxtFileBean fileBean : fileBeanList) {
ZdxtFileCommon zdxtFileCommon = new ZdxtFileCommon();
BeanUtil.copyProperties(fileBean, zdxtFileCommon);
fileList.add(zdxtFileCommon);
}
FilePreviewUtilBean filePreviewUtilBean = new FilePreviewUtilBean();
return filePreviewUtilBean.attachementToAttFileRespDTO(fileList);
}
@Override
public int removeFile(String key) {
return zdxtFileCommonApi.deleteZdxtFileById(key);
}
} }

9
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/KnowledgeLibraryMapper.xml

@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="com.zdxt.knowledge.domain.KnowledgeLibrary" id="KnowledgeLibraryResult"> <resultMap type="com.zdxt.knowledge.domain.KnowledgeLibrary" id="KnowledgeLibraryResult">
<result property="guid" column="guid" /> <result property="guid" column="guid" />
<result property="title" column="title" /> <result property="title" column="title" />
<result property="subTitle" column="sub_title" />
<result property="content" column="content" /> <result property="content" column="content" />
<result property="flag" column="flag" /> <result property="flag" column="flag" />
<result property="srot" column="srot" /> <result property="srot" column="srot" />
@ -21,13 +22,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectKnowledgeLibraryVo"> <sql id="selectKnowledgeLibraryVo">
select guid, title, content, flag, srot, state, publishDate, publishState, examineState, creator, create_time, updator, update_time from knowledge_library select guid, title, sub_title, content, flag, srot, state, publishDate, publishState, examineState, creator, create_time, updator, update_time from knowledge_library
</sql> </sql>
<select id="selectKnowledgeLibraryList" parameterType="KnowledgeLibrary" resultMap="KnowledgeLibraryResult"> <select id="selectKnowledgeLibraryList" parameterType="KnowledgeLibrary" resultMap="KnowledgeLibraryResult">
<include refid="selectKnowledgeLibraryVo"/> <include refid="selectKnowledgeLibraryVo"/>
<where> <where>
<if test="title != null and title != ''"> and title = #{title}</if> <if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="subTitle != null and subTitle != ''"> and sub_title like concat('%', #{subTitle}, '%')</if>
<if test="content != null and content != ''"> and content = #{content}</if> <if test="content != null and content != ''"> and content = #{content}</if>
<if test="flag != null and flag != ''"> and flag = #{flag}</if> <if test="flag != null and flag != ''"> and flag = #{flag}</if>
<if test="srot != null "> and srot = #{srot}</if> <if test="srot != null "> and srot = #{srot}</if>
@ -50,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="guid != null and guid != ''">guid,</if> <if test="guid != null and guid != ''">guid,</if>
<if test="title != null and title != ''">title,</if> <if test="title != null and title != ''">title,</if>
<if test="subTitle != null and subTitle != ''">sub_title,</if>
<if test="content != null and content != ''">content,</if> <if test="content != null and content != ''">content,</if>
<if test="flag != null and flag != ''">flag,</if> <if test="flag != null and flag != ''">flag,</if>
<if test="srot != null ">srot,</if> <if test="srot != null ">srot,</if>
@ -65,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="guid != null and guid != ''">#{guid},</if> <if test="guid != null and guid != ''">#{guid},</if>
<if test="title != null and title != ''">#{title},</if> <if test="title != null and title != ''">#{title},</if>
<if test="subTitle != null and subTitle != ''">#{subTitle},</if>
<if test="content != null and content != ''">#{content},</if> <if test="content != null and content != ''">#{content},</if>
<if test="flag != null and flag != ''">#{flag},</if> <if test="flag != null and flag != ''">#{flag},</if>
<if test="srot != null ">#{srot},</if> <if test="srot != null ">#{srot},</if>
@ -83,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update knowledge_library update knowledge_library
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="title != null and title != ''">title = #{title},</if> <if test="title != null and title != ''">title = #{title},</if>
<if test="subTitle != null and subTitle != ''">sub_title = #{subTitle},</if>
<if test="content != null and content != ''">content = #{content},</if> <if test="content != null and content != ''">content = #{content},</if>
<if test="flag != null and flag != ''">flag = #{flag},</if> <if test="flag != null and flag != ''">flag = #{flag},</if>
<if test="srot != null ">srot = #{srot},</if> <if test="srot != null ">srot = #{srot},</if>

Loading…
Cancel
Save