From 92d65078852b0814691b218cb70eee5334063519 Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Wed, 30 Oct 2019 21:51:18 +0800 Subject: [PATCH 01/10] :oncoming_police_car: README --- README-zh.md | 48 +++++++++++++++++++++++++++--------------------- README.md | 49 +++++++++++++++++++++++++++---------------------- 2 files changed, 54 insertions(+), 43 deletions(-) diff --git a/README-zh.md b/README-zh.md index a8f1db9c..3886bd66 100644 --- a/README-zh.md +++ b/README-zh.md @@ -102,35 +102,41 @@ mvn clean package -Plocal ### 1. 创建数据库表 ```sql - -- ---------------------------- -- Table structure for sys_user -- ---------------------------- -drop table if exists `sys_user`; -create table sys_user +DROP TABLE IF EXISTS `sys_user`; +CREATE TABLE `sys_user` ( - id bigint not null comment '主键' - primary key, - username varchar(20) not null comment '用户名', - nickname varchar(20) null comment '昵称', - password varchar(64) not null comment '密码', - salt varchar(32) null comment '盐值', - remark varchar(200) null comment 'remark', - status int default 1 not null comment '状态,0:禁用,1:启用', - create_time timestamp default CURRENT_TIMESTAMP null comment '创建时间', - update_time timestamp null comment '修改时间', - constraint sys_user_username_uindex - unique (username) -) - comment '系统用户'; + `id` bigint(20) NOT NULL COMMENT '主键', + `username` varchar(20) NOT NULL COMMENT '用户名', + `nickname` varchar(20) DEFAULT NULL COMMENT '昵称', + `password` varchar(64) NOT NULL COMMENT '密码', + `salt` varchar(32) DEFAULT NULL COMMENT '盐值', + `phone` varchar(20) NOT NULL COMMENT '手机号码', + `gender` int(11) NOT NULL DEFAULT '1' COMMENT '性别,0:女,1:男,默认1', + `head` varchar(200) null comment '头像', + `remark` varchar(200) DEFAULT NULL COMMENT 'remark', + `state` int(11) NOT NULL DEFAULT '1' COMMENT '状态,0:禁用,1:启用,2:锁定', + `department_id` bigint(20) NOT NULL COMMENT '部门id', + `role_id` bigint(20) NOT NULL COMMENT '角色id', + `deleted` int(11) NOT NULL DEFAULT '0' COMMENT '逻辑删除,0:未删除,1:已删除', + `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本', + `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` timestamp NULL DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `sys_user_username_uindex` (`username`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT ='系统用户'; -- ---------------------------- -- Records of sys_user -- ---------------------------- -INSERT INTO spring_boot_plus.sys_user (id, username, nickname, password, salt, remark, state, create_time, update_time) - VALUES (1, 'admin', '管理员', '751ade2f90ceb660cb2460f12cc6fe08268e628e4607bdb88a00605b3d66973c', 'e4cc3292e3ebc483998adb2c0e4e640e', 'Administrator Account', 1, '2019-08-26 00:52:01', null); -INSERT INTO spring_boot_plus.sys_user (id, username, nickname, password, salt, remark, state, create_time, update_time) - VALUES (2, 'test', '测试人员', '751ade2f90ceb660cb2460f12cc6fe08268e628e4607bdb88a00605b3d66973c', '99952b31c18156169a26bec80fd211f6', 'Tester Account', 1, '2019-10-05 14:04:27', null); +INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time) + VALUES (1, 'admin', '管理员', '11a254dab80d52bc4a347e030e54d861a9d2cdb2af2185a9ca4a7318e830d04d', '666', '', 1, 'http://localhost:8888//resource/201910281559227.jpg', 'Administrator Account', 1, 1, 1, 0, 1, '2019-08-26 00:52:01', '2019-10-27 23:32:29'); +INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time) + VALUES (2, 'test', '测试人员', '34783fb724b259beb71a1279f7cd93bdcfd92a273d566f926419a37825c500df', '087c2e9857f35f1e243367f3b89b81c1', '', 1, null, 'Tester Account', 1, 1, 2, 0, 0, '2019-10-05 14:04:27', null); ``` diff --git a/README.md b/README.md index f22d43d6..dcf40f42 100644 --- a/README.md +++ b/README.md @@ -104,36 +104,41 @@ mvn clean package -Plocal ### 1. Create Table ```sql - -- ---------------------------- -- Table structure for sys_user -- ---------------------------- -drop table if exists `sys_user`; -create table sys_user +DROP TABLE IF EXISTS `sys_user`; +CREATE TABLE `sys_user` ( - id bigint not null comment '' - primary key, - username varchar(20) not null comment '', - nickname varchar(20) null comment '', - password varchar(64) not null comment '', - salt varchar(32) null comment '', - remark varchar(200) null comment '', - status int default 1 not null comment '', - create_time timestamp default CURRENT_TIMESTAMP null comment '', - update_time timestamp null comment '', - constraint sys_user_username_uindex - unique (username) -) - comment 'SysUser'; + `id` bigint(20) NOT NULL COMMENT 'id', + `username` varchar(20) NOT NULL COMMENT 'username', + `nickname` varchar(20) DEFAULT NULL COMMENT 'nickname', + `password` varchar(64) NOT NULL COMMENT 'password', + `salt` varchar(32) DEFAULT NULL COMMENT 'salt', + `phone` varchar(20) NOT NULL COMMENT 'phone', + `gender` int(11) NOT NULL DEFAULT '1' COMMENT 'gender,0:female,1:male,default:1', + `head` varchar(200) null comment 'head', + `remark` varchar(200) DEFAULT NULL COMMENT 'remark', + `state` int(11) NOT NULL DEFAULT '1' COMMENT 'state,0:disable,1:enable,2:lock', + `department_id` bigint(20) NOT NULL COMMENT 'department id', + `role_id` bigint(20) NOT NULL COMMENT 'role id', + `deleted` int(11) NOT NULL DEFAULT '0' COMMENT 'logic delete,0:not-delete,1:delete', + `version` int(11) NOT NULL DEFAULT '0' COMMENT 'version', + `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time', + `update_time` timestamp NULL DEFAULT NULL COMMENT 'update time', + PRIMARY KEY (`id`), + UNIQUE KEY `sys_user_username_uindex` (`username`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT ='SysUser'; -- ---------------------------- -- Records of sys_user -- ---------------------------- -INSERT INTO spring_boot_plus.sys_user (id, username, nickname, password, salt, remark, state, create_time, update_time) - VALUES (1, 'admin', 'Administrators', '751ade2f90ceb660cb2460f12cc6fe08268e628e4607bdb88a00605b3d66973c', 'e4cc3292e3ebc483998adb2c0e4e640e', 'Administrator Account', 1, '2019-08-26 00:52:01', null); - -INSERT INTO spring_boot_plus.sys_user (id, username, nickname, password, salt, remark, state, create_time, update_time) - VALUES (2, 'test', 'Testers', '751ade2f90ceb660cb2460f12cc6fe08268e628e4607bdb88a00605b3d66973c', '99952b31c18156169a26bec80fd211f6', 'Tester Account', 1, '2019-10-05 14:04:27', null); +INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time) + VALUES (1, 'admin', 'Administrator', '11a254dab80d52bc4a347e030e54d861a9d2cdb2af2185a9ca4a7318e830d04d', '666', '', 1, 'http://localhost:8888//resource/201910281559227.jpg', 'Administrator Account', 1, 1, 1, 0, 1, '2019-08-26 00:52:01', '2019-10-27 23:32:29'); +INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time) + VALUES (2, 'test', 'Tester', '34783fb724b259beb71a1279f7cd93bdcfd92a273d566f926419a37825c500df', '087c2e9857f35f1e243367f3b89b81c1', '', 1, null, 'Tester Account', 1, 1, 2, 0, 0, '2019-10-05 14:04:27', null); ``` From b78aa254c44023390ed39a839e960d61ca48e86f Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Wed, 30 Oct 2019 22:01:41 +0800 Subject: [PATCH 02/10] :oncoming_police_car: SpringBootPlusGenerator --- README-zh.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-zh.md b/README-zh.md index 3886bd66..414f20f9 100644 --- a/README-zh.md +++ b/README-zh.md @@ -146,7 +146,7 @@ INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, hea >修改组件名称/作者/数据库表名称/主键id ```text -/src/test/java/io/geekidea/springbootplus/test/CodeGenerator.java +/src/test/java/io/geekidea/springbootplus/test/SpringBootPlusGenerator.java ``` ```java diff --git a/README.md b/README.md index dcf40f42..64c03f56 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, hea > Modify module name / author / table name / primary key id ```text -/src/test/java/io/geekidea/springbootplus/test/CodeGenerator.java +/src/test/java/io/geekidea/springbootplus/test/SpringBootPlusGenerator.java ``` ```java From b9612ebc6adceb560420d497ab2af783ca532c00 Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Thu, 31 Oct 2019 20:52:12 +0800 Subject: [PATCH 03/10] =?UTF-8?q?:oncoming=5Fpolice=5Fcar:=20fix=20doGetAu?= =?UTF-8?q?thorizationInfo(PrincipalCollection=20principalCollection)?= =?UTF-8?q?=E8=A2=AB=E8=B0=83=E7=94=A8=E4=B8=A4=E6=AC=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootplus/shiro/config/ShiroConfig.java | 15 +-------------- .../springbootplus/shiro/jwt/JwtRealm.java | 1 - 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/main/java/io/geekidea/springbootplus/shiro/config/ShiroConfig.java b/src/main/java/io/geekidea/springbootplus/shiro/config/ShiroConfig.java index ffa7297b..bd373caf 100644 --- a/src/main/java/io/geekidea/springbootplus/shiro/config/ShiroConfig.java +++ b/src/main/java/io/geekidea/springbootplus/shiro/config/ShiroConfig.java @@ -46,7 +46,6 @@ import org.apache.shiro.spring.web.ShiroFilterFactoryBean; import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.apache.shiro.web.mgt.DefaultWebSessionStorageEvaluator; -import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; @@ -253,9 +252,9 @@ private Map addDefaultFilterDefinition(Map filte } else { String[] strings = value.split(","); List list = new ArrayList<>(); - list.addAll(Arrays.asList(strings)); // 添加默认filter过滤 list.add(REQUEST_PATH_FILTER_NAME); + list.addAll(Arrays.asList(strings)); definition = String.join(",", list); } map.put(key, definition); @@ -300,18 +299,6 @@ public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { return new LifecycleBeanPostProcessor(); } - /** - * depends-on lifecycleBeanPostProcessor - * - * @return - */ - @Bean - public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { - DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator(); - defaultAdvisorAutoProxyCreator.setProxyTargetClass(true); - return defaultAdvisorAutoProxyCreator; - } - @Bean public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); diff --git a/src/main/java/io/geekidea/springbootplus/shiro/jwt/JwtRealm.java b/src/main/java/io/geekidea/springbootplus/shiro/jwt/JwtRealm.java index 25c6f710..35d9202d 100644 --- a/src/main/java/io/geekidea/springbootplus/shiro/jwt/JwtRealm.java +++ b/src/main/java/io/geekidea/springbootplus/shiro/jwt/JwtRealm.java @@ -59,7 +59,6 @@ public boolean supports(AuthenticationToken token) { */ @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { - // TODO 被调用两次 log.debug("doGetAuthorizationInfo principalCollection..."); // 设置角色/权限信息 JwtToken jwtToken = (JwtToken) principalCollection.getPrimaryPrincipal(); From a54378c3ec822fe319aedd75ed9c74999400883b Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Thu, 31 Oct 2019 20:57:02 +0800 Subject: [PATCH 04/10] =?UTF-8?q?:oncoming=5Fpolice=5Fcar:=20fix=E6=89=93?= =?UTF-8?q?=E5=8C=85=E4=BE=9D=E8=B5=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/deploy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/deploy.sh b/deploy/deploy.sh index f97ff1db..c6e79506 100644 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -51,8 +51,8 @@ fi pwd # 2. maven打包 -mvn clean -mvn package -Ptest +mvn clean install +mvn clean package -Ptest pwd # 判断是否生成成功 From 246a0d3719d5cb7837ea89e8e4a084a83d92ef86 Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Thu, 31 Oct 2019 22:38:04 +0800 Subject: [PATCH 05/10] =?UTF-8?q?:oncoming=5Fpolice=5Fcar:=20=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8xss=E7=9B=AE=E5=BD=95=E5=88=B0common=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 15 +++++++++++++++ .../{ => common}/xss/XssFilter.java | 2 +- .../xss/XssHttpServletRequestWrapper.java | 2 +- .../{ => common}/xss/XssJacksonDeserializer.java | 2 +- .../{ => common}/xss/XssJacksonSerializer.java | 2 +- .../config/json/jackson/JacksonConfig.java | 4 ++-- 6 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 TODO.md rename src/main/java/io/geekidea/springbootplus/{ => common}/xss/XssFilter.java (97%) rename src/main/java/io/geekidea/springbootplus/{ => common}/xss/XssHttpServletRequestWrapper.java (97%) rename src/main/java/io/geekidea/springbootplus/{ => common}/xss/XssJacksonDeserializer.java (96%) rename src/main/java/io/geekidea/springbootplus/{ => common}/xss/XssJacksonSerializer.java (96%) diff --git a/TODO.md b/TODO.md new file mode 100644 index 00000000..461ed224 --- /dev/null +++ b/TODO.md @@ -0,0 +1,15 @@ +# TODO + +## [V1.5] +- 代码生成起优化,是否生成自定义update方法 +- 黑白名单,配置文件和数据库可配置,并缓存到Redis +- Redis Cache注解使用 +- ok http工具类 +- Excel解析 +- 项目代码遵循阿里代码规范优化 +- 字典表 +- 配置参数表 +- 上传文件附件表 + +## [V1.6] +- Spring security集成 \ No newline at end of file diff --git a/src/main/java/io/geekidea/springbootplus/xss/XssFilter.java b/src/main/java/io/geekidea/springbootplus/common/xss/XssFilter.java similarity index 97% rename from src/main/java/io/geekidea/springbootplus/xss/XssFilter.java rename to src/main/java/io/geekidea/springbootplus/common/xss/XssFilter.java index c219dd42..fe0fc633 100644 --- a/src/main/java/io/geekidea/springbootplus/xss/XssFilter.java +++ b/src/main/java/io/geekidea/springbootplus/common/xss/XssFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.geekidea.springbootplus.xss; +package io.geekidea.springbootplus.common.xss; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/io/geekidea/springbootplus/xss/XssHttpServletRequestWrapper.java b/src/main/java/io/geekidea/springbootplus/common/xss/XssHttpServletRequestWrapper.java similarity index 97% rename from src/main/java/io/geekidea/springbootplus/xss/XssHttpServletRequestWrapper.java rename to src/main/java/io/geekidea/springbootplus/common/xss/XssHttpServletRequestWrapper.java index 8a91ccd0..bf0d11e1 100644 --- a/src/main/java/io/geekidea/springbootplus/xss/XssHttpServletRequestWrapper.java +++ b/src/main/java/io/geekidea/springbootplus/common/xss/XssHttpServletRequestWrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.geekidea.springbootplus.xss; +package io.geekidea.springbootplus.common.xss; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.text.StringEscapeUtils; diff --git a/src/main/java/io/geekidea/springbootplus/xss/XssJacksonDeserializer.java b/src/main/java/io/geekidea/springbootplus/common/xss/XssJacksonDeserializer.java similarity index 96% rename from src/main/java/io/geekidea/springbootplus/xss/XssJacksonDeserializer.java rename to src/main/java/io/geekidea/springbootplus/common/xss/XssJacksonDeserializer.java index d612dbdb..27a76323 100644 --- a/src/main/java/io/geekidea/springbootplus/xss/XssJacksonDeserializer.java +++ b/src/main/java/io/geekidea/springbootplus/common/xss/XssJacksonDeserializer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.geekidea.springbootplus.xss; +package io.geekidea.springbootplus.common.xss; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/src/main/java/io/geekidea/springbootplus/xss/XssJacksonSerializer.java b/src/main/java/io/geekidea/springbootplus/common/xss/XssJacksonSerializer.java similarity index 96% rename from src/main/java/io/geekidea/springbootplus/xss/XssJacksonSerializer.java rename to src/main/java/io/geekidea/springbootplus/common/xss/XssJacksonSerializer.java index 71bdbde8..1bb11381 100644 --- a/src/main/java/io/geekidea/springbootplus/xss/XssJacksonSerializer.java +++ b/src/main/java/io/geekidea/springbootplus/common/xss/XssJacksonSerializer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.geekidea.springbootplus.xss; +package io.geekidea.springbootplus.common.xss; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/src/main/java/io/geekidea/springbootplus/config/json/jackson/JacksonConfig.java b/src/main/java/io/geekidea/springbootplus/config/json/jackson/JacksonConfig.java index 0a9e4908..2f4dbe53 100644 --- a/src/main/java/io/geekidea/springbootplus/config/json/jackson/JacksonConfig.java +++ b/src/main/java/io/geekidea/springbootplus/config/json/jackson/JacksonConfig.java @@ -34,8 +34,8 @@ import io.geekidea.springbootplus.config.json.jackson.serializer.JacksonDateSerializer; import io.geekidea.springbootplus.config.json.jackson.serializer.JacksonIntegerDeserializer; import io.geekidea.springbootplus.constant.DatePattern; -import io.geekidea.springbootplus.xss.XssJacksonDeserializer; -import io.geekidea.springbootplus.xss.XssJacksonSerializer; +import io.geekidea.springbootplus.common.xss.XssJacksonDeserializer; +import io.geekidea.springbootplus.common.xss.XssJacksonSerializer; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; From 4a339ecf3e3c021d3372a17df1f5299898e68524 Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Fri, 1 Nov 2019 13:33:35 +0800 Subject: [PATCH 06/10] =?UTF-8?q?:oncoming=5Fpolice=5Fcar:=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=AA=8C=E8=AF=81=E7=A0=81=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96SpringBootPlusConfig=E7=B1=BB?= =?UTF-8?q?=EF=BC=8CREADME.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md => CHANGELOG_TODO.md | 3 +- README-zh.md | 43 ++++++++++++ README.md | 42 ++++++++++++ .../core/config/SpringBootPlusConfig.java | 48 ------------- .../config/SpringBootPlusWebMvcConfig.java | 63 ++++++++++++++---- .../VerificationCodeController.java | 7 +- src/main/resources/static/favicon.ico | Bin 0 -> 1150 bytes src/main/resources/static/verifyCode.html | 45 ++++++++++++- 8 files changed, 183 insertions(+), 68 deletions(-) rename TODO.md => CHANGELOG_TODO.md (90%) create mode 100644 src/main/resources/static/favicon.ico diff --git a/TODO.md b/CHANGELOG_TODO.md similarity index 90% rename from TODO.md rename to CHANGELOG_TODO.md index 461ed224..1841efb4 100644 --- a/TODO.md +++ b/CHANGELOG_TODO.md @@ -1,4 +1,4 @@ -# TODO +# CHANGELOG TODO ## [V1.5] - 代码生成起优化,是否生成自定义update方法 @@ -10,6 +10,7 @@ - 字典表 - 配置参数表 - 上传文件附件表 +- Redis分布式锁 ## [V1.6] - Spring security集成 \ No newline at end of file diff --git a/README-zh.md b/README-zh.md index 414f20f9..287f7664 100644 --- a/README-zh.md +++ b/README-zh.md @@ -356,6 +356,49 @@ sh deploy.sh tail -f -n 1000 /root/spring-boot-plus-server/logs/spring-boot-plus.log ``` + +## spring-boot-plus Views + +### spring-boot-plus IDEA Sources Views + +![spring-boot-plus-idea](https://spring-boot-plus.gitee.io/img/home/spring-boot-plus-idea.png) + +### [Spring Boot Admin Instances](http://47.105.159.10:8888/instances/e211ba082db8/details) +

+ + spring-boot-admin instances + +

+ +### [Spring Boot Admin Statistics](http://47.105.159.10:8888/instances/e211ba082db8/details) +

+ + spring-boot-admin statistics + +

+ +### [Spring Boot Admin Log](http://47.105.159.10:8888/instances/e211ba082db8/logfile) +

+ + spring-boot-admin log + +

+ +### [spring-boot-plus Swagger文档](http://47.105.159.10:8888/swagger-ui.html) +

+ + spring-boot-plus swagger docs + +

+ +### [spring-boot-plus Java Api Docs](http://geekidea.io/spring-boot-plus-apidocs/) +

+ + spring-boot-plus Java Api Docs + +

+ + ## spring-boot-plus 视频 :movie_camera: - [5分钟完成增删改查](https://www.bilibili.com/video/av67401204) - [CentOS 快速安装 JDK/Git/Maven/Redis/MySQL](https://www.bilibili.com/video/av67218836/) diff --git a/README.md b/README.md index 64c03f56..e3ce2a98 100644 --- a/README.md +++ b/README.md @@ -360,6 +360,48 @@ tail -f -n 1000 /root/spring-boot-plus-server/logs/spring-boot-plus.log ``` +## spring-boot-plus Views + +### spring-boot-plus IDEA Sources Views + +![spring-boot-plus-idea](https://springboot.plus/img/home/spring-boot-plus-idea.png) + +### [Spring Boot Admin Instances](http://47.105.159.10:8888/instances/e211ba082db8/details) +

+ + spring-boot-admin instances + +

+ +### [Spring Boot Admin Statistics](http://47.105.159.10:8888/instances/e211ba082db8/details) +

+ + spring-boot-admin statistics + +

+ +### [Spring Boot Admin Log](http://47.105.159.10:8888/instances/e211ba082db8/logfile) +

+ + spring-boot-admin log + +

+ +### [spring-boot-plus Swagger文档](http://47.105.159.10:8888/swagger-ui.html) +

+ + spring-boot-plus swagger docs + +

+ +### [spring-boot-plus Java Api Docs](http://geekidea.io/spring-boot-plus-apidocs/) +

+ + spring-boot-plus Java Api Docs + +

+ + ## spring-boot-plus Videos :movie_camera: - [5-Minutes-Finish-CRUD](https://www.bilibili.com/video/av67401204) - [CentOS Quick Installation JDK/Git/Maven/Redis/MySQL](https://www.bilibili.com/video/av67218836/) diff --git a/src/main/java/io/geekidea/springbootplus/core/config/SpringBootPlusConfig.java b/src/main/java/io/geekidea/springbootplus/core/config/SpringBootPlusConfig.java index a3b07174..b265725f 100644 --- a/src/main/java/io/geekidea/springbootplus/core/config/SpringBootPlusConfig.java +++ b/src/main/java/io/geekidea/springbootplus/core/config/SpringBootPlusConfig.java @@ -16,13 +16,8 @@ package io.geekidea.springbootplus.core.config; import io.geekidea.springbootplus.core.properties.*; -import io.geekidea.springbootplus.interceptor.PermissionInterceptor; -import io.geekidea.springbootplus.resource.interceptor.DownloadInterceptor; -import io.geekidea.springbootplus.resource.interceptor.ResourceInterceptor; -import io.geekidea.springbootplus.resource.interceptor.UploadInterceptor; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** @@ -43,47 +38,4 @@ }) public class SpringBootPlusConfig { - /** - * 权限拦截器 - * - * @return - */ - @Bean - public PermissionInterceptor permissionInterceptor() { - PermissionInterceptor permissionInterceptor = new PermissionInterceptor(); - return permissionInterceptor; - } - - /** - * 上传拦截器 - * - * @return - */ - @Bean - public UploadInterceptor uploadInterceptor() { - UploadInterceptor uploadInterceptor = new UploadInterceptor(); - return uploadInterceptor; - } - - /** - * 资源拦截器 - * - * @return - */ - @Bean - public ResourceInterceptor resourceInterceptor() { - ResourceInterceptor resourceInterceptor = new ResourceInterceptor(); - return resourceInterceptor; - } - - /** - * 下载拦截器 - * - * @return - */ - @Bean - public DownloadInterceptor downloadInterceptor() { - DownloadInterceptor downloadInterceptor = new DownloadInterceptor(); - return downloadInterceptor; - } } diff --git a/src/main/java/io/geekidea/springbootplus/core/config/SpringBootPlusWebMvcConfig.java b/src/main/java/io/geekidea/springbootplus/core/config/SpringBootPlusWebMvcConfig.java index 1c249b76..f565f61c 100644 --- a/src/main/java/io/geekidea/springbootplus/core/config/SpringBootPlusWebMvcConfig.java +++ b/src/main/java/io/geekidea/springbootplus/core/config/SpringBootPlusWebMvcConfig.java @@ -17,9 +17,9 @@ package io.geekidea.springbootplus.core.config; import com.alibaba.fastjson.JSON; -import io.geekidea.springbootplus.interceptor.PermissionInterceptor; import io.geekidea.springbootplus.core.properties.SpringBootPlusInterceptorProperties; import io.geekidea.springbootplus.core.properties.SpringBootPlusProperties; +import io.geekidea.springbootplus.interceptor.PermissionInterceptor; import io.geekidea.springbootplus.resource.interceptor.DownloadInterceptor; import io.geekidea.springbootplus.resource.interceptor.ResourceInterceptor; import io.geekidea.springbootplus.resource.interceptor.UploadInterceptor; @@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; @@ -44,20 +45,56 @@ @Configuration public class SpringBootPlusWebMvcConfig implements WebMvcConfigurer { + /** + * spring-boot-plus配置属性 + */ @Autowired private SpringBootPlusProperties springBootPlusProperties; - @Autowired - private PermissionInterceptor permissionInterceptor; + /** + * 权限拦截器 + * + * @return + */ + @Bean + public PermissionInterceptor permissionInterceptor() { + PermissionInterceptor permissionInterceptor = new PermissionInterceptor(); + return permissionInterceptor; + } - @Autowired - private ResourceInterceptor resourceInterceptor; + /** + * 上传拦截器 + * + * @return + */ + @Bean + public UploadInterceptor uploadInterceptor() { + UploadInterceptor uploadInterceptor = new UploadInterceptor(); + return uploadInterceptor; + } - @Autowired - private UploadInterceptor uploadInterceptor; + /** + * 资源拦截器 + * + * @return + */ + @Bean + public ResourceInterceptor resourceInterceptor() { + ResourceInterceptor resourceInterceptor = new ResourceInterceptor(); + return resourceInterceptor; + } + + /** + * 下载拦截器 + * + * @return + */ + @Bean + public DownloadInterceptor downloadInterceptor() { + DownloadInterceptor downloadInterceptor = new DownloadInterceptor(); + return downloadInterceptor; + } - @Autowired - private DownloadInterceptor downloadInterceptor; @PostConstruct public void init(){ @@ -71,25 +108,25 @@ public void addInterceptors(InterceptorRegistry registry) { // 上传拦截器 if (interceptorConfig.getUpload().isEnabled()){ - registry.addInterceptor(uploadInterceptor) + registry.addInterceptor(uploadInterceptor()) .addPathPatterns(interceptorConfig.getUpload().getIncludePaths()); } // 资源拦截器注册 if (interceptorConfig.getResource().isEnabled()){ - registry.addInterceptor(resourceInterceptor) + registry.addInterceptor(resourceInterceptor()) .addPathPatterns(interceptorConfig.getResource().getIncludePaths()); } // 下载拦截器注册 if (interceptorConfig.getDownload().isEnabled()){ - registry.addInterceptor(downloadInterceptor) + registry.addInterceptor(downloadInterceptor()) .addPathPatterns(interceptorConfig.getDownload().getIncludePaths()); } if (interceptorConfig.getPermission().isEnabled()){ // 权限拦截器注册 - registry.addInterceptor(permissionInterceptor) + registry.addInterceptor(permissionInterceptor()) .addPathPatterns(interceptorConfig.getPermission().getIncludePaths()) .excludePathPatterns(interceptorConfig.getPermission().getExcludePaths()); } diff --git a/src/main/java/io/geekidea/springbootplus/system/controller/VerificationCodeController.java b/src/main/java/io/geekidea/springbootplus/system/controller/VerificationCodeController.java index 3ed74459..5d233a80 100644 --- a/src/main/java/io/geekidea/springbootplus/system/controller/VerificationCodeController.java +++ b/src/main/java/io/geekidea/springbootplus/system/controller/VerificationCodeController.java @@ -24,7 +24,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.http.MediaType; @@ -60,7 +59,6 @@ public class VerificationCodeController { * 获取验证码 */ @GetMapping("/getImage") - @RequiresPermissions("verification:code") @ApiOperation(value = "获取验证码", notes = "获取验证码", response = ApiResult.class) public void getImage(HttpServletResponse response) throws Exception { VerificationCode verificationCode = new VerificationCode(); @@ -68,7 +66,7 @@ public void getImage(HttpServletResponse response) throws Exception { String code = verificationCode.getText(); String verifyToken = UUIDUtil.getUUID(); // 缓存到Redis - redisTemplate.opsForValue().set(String.format(CommonRedisKey.VERIFY_CODE, verifyToken), code, 10, TimeUnit.MINUTES); + redisTemplate.opsForValue().set(String.format(CommonRedisKey.VERIFY_CODE, verifyToken), code, 5, TimeUnit.MINUTES); response.setHeader(CommonConstant.VERIFY_TOKEN, verifyToken); response.setContentType(MediaType.IMAGE_JPEG_VALUE); response.setHeader("Pragma", "No-cache"); @@ -82,7 +80,6 @@ public void getImage(HttpServletResponse response) throws Exception { * 获取图片Base64验证码 */ @GetMapping("/getBase64Image") - @RequiresPermissions("verification:code") @ResponseBody @ApiOperation(value = "获取图片Base64验证码", notes = "获取图片Base64验证码", response = ApiResult.class) public ApiResult getCode(HttpServletResponse response) throws Exception { @@ -99,7 +96,7 @@ public ApiResult getCode(HttpServletResponse response) throws Exception { map.put(CommonConstant.IMAGE, CommonConstant.BASE64_PREFIX + base64); map.put(CommonConstant.VERIFY_TOKEN, verifyToken); // 缓存到Redis - redisTemplate.opsForValue().set(String.format(CommonRedisKey.VERIFY_CODE, verifyToken), code, 10, TimeUnit.MINUTES); + redisTemplate.opsForValue().set(String.format(CommonRedisKey.VERIFY_CODE, verifyToken), code, 5, TimeUnit.MINUTES); return ApiResult.ok(map); } diff --git a/src/main/resources/static/favicon.ico b/src/main/resources/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..bd5a6781eb17ad74e461e28e1a21d1a8a58c6eff GIT binary patch literal 1150 zcmaiz&nrYx6vvO6#;A!|$ihOFv&0`Db#Jni`~|YGoMvHRiIlRS)Vpi^0g{z05ZPEr zR1 zGu?>nOYH1dcQG#wXQsOqiX&TqUxWAkmo%KMQKQgV15V{HURy3Ql~z8vA~p5gNpEKO z;w;DLD*cu@+lkMq&Sot78u%+dkNpuxW(H24*cA38b`E=<9&x}qv!Z5N1sm%pv(H*z;TIEbl-X}_I*5^6f9QBze+pDt^JK9BH{Wb9%Luv8l%Mq0D=zTE_oK%i`8>6B=ShEfm&}=id)Vxqe!q-g z1RL%Tm{a^ZqThTGdBZ;QTztib`=d3eUGaIZ!QCMb-VeIt{$~6FJ!%1y?YxW6`?0^? zPcnzIGvHh2=zNQsYkR-%10qkoshqEgTtAC!jf)i6tV-W@Dw{hZSNkH0@p$F_0Fod@ AMF0Q* literal 0 HcmV?d00001 diff --git a/src/main/resources/static/verifyCode.html b/src/main/resources/static/verifyCode.html index 792e58f6..916e504d 100644 --- a/src/main/resources/static/verifyCode.html +++ b/src/main/resources/static/verifyCode.html @@ -21,6 +21,49 @@ 验证码 - + +
+

方式一:获取图片

+ +

verifyToken:查看Responses Headers

+
+ +
+ +
+

方式二:获取base64图片编码

+ +

+
+ + + \ No newline at end of file From 23b5d466fa29682351069346877f13ef37c107a1 Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Fri, 1 Nov 2019 20:25:54 +0800 Subject: [PATCH 07/10] =?UTF-8?q?:oncoming=5Fpolice=5Fcar:=20foobar?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG_TODO.md | 14 ++- README-zh.md | 74 +++++++-------- README.md | 81 ++++++++--------- docs/db/mysql_spring_boot_plus.sql | 29 ++++++ .../foobar/controller/FooBarController.java | 90 +++++++++++++++++++ .../springbootplus/foobar/entity/FooBar.java | 62 +++++++++++++ .../foobar/mapper/FooBarMapper.java | 42 +++++++++ .../foobar/param/FooBarQueryParam.java | 24 +++++ .../foobar/service/FooBarService.java | 66 ++++++++++++++ .../service/impl/FooBarServiceImpl.java | 67 ++++++++++++++ .../foobar/vo/FooBarQueryVo.java | 52 +++++++++++ src/main/resources/config/application.yml | 2 +- .../resources/mapper/foobar/FooBarMapper.xml | 22 +++++ src/main/resources/mapper/package.json | 4 - .../test/SpringBootPlusGenerator.java | 8 +- 15 files changed, 536 insertions(+), 101 deletions(-) create mode 100644 src/main/java/io/geekidea/springbootplus/foobar/controller/FooBarController.java create mode 100644 src/main/java/io/geekidea/springbootplus/foobar/entity/FooBar.java create mode 100644 src/main/java/io/geekidea/springbootplus/foobar/mapper/FooBarMapper.java create mode 100644 src/main/java/io/geekidea/springbootplus/foobar/param/FooBarQueryParam.java create mode 100644 src/main/java/io/geekidea/springbootplus/foobar/service/FooBarService.java create mode 100644 src/main/java/io/geekidea/springbootplus/foobar/service/impl/FooBarServiceImpl.java create mode 100644 src/main/java/io/geekidea/springbootplus/foobar/vo/FooBarQueryVo.java create mode 100644 src/main/resources/mapper/foobar/FooBarMapper.xml delete mode 100644 src/main/resources/mapper/package.json diff --git a/CHANGELOG_TODO.md b/CHANGELOG_TODO.md index 1841efb4..5cb005a9 100644 --- a/CHANGELOG_TODO.md +++ b/CHANGELOG_TODO.md @@ -1,16 +1,24 @@ # CHANGELOG TODO +## [V1.4] +- 部门树形列表 + ## [V1.5] -- 代码生成起优化,是否生成自定义update方法 +- 代码生成起优化,是否生成自定义update方法,生成version,deleted注解 - 黑白名单,配置文件和数据库可配置,并缓存到Redis - Redis Cache注解使用 - ok http工具类 -- Excel解析 +- Excel解析,导入导出 - 项目代码遵循阿里代码规范优化 - 字典表 - 配置参数表 - 上传文件附件表 - Redis分布式锁 +- 接口限流,ip限流,频率限流 +- Shiro Redis缓存 +- ApplicationRunner + ## [V1.6] -- Spring security集成 \ No newline at end of file +- Spring security集成 +- HikariCP \ No newline at end of file diff --git a/README-zh.md b/README-zh.md index 287f7664..de16dca9 100644 --- a/README-zh.md +++ b/README-zh.md @@ -103,43 +103,36 @@ mvn clean package -Plocal ### 1. 创建数据库表 ```sql -- ---------------------------- --- Table structure for sys_user +-- Table structure for foo_bar -- ---------------------------- -DROP TABLE IF EXISTS `sys_user`; -CREATE TABLE `sys_user` +DROP TABLE IF EXISTS `foo_bar`; +CREATE TABLE `foo_bar` ( `id` bigint(20) NOT NULL COMMENT '主键', - `username` varchar(20) NOT NULL COMMENT '用户名', - `nickname` varchar(20) DEFAULT NULL COMMENT '昵称', - `password` varchar(64) NOT NULL COMMENT '密码', - `salt` varchar(32) DEFAULT NULL COMMENT '盐值', - `phone` varchar(20) NOT NULL COMMENT '手机号码', - `gender` int(11) NOT NULL DEFAULT '1' COMMENT '性别,0:女,1:男,默认1', - `head` varchar(200) null comment '头像', - `remark` varchar(200) DEFAULT NULL COMMENT 'remark', - `state` int(11) NOT NULL DEFAULT '1' COMMENT '状态,0:禁用,1:启用,2:锁定', - `department_id` bigint(20) NOT NULL COMMENT '部门id', - `role_id` bigint(20) NOT NULL COMMENT '角色id', - `deleted` int(11) NOT NULL DEFAULT '0' COMMENT '逻辑删除,0:未删除,1:已删除', + `name` varchar(20) NOT NULL COMMENT '名称', + `foo` varchar(20) DEFAULT NULL COMMENT 'Foo', + `bar` varchar(20) NOT NULL COMMENT 'Bar', + `remark` varchar(200) DEFAULT NULL COMMENT '备注', + `state` int(11) NOT NULL DEFAULT '1' COMMENT '状态,0:禁用,1:启用', `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本', `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` timestamp NULL DEFAULT NULL COMMENT '修改时间', - PRIMARY KEY (`id`), - UNIQUE KEY `sys_user_username_uindex` (`username`) + PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci COMMENT ='系统用户'; + COLLATE = utf8mb4_general_ci COMMENT ='FooBar'; -- ---------------------------- --- Records of sys_user +-- Records of foo_bar -- ---------------------------- -INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time) - VALUES (1, 'admin', '管理员', '11a254dab80d52bc4a347e030e54d861a9d2cdb2af2185a9ca4a7318e830d04d', '666', '', 1, 'http://localhost:8888//resource/201910281559227.jpg', 'Administrator Account', 1, 1, 1, 0, 1, '2019-08-26 00:52:01', '2019-10-27 23:32:29'); -INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time) - VALUES (2, 'test', '测试人员', '34783fb724b259beb71a1279f7cd93bdcfd92a273d566f926419a37825c500df', '087c2e9857f35f1e243367f3b89b81c1', '', 1, null, 'Tester Account', 1, 1, 2, 0, 0, '2019-10-05 14:04:27', null); +INSERT INTO foo_bar (id, name, foo, bar, remark, state, version, create_time, update_time) + VALUES (1, 'FooBar', 'foo', 'bar', 'remark...', 1, 0, '2019-11-01 14:05:14', null); +INSERT INTO foo_bar (id, name, foo, bar, remark, state, version, create_time, update_time) + VALUES (2, 'HelloWorld', 'hello', 'world', null, 1, 0, '2019-11-01 14:05:14', null); ``` + ### 2.使用代码生成器生成增删改查代码 > 修改数据库信息 @@ -175,7 +168,7 @@ public class SpringBootPlusGenerator { // 组件作者等配置 codeGenerator - .setModuleName("system") + .setModuleName("foobar") .setAuthor("geekidea") .setPkIdColumnName("id"); @@ -201,7 +194,7 @@ public class SpringBootPlusGenerator { .setGeneratorMapperXml(true); // 是否生成Shiro RequiresPermissions注解 - codeGenerator.setRequiresPermissions(true); + codeGenerator.setRequiresPermissions(false); // 是否覆盖已有文件 codeGenerator.setFileOverride(true); @@ -212,9 +205,7 @@ public class SpringBootPlusGenerator { // 需要生成的表数组 // xxx,yyy,zzz为需要生成代码的表名称 String[] tables = { - "xxx", - "yyy", - "zzz", + "foo_bar" }; // 循环生成 @@ -233,31 +224,30 @@ public class SpringBootPlusGenerator { > 生成的代码结构 ```text -/src/main/java/io/geekidea/springbootplus/system +/src/main/java/io/geekidea/springbootplus/foobar ``` ```text -└── system +└── foobar + ├── controller + │   └── FooBarController.java ├── entity - │   └── SysUser.java + │   └── FooBar.java ├── mapper - │   └── SysUserMapper.java + │   └── FooBarMapper.java + ├── param + │   └── FooBarQueryParam.java ├── service - │   ├── SysUserService.java + │   ├── FooBarService.java │   └── impl - │   └── SysUserServiceImpl.java - └── web - ├── controller - │   └── SysUserController.java - ├── param - │   └── SysUserQueryParam.java - └── vo - └── SysUserQueryVo.java + │   └── FooBarServiceImpl.java + └── vo + └── FooBarQueryVo.java ``` > Mapper XML ```text -/src/main/resources/mapper/system/SysUserMapper.xml +/src/main/resources/mapper/foobar/FooBarMapper.xml ``` ### 3. 启动项目 diff --git a/README.md b/README.md index e3ce2a98..da21d5de 100644 --- a/README.md +++ b/README.md @@ -105,40 +105,32 @@ mvn clean package -Plocal ### 1. Create Table ```sql -- ---------------------------- --- Table structure for sys_user +-- Table structure for foo_bar -- ---------------------------- -DROP TABLE IF EXISTS `sys_user`; -CREATE TABLE `sys_user` +DROP TABLE IF EXISTS `foo_bar`; +CREATE TABLE `foo_bar` ( - `id` bigint(20) NOT NULL COMMENT 'id', - `username` varchar(20) NOT NULL COMMENT 'username', - `nickname` varchar(20) DEFAULT NULL COMMENT 'nickname', - `password` varchar(64) NOT NULL COMMENT 'password', - `salt` varchar(32) DEFAULT NULL COMMENT 'salt', - `phone` varchar(20) NOT NULL COMMENT 'phone', - `gender` int(11) NOT NULL DEFAULT '1' COMMENT 'gender,0:female,1:male,default:1', - `head` varchar(200) null comment 'head', - `remark` varchar(200) DEFAULT NULL COMMENT 'remark', - `state` int(11) NOT NULL DEFAULT '1' COMMENT 'state,0:disable,1:enable,2:lock', - `department_id` bigint(20) NOT NULL COMMENT 'department id', - `role_id` bigint(20) NOT NULL COMMENT 'role id', - `deleted` int(11) NOT NULL DEFAULT '0' COMMENT 'logic delete,0:not-delete,1:delete', - `version` int(11) NOT NULL DEFAULT '0' COMMENT 'version', - `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time', - `update_time` timestamp NULL DEFAULT NULL COMMENT 'update time', - PRIMARY KEY (`id`), - UNIQUE KEY `sys_user_username_uindex` (`username`) + `id` bigint(20) NOT NULL COMMENT 'ID', + `name` varchar(20) NOT NULL COMMENT 'Name', + `foo` varchar(20) DEFAULT NULL COMMENT 'Foo', + `bar` varchar(20) NOT NULL COMMENT 'Bar', + `remark` varchar(200) DEFAULT NULL COMMENT 'Remark', + `state` int(11) NOT NULL DEFAULT '1' COMMENT 'State,0:Disable,1:Enable', + `version` int(11) NOT NULL DEFAULT '0' COMMENT 'Version', + `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Create Time', + `update_time` timestamp NULL DEFAULT NULL COMMENT 'Update Time', + PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci COMMENT ='SysUser'; + COLLATE = utf8mb4_general_ci COMMENT ='FooBar'; -- ---------------------------- --- Records of sys_user +-- Records of foo_bar -- ---------------------------- -INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time) - VALUES (1, 'admin', 'Administrator', '11a254dab80d52bc4a347e030e54d861a9d2cdb2af2185a9ca4a7318e830d04d', '666', '', 1, 'http://localhost:8888//resource/201910281559227.jpg', 'Administrator Account', 1, 1, 1, 0, 1, '2019-08-26 00:52:01', '2019-10-27 23:32:29'); -INSERT INTO sys_user (id, username, nickname, password, salt, phone, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time) - VALUES (2, 'test', 'Tester', '34783fb724b259beb71a1279f7cd93bdcfd92a273d566f926419a37825c500df', '087c2e9857f35f1e243367f3b89b81c1', '', 1, null, 'Tester Account', 1, 1, 2, 0, 0, '2019-10-05 14:04:27', null); +INSERT INTO foo_bar (id, name, foo, bar, remark, state, version, create_time, update_time) + VALUES (1, 'FooBar', 'foo', 'bar', 'remark...', 1, 0, '2019-11-01 14:05:14', null); +INSERT INTO foo_bar (id, name, foo, bar, remark, state, version, create_time, update_time) + VALUES (2, 'HelloWorld', 'hello', 'world', null, 1, 0, '2019-11-01 14:05:14', null); ``` @@ -177,7 +169,7 @@ public class SpringBootPlusGenerator { // Configuration of component author, etc. codeGenerator - .setModuleName("system") + .setModuleName("foobar") .setAuthor("geekidea") .setPkIdColumnName("id"); @@ -202,7 +194,7 @@ public class SpringBootPlusGenerator { .setGeneratorMapperXml(true); // Generated RequiresPermissions Annotation - codeGenerator.setRequiresPermissions(true); + codeGenerator.setRequiresPermissions(false); // Overwrite existing file or not codeGenerator.setFileOverride(true); @@ -212,9 +204,7 @@ public class SpringBootPlusGenerator { // Table array to be generated String[] tables = { - "xxx", - "yyy", - "zzz", + "foo_bar" }; // Cycle generation @@ -233,31 +223,30 @@ public class SpringBootPlusGenerator { > Generated code structure ```text -/src/main/java/io/geekidea/springbootplus/system +/src/main/java/io/geekidea/springbootplus/foobar ``` ```text -└── system +└── foobar + ├── controller + │   └── FooBarController.java ├── entity - │   └── SysUser.java + │   └── FooBar.java ├── mapper - │   └── SysUserMapper.java + │   └── FooBarMapper.java + ├── param + │   └── FooBarQueryParam.java ├── service - │   ├── SysUserService.java + │   ├── FooBarService.java │   └── impl - │   └── SysUserServiceImpl.java - └── web - ├── controller - │   └── SysUserController.java - ├── param - │   └── SysUserQueryParam.java - └── vo - └── SysUserQueryVo.java + │   └── FooBarServiceImpl.java + └── vo + └── FooBarQueryVo.java ``` > Mapper XML ```text -/src/main/resources/mapper/system/SysUserMapper.xml +/src/main/resources/mapper/foobar/FooBarMapper.xml ``` ### 3. Startup Project diff --git a/docs/db/mysql_spring_boot_plus.sql b/docs/db/mysql_spring_boot_plus.sql index 9a04d537..4d0995b4 100644 --- a/docs/db/mysql_spring_boot_plus.sql +++ b/docs/db/mysql_spring_boot_plus.sql @@ -65,6 +65,35 @@ INSERT INTO `sys_log` VALUES (1060438799600861185, 0, 'C', 100000, '2018-11-08 1 INSERT INTO `sys_log` VALUES (1060438809495224322, 0, 'D', 100000, '2018-11-08 15:42:13'); +-- ---------------------------- +-- Table structure for foo_bar +-- ---------------------------- +DROP TABLE IF EXISTS `foo_bar`; +CREATE TABLE `foo_bar` +( + `id` bigint(20) NOT NULL COMMENT '主键', + `name` varchar(20) NOT NULL COMMENT '名称', + `foo` varchar(20) DEFAULT NULL COMMENT 'Foo', + `bar` varchar(20) NOT NULL COMMENT 'Bar', + `remark` varchar(200) DEFAULT NULL COMMENT '备注', + `state` int(11) NOT NULL DEFAULT '1' COMMENT '状态,0:禁用,1:启用', + `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本', + `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` timestamp NULL DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT ='FooBar'; + +-- ---------------------------- +-- Records of foo_bar +-- ---------------------------- +INSERT INTO foo_bar (id, name, foo, bar, remark, state, version, create_time, update_time) +VALUES (1, 'FooBar', 'foo', 'bar', 'remark...', 1, 0, '2019-11-01 14:05:14', null); +INSERT INTO foo_bar (id, name, foo, bar, remark, state, version, create_time, update_time) +VALUES (2, 'HelloWorld', 'hello', 'world', null, 1, 0, '2019-11-01 14:05:14', null); + + -- ---------------------------- -- Table structure for sys_department -- ---------------------------- diff --git a/src/main/java/io/geekidea/springbootplus/foobar/controller/FooBarController.java b/src/main/java/io/geekidea/springbootplus/foobar/controller/FooBarController.java new file mode 100644 index 00000000..110f1886 --- /dev/null +++ b/src/main/java/io/geekidea/springbootplus/foobar/controller/FooBarController.java @@ -0,0 +1,90 @@ +package io.geekidea.springbootplus.foobar.controller; + +import io.geekidea.springbootplus.foobar.entity.FooBar; +import io.geekidea.springbootplus.foobar.service.FooBarService; +import io.geekidea.springbootplus.foobar.param.FooBarQueryParam; +import io.geekidea.springbootplus.foobar.vo.FooBarQueryVo; +import io.geekidea.springbootplus.common.api.ApiResult; +import io.geekidea.springbootplus.common.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +import javax.validation.Valid; + +import io.geekidea.springbootplus.common.vo.Paging; +import io.geekidea.springbootplus.common.param.IdParam; + +/** + *
+ * FooBar 前端控制器
+ * 
+ * + * @author geekidea + * @since 2019-11-01 + */ +@Slf4j +@RestController +@RequestMapping("/fooBar") +@Api("FooBar API") +public class FooBarController extends BaseController { + + @Autowired + private FooBarService fooBarService; + + /** + * 添加FooBar + */ + @PostMapping("/add") + @ApiOperation(value = "添加FooBar对象", notes = "添加FooBar", response = ApiResult.class) + public ApiResult addFooBar(@Valid @RequestBody FooBar fooBar) throws Exception { + boolean flag = fooBarService.saveFooBar(fooBar); + return ApiResult.result(flag); + } + + /** + * 修改FooBar + */ + @PostMapping("/update") + @ApiOperation(value = "修改FooBar对象", notes = "修改FooBar", response = ApiResult.class) + public ApiResult updateFooBar(@Valid @RequestBody FooBar fooBar) throws Exception { + boolean flag = fooBarService.updateFooBar(fooBar); + return ApiResult.result(flag); + } + + /** + * 删除FooBar + */ + @PostMapping("/delete/{id}") + @ApiOperation(value = "删除FooBar对象", notes = "删除FooBar", response = ApiResult.class) + public ApiResult deleteFooBar(@PathVariable("id") Long id) throws Exception { + boolean flag = fooBarService.deleteFooBar(id); + return ApiResult.result(flag); + } + + /** + * 获取FooBar + */ + @GetMapping("/info/{id}") + @ApiOperation(value = "获取FooBar对象详情", notes = "查看FooBar", response = FooBarQueryVo.class) + public ApiResult getFooBar(@PathVariable("id") Long id) throws Exception { + FooBarQueryVo fooBarQueryVo = fooBarService.getFooBarById(id); + return ApiResult.ok(fooBarQueryVo); + } + + /** + * FooBar分页列表 + */ + @PostMapping("/getPageList") + @ApiOperation(value = "获取FooBar分页列表", notes = "FooBar分页列表", response = FooBarQueryVo.class) + public ApiResult> getFooBarPageList(@Valid @RequestBody FooBarQueryParam fooBarQueryParam) throws Exception { + Paging paging = fooBarService.getFooBarPageList(fooBarQueryParam); + return ApiResult.ok(paging); + } + +} + diff --git a/src/main/java/io/geekidea/springbootplus/foobar/entity/FooBar.java b/src/main/java/io/geekidea/springbootplus/foobar/entity/FooBar.java new file mode 100644 index 00000000..268fe32e --- /dev/null +++ b/src/main/java/io/geekidea/springbootplus/foobar/entity/FooBar.java @@ -0,0 +1,62 @@ +package io.geekidea.springbootplus.foobar.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableId; +import io.geekidea.springbootplus.common.entity.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *
+ * FooBar
+ * 
+ * + * @author geekidea + * @since 2019-11-01 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "FooBar对象", description = "FooBar") +public class FooBar extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "ID") + @TableId(value = "id", type = IdType.ID_WORKER) + private Long id; + + @ApiModelProperty(value = "Name") + @NotBlank(message = "Name不能为空") + private String name; + + @ApiModelProperty(value = "Foo") + private String foo; + + @ApiModelProperty(value = "Bar") + @NotBlank(message = "Bar不能为空") + private String bar; + + @ApiModelProperty(value = "Remark") + private String remark; + + @ApiModelProperty(value = "State,0:Disable,1:Enable") + private Integer state; + + @ApiModelProperty(value = "Version") + private Integer version; + + @ApiModelProperty(value = "Create Time") + private Date createTime; + + @ApiModelProperty(value = "Update Time") + private Date updateTime; + +} diff --git a/src/main/java/io/geekidea/springbootplus/foobar/mapper/FooBarMapper.java b/src/main/java/io/geekidea/springbootplus/foobar/mapper/FooBarMapper.java new file mode 100644 index 00000000..b9fccc82 --- /dev/null +++ b/src/main/java/io/geekidea/springbootplus/foobar/mapper/FooBarMapper.java @@ -0,0 +1,42 @@ +package io.geekidea.springbootplus.foobar.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import io.geekidea.springbootplus.foobar.entity.FooBar; +import io.geekidea.springbootplus.foobar.param.FooBarQueryParam; +import io.geekidea.springbootplus.foobar.vo.FooBarQueryVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.io.Serializable; + +/** + *
+ * FooBar Mapper 接口
+ * 
+ * + * @author geekidea + * @since 2019-11-01 + */ +@Repository +public interface FooBarMapper extends BaseMapper { + + /** + * 根据ID获取查询对象 + * + * @param id + * @return + */ + FooBarQueryVo getFooBarById(Serializable id); + + /** + * 获取分页对象 + * + * @param page + * @param fooBarQueryParam + * @return + */ + IPage getFooBarPageList(@Param("page") Page page, @Param("param") FooBarQueryParam fooBarQueryParam); + +} diff --git a/src/main/java/io/geekidea/springbootplus/foobar/param/FooBarQueryParam.java b/src/main/java/io/geekidea/springbootplus/foobar/param/FooBarQueryParam.java new file mode 100644 index 00000000..bc23f13e --- /dev/null +++ b/src/main/java/io/geekidea/springbootplus/foobar/param/FooBarQueryParam.java @@ -0,0 +1,24 @@ +package io.geekidea.springbootplus.foobar.param; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import io.geekidea.springbootplus.common.param.OrderQueryParam; + +/** + *
+ * FooBar 查询参数对象
+ * 
+ * + * @author geekidea + * @date 2019-11-01 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "FooBarQueryParam对象", description = "FooBar查询参数") +public class FooBarQueryParam extends OrderQueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/io/geekidea/springbootplus/foobar/service/FooBarService.java b/src/main/java/io/geekidea/springbootplus/foobar/service/FooBarService.java new file mode 100644 index 00000000..90149571 --- /dev/null +++ b/src/main/java/io/geekidea/springbootplus/foobar/service/FooBarService.java @@ -0,0 +1,66 @@ +package io.geekidea.springbootplus.foobar.service; + +import io.geekidea.springbootplus.foobar.entity.FooBar; +import io.geekidea.springbootplus.common.service.BaseService; +import io.geekidea.springbootplus.foobar.param.FooBarQueryParam; +import io.geekidea.springbootplus.foobar.vo.FooBarQueryVo; +import io.geekidea.springbootplus.common.vo.Paging; + +import java.io.Serializable; + +/** + *
+ * FooBar 服务类
+ * 
+ * + * @author geekidea + * @since 2019-11-01 + */ +public interface FooBarService extends BaseService { + + /** + * 保存 + * + * @param fooBar + * @return + * @throws Exception + */ + boolean saveFooBar(FooBar fooBar) throws Exception; + + /** + * 修改 + * + * @param fooBar + * @return + * @throws Exception + */ + boolean updateFooBar(FooBar fooBar) throws Exception; + + /** + * 删除 + * + * @param id + * @return + * @throws Exception + */ + boolean deleteFooBar(Long id) throws Exception; + + /** + * 根据ID获取查询对象 + * + * @param id + * @return + * @throws Exception + */ + FooBarQueryVo getFooBarById(Serializable id) throws Exception; + + /** + * 获取分页对象 + * + * @param fooBarQueryParam + * @return + * @throws Exception + */ + Paging getFooBarPageList(FooBarQueryParam fooBarQueryParam) throws Exception; + +} diff --git a/src/main/java/io/geekidea/springbootplus/foobar/service/impl/FooBarServiceImpl.java b/src/main/java/io/geekidea/springbootplus/foobar/service/impl/FooBarServiceImpl.java new file mode 100644 index 00000000..345e02a0 --- /dev/null +++ b/src/main/java/io/geekidea/springbootplus/foobar/service/impl/FooBarServiceImpl.java @@ -0,0 +1,67 @@ +package io.geekidea.springbootplus.foobar.service.impl; + +import io.geekidea.springbootplus.foobar.entity.FooBar; +import io.geekidea.springbootplus.foobar.mapper.FooBarMapper; +import io.geekidea.springbootplus.foobar.service.FooBarService; +import io.geekidea.springbootplus.foobar.param.FooBarQueryParam; +import io.geekidea.springbootplus.foobar.vo.FooBarQueryVo; +import io.geekidea.springbootplus.common.service.impl.BaseServiceImpl; +import io.geekidea.springbootplus.common.vo.Paging; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import java.io.Serializable; + + +/** + *
+ * FooBar 服务实现类
+ * 
+ * + * @author geekidea + * @since 2019-11-01 + */ +@Slf4j +@Service +public class FooBarServiceImpl extends BaseServiceImpl implements FooBarService { + + @Autowired + private FooBarMapper fooBarMapper; + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean saveFooBar(FooBar fooBar) throws Exception { + return super.save(fooBar); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateFooBar(FooBar fooBar) throws Exception { + return super.updateById(fooBar); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean deleteFooBar(Long id) throws Exception { + return super.removeById(id); + } + + @Override + public FooBarQueryVo getFooBarById(Serializable id) throws Exception { + return fooBarMapper.getFooBarById(id); + } + + @Override + public Paging getFooBarPageList(FooBarQueryParam fooBarQueryParam) throws Exception { + Page page = setPageParam(fooBarQueryParam, OrderItem.desc("create_time")); + IPage iPage = fooBarMapper.getFooBarPageList(page, fooBarQueryParam); + return new Paging(iPage); + } + +} diff --git a/src/main/java/io/geekidea/springbootplus/foobar/vo/FooBarQueryVo.java b/src/main/java/io/geekidea/springbootplus/foobar/vo/FooBarQueryVo.java new file mode 100644 index 00000000..1581d9a2 --- /dev/null +++ b/src/main/java/io/geekidea/springbootplus/foobar/vo/FooBarQueryVo.java @@ -0,0 +1,52 @@ +package io.geekidea.springbootplus.foobar.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; +import java.io.Serializable; + +import java.util.Date; + +/** + *
+ * FooBar 查询结果对象
+ * 
+ * + * @author geekidea + * @date 2019-11-01 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "FooBarQueryVo对象", description = "FooBar查询参数") +public class FooBarQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "ID") + private Long id; + + @ApiModelProperty(value = "Name") + private String name; + + @ApiModelProperty(value = "Foo") + private String foo; + + @ApiModelProperty(value = "Bar") + private String bar; + + @ApiModelProperty(value = "Remark") + private String remark; + + @ApiModelProperty(value = "State,0:Disable,1:Enable") + private Integer state; + + @ApiModelProperty(value = "Version") + private Integer version; + + @ApiModelProperty(value = "Create Time") + private Date createTime; + + @ApiModelProperty(value = "Update Time") + private Date updateTime; + +} \ No newline at end of file diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index 34b4a877..ffb8d222 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -145,10 +145,10 @@ spring-boot-plus: /templates/**=anon /druid/**=anon /hello/world=anon - /ip/**=anon /sysLog/**=anon /verificationCode/**=anon /resource/**=anon + /fooBar/**=anon # 权限配置 permission: # 排除登陆登出相关 diff --git a/src/main/resources/mapper/foobar/FooBarMapper.xml b/src/main/resources/mapper/foobar/FooBarMapper.xml new file mode 100644 index 00000000..e2aae616 --- /dev/null +++ b/src/main/resources/mapper/foobar/FooBarMapper.xml @@ -0,0 +1,22 @@ + + + + + + + id, name, foo, bar, remark, state, version, create_time, update_time + + + + + + + diff --git a/src/main/resources/mapper/package.json b/src/main/resources/mapper/package.json deleted file mode 100644 index 234b94ae..00000000 --- a/src/main/resources/mapper/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "mapper", - "description": "Mybatis Mapper XML" -} diff --git a/src/test/java/io/geekidea/springbootplus/test/SpringBootPlusGenerator.java b/src/test/java/io/geekidea/springbootplus/test/SpringBootPlusGenerator.java index f28db02c..70049e23 100644 --- a/src/test/java/io/geekidea/springbootplus/test/SpringBootPlusGenerator.java +++ b/src/test/java/io/geekidea/springbootplus/test/SpringBootPlusGenerator.java @@ -41,7 +41,7 @@ public static void main(String[] args) { // 组件作者等配置 codeGenerator - .setModuleName("system") + .setModuleName("foobar") .setAuthor("geekidea") .setPkIdColumnName("id"); @@ -67,7 +67,7 @@ public static void main(String[] args) { .setGeneratorMapperXml(true); // 是否生成Shiro RequiresPermissions注解 - codeGenerator.setRequiresPermissions(true); + codeGenerator.setRequiresPermissions(false); // 是否覆盖已有文件 codeGenerator.setFileOverride(true); @@ -78,9 +78,7 @@ public static void main(String[] args) { // 需要生成的表数组 // xxx,yyy,zzz为需要生成代码的表名称 String[] tables = { - "xxx", - "yyy", - "zzz" + "foo_bar" }; // 循环生成 From 79ff209e46c610bd8f81210c1b433c578f8c0e12 Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Fri, 1 Nov 2019 22:17:49 +0800 Subject: [PATCH 08/10] =?UTF-8?q?:oncoming=5Fpolice=5Fcar:=20=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=89=80=E6=9C=89=E9=83=A8=E9=97=A8=E7=9A=84=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=92=8C=E6=A0=91=E5=BD=A2=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/db/mysql_spring_boot_plus.sql | 13 +++- .../controller/SysDepartmentController.java | 25 ++++++- .../controller/SysPermissionController.java | 8 +-- .../system/convert/SysDepartmentConvert.java | 53 ++++++++++++++ .../system/service/SysDepartmentService.java | 18 ++++- .../impl/SysDepartmentServiceImpl.java | 48 +++++++++++++ .../impl/SysPermissionServiceImpl.java | 3 + .../system/vo/SysDepartmentTreeVo.java | 71 +++++++++++++++++++ 8 files changed, 230 insertions(+), 9 deletions(-) create mode 100644 src/main/java/io/geekidea/springbootplus/system/convert/SysDepartmentConvert.java create mode 100644 src/main/java/io/geekidea/springbootplus/system/vo/SysDepartmentTreeVo.java diff --git a/docs/db/mysql_spring_boot_plus.sql b/docs/db/mysql_spring_boot_plus.sql index 4d0995b4..6f5d5b08 100644 --- a/docs/db/mysql_spring_boot_plus.sql +++ b/docs/db/mysql_spring_boot_plus.sql @@ -118,8 +118,17 @@ CREATE TABLE `sys_department` -- ---------------------------- -- Records of sys_department -- ---------------------------- -INSERT INTO sys_department (id, name, parent_id, state, sort, remark, version, create_time, update_time) VALUES (1, '管理部', null, 1, 0, null, 0, '2019-10-25 09:46:49', null); -INSERT INTO sys_department (id, name, parent_id, state, sort, remark, version, create_time, update_time) VALUES (2, '测试部', null, 1, 0, null, 0, '2019-10-25 09:47:06', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (1, '管理部', null, 1, 1, 0, null, 0, '2019-10-25 09:46:49', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (2, '技术部', null, 1, 1, 0, null, 0, '2019-11-01 20:45:43', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (20, '前端开发部', 2, 2, 1, 0, null, 0, '2019-11-01 20:48:38', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (21, '后台开发部', 2, 2, 1, 0, null, 0, '2019-11-01 20:48:38', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (22, '测试部', 2, 2, 1, 0, null, 0, '2019-11-01 20:48:38', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (201, '前端一组', 20, 3, 1, 0, null, 0, '2019-11-01 20:48:38', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (202, '前端二组', 20, 3, 1, 0, null, 0, '2019-11-01 20:48:38', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (203, '后台一组', 21, 3, 1, 0, null, 0, '2019-11-01 20:48:38', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (204, '后台二组', 21, 3, 1, 0, null, 0, '2019-11-01 20:48:38', null); +INSERT INTO sys_department (id, name, parent_id, level, state, sort, remark, version, create_time, update_time) VALUES (205, '测试一组', 22, 3, 1, 0, null, 0, '2019-11-01 20:48:38', null); + -- ---------------------------- -- Table structure for sys_user diff --git a/src/main/java/io/geekidea/springbootplus/system/controller/SysDepartmentController.java b/src/main/java/io/geekidea/springbootplus/system/controller/SysDepartmentController.java index 600deea7..a8f4c2e3 100644 --- a/src/main/java/io/geekidea/springbootplus/system/controller/SysDepartmentController.java +++ b/src/main/java/io/geekidea/springbootplus/system/controller/SysDepartmentController.java @@ -23,15 +23,16 @@ import io.geekidea.springbootplus.system.param.SysDepartmentQueryParam; import io.geekidea.springbootplus.system.service.SysDepartmentService; import io.geekidea.springbootplus.system.vo.SysDepartmentQueryVo; +import io.geekidea.springbootplus.system.vo.SysDepartmentTreeVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.util.List; /** *
@@ -105,5 +106,27 @@ public ApiResult> getSysDepartmentPageList(@Valid @
         return ApiResult.ok(paging);
     }
 
+    /**
+     * 获取所有部门列表
+     */
+    @PostMapping("/getAllDepartmentList")
+//    @RequiresPermissions("sys:department:all:list")
+    @ApiOperation(value = "获取所有部门的树形列表", notes = "获取所有部门的树形列表", response = SysDepartment.class)
+    public ApiResult> getAllDepartmentList() throws Exception {
+        List list = sysDepartmentService.getAllDepartmentList();
+        return ApiResult.ok(list);
+    }
+
+    /**
+     * 获取所有部门的树形列表
+     */
+    @PostMapping("/getAllDepartmentTree")
+//    @RequiresPermissions("sys:department:all:tree")
+    @ApiOperation(value = "获取所有部门的树形列表", notes = "获取所有部门的树形列表", response = SysDepartmentTreeVo.class)
+    public ApiResult> getAllDepartmentTree() throws Exception {
+        List treeVos = sysDepartmentService.getAllDepartmentTree();
+        return ApiResult.ok(treeVos);
+    }
+
 }
 
diff --git a/src/main/java/io/geekidea/springbootplus/system/controller/SysPermissionController.java b/src/main/java/io/geekidea/springbootplus/system/controller/SysPermissionController.java
index 4dc584af..3a9ce856 100644
--- a/src/main/java/io/geekidea/springbootplus/system/controller/SysPermissionController.java
+++ b/src/main/java/io/geekidea/springbootplus/system/controller/SysPermissionController.java
@@ -124,8 +124,8 @@ public ApiResult getAllMenuList() throws Exception {
     @RequiresPermissions("sys:permission:all:menu:tree")
     @ApiOperation(value = "获取所有菜单列表", notes = "获取所有菜单列表", response = SysPermissionTreeVo.class)
     public ApiResult getAllMenuTree() throws Exception {
-        List list = sysPermissionService.getAllMenuTree();
-        return ApiResult.ok(list);
+        List treeVos = sysPermissionService.getAllMenuTree();
+        return ApiResult.ok(treeVos);
     }
 
 
@@ -147,8 +147,8 @@ public ApiResult getMenuListByUserId(@PathVariable("userId") Long
     @RequiresPermissions("sys:permission:menu:tree")
     @ApiOperation(value = "根据用户id获取菜单树形列表", notes = "根据用户id获取菜单树形列表", response = SysPermissionTreeVo.class)
     public ApiResult getMenuTreeByUserId(@PathVariable("userId") Long userId) throws Exception {
-        List list = sysPermissionService.getMenuTreeByUserId(userId);
-        return ApiResult.ok(list);
+        List treeVos = sysPermissionService.getMenuTreeByUserId(userId);
+        return ApiResult.ok(treeVos);
     }
 
     /**
diff --git a/src/main/java/io/geekidea/springbootplus/system/convert/SysDepartmentConvert.java b/src/main/java/io/geekidea/springbootplus/system/convert/SysDepartmentConvert.java
new file mode 100644
index 00000000..78e46e9d
--- /dev/null
+++ b/src/main/java/io/geekidea/springbootplus/system/convert/SysDepartmentConvert.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.geekidea.springbootplus.system.convert;
+
+import io.geekidea.springbootplus.system.entity.SysDepartment;
+import io.geekidea.springbootplus.system.vo.SysDepartmentTreeVo;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+
+/**
+ * 部门对象转换器
+ *
+ * @author geekidea
+ * @date 2019-11-01
+ **/
+@Mapper
+public interface SysDepartmentConvert {
+
+    SysDepartmentConvert INSTANCE = Mappers.getMapper(SysDepartmentConvert.class);
+
+    /**
+     * SysDepartment转换成SysDepartmentTreeVo对象
+     *
+     * @param sysDepartment
+     * @return
+     */
+    SysDepartmentTreeVo entityToTreeVo(SysDepartment sysDepartment);
+
+    /**
+     * SysDepartment列表转换成SysDepartmentTreeVo列表
+     *
+     * @param list
+     * @return
+     */
+    List listToTreeVoList(List list);
+
+}
diff --git a/src/main/java/io/geekidea/springbootplus/system/service/SysDepartmentService.java b/src/main/java/io/geekidea/springbootplus/system/service/SysDepartmentService.java
index c3d8e63a..656a2b7c 100644
--- a/src/main/java/io/geekidea/springbootplus/system/service/SysDepartmentService.java
+++ b/src/main/java/io/geekidea/springbootplus/system/service/SysDepartmentService.java
@@ -16,13 +16,15 @@
 
 package io.geekidea.springbootplus.system.service;
 
-import io.geekidea.springbootplus.system.entity.SysDepartment;
 import io.geekidea.springbootplus.common.service.BaseService;
+import io.geekidea.springbootplus.common.vo.Paging;
+import io.geekidea.springbootplus.system.entity.SysDepartment;
 import io.geekidea.springbootplus.system.param.SysDepartmentQueryParam;
 import io.geekidea.springbootplus.system.vo.SysDepartmentQueryVo;
-import io.geekidea.springbootplus.common.vo.Paging;
+import io.geekidea.springbootplus.system.vo.SysDepartmentTreeVo;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * 
@@ -88,4 +90,16 @@ public interface SysDepartmentService extends BaseService {
      */
     boolean isEnableSysDepartment(Long id) throws Exception;
 
+    /**
+     * 获取所有可用的部门列表
+     * @return
+     */
+    List getAllDepartmentList();
+
+    /**
+     * 获取所有可用的部门树形列表
+     * @return
+     */
+    List getAllDepartmentTree();
+
 }
diff --git a/src/main/java/io/geekidea/springbootplus/system/service/impl/SysDepartmentServiceImpl.java b/src/main/java/io/geekidea/springbootplus/system/service/impl/SysDepartmentServiceImpl.java
index f794ce04..7f886ad2 100644
--- a/src/main/java/io/geekidea/springbootplus/system/service/impl/SysDepartmentServiceImpl.java
+++ b/src/main/java/io/geekidea/springbootplus/system/service/impl/SysDepartmentServiceImpl.java
@@ -23,17 +23,22 @@
 import io.geekidea.springbootplus.common.service.impl.BaseServiceImpl;
 import io.geekidea.springbootplus.common.vo.Paging;
 import io.geekidea.springbootplus.enums.StateEnum;
+import io.geekidea.springbootplus.system.convert.SysDepartmentConvert;
 import io.geekidea.springbootplus.system.entity.SysDepartment;
 import io.geekidea.springbootplus.system.mapper.SysDepartmentMapper;
 import io.geekidea.springbootplus.system.param.SysDepartmentQueryParam;
 import io.geekidea.springbootplus.system.service.SysDepartmentService;
 import io.geekidea.springbootplus.system.vo.SysDepartmentQueryVo;
+import io.geekidea.springbootplus.system.vo.SysDepartmentTreeVo;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
@@ -91,4 +96,47 @@ public boolean isEnableSysDepartment(Long id) throws Exception {
         return count > 0;
     }
 
+    @Override
+    public List getAllDepartmentList() {
+        SysDepartment sysDepartment = new SysDepartment().setState(StateEnum.ENABLE.ordinal());
+        // 获取所有已启用的部门列表
+        return sysDepartmentMapper.selectList(new QueryWrapper(sysDepartment));
+    }
+
+    @Override
+    public List getAllDepartmentTree() {
+        List sysDepartmentList = getAllDepartmentList();
+        if (CollectionUtils.isEmpty(sysDepartmentList)) {
+            throw new IllegalArgumentException("SysDepartment列表不能为空");
+        }
+        List list = SysDepartmentConvert.INSTANCE.listToTreeVoList(sysDepartmentList);
+        List treeVos = new ArrayList<>();
+        for (SysDepartmentTreeVo treeVo : list) {
+            if (treeVo.getParentId() == null) {
+                treeVos.add(findChildren(treeVo, list));
+            }
+        }
+        return treeVos;
+    }
+
+    /**
+     * 递归获取树形结果列表
+     *
+     * @param tree
+     * @param list
+     * @return
+     */
+    public SysDepartmentTreeVo findChildren(SysDepartmentTreeVo tree, List list) {
+        for (SysDepartmentTreeVo vo : list) {
+            if (tree.getId().equals(vo.getParentId())) {
+                if (tree.getChildren() == null) {
+                    tree.setChildren(new ArrayList<>());
+                }
+                tree.getChildren().add(findChildren(vo, list));
+            }
+        }
+        return tree;
+    }
+
+
 }
diff --git a/src/main/java/io/geekidea/springbootplus/system/service/impl/SysPermissionServiceImpl.java b/src/main/java/io/geekidea/springbootplus/system/service/impl/SysPermissionServiceImpl.java
index 409d6466..a9467d99 100644
--- a/src/main/java/io/geekidea/springbootplus/system/service/impl/SysPermissionServiceImpl.java
+++ b/src/main/java/io/geekidea/springbootplus/system/service/impl/SysPermissionServiceImpl.java
@@ -142,6 +142,9 @@ public List getAllMenuTree() throws Exception {
 
     @Override
     public List convertSysPermissionTreeVoList(List list) {
+        if (CollectionUtils.isEmpty(list)) {
+            throw new IllegalArgumentException("SysPermission列表不能为空");
+        }
         // 按level分组获取map
         Map> map = list.stream().collect(Collectors.groupingBy(SysPermission::getLevel));
         List treeVos = new ArrayList<>();
diff --git a/src/main/java/io/geekidea/springbootplus/system/vo/SysDepartmentTreeVo.java b/src/main/java/io/geekidea/springbootplus/system/vo/SysDepartmentTreeVo.java
new file mode 100644
index 00000000..b6d9b4c0
--- /dev/null
+++ b/src/main/java/io/geekidea/springbootplus/system/vo/SysDepartmentTreeVo.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.geekidea.springbootplus.system.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 
+ * 部门TreeVo
+ * 
+ * + * @author geekidea + * @since 2019-11-1 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "SysDepartmentTreeVo对象", description = "部门") +public class SysDepartmentTreeVo implements Serializable { + private static final long serialVersionUID = -2250233632748939400L; + + @ApiModelProperty(value = "主键") + private Long id; + + @ApiModelProperty(value = "部门名称") + private String name; + + @ApiModelProperty(value = "父id") + private Long parentId; + + @ApiModelProperty(value = "状态,0:禁用,1:启用") + private Integer state; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty(value = "版本") + private Integer version; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "修改时间") + private Date updateTime; + + private List children; + +} From 9f5d62854dda2921e0dd72013eb1aa27c34e251c Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Sat, 2 Nov 2019 00:22:00 +0800 Subject: [PATCH 09/10] =?UTF-8?q?:oncoming=5Fpolice=5Fcar:=20Jackson?= =?UTF-8?q?=E6=8C=89=E7=85=A7=E5=AD=97=E6=AE=B5=E9=A1=BA=E5=BA=8F=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/db/mysql_spring_boot_plus.sql | 1 - .../core/aop/AbstractLogAop.java | 10 +-- .../geekidea/springbootplus/util/Jackson.java | 62 +++++++++++++++++++ 3 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 src/main/java/io/geekidea/springbootplus/util/Jackson.java diff --git a/docs/db/mysql_spring_boot_plus.sql b/docs/db/mysql_spring_boot_plus.sql index 6f5d5b08..bbdffb42 100644 --- a/docs/db/mysql_spring_boot_plus.sql +++ b/docs/db/mysql_spring_boot_plus.sql @@ -309,7 +309,6 @@ INSERT INTO sys_role_permission (id, role_id, permission_id, state, remark, vers INSERT INTO sys_role_permission (id, role_id, permission_id, state, remark, version, create_time, update_time) VALUES (29, 1, 4002, 1, null, 0, '2019-10-26 22:16:19', null); INSERT INTO sys_role_permission (id, role_id, permission_id, state, remark, version, create_time, update_time) VALUES (30, 1, 4003, 1, null, 0, '2019-10-26 22:16:19', null); INSERT INTO sys_role_permission (id, role_id, permission_id, state, remark, version, create_time, update_time) VALUES (31, 1, 4004, 1, null, 0, '2019-10-26 22:16:19', null); -INSERT INTO sys_role_permission (id, role_id, permission_id, state, remark, version, create_time, update_time) VALUES (32, 1, 4005, 1, null, 0, '2019-10-26 22:16:19', null); INSERT INTO sys_role_permission (id, role_id, permission_id, state, remark, version, create_time, update_time) VALUES (100, 1, 1, 1, null, 0, '2019-10-26 22:16:19', null); INSERT INTO sys_role_permission (id, role_id, permission_id, state, remark, version, create_time, update_time) VALUES (101, 1, 100, 1, null, 0, '2019-10-26 22:16:19', null); INSERT INTO sys_role_permission (id, role_id, permission_id, state, remark, version, create_time, update_time) VALUES (102, 1, 1000, 1, null, 0, '2019-10-26 22:16:19', null); diff --git a/src/main/java/io/geekidea/springbootplus/core/aop/AbstractLogAop.java b/src/main/java/io/geekidea/springbootplus/core/aop/AbstractLogAop.java index a52a1584..52e31608 100644 --- a/src/main/java/io/geekidea/springbootplus/core/aop/AbstractLogAop.java +++ b/src/main/java/io/geekidea/springbootplus/core/aop/AbstractLogAop.java @@ -16,7 +16,6 @@ package io.geekidea.springbootplus.core.aop; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import io.geekidea.springbootplus.common.api.ApiCode; import io.geekidea.springbootplus.common.api.ApiResult; @@ -25,6 +24,7 @@ import io.geekidea.springbootplus.util.AnsiUtil; import io.geekidea.springbootplus.util.DateUtil; import io.geekidea.springbootplus.util.IpUtil; +import io.geekidea.springbootplus.util.Jackson; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; @@ -294,9 +294,9 @@ protected String formatRequestInfo(Map map) { String requestInfo = null; try { if (logAopConfig.isRequestLogFormat()) { - requestInfo = "\n" + JSON.toJSONString(map, true); + requestInfo = "\n" + Jackson.toJsonString(map, true); } else { - requestInfo = JSON.toJSONString(map); + requestInfo = Jackson.toJsonString(map); } } catch (Exception e) { e.printStackTrace(); @@ -323,9 +323,9 @@ protected String formatResponseInfo(ApiResult apiResult) { String responseResultInfo = "responseResult:"; try { if (logAopConfig.isResponseLogFormat()) { - responseResultInfo += "\n" + JSON.toJSONString(apiResult, true); + responseResultInfo += "\n" + Jackson.toJsonString(apiResult, true); } else { - responseResultInfo += JSON.toJSONString(apiResult); + responseResultInfo += Jackson.toJsonString(apiResult); } int code = apiResult.getCode(); if (code == ApiCode.SUCCESS.getCode()) { diff --git a/src/main/java/io/geekidea/springbootplus/util/Jackson.java b/src/main/java/io/geekidea/springbootplus/util/Jackson.java new file mode 100644 index 00000000..9ddc63fe --- /dev/null +++ b/src/main/java/io/geekidea/springbootplus/util/Jackson.java @@ -0,0 +1,62 @@ +/* + * Copyright 2019-2029 geekidea(https://github.com/geekidea) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.geekidea.springbootplus.util; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +/** + * Jackson序列化工具类 + * + * @author geekidea + * @date 2019-11-01 + **/ +public class Jackson { + + /** + * 键按自然顺序输出 + * + * @param object + * @return + */ + public static String toJsonString(Object object) { + return toJsonString(object, false); + } + + /** + * 键按自然顺序格式化输出 + * + * @param object + * @param prettyFormat + * @return + */ + public static String toJsonString(Object object, boolean prettyFormat) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + //格式化输出 + objectMapper.configure(SerializationFeature.INDENT_OUTPUT, prettyFormat); + //键按自然顺序输出 + objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); + return objectMapper.writeValueAsString(object); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return null; + } + +} From b1030237751945082e50bb1d391f5a53da61b7df Mon Sep 17 00:00:00 2001 From: springboot-plus Date: Sat, 2 Nov 2019 10:48:13 +0800 Subject: [PATCH 10/10] =?UTF-8?q?:oncoming=5Fpolice=5Fcar:=20sys=5Fdepartm?= =?UTF-8?q?ent=E6=B7=BB=E5=8A=A0level=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README-zh.md | 2 +- README.md | 2 +- docs/db/mysql_spring_boot_plus.sql | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README-zh.md b/README-zh.md index de16dca9..d94b79dd 100644 --- a/README-zh.md +++ b/README-zh.md @@ -1,6 +1,6 @@

- spring-boot-plus logo + spring-boot-plus logo

diff --git a/README.md b/README.md index da21d5de..f1bee8f7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- spring-boot-plus logo + spring-boot-plus logo

diff --git a/docs/db/mysql_spring_boot_plus.sql b/docs/db/mysql_spring_boot_plus.sql index bbdffb42..e56817dd 100644 --- a/docs/db/mysql_spring_boot_plus.sql +++ b/docs/db/mysql_spring_boot_plus.sql @@ -103,6 +103,7 @@ CREATE TABLE `sys_department` `id` bigint(20) NOT NULL COMMENT '主键', `name` varchar(32) NOT NULL COMMENT '部门名称', `parent_id` bigint(20) DEFAULT NULL COMMENT '父id', + `level` int NULL COMMENT '部门层级', `state` int(11) NOT NULL DEFAULT '1' COMMENT '状态,0:禁用,1:启用', `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序', `remark` varchar(200) DEFAULT NULL COMMENT '备注',