From 8696e6acf98bfb22bbd27ee0a765d5cc466de2a6 Mon Sep 17 00:00:00 2001 From: lsy <18332763730@163.com> Date: Fri, 16 Feb 2018 12:41:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=BB=E9=94=AE=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/mybatisStart.properties | 23 +- .../main/resources/templates/moudel_js.ftl | 66 +++ .../main/resources/templates/moudel_vue.ftl | 442 ++++++++++++++++++ .../common/service/impl/SsmServiceImpl.java | 2 +- .../impl/UpmsOrganizationServiceImpl.java | 7 +- .../mappers/UpmsOrganizationMapper.xml | 2 +- 6 files changed, 536 insertions(+), 6 deletions(-) create mode 100644 boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/moudel_js.ftl create mode 100644 boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/moudel_vue.ftl diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisStart.properties b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisStart.properties index b9230c5..4ce9f40 100644 --- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisStart.properties +++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisStart.properties @@ -1,15 +1,32 @@ -#mybatisGeneratorExtend \u6240\u9700\u8981\u7684\u5FC5\u8981\u7684\u914D\u7F6E\u6587\u4EF6 +#mybatisGeneratorExtend +# \u4E00\u7EA7\u914D\u7F6E\u53C2\u6570 db.driverLocation=/root/mysql-connector-java-5.1.40-bin.jar db.driverClassName=com.mysql.jdbc.Driver db.url=jdbc:mysql://127.0.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false db.username=root db.password=studyj2e + +# \u4E8C\u7EA7\u914D\u7F6E\u53C2\u6570,\u914D\u5408\u4E00\u7EA7\u914D\u7F6E\u53C2\u6570\u751F\u6210mybatis_generator\u7684\u914D\u7F6E\u6587\u4EF6 mybatisGenerator.pojoPackage=pojoPackage mybatisGenerator.daoPackage=daoPackage mybatisGenerator.tablesPrefix=upms -# service controllerËùÐèҪµÄÅäÖà + +# \u4F9D\u8D56\u4E8E\u4E00\u7EA7,\u4E8C\u7EA7\u914D\u7F6E\u53C2\u6570 \u751F\u6210service controller mybatisGenerator.servicePackage=daoPackage mybatisGenerator.controllerPackage=daoPackage mybatisGenerator.serviceImplPackage=daoPackage mybatisGenerator.primaryKeyType=daoPackage -mybatisGenerator.isOverWrite=false \ No newline at end of file +mybatisGenerator.isOverWrite=false + +# js controller\u5C42 vue-element \u4EE3\u7801\u751F\u6210\u6240\u9700\u8981\u7684\u53C2\u6570.\u4EC5\u4EC5\u4F9D\u8D56\u4E8E\u4E00\u7EA7\u53C2\u6570 +# \u6839\u636E\u54EA\u5F20\u6570\u636E\u8868\u751F\u6210 +vue.tablePrefix=upms_ +# js\u6587\u4EF6\u7684\u751F\u6210\u8DEF\u5F84 +vue.js.createPath= +# vue\u6587\u4EF6\u7684\u751F\u6210\u8DEF\u5F84 +vue.vue.createPath= +# +# +# +# + diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/moudel_js.ftl b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/moudel_js.ftl new file mode 100644 index 0000000..6060f8b --- /dev/null +++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/moudel_js.ftl @@ -0,0 +1,66 @@ +import request from '@/utils/request' +import service from '@/api/config/const' +import { paramToString, like, update } from '@/utils/param' + +const baseUrl = '/upmsOrganization' +/** +* 添加 +* @param pojo +* @returns {*} +*/ +export function add(pojo) { +return request.post(service.upms + baseUrl, paramToString(pojo)) +} + +/** +* 根据id查询 +* @param id +* @returns {V|*} +*/ +export function getById(id) { +return request.get(service.upms + baseUrl + '/' + id) +} + +/** +* 条件查询 +* @param pojo +* @param pageNum +* @param pageSize +* @param orderBy +* @returns {V|*} +*/ +export function getByCondition(pojo, pageNum, pageSize, orderBy) { +const data = {} +// 拼接查询条件 +if (pojo) { +pojo.name == null ? '' : data.name = like(pojo.name) +pojo.pid == null ? '' : data.pid = pojo.pid +} +pageNum == null ? '' : data.pageNum = pageNum +pageSize == null ? '' : data.pageSize = pageSize +orderBy == null ? '' : data.orderBy = orderBy +return request.get(service.upms + baseUrl + '?' + paramToString(data)) +} + +/** +* 根据id删除多个 +* @param ids +* @returns {boolean|*} +*/ +export function deleteByIds(ids) { +const data = { +ids: ids +} +return request.delete(service.upms + baseUrl + '?' + paramToString(data)) +} + +/** +* 更新数据 +* @param pojo +* @returns {*} +*/ +export function updateSelectiveById(pojo) { +const data = {} +update(data, pojo) +return request.put(service.upms + baseUrl + '/' + pojo.id, paramToString(data)) +} diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/moudel_vue.ftl b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/moudel_vue.ftl new file mode 100644 index 0000000..80ef81a --- /dev/null +++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/moudel_vue.ftl @@ -0,0 +1,442 @@ +<#----> + + + + + + diff --git a/boot-starter/boot-starter-ssm/src/main/java/com/micro/fast/common/service/impl/SsmServiceImpl.java b/boot-starter/boot-starter-ssm/src/main/java/com/micro/fast/common/service/impl/SsmServiceImpl.java index 9d01641..e84aa4d 100644 --- a/boot-starter/boot-starter-ssm/src/main/java/com/micro/fast/common/service/impl/SsmServiceImpl.java +++ b/boot-starter/boot-starter-ssm/src/main/java/com/micro/fast/common/service/impl/SsmServiceImpl.java @@ -33,7 +33,7 @@ public class SsmServiceImpl,InitializingBean { @Override public ServerResponse add(UpmsOrganization pojo) { + if (pojo.getPid().equals(pojo.getId())) { + return ServerResponse.errorMsg("不予许以自身为父节点"); + } if (pojo.getPid() == 0) { // 如果是创建根节点就检查根节点是否已经被创建 UpmsOrganization upmsOrganization = new UpmsOrganization(); @@ -47,7 +50,9 @@ implements UpmsOrganizationService,InitializingBean { @Override public ServerResponse update(UpmsOrganization pojo) { - + if (pojo.getPid().equals(pojo.getId())) { + return ServerResponse.errorMsg("不予许以自身为父节点"); + } if ( pojo.getPid() == 0) { UpmsOrganization upmsOrganization = new UpmsOrganization(); upmsOrganization.setPid(0); diff --git a/ms/upms/src/main/resources/mappers/UpmsOrganizationMapper.xml b/ms/upms/src/main/resources/mappers/UpmsOrganizationMapper.xml index 3a134f5..d024a8b 100644 --- a/ms/upms/src/main/resources/mappers/UpmsOrganizationMapper.xml +++ b/ms/upms/src/main/resources/mappers/UpmsOrganizationMapper.xml @@ -29,7 +29,7 @@ values (#{id,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{ctime,jdbcType=BIGINT}) - + insert into upms_organization