Browse Source

勋章优化

master
yanyan 3 years ago
parent
commit
5c8b6e89ff
  1. 41
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/add.html
  2. 20
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/detail.html
  3. 17
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/edit.html
  4. 94
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/manage.html
  5. 201
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/selected.html
  6. 24
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/view.html
  7. 43
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneMedalController.java
  8. 26
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneMedal.java
  9. 5
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/ISceneMedalService.java
  10. 32
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/SceneMedalServiceImpl.java
  11. 17
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneMedalMapper.xml

41
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/add.html

@ -3,7 +3,7 @@
<head>
<th:block th:include="zdxtInclude :: header('新增')"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/>
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
@ -28,12 +28,13 @@
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-2 control-label">类型:</label>
<div class="col-sm-10">
<select name="type" id="type" class="form-control m-b" th:with="type=${@dict.getType('medal_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
<label class="col-sm-4 control-label is-required">启用:</label>
<div class="col-sm-8">
<select name="hide" class="form-control">
<option value="1"></option>
<option value="0"></option>
</select>
</div>
</div>
@ -41,23 +42,23 @@
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">场景:</label>
<div class="form-group" hidden>
<label class="col-sm-4 control-label is-required">场景:</label>
<div class="col-sm-8">
<select id="scene" class="form-control select2-multiple">
<option th:each="scene:${sceneList}" th:value="${scene.guid}" th:text="${scene.name}" th:disabled="${scene.status == '1'}"></option>
<option th:each="scene:${sceneList}" th:value="${scene.guid}" th:text="${scene.name}"
th:disabled="${scene.status == '1'}"></option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">启用</label>
<div class="form-group" hidden>
<label class="col-sm-4 control-label is-required">区间</label>
<div class="col-sm-8">
<select name="hide" class="form-control">
<option value="1"></option>
<option value="0"></option>
</select>
<input class="form-control" type="text" name="level" id="level" required>
</div>
</div>
</div>
@ -66,9 +67,17 @@
</div>
<th:block th:include="zdxtInclude :: footer"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/>
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: select2-js"/>
<script type="text/javascript" th:inline="javascript">
var prefix = ctx + "small/project/medal"
var type = [[${type}]];
if (type === "1") {
$("#scene").parent().parent().show();
$("#level").parent().parent().hide();
} else if (type === "2") {
$("#level").parent().parent().show();
$("#scene").parent().parent().hide();
}
$("#form-medal-add").validate({
focusCleanup: true

20
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/detail.html

@ -15,7 +15,7 @@
<input name="name" th:field="*{name}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<div class="form-group" hidden>
<label class="col-sm-3 control-label">场景:</label>
<div class="col-sm-8">
<select id="scene" class="form-control select2-multiple">
@ -23,6 +23,12 @@
</select>
</div>
</div>
<div class="form-group" hidden>
<label class="col-sm-3 control-label">区间:</label>
<div class="col-sm-8">
<input name="level" th:field="*{level}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">类型:</label>
<div class="col-sm-8">
@ -52,6 +58,12 @@
<input name="createTime" th:field="*{createTime}" class="form-control" type="text">
</div>
</div>
<!-- <div class="form-group">-->
<!-- <label class="col-sm-3 control-label">image:</label>-->
<!-- <div class="col-sm-8">-->
<!-- <img th:src="*{iconPath}" class="form-control" type="text">-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group" id="fileTitle">
<label class="col-sm-3 control-label">图标:</label>
<div id="fileIn" class="col-sm-8" readonly>
@ -72,6 +84,12 @@
<th:block th:include="include :: select2-js" />
<script type="text/javascript" th:inline="javascript">
var prefix = ctx + "small/project/medal";
var sceneMedal = [[${sceneMedal}]];
if (sceneMedal.type === "1"){
$("#scene").parent().parent().show();
} else if (sceneMedal.type === "2"){
$("[name='level']").parent().parent().show();
}
$(function () {
// 渲染文件要素信息

17
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/edit.html

@ -15,7 +15,7 @@
<input name="name" th:field="*{name}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<div class="form-group" hidden>
<label class="col-sm-3 control-label">场景:</label>
<div class="col-sm-8">
<select id="scene" class="form-control select2-multiple">
@ -23,12 +23,10 @@
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">类型</label>
<div class="form-group" hidden>
<label class="col-sm-3 control-label">区间</label>
<div class="col-sm-8">
<select name="type" class="form-control m-b" th:with="type=${@dict.getType('medal_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
</select>
<input name="level" th:field="*{level}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
@ -60,12 +58,19 @@
<th:block th:include="include :: select2-js" />
<script type="text/javascript" th:inline="javascript">
var prefix = ctx + "small/project/medal"
var sceneMedal = [[${sceneMedal}]];
$("#form-medal-edit").validate({
focusCleanup: true
});
var isFlieIn = true;
if (sceneMedal.type === "1"){
$("#scene").parent().parent().show();
} else if (sceneMedal.type === "2"){
$("[name='level']").parent().parent().show();
}
$(function() {
// 渲染要素信息
renderVersionAtt();

94
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/manage.html

@ -0,0 +1,94 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="zdxtInclude :: header('奖章配置')"/>
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<p>类型:</p>
<input type="text" name="dictLabel"/>
<input type="text" name="dictType" value="medal_type" hidden/>
</li>
<li>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-reset btn-rounded btn-sm" onclick="reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="col-sm-12 select-table table-bordered">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="zdxtInclude :: footer"/>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('project:medal:edit')}]];
var removeFlag = [[${@permission.hasPermi('project:medal:remove')}]];
var detailFlag = [[${@permission.hasPermi('project:medal:detail')}]];
var types = [[${@dict.getType('medal_type')}]];
var prefix = ctx + "system/dict/data";
$(function () {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add/{}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
detailUrl: prefix + "/detail/{guid}",
modalName: "主页",
columns: [{
checkbox: true
},
{
field: 'dictLabel',
title: '勋章类型'
},
// {
// field : 'type',
// title : '类型',
// formatter : function (value, row, index) {
// return $.table.selectDictLabel(types, value);
// }
// },
{
field: 'createBy',
title: '创建人'
},
{
field: 'createTime',
title: '创建时间'
},
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs" href="/small/project/medal/view/'+row.dictValue+'"><i class="fa fa-eject"></i>列表</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
function reset() {
$("[name='dictLabel']").val("");
$.table.search()
}
</script>
</body>
</html>

201
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/selected.html

@ -0,0 +1,201 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="zdxtInclude :: header('编辑')" />
<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-tab-edit" th:object="${sceneMedal}">
<input name="guid" th:field="*{guid}" type="hidden">
<div class="form-group" id="fileTitle">
<label class="col-sm-3 control-label">成就图标:</label>
<div id="fileIn" class="col-sm-8" readonly>
<div class="file-loading">
<input id="fileInput" name="file" type="file" multiple>
</div>
</div>
<div id="fileOut" class="col-sm-8" style="display: none" readonly>
<div class="file-loading">
<input id="fileOutput" name="file" type="file" multiple>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer" />
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/>
<script type="text/javascript" th:inline="javascript">
var prefix = ctx + "small/project/medal"
$("#form-tab-edit").validate({
focusCleanup: true
});
var isFlieIn = true;
$(function() {
// 渲染要素信息
renderVersionAtt();
})
function submitHandler() {
if (isFlieIn) {
$('#fileInput').fileinput('upload');
} else {
$('#fileOutput').fileinput('upload');
}
}
/** 附件相关 */
/** 渲染附件信息 */
function renderVersionAtt() {
var key = $("[name='guid']").val() + "0000";
$.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 + "/selected", result.data.filePreview);
}
},
error: function (error) {
$.modal.alertWarning("附件预览失败!");
}
});
}
/** 上传附件 */
function uploadFiles() {
var filePreview = { fileList: null, previewRespDTOS: null }
initFile("fileInput", prefix + "/selected", 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-tab-edit").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;
}
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();
}
</script>
</body>
</html>

24
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/medal/view.html

@ -14,6 +14,7 @@
<p>名称:</p>
<input type="text" name="name"/>
</li>
<input type="text" name="type" hidden/>
<li>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
@ -40,9 +41,12 @@
var editFlag = [[${@permission.hasPermi('project:medal:edit')}]];
var removeFlag = [[${@permission.hasPermi('project:medal:remove')}]];
var detailFlag = [[${@permission.hasPermi('project:medal:detail')}]];
var types = [[${@dict.getType('medal_type')}]];
var prefix = ctx + "small/project/medal";
$(function () {
var type = [[${type}]];
$("[name='type']").val(type);
var options = {
url: prefix + "/list",
createUrl: prefix + "/add/{}",
@ -65,6 +69,13 @@
return value === 0 ? "否" : "是";
}
},
{
field: 'type',
title: '类型',
formatter: function (value, row, index) {
return $.table.selectDictLabel(types, value);
}
},
{
field: 'creator',
title: '创建人'
@ -78,6 +89,7 @@
align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-primary btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="selected(\'' + row.guid + '\')"><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.guid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-primary btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.guid + '\')"><i class="fa fa-eye"></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>');
@ -94,7 +106,17 @@
}
function add() {
$.modal.open("新增", ctx + "small/project/medal/add", 800, 450);
var type = [[${type}]];
$.modal.open("新增", ctx + "small/project/medal/add/" + type, 800, 450);
}
function selected(id) {
var selectedUrl = prefix + "/selected/{guid}";
var url = "/404.html";
if ($.common.isNotEmpty(id)) {
url = selectedUrl.replace("{guid}", id);
}
$.modal.open("编辑", url);
}
function sort(id) {

43
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneMedalController.java

@ -5,10 +5,8 @@ import com.zdxt.common.controller.BaseController;
import com.zdxt.common.util.TableDataInfo;
import com.zdxt.knowledge.domain.SceneManage;
import com.zdxt.knowledge.domain.SceneMedal;
import com.zdxt.knowledge.domain.WechatUser;
import com.zdxt.knowledge.service.ISceneManageService;
import com.zdxt.knowledge.service.ISceneMedalService;
import com.zdxt.knowledge.service.WechatService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -27,21 +25,47 @@ import java.util.List;
* @date 2023-01-22
*/
@Controller
@RequestMapping("/small/project/medal")
@RequestMapping("/small/project/medal")
public class SceneMedalController extends BaseController {
private String prefix = "project/medal";
@Autowired
private ISceneMedalService sceneMedalService;
@Autowired private ISceneManageService sceneManageService;
@Autowired private WechatService wechatService;
@Autowired
private ISceneManageService sceneManageService;
@RequiresPermissions("project:medal:view")
@GetMapping("/view")
public String manage() {
return prefix + "/manage";
}
@RequiresPermissions("project:medal:view")
@GetMapping("/view/{type}")
public String view(@PathVariable("type") String type, ModelMap mmap) {
mmap.put("type", type);
return prefix + "/view";
}
/**
* 成就勋章图标
*/
@GetMapping("/selected/{guid}")
public String selected(@PathVariable("guid") String guid, ModelMap mmap) {
SceneMedal sceneMedal = sceneMedalService.selectSceneMedalById(guid);
mmap.put("sceneMedal", sceneMedal);
return prefix + "/selected";
}
/**
* 修改保存
*/
@RequiresPermissions("project:medal:edit")
@PostMapping("/selected")
@ResponseBody
public ZDResponse selectedSave(@RequestParam("file") MultipartFile[] files, SceneMedal sceneMedal) {
return sceneMedalService.selected(files, sceneMedal);
}
/**
* 查询
@ -54,6 +78,7 @@ public class SceneMedalController extends BaseController {
List<SceneMedal> list = sceneMedalService.selectSceneMedalList(sceneMedal);
return getDataTable(list);
}
/**
* 查询
*/
@ -82,9 +107,10 @@ public class SceneMedalController extends BaseController {
/**
* 新增
*/
@GetMapping("/add")
public String add(ModelMap mmap) {
@GetMapping("/add/{type}")
public String add(@PathVariable("type") String type, ModelMap mmap) {
List<SceneManage> sceneList = sceneManageService.selectSceneManageListAll(new SceneManage());
mmap.put("type", type);
mmap.put("sceneList", sceneList);
return prefix + "/add";
}
@ -119,8 +145,7 @@ public class SceneMedalController extends BaseController {
@PostMapping("/edit")
@ResponseBody
public ZDResponse editSave(@RequestParam("file") MultipartFile[] files, SceneMedal sceneMedal) {
return sceneMedalService.updateSceneMedal(files, sceneMedal) > 0
? ZDResponse.success() : ZDResponse.error("编辑失败");
return sceneMedalService.updateSceneMedal(files, sceneMedal);
}
/**

26
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneMedal.java

@ -30,9 +30,19 @@ public class SceneMedal implements Serializable {
*/
private String iconPath;
/**
* 成就图标
*/
private String achieveIconPath;
/** 绑定场景Id */
private String sceneId;
/**
* 分数
*/
private Integer level;
/** 类型 */
private String type;
@ -147,4 +157,20 @@ public class SceneMedal implements Serializable {
public void setHide(Integer hide) {
this.hide = hide;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getAchieveIconPath() {
return achieveIconPath;
}
public void setAchieveIconPath(String achieveIconPath) {
this.achieveIconPath = achieveIconPath;
}
}

5
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/ISceneMedalService.java

@ -1,5 +1,6 @@
package com.zdxt.knowledge.service;
import com.zdxt.common.ZDResponse;
import com.zdxt.common.zdxtFile.AttFileRespDTO;
import com.zdxt.knowledge.domain.SceneMedal;
import org.springframework.web.multipart.MultipartFile;
@ -44,7 +45,7 @@ public interface ISceneMedalService {
* @param sceneMedal
* @return 结果
*/
public int updateSceneMedal(MultipartFile[] files, SceneMedal sceneMedal);
public ZDResponse updateSceneMedal(MultipartFile[] files, SceneMedal sceneMedal);
/**
* 批量删除
@ -77,4 +78,6 @@ public interface ISceneMedalService {
* @return
*/
public int removeFile(String key);
ZDResponse selected(MultipartFile[] files, SceneMedal sceneMedal);
}

32
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/SceneMedalServiceImpl.java

@ -7,6 +7,7 @@ import com.zdxt.auth.dto.ZdxtFileBean;
import com.zdxt.auth.feign.FileUploadApi;
import com.zdxt.auth.feign.UserApi;
import com.zdxt.auth.feign.ZdxtFileCommonApi;
import com.zdxt.common.ZDResponse;
import com.zdxt.common.util.Convert;
import com.zdxt.common.util.DateUtils;
import com.zdxt.common.util.StringUtils;
@ -95,17 +96,21 @@ public class SceneMedalServiceImpl implements ISceneMedalService {
* @return 结果
*/
@Override
public int updateSceneMedal(MultipartFile[] files, SceneMedal sceneMedal) {
if (ObjectUtil.isEmpty(files) || files.length > 1) {
return -1;
public ZDResponse updateSceneMedal(MultipartFile[] files, SceneMedal sceneMedal) {
if (ObjectUtil.isNotEmpty(files) && files.length > 1) {
return ZDResponse.error("单次只允许上传一个文件");
}
String uploadFilePath = "";
if (ObjectUtil.isNotEmpty(files)) {
zdxtFileCommonApi.deleteZdxtFileByIds(sceneMedal.getGuid());
// 上传文件,并在附件表中添加记录
String uploadFilePath = fileUploadApi.upload(files[0]);
uploadFilePath = fileUploadApi.upload(files[0]);
zdxtFileCommonApi.insertZdxtFile(files[0], sceneMedal.getGuid() + "", uploadFilePath);
}
//更新数据
sceneMedal.setIconPath(uploadFilePath);
return sceneMedalMapper.updateSceneMedal(sceneMedal);
return sceneMedalMapper.updateSceneMedal(sceneMedal) > 0 ?
ZDResponse.success("编辑成功") : ZDResponse.error("编辑失败");
}
/**
@ -146,4 +151,21 @@ public class SceneMedalServiceImpl implements ISceneMedalService {
return zdxtFileCommonApi.deleteZdxtFileById(key);
}
@Override
public ZDResponse selected(MultipartFile[] files, SceneMedal sceneMedal) {
if (ObjectUtil.isEmpty(files) || files.length > 1) {
return ZDResponse.error("文件不能为空且只允许上传一张图片");
}
String uploadPath = fileUploadApi.upload(files[0]);
sceneMedal.setAchieveIconPath(uploadPath);
int result = sceneMedalMapper.updateSceneMedal(sceneMedal);
// 上传文件,并在附件表中添加记录
if (result > 0) {
zdxtFileCommonApi.deleteZdxtFileByIds(sceneMedal.getGuid() + "0000");
zdxtFileCommonApi.insertZdxtFile(files[0], sceneMedal.getGuid() + "0000", uploadPath);
return ZDResponse.success();
}
return ZDResponse.error("编辑成就勋章图片失败");
}
}

17
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneMedalMapper.xml

@ -7,9 +7,11 @@
<result property="guid" column="guid"/>
<result property="name" column="name"/>
<result property="iconPath" column="icon_path"/>
<result property="achieveIconPath" column="achieve_icon_path"/>
<result property="sceneId" column="scene_id"/>
<result property="type" column="type"/>
<result property="hide" column="hide"/>
<result property="level" column="level"/>
<result property="creator" column="creator"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
@ -20,9 +22,11 @@
select guid,
name,
icon_path,
achieve_icon_path,
scene_id,
type,
hide,
level,
creator,
create_time,
update_by,
@ -35,6 +39,7 @@
<where>
and hide = 1
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''">and type = #{type}</if>
<if test="creator != null and creator != ''">and creator = #{creator}</if>
<if test="sceneId != null and sceneId != ''">and scene_id = #{sceneId}</if>
</where>
@ -51,9 +56,11 @@
<if test="guid != null ">guid,</if>
<if test="name != null and name != ''">`name`,</if>
<if test="iconPath != null and iconPath != ''">icon_path,</if>
<if test="achieveIconPath != null and achieveIconPath != ''">achieve_icon_path,</if>
<if test="sceneId != null and sceneId != ''">scene_id,</if>
<if test="type != null and type != ''">type,</if>
<if test="hide != null and hide != ''">hide,</if>
<if test="hide != null">hide,</if>
<if test="level != null">level,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="createTime != null ">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
@ -63,9 +70,11 @@
<if test="guid != null ">#{guid},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="iconPath != null and iconPath != ''">#{iconPath},</if>
<if test="achieveIconPath != null and achieveIconPath != ''">#{achieveIconPath},</if>
<if test="sceneId != null and sceneId != ''">#{sceneId},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="hide != null and hide != ''">#{hide},</if>
<if test="hide != null">#{hide},</if>
<if test="level != null">#{level},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
@ -78,9 +87,11 @@
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="iconPath != null and iconPath != ''">icon_path = #{iconPath},</if>
<if test="achieveIconPath != null and achieveIconPath != ''">achieve_icon_path = #{achieveIconPath},</if>
<if test="sceneId != null and sceneId != ''">scene_id = #{sceneId},</if>
<if test="type != null and type != ''">type = #{type},</if>
<if test="hide != null and hide != ''">hide = #{hide},</if>
<if test="hide != null ">hide = #{hide},</if>
<if test="level != null">level = #{level},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null ">update_time = #{updateTime},</if>
</trim>

Loading…
Cancel
Save