From 1dcf6532a97a371e62b1cc83733bb6d7c15181ec Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Mon, 5 Nov 2018 14:34:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E5=99=A8?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=E4=BF=A1=E6=81=AF=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/skyeye/common/constans/Constants.java | 5 + .../dao/ExExplainToCodeModelDao.java | 13 ++ .../service/ExExplainToCodeModelService.java | 16 +++ .../impl/ExExplainToCodeModelServiceImpl.java | 127 ++++++++++++++++++ .../ExExplainToCodeModelController.java | 81 +++++++++++ .../dbmapper/ExExplainToCodeModelMapper.xml | 35 +++++ .../src/main/resources/mapping/reqmapping.xml | 16 +++ .../main/webapp/js/codemodel/codemodeladd.js | 28 ++-- .../main/webapp/js/codemodel/codemodeledit.js | 26 ++-- .../js/exexplain/exexplaintocodemodel.js | 82 +++++++++++ .../webapp/tpl/codemodel/codemodeladd.html | 12 -- .../webapp/tpl/codemodel/codemodeledit.html | 11 -- .../tpl/exexplain/exexplaintocodemodel.html | 40 ++++++ 13 files changed, 448 insertions(+), 44 deletions(-) create mode 100644 skyeye-dao/src/main/java/com/skyeye/exexplain/dao/ExExplainToCodeModelDao.java create mode 100644 skyeye-service/src/main/java/com/skyeye/exexplain/service/ExExplainToCodeModelService.java create mode 100644 skyeye-service/src/main/java/com/skyeye/exexplain/service/impl/ExExplainToCodeModelServiceImpl.java create mode 100644 skyeye-web/src/main/java/com/skyeye/exexplain/controller/ExExplainToCodeModelController.java create mode 100644 skyeye-web/src/main/resources/dbmapper/ExExplainToCodeModelMapper.xml create mode 100644 skyeye-web/src/main/webapp/js/exexplain/exexplaintocodemodel.js create mode 100644 skyeye-web/src/main/webapp/tpl/exexplain/exexplaintocodemodel.html diff --git a/skyeye-common/src/main/java/com/skyeye/common/constans/Constants.java b/skyeye-common/src/main/java/com/skyeye/common/constans/Constants.java index 2b26e984c..edd9c95e2 100644 --- a/skyeye-common/src/main/java/com/skyeye/common/constans/Constants.java +++ b/skyeye-common/src/main/java/com/skyeye/common/constans/Constants.java @@ -84,5 +84,10 @@ public class Constants { */ public static final String PROJECT_WEB = "\\skyeye\\skyeye-web"; + /** + * 保存模板说明的redis的key + */ + public static final String REDIS_CODEMODEL_EXPLAIN_EXEXPLAINTOCODEMODEL = "exexplaintocodemodel"; + } diff --git a/skyeye-dao/src/main/java/com/skyeye/exexplain/dao/ExExplainToCodeModelDao.java b/skyeye-dao/src/main/java/com/skyeye/exexplain/dao/ExExplainToCodeModelDao.java new file mode 100644 index 000000000..49f2708d5 --- /dev/null +++ b/skyeye-dao/src/main/java/com/skyeye/exexplain/dao/ExExplainToCodeModelDao.java @@ -0,0 +1,13 @@ +package com.skyeye.exexplain.dao; + +import java.util.Map; + +public interface ExExplainToCodeModelDao { + + public int insertExExplainToCodeModelMation(Map map) throws Exception; + + public Map queryExExplainToCodeModelMation(Map map) throws Exception; + + public int editExExplainToCodeModelMationById(Map map) throws Exception; + +} diff --git a/skyeye-service/src/main/java/com/skyeye/exexplain/service/ExExplainToCodeModelService.java b/skyeye-service/src/main/java/com/skyeye/exexplain/service/ExExplainToCodeModelService.java new file mode 100644 index 000000000..621a0e930 --- /dev/null +++ b/skyeye-service/src/main/java/com/skyeye/exexplain/service/ExExplainToCodeModelService.java @@ -0,0 +1,16 @@ +package com.skyeye.exexplain.service; + +import com.skyeye.common.object.InputObject; +import com.skyeye.common.object.OutputObject; + +public interface ExExplainToCodeModelService { + + public void insertExExplainToCodeModelMation(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void queryExExplainToCodeModelMation(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void editExExplainToCodeModelMationById(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void queryExExplainToCodeModelMationToShow(InputObject inputObject, OutputObject outputObject) throws Exception; + +} diff --git a/skyeye-service/src/main/java/com/skyeye/exexplain/service/impl/ExExplainToCodeModelServiceImpl.java b/skyeye-service/src/main/java/com/skyeye/exexplain/service/impl/ExExplainToCodeModelServiceImpl.java new file mode 100644 index 000000000..f9df2d2bf --- /dev/null +++ b/skyeye-service/src/main/java/com/skyeye/exexplain/service/impl/ExExplainToCodeModelServiceImpl.java @@ -0,0 +1,127 @@ +package com.skyeye.exexplain.service.impl; + +import java.util.HashMap; +import java.util.Map; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.skyeye.exexplain.dao.ExExplainToCodeModelDao; +import com.skyeye.exexplain.service.ExExplainToCodeModelService; +import com.skyeye.jedis.JedisClient; + +import net.sf.json.JSONObject; + +import com.alibaba.fastjson.JSON; +import com.skyeye.common.constans.Constants; +import com.skyeye.common.object.InputObject; +import com.skyeye.common.object.OutputObject; +import com.skyeye.common.util.ToolUtil; + +@Service +public class ExExplainToCodeModelServiceImpl implements ExExplainToCodeModelService{ + + @Autowired + private ExExplainToCodeModelDao exExplainToCodeModelDao; + + @Autowired + public JedisClient jedisClient; + + /** + * + * @Title: insertExExplainToCodeModelMation + * @Description: 添加代码生成器说明信息 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @Override + public void insertExExplainToCodeModelMation(InputObject inputObject, OutputObject outputObject) throws Exception { + Map map = inputObject.getParams(); + Map bean = exExplainToCodeModelDao.queryExExplainToCodeModelMation(map); + if(bean == null){ + Map user = inputObject.getLogParams(); + String id = ToolUtil.getSurFaceId(); + map.put("id", id); + map.put("createId", user.get("id")); + map.put("createTime", ToolUtil.getTimeAndToString()); + exExplainToCodeModelDao.insertExExplainToCodeModelMation(map); + jedisClient.del(Constants.REDIS_CODEMODEL_EXPLAIN_EXEXPLAINTOCODEMODEL); + bean = new HashMap<>(); + bean.put("id", id); + outputObject.setBean(bean); + }else{ + outputObject.setreturnMessage("该代码生成器说明已存在,不可进行二次保存"); + } + } + + /** + * + * @Title: queryExExplainToCodeModelMation + * @Description: 编辑代码生成器说明信息时进行回显 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @Override + public void queryExExplainToCodeModelMation(InputObject inputObject, OutputObject outputObject) throws Exception { + Map map = inputObject.getParams(); + Map bean = exExplainToCodeModelDao.queryExExplainToCodeModelMation(map); + outputObject.setBean(bean); + outputObject.settotal(1); + } + + /** + * + * @Title: editExExplainToCodeModelMationById + * @Description: 编辑代码生成器说明信息 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @Override + public void editExExplainToCodeModelMationById(InputObject inputObject, OutputObject outputObject) throws Exception { + Map map = inputObject.getParams(); + Map bean = exExplainToCodeModelDao.queryExExplainToCodeModelMation(map); + if(bean == null){ + outputObject.setreturnMessage("该代码生成器说明不存在,不可进行编辑"); + }else{ + jedisClient.del(Constants.REDIS_CODEMODEL_EXPLAIN_EXEXPLAINTOCODEMODEL); + exExplainToCodeModelDao.editExExplainToCodeModelMationById(map); + } + } + + /** + * + * @Title: queryExExplainToCodeModelMationToShow + * @Description: 获取代码生成器说明信息供展示 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @SuppressWarnings("unchecked") + @Override + public void queryExExplainToCodeModelMationToShow(InputObject inputObject, OutputObject outputObject) throws Exception { + Map map = inputObject.getParams(); + if(jedisClient.exists(Constants.REDIS_CODEMODEL_EXPLAIN_EXEXPLAINTOCODEMODEL)){ + map = JSONObject.fromObject(jedisClient.get(Constants.REDIS_CODEMODEL_EXPLAIN_EXEXPLAINTOCODEMODEL)); + }else{ + Map bean = exExplainToCodeModelDao.queryExExplainToCodeModelMation(map); + if(bean == null){ + map.put("title", "标题"); + map.put("content", "等待发布说明。"); + }else{ + jedisClient.set(Constants.REDIS_CODEMODEL_EXPLAIN_EXEXPLAINTOCODEMODEL, JSON.toJSONString(bean)); + map = bean; + } + } + outputObject.setBean(map); + } + +} diff --git a/skyeye-web/src/main/java/com/skyeye/exexplain/controller/ExExplainToCodeModelController.java b/skyeye-web/src/main/java/com/skyeye/exexplain/controller/ExExplainToCodeModelController.java new file mode 100644 index 000000000..6dc94e5a7 --- /dev/null +++ b/skyeye-web/src/main/java/com/skyeye/exexplain/controller/ExExplainToCodeModelController.java @@ -0,0 +1,81 @@ +package com.skyeye.exexplain.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.skyeye.exexplain.service.ExExplainToCodeModelService; +import com.skyeye.common.object.InputObject; +import com.skyeye.common.object.OutputObject; + +@Controller +public class ExExplainToCodeModelController { + + @Autowired + private ExExplainToCodeModelService exExplainToCodeModelService; + + /** + * + * @Title: insertExExplainToCodeModelMation + * @Description: 添加代码生成器说明信息 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @RequestMapping("/post/ExExplainToCodeModelController/insertExExplainToCodeModelMation") + @ResponseBody + public void insertExExplainToCodeModelMation(InputObject inputObject, OutputObject outputObject) throws Exception{ + exExplainToCodeModelService.insertExExplainToCodeModelMation(inputObject, outputObject); + } + + /** + * + * @Title: queryExExplainToCodeModelMation + * @Description: 编辑代码生成器说明信息时进行回显 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @RequestMapping("/post/ExExplainToCodeModelController/queryExExplainToCodeModelMation") + @ResponseBody + public void queryExExplainToCodeModelMation(InputObject inputObject, OutputObject outputObject) throws Exception{ + exExplainToCodeModelService.queryExExplainToCodeModelMation(inputObject, outputObject); + } + + /** + * + * @Title: editExExplainToCodeModelMationById + * @Description: 编辑代码生成器说明信息 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @RequestMapping("/post/ExExplainToCodeModelController/editExExplainToCodeModelMationById") + @ResponseBody + public void editExExplainToCodeModelMationById(InputObject inputObject, OutputObject outputObject) throws Exception{ + exExplainToCodeModelService.editExExplainToCodeModelMationById(inputObject, outputObject); + } + + /** + * + * @Title: queryExExplainToCodeModelMationToShow + * @Description: 获取代码生成器说明信息供展示 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @RequestMapping("/post/ExExplainToCodeModelController/queryExExplainToCodeModelMationToShow") + @ResponseBody + public void queryExExplainToCodeModelMationToShow(InputObject inputObject, OutputObject outputObject) throws Exception{ + exExplainToCodeModelService.queryExExplainToCodeModelMationToShow(inputObject, outputObject); + } + +} diff --git a/skyeye-web/src/main/resources/dbmapper/ExExplainToCodeModelMapper.xml b/skyeye-web/src/main/resources/dbmapper/ExExplainToCodeModelMapper.xml new file mode 100644 index 000000000..6a4b53a25 --- /dev/null +++ b/skyeye-web/src/main/resources/dbmapper/ExExplainToCodeModelMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + INSERT into ex_explain_to_code_model + (id, title, content, create_id, create_time) + VALUES + (#{id}, #{title}, #{content}, #{createId}, #{createTime}) + + + + UPDATE ex_explain_to_code_model + + + title = #{title}, + + + content = #{content}, + + + WHERE id = #{id} + + + \ No newline at end of file diff --git a/skyeye-web/src/main/resources/mapping/reqmapping.xml b/skyeye-web/src/main/resources/mapping/reqmapping.xml index 269b06cd4..24516e02c 100644 --- a/skyeye-web/src/main/resources/mapping/reqmapping.xml +++ b/skyeye-web/src/main/resources/mapping/reqmapping.xml @@ -383,4 +383,20 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/skyeye-web/src/main/webapp/js/codemodel/codemodeladd.js b/skyeye-web/src/main/webapp/js/codemodel/codemodeladd.js index 0893bfa47..a5fa18c97 100644 --- a/skyeye-web/src/main/webapp/js/codemodel/codemodeladd.js +++ b/skyeye-web/src/main/webapp/js/codemodel/codemodeladd.js @@ -9,17 +9,23 @@ layui.config({ var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 var $ = layui.$, form = layui.form; - - layer.open({ - type: 1, - closeBtn: 0,//关闭按钮 - resize: false,//是否允许拉伸 - offset: 'l', // 具体配置参考:offset参数项 - content: $("#modelContentDiv").html(), - area: ['200px', '400px'], - shade: 0, //不显示遮罩 - title: '注意事项' - }); + + AjaxPostUtil.request({url:reqBasePath + "exexplaintocodemodel002", params:{}, type:'json', callback:function(json){ + if(json.returnCode == 0){ + layer.open({ + type: 1, + closeBtn: 0,//关闭按钮 + resize: false,//是否允许拉伸 + offset: 'l', // 具体配置参考:offset参数项 + content: json.bean.content, + area: ['200px', '400px'], + shade: 0, //不显示遮罩 + title: json.bean.title + }); + }else{ + top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000}); + } + }}); var editor = CodeMirror.fromTextArea(document.getElementById("modelContent"), { mode : "text/x-java", // 模式 diff --git a/skyeye-web/src/main/webapp/js/codemodel/codemodeledit.js b/skyeye-web/src/main/webapp/js/codemodel/codemodeledit.js index ece895ae0..1ba2dce00 100644 --- a/skyeye-web/src/main/webapp/js/codemodel/codemodeledit.js +++ b/skyeye-web/src/main/webapp/js/codemodel/codemodeledit.js @@ -11,16 +11,22 @@ layui.config({ form = layui.form; var editor; - layer.open({ - type: 1, - closeBtn: 0,//关闭按钮 - resize: false,//是否允许拉伸 - offset: 'l', // 具体配置参考:offset参数项 - content: $("#modelContentDiv").html(), - area: ['200px', '400px'], - shade: 0, //不显示遮罩 - title: '注意事项' - }); + AjaxPostUtil.request({url:reqBasePath + "exexplaintocodemodel002", params:{}, type:'json', callback:function(json){ + if(json.returnCode == 0){ + layer.open({ + type: 1, + closeBtn: 0,//关闭按钮 + resize: false,//是否允许拉伸 + offset: 'l', // 具体配置参考:offset参数项 + content: json.bean.content, + area: ['200px', '400px'], + shade: 0, //不显示遮罩 + title: json.bean.title + }); + }else{ + top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000}); + } + }}); showGrid({ id: "showForm", diff --git a/skyeye-web/src/main/webapp/js/exexplain/exexplaintocodemodel.js b/skyeye-web/src/main/webapp/js/exexplain/exexplaintocodemodel.js new file mode 100644 index 000000000..766bb5b09 --- /dev/null +++ b/skyeye-web/src/main/webapp/js/exexplain/exexplaintocodemodel.js @@ -0,0 +1,82 @@ + +var rowId = ""; + +layui.config({ + base: basePath, + version: skyeyeVersion +}).define(['table', 'jquery', 'winui'], function (exports) { + winui.renderColor(); + layui.use(['form', 'layedit'], function (form) { + var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 + var $ = layui.$, + form = layui.form, + layedit = layui.layedit; + + var layContent; + + AjaxPostUtil.request({url:reqBasePath + "exexplaintocodemodel002", params:{}, type:'json', callback:function(json){ + if(json.returnCode == 0){ + if(!isNull(json.bean)){ + rowId = json.bean.id; + $("#title").val(json.bean.title); + $("#content").val(json.bean.content); + } + layContent = layedit.build('content', { + tool: [ + 'strong' //加粗 + ,'italic' //斜体 + ,'underline' //下划线 + ,'del' //删除线 + ,'|' //分割线 + ,'left' //左对齐 + ,'center' //居中对齐 + ,'right' //右对齐 + ,'link' //超链接 + ,'unlink' //清除链接 + ,'face' //表情 + ] + }); + }else{ + top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000}); + } + }}); + + form.render(); + + form.on('submit(formAddBean)', function (data) { + //表单验证 + if (winui.verifyForm(data.elem)) { + if(isNull(layedit.getContent(layContent))){ + top.winui.window.msg('请输入内容。', {icon: 2,time: 2000}); + }else{ + var params = { + title: $("#title").val(), + content: encodeURI(layedit.getContent(layContent)), + }; + if(isNull(rowId)){ + AjaxPostUtil.request({url:reqBasePath + "exexplaintocodemodel001", params:params, type:'json', callback:function(json){ + if(json.returnCode == 0){ + rowId = json.bean.id; + top.winui.window.msg('保存成功', {icon: 1,time: 2000}); + }else{ + top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000}); + } + }}); + }else{ + params.rowId = rowId; + AjaxPostUtil.request({url:reqBasePath + "exexplaintocodemodel003", params:params, type:'json', callback:function(json){ + if(json.returnCode == 0){ + top.winui.window.msg('保存成功', {icon: 1,time: 2000}); + }else{ + top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000}); + } + }}); + } + } + } + return false; + }); + + }); + +}); \ No newline at end of file diff --git a/skyeye-web/src/main/webapp/tpl/codemodel/codemodeladd.html b/skyeye-web/src/main/webapp/tpl/codemodel/codemodeladd.html index b072a974b..44228ae32 100644 --- a/skyeye-web/src/main/webapp/tpl/codemodel/codemodeladd.html +++ b/skyeye-web/src/main/webapp/tpl/codemodel/codemodeladd.html @@ -76,18 +76,6 @@ -
- 模板使用替换事项:
- 1.${{controllerPackage}}为Controller包名替换
- 2.${{servicePackage}}为Service包名替换
- 3.${{serviceImplPackage}}为ServiceImpl包名替换
- 4.${{daoPackage}}为Dao包名替换
- 5.${{tableName}}为Controller、Service等层的类名,类方法。
- 6.${{objectName}}为对象名
- 7.${{notesName}}为注释对象名
- 8.${{urlName}}为请求链接对象名
-
- + + + + \ No newline at end of file -- GitLab