Compare commits

...

85 Commits

Author SHA1 Message Date
曾文豪
c9679eeeac publish 2.0.0.rc2 2024-06-28 10:57:08 +08:00
曾文豪
08a3c52f34 publish 2.0.0.rc1 2024-06-26 10:22:33 +08:00
曾文豪
5a25006189 fix:修复授权过期的bug 2024-06-26 10:19:30 +08:00
曾文豪
093d39a108 feat:web模块包名调整 2024-06-26 10:13:42 +08:00
曾文豪
c0ded4356f feat:移除功能点 2024-06-26 10:11:19 +08:00
曾文豪
8f7d543c8b feat:移除job类的接口、方法 2024-06-26 10:08:29 +08:00
曾文豪
67bb6041c6 feat:sql导入 2024-06-26 10:00:47 +08:00
曾文豪
78cb8dafeb perf:调整获取自己的功能点 2024-06-26 09:03:36 +08:00
曾文豪
d77eb50a5b feat:提交角色授权 2024-06-25 23:23:50 +08:00
曾文豪
aee4fa86f6 feat;增加角色模块 2024-06-25 18:51:29 +08:00
曾文豪
a10b57f6fc feat;增加角色模块 2024-06-25 18:46:13 +08:00
曾文豪
d2229e0028 feat;增加角色模块 2024-06-25 18:32:08 +08:00
曾文豪
80cd48b97c feat;增加角色模块 2024-06-24 19:15:47 +08:00
曾文豪
0e6bee4714 publish 1.1.5 2024-06-19 13:54:11 +08:00
曾文豪
ae67cc53ec Merge branch 'new_characterUtils' into 'master'
优化移除特殊字符方法

See merge request tiesheng/tiesheng!5
2024-06-19 05:53:24 +00:00
‘毛文春’
419cb06ff6 feat:新增字符串处理工具类 2024-06-19 13:53:01 +08:00
曾文豪
384ac928e3 publish 1.1.4 2024-06-19 13:46:50 +08:00
曾文豪
130cd45de2 Merge branch 'new_CharacterUtil' into 'master'
新增字符串处理工具类

See merge request tiesheng/tiesheng!4
2024-06-19 05:45:11 +00:00
‘毛文春’
6840faa9d8 feat:新增字符串处理工具类 2024-06-19 13:44:53 +08:00
曾文豪
b6caecf140 publish 1.1.3 2024-06-11 16:11:14 +08:00
曾文豪
fdcb1614cc test:测试一下接口 2024-04-22 14:22:43 +08:00
曾文豪
88bc553213 publish 1.1.2 2024-04-17 13:56:38 +08:00
曾文豪
5942c4cea4 publish 1.1.1 2024-04-17 13:46:51 +08:00
曾文豪
ef34146563 publish 1.1.0 2024-04-16 20:00:41 +08:00
曾文豪
1c8bc648ea Revert "publish 1.0.24-test2"
This reverts commit b4334f4a5b.
2024-04-15 13:57:07 +08:00
曾文豪
144ca50fea Revert "publish 1.0.24-test3"
This reverts commit 1d2cabb048.
2024-04-15 13:56:55 +08:00
曾文豪
1d2cabb048 publish 1.0.24-test3 2024-04-15 13:36:50 +08:00
曾文豪
b4334f4a5b publish 1.0.24-test2 2024-04-15 13:09:00 +08:00
曾文豪
ce44e4a05a Revert "publish 1.0.24-test"
This reverts commit a7024f7a8d.
2024-04-15 12:34:59 +08:00
曾文豪
a7024f7a8d publish 1.0.24-test 2024-04-15 12:31:15 +08:00
曾文豪
c2fe494ed9 publish 1.0.24 2024-04-13 10:51:03 +08:00
曾文豪
07de3f6ba7 feat:获取系统配置增加一个方法 2024-04-13 10:50:37 +08:00
曾文豪
1c521e5378 fix:修复token是否有效的判定条件 2024-04-13 10:45:57 +08:00
曾文豪
e98e98d659 publish 1.0.23 2024-02-28 09:36:58 +08:00
曾文豪
75d052bd0c perf:钉钉工作通知的内容完全自定义 2024-02-28 09:36:21 +08:00
曾文豪
3758826987 perf:更新一个文案 2024-02-23 16:17:17 +08:00
曾文豪
8a4cf8e439 publish 1.0.22 2024-01-31 17:34:25 +08:00
曾文豪
09203ac78d publish 1.0.21 2024-01-31 17:06:54 +08:00
曾文豪
ef5861327c publish 1.0.20 2024-01-24 13:42:17 +08:00
曾文豪
23faaa8f67 publish 1.0.19 2024-01-11 11:29:45 +08:00
曾文豪
341c82e0bc perf:创建时间可以自行设置 2024-01-11 11:29:03 +08:00
曾文豪
d2d53523a8 publish 1.0.18 2024-01-09 17:51:27 +08:00
曾文豪
fc00bad49a publish 1.0.17 2023-12-27 15:46:16 +08:00
曾文豪
6dd4e19e39 publish 1.0.16 2023-12-06 16:43:31 +08:00
曾文豪
4373ec7c0e publish 1.0.15 2023-11-20 16:23:18 +08:00
曾文豪
5cc135d8e2 fix:兼容windows服务器的路径问题 2023-11-20 16:22:49 +08:00
曾文豪
69a9681b48 publish 1.0.14 2023-08-22 09:29:12 +08:00
曾文豪
6c39dc24bd chore:更新ci 2023-08-22 09:28:06 +08:00
曾文豪
952341918a publish 1.0.13 2023-08-21 15:29:18 +08:00
曾文豪
5dde3e3e9f publish 1.1.0 2023-08-21 15:21:54 +08:00
曾文豪
c5c7afd7f6 feat:globalConfig增加ext属性 2023-08-21 15:11:47 +08:00
曾文豪
ceb13dc78d perf:删除其他代码 2023-08-14 15:48:55 +08:00
曾文豪
0fabc7aae9 perf:优化部分代码 2023-08-14 15:43:48 +08:00
曾文豪
28a2fa0262 perf:增加网络请求超时、重定向的配置 2023-08-10 18:10:49 +08:00
曾文豪
cc3ab52885 perf:过程中保存错误日志,而不是在最后保存,方式错误日志丢失 2023-08-10 18:07:27 +08:00
曾文豪
027587ae02 perf:更新数据库对比插件 2023-08-10 17:55:09 +08:00
曾文豪
353851a0aa perf:/operation/page接口需要鉴权 2023-07-19 10:39:45 +08:00
曾文豪
1db6d88e4e feat(web):增加DaoBase的常量 2023-07-11 10:05:53 +08:00
曾文豪
7e69138ef7 feat(web):增加DaoBase的常量 2023-07-11 10:05:27 +08:00
曾文豪
ea211b1bfc chore:更新日志 2023-07-11 09:03:16 +08:00
曾文豪
101270e881 perf(web):操作日志优化
1,不再返回params字段
2,params字段有text改为longtext
2023-07-11 08:58:48 +08:00
曾文豪
a658298363 perf:优化slat长度的校验 2023-07-10 09:44:07 +08:00
曾文豪
65beecc330 docs: 文档调整 2023-07-05 14:14:33 +08:00
曾文豪
ea24bf3479 perf(encrypt):加解密调整 2023-07-05 14:11:01 +08:00
曾文豪
90e504e7fd fix:验签接口调整 2023-07-05 13:58:01 +08:00
曾文豪
5db42f5bc8 publish 1.0.12 2023-07-05 13:55:14 +08:00
曾文豪
37d84e2f36 docs: 文档调整 2023-06-30 10:24:13 +08:00
曾文豪
f59d56be9e docs: 文档调整 2023-06-28 13:04:11 +08:00
曾文豪
7f4871fe19 publish 1.0.10 2023-06-28 13:03:03 +08:00
曾文豪
34e3cb2f09 docs: 文档调整 2023-06-14 09:44:11 +08:00
曾文豪
7c1abb9b97 docs: 文档调整 2023-06-14 09:39:38 +08:00
曾文豪
a649bdae7c publish 1.0.9 2023-06-14 09:32:50 +08:00
曾文豪
7b6eccb0d5 feat: 登录接口增加timestamp、sign字段,用于验证本次是否通过 2023-06-14 09:27:01 +08:00
曾文豪
c700ddc90a publish 1.0.8 2023-06-13 09:42:50 +08:00
曾文豪
4254bf47bf fix: 修复微信、钉钉跳转bug 2023-06-13 09:42:15 +08:00
曾文豪
e0b1720c4a chore: 升级插件依赖0.0.6 2023-06-07 17:19:40 +08:00
曾文豪
9cd7b069a8 docs: 更新文档 2023-06-06 14:27:36 +08:00
曾文豪
0ca3d13659 perf(database): 优化DbDataInitializer接口 2023-06-06 14:25:38 +08:00
曾文豪
0ac237fbbd publish 1.0.7 2023-06-06 14:22:44 +08:00
曾文豪
d9da55d4bf feat(database): 增加db/data目录,存放初始化数据的sql 2023-06-06 14:14:22 +08:00
曾文豪
802152badd publish 1.0.7 2023-06-06 11:30:44 +08:00
曾文豪
7b4169f3e6 feat(web): 增加uploadFileCustomize方法,允许自定义文件存放情况
可根据情况存放如OSS之类的
2023-06-06 11:29:19 +08:00
曾文豪
c3b3831378 feat(login): 增加默认值,防止token解析异常 2023-06-06 10:50:27 +08:00
曾文豪
73e6470b39 publish 1.0.6 2023-05-26 15:18:38 +08:00
曾文豪
458d118d85 publish 1.0.6 2023-05-26 13:23:17 +08:00
156 changed files with 3146 additions and 1491 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,23 +1,10 @@
stages: stages:
- deploy - deploy
- package
build-jar:
stage: deploy
tags:
- hzkepai
rules:
- if: $CI_COMMIT_BRANCH == "master"
script:
- mvn clean package -Dmaven.test.skip=true
- systemctl stop tieshengboot-ademo
- cp springboot-ademo/target/*.jar /usr/local/nginx/html/demo.tmp.kepai365.ltd/
- systemctl start tieshengboot-ademo
deploy-jar: deploy-jar:
stage: deploy stage: deploy
tags: tags:
- hzkepai - zengos
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
script: script:

View File

@@ -1,36 +1,48 @@
## 1.0.5 ## 1.1.0
### 新增 - featglobalConfig增加ext属性。
- feat增加网络请求超时、重定向的配置。
- perf更新数据库对比插件。
- feat(web)增加DaoBase的常量。
- perf(web):操作日志优化。
> 1新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
## 1.0.12
- perf(encrypt):开启关闭加解密移动到**yaml**中配置,移除**EnableEncryptConfig**注解。
- feat(login):登录接口增加验签步骤,可通过**validLoginSign**属性开启或关闭(默认)。
- perf(login):可重写**onSignError**方法自定义验签错误的跳转。
- fix(login)修复微信、钉钉授权跳转地址错误的bug
## 1.0.7
- feat(web): 增加uploadFileCustomize方法允许自定义文件存放情况
- feat(database): 增加db/data目录存放初始化数据的sql
- perf(login): 增加默认值防止token解析异常
## 1.0.6
- feat(web):新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
- feat(web)**OperationLog** 增加 desensitize 属性,用来脱敏指定的字段。
## 1.0.2 ## 1.0.2
### 调整 - feat(database):增加数据库定时备份;
- feat(database)增加过期备份的删除操作默认过期时间为7天
> 1增加数据库定时备份 - perf(message):调整阿里云短信类,方便扩展其他方法。
> 2增加过期备份的删除操作默认过期时间为7天 - perf(message)消息发送接口该body类型为 **JSONObject**
> 3调整阿里云短信类方便扩展其他方法。 - perf(message):调整消息发送接口和方法(不兼容旧版本)
> 4消息发送接口该body类型为 **JSONObject**
> 5调整消息发送接口和方法不兼容旧版本
## 1.0.1 ## 1.0.1
### 调整 - perf(web)fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
## 1.0.0 ## 1.0.0
### 升级 - perfhutool依赖升级5.8.11 -> 5.8.16
- perffastjson依赖升级1.2.78 -> 1.2.83
> 1hutool依赖升级:5.8.11 -> 5.8.16 - perfmybatis-plus依赖升级:3.5.1 -> 3.5.3
> 2fastjson依赖升级1.2.78 -> 1.2.83 - perf**TieshengWebConfigurer** 增加 **configSystemCheck** 方法,可根据情况校验系统配置参数。
> 3mybatis-plus依赖升级3.5.1 -> 3.5.3
### 调整
> 1**TieshengWebConfigurer** 增加 **configSystemCheck** 方法,可根据情况校验系统配置参数。
从该版本开始,仓库地址改为: 从该版本开始,仓库地址改为:

29
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>springboot-parent</name> <name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description> <description>杭州铁晟科技有限公司基础依赖</description>
@@ -28,6 +28,7 @@
<module>springboot-message</module> <module>springboot-message</module>
<module>springboot-encrypt</module> <module>springboot-encrypt</module>
<module>springboot-annotation</module> <module>springboot-annotation</module>
<module>springboot-role</module>
</modules> </modules>
<properties> <properties>
@@ -57,55 +58,61 @@
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId>
<version>2.0.0.rc2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -136,7 +143,7 @@
<plugin> <plugin>
<groupId>com.tiesheng.springboot-plugin</groupId> <groupId>com.tiesheng.springboot-plugin</groupId>
<artifactId>tiesheng-maven-plugin</artifactId> <artifactId>tiesheng-maven-plugin</artifactId>
<version>0.0.5</version> <version>1.0.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

View File

@@ -6,11 +6,11 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>
<version>1.0.0</version> <version>2.0.0.rc2</version>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
@@ -26,6 +26,11 @@
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>

View File

@@ -1,9 +1,8 @@
package com.tiesheng.demo; package com.tiesheng.demo;
import com.tiesheng.core.EnableTieshengWeb; import com.tiesheng.web.EnableTieshengWeb;
import com.tiesheng.demo.config.DemoWebConfigurer; import com.tiesheng.demo.config.DemoWebConfigurer;
import com.tiesheng.encrypt.EnableEncryptConfig;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -14,7 +13,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement @EnableTransactionManagement
@SpringBootApplication @SpringBootApplication
@EnableTieshengWeb(webConfigurer = DemoWebConfigurer.class) @EnableTieshengWeb(webConfigurer = DemoWebConfigurer.class)
//@EnableEncryptConfig
public class DemoApplication { public class DemoApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -1,10 +1,10 @@
package com.tiesheng.demo.config; package com.tiesheng.demo.config;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.tiesheng.core.pojos.RequestUserInfo; import com.tiesheng.web.pojos.RequestUserInfo;
import com.tiesheng.core.pojos.dao.CorePlatformUnique; import com.tiesheng.web.pojos.dao.CorePlatformUnique;
import com.tiesheng.core.service.TieshengWebConfigurer; import com.tiesheng.web.service.TieshengWebConfigurer;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.util.config.GlobalConfig; import com.tiesheng.util.config.GlobalConfig;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -31,9 +31,6 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
TokenBean tokenBean = null; TokenBean tokenBean = null;
if (!StrUtil.isEmpty(platformUnique.getUserId())) { if (!StrUtil.isEmpty(platformUnique.getUserId())) {
tokenBean = new TokenBean(platformUnique.getUserId(), "", globalConfig.getService()); tokenBean = new TokenBean(platformUnique.getUserId(), "", globalConfig.getService());
} else {
// 获取用户信息判断是否可登录
} }
return tokenBean; return tokenBean;

View File

@@ -1,8 +1,7 @@
package com.tiesheng.demo.config; package com.tiesheng.demo.config;
import com.tiesheng.core.service.CoreConfigService; import com.tiesheng.web.service.CoreConfigService;
import com.tiesheng.core.service.CoreJobService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -14,19 +13,11 @@ import javax.annotation.PostConstruct;
@Component @Component
public class TestJobConfig { public class TestJobConfig {
@Autowired
CoreJobService coreJobService;
@Autowired @Autowired
CoreConfigService coreConfigService; CoreConfigService coreConfigService;
@PostConstruct @PostConstruct
public void init() { public void init() {
coreConfigService.refreshFunc("230328001", "demo", "辅导员统计", "辅导员责任班级,学生展示");
// 辅导员职位
coreJobService.refresh("class_fdy", "辅导员", "辅导员", 1);
} }
} }

View File

@@ -9,13 +9,13 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.listener.ReadListener;
import com.tiesheng.annotation.token.TokenIgnore; import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.core.service.CoreLogService; import com.tiesheng.web.service.CoreLogService;
import com.tiesheng.core.service.CoreMessageService; import com.tiesheng.web.service.CoreMessageService;
import com.tiesheng.core.util.ProcessImportConsumer; import com.tiesheng.web.util.ProcessImportConsumer;
import com.tiesheng.database.config.DbBackupConfig; import com.tiesheng.database.config.DbBackupConfig;
import com.tiesheng.demo.pojos.PoiBean; import com.tiesheng.demo.pojos.PoiBean;
import com.tiesheng.demo.pojos.TestFile; import com.tiesheng.demo.pojos.TestFile;
import com.tiesheng.login.config.token.TsTokenConfig; import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.message.pojos.MessageReqResp; import com.tiesheng.message.pojos.MessageReqResp;
import com.tiesheng.message.pojos.UserChannel; import com.tiesheng.message.pojos.UserChannel;
import com.tiesheng.util.config.EncryptConfig; import com.tiesheng.util.config.EncryptConfig;
@@ -24,8 +24,7 @@ import com.tiesheng.util.config.Ip2regionConfig;
import com.tiesheng.util.pojos.ApiResp; import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.FileUploadPath; import com.tiesheng.util.pojos.FileUploadPath;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
@@ -57,7 +56,6 @@ public class TestController {
@RequestMapping("/index") @RequestMapping("/index")
public ApiResp<String> index() { public ApiResp<String> index() {
dbBackupConfig.dbBackup();
return ApiResp.respOK("hello world"); return ApiResp.respOK("hello world");
} }
@@ -88,12 +86,12 @@ public class TestController {
} }
@RequestMapping("/send") @GetMapping("/send")
@TokenIgnore @TokenIgnore
public ApiResp<MessageReqResp> sendMessage() { public ApiResp<MessageReqResp> sendMessage() {
MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"), MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
JSONUtil.createObj().putOpt("code", "123456").putOpt("template_code", "SMS_154950909")); JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
return ApiResp.respOK(reqResp); return ApiResp.respOK(reqResp);
} }

View File

@@ -0,0 +1,32 @@
package com.tiesheng.demo.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.tiesheng.message.config.aliyun.AliyunSmsHandler;
import com.tiesheng.message.pojos.AliyunTempParam;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Service
public class DemoSmsHandler implements AliyunSmsHandler {
@Override
public AliyunTempParam handler(JSONObject obj) {
String action = obj.getStr("action");
AliyunTempParam param = new AliyunTempParam();
param.setSignName("智慧校园");
if (Objects.equals(action, "sms-visitor-invite")) {
param.setTemplateCode("SMS_276125463");
param.setTemplateParam(JSONUtil.createObj()
.putOpt("date", DateUtil.today())
);
}
return param;
}
}

View File

@@ -19,10 +19,12 @@ tiesheng:
test-map: test-map:
"1111": "1111":
id: "1111" id: "1111"
role-id: "student_bks"
global: global:
version: 2 version: 2
host: http://localhost:8100 host: http://localhost:8100
aliyun: aliyun:
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
sign-name: 阿里云短信测试 encrypt:
body: false

View File

@@ -9,6 +9,7 @@ spring:
servlet: servlet:
multipart: multipart:
max-file-size: 20MB max-file-size: 20MB
max-request-size: 20MB
web: web:
resources: resources:
static-locations: classpath:/static/,file:static/ static-locations: classpath:/static/,file:static/
@@ -24,3 +25,4 @@ tiesheng:
token: token:
ignore-paths: ignore-paths:
- /test/index - /test/index

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>

View File

@@ -21,4 +21,12 @@ public @interface OperationLog {
*/ */
String insertKey() default ""; String insertKey() default "";
/**
* 需要脱敏的字段
*
* @return
*/
String[] desensitize() default {};
} }

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>

View File

@@ -20,7 +20,8 @@ import java.util.List;
public class DbMigrationConfig { public class DbMigrationConfig {
private String table = "core_config_db"; private String table = "core_config_db";
private List<String> locations = CollUtil.newArrayList("classpath*:db/migration/*.sql"); private List<String> migrations = CollUtil.newArrayList("classpath*:db/migration/*.sql");
private List<String> datas = CollUtil.newArrayList("classpath*:db/data/*.sql");
private String ignoreSqls = "drop table,delete from"; private String ignoreSqls = "drop table,delete from";
/** /**
@@ -57,12 +58,20 @@ public class DbMigrationConfig {
this.table = table; this.table = table;
} }
public List<String> getLocations() { public List<String> getMigrations() {
return locations; return migrations;
} }
public void setLocations(List<String> locations) { public void setMigrations(List<String> migrations) {
this.locations = locations; this.migrations = migrations;
}
public List<String> getDatas() {
return datas;
}
public void setDatas(List<String> datas) {
this.datas = datas;
} }
public String getIgnoreSqls() { public String getIgnoreSqls() {

View File

@@ -8,7 +8,6 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Db; import cn.hutool.db.Db;
import cn.hutool.db.Entity; import cn.hutool.db.Entity;
import cn.hutool.log.LogFactory;
import com.tiesheng.database.config.DbMigrationConfig; import com.tiesheng.database.config.DbMigrationConfig;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.boot.web.servlet.ServletContextInitializer;
@@ -38,17 +37,24 @@ public class DbMigrationInitializer implements ServletContextInitializer {
DataSource dataSource; DataSource dataSource;
@Autowired @Autowired
DbMigrationConfig dbMigrationConfig; DbMigrationConfig dbMigrationConfig;
@Autowired(required = false) @Autowired
List<DbDataInitializer> dbDataInitializerList; List<DbDataInitializer> dbDataInitializerList;
@Override @Override
public void onStartup(ServletContext servletContext) { public void onStartup(ServletContext servletContext) {
try { try {
startDeal();
if (dbDataInitializerList != null) { // 初始化
dbDataInitializerList.forEach(DbDataInitializer::init); Db coreDb = Db.use(dataSource);
} dbMigrationConfig.checkDbExists(coreDb);
startDeal(coreDb, dbMigrationConfig.getMigrations());
startDeal(coreDb, dbMigrationConfig.getDatas());
// 其他数据初始化
dbDataInitializerList.forEach(DbDataInitializer::init);
} catch (Exception ignore) { } catch (Exception ignore) {
} }
} }
@@ -59,18 +65,13 @@ public class DbMigrationInitializer implements ServletContextInitializer {
* *
* @throws Exception * @throws Exception
*/ */
private void startDeal() throws Exception { private void startDeal(Db coreDb, List<String> locations) throws Exception {
Db coreDb = Db.use(dataSource);
dbMigrationConfig.checkDbExists(coreDb);
PathMatchingResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver(); PathMatchingResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
List<Resource> resourceList = new ArrayList<>(); List<Resource> resourceList = new ArrayList<>();
for (String location : dbMigrationConfig.getLocations()) { for (String location : locations) {
Resource[] resources = patternResolver.getResources(location); Resource[] resources = patternResolver.getResources(location);
resourceList.addAll(Arrays.asList(resources)); resourceList.addAll(Arrays.asList(resources));
} }
// 排序后执行sql
resourceList.sort((o1, o2) -> StrUtil.compare(o1.getFilename(), o2.getFilename(), true)); resourceList.sort((o1, o2) -> StrUtil.compare(o1.getFilename(), o2.getFilename(), true));
for (Resource resource : resourceList) { for (Resource resource : resourceList) {
migrationByResource(resource, coreDb); migrationByResource(resource, coreDb);
@@ -94,8 +95,8 @@ public class DbMigrationInitializer implements ServletContextInitializer {
if (entity == null) { if (entity == null) {
return; return;
} }
AtomicReference<Integer> success= new AtomicReference<>(0); AtomicReference<Integer> success = new AtomicReference<>(0);
AtomicReference<Integer> fail= new AtomicReference<>(0); AtomicReference<Integer> fail = new AtomicReference<>(0);
db.tx((VoidFunc1<Db>) parameter -> { db.tx((VoidFunc1<Db>) parameter -> {
List<String> split = StrUtil.split(readUtf8, ";"); List<String> split = StrUtil.split(readUtf8, ";");
for (String sql : split) { for (String sql : split) {
@@ -114,7 +115,6 @@ public class DbMigrationInitializer implements ServletContextInitializer {
} }
} }
}); });
LogFactory.get().info("执行sql文件{},成功数:{},失败数:{}。",filename,success.get(),fail.get());
entity.set("checksum", checksum.getValue()); entity.set("checksum", checksum.getValue());
entity.set("update_time", DateUtil.date()); entity.set("update_time", DateUtil.date());
db.update(entity, Entity.create(dbMigrationConfig.getTable()).set("id", entity.get("id"))); db.update(entity, Entity.create(dbMigrationConfig.getTable()).set("id", entity.get("id")));

View File

@@ -0,0 +1,13 @@
package com.tiesheng.database.service.impl;
import com.tiesheng.database.service.DbDataInitializer;
import org.springframework.stereotype.Component;
@Component
public class DefaultDbDataInitializer implements DbDataInitializer {
@Override
public void init() {
}
}

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>

View File

@@ -1,21 +0,0 @@
package com.tiesheng.encrypt;
import com.tiesheng.encrypt.config.DecryptRequestBodyAdvice;
import com.tiesheng.encrypt.config.EncryptResponseBodyAdvice;
import org.springframework.context.annotation.Import;
import java.lang.annotation.*;
/**
* @author hao
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
@Import({
DecryptRequestBodyAdvice.class,
EncryptResponseBodyAdvice.class,
})
public @interface EnableEncryptConfig {
}

View File

@@ -0,0 +1,10 @@
package com.tiesheng.encrypt;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan({
"com.tiesheng.encrypt.**.*",
})
public class EncryptAutoConfigurer {
}

View File

@@ -37,7 +37,7 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice<ApiResp> {
try { try {
Object data = body.getData(); Object data = body.getData();
if (data == null || !body.successful()) { if (data == null || !body.successful() || !encryptConfig.isBody()) {
return body; return body;
} }

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>

View File

@@ -1,9 +1,10 @@
package com.tiesheng.login.config.token; package com.tiesheng.login.config;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.token.TokenIgnore; import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.util.ServletKit; import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.TsTokenConfig;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;

View File

@@ -6,7 +6,8 @@ import cn.hutool.core.util.URLUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.tiesheng.annotation.operation.OperationIgnore; import com.tiesheng.annotation.operation.OperationIgnore;
import com.tiesheng.annotation.token.TokenIgnore; import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.login.pojos.CodeExtraDTO; import com.tiesheng.login.pojos.CodeExtraDTO;
import com.tiesheng.login.pojos.DoLoginInfo; import com.tiesheng.login.pojos.DoLoginInfo;
import com.tiesheng.login.pojos.UniqueIndexDTO; import com.tiesheng.login.pojos.UniqueIndexDTO;
@@ -15,6 +16,7 @@ import com.tiesheng.login.service.TieshengLoginConfigurer;
import com.tiesheng.platform.config.ding.PlatformDingConfig; import com.tiesheng.platform.config.ding.PlatformDingConfig;
import com.tiesheng.platform.config.ding.bean.DingJsapiSignature; import com.tiesheng.platform.config.ding.bean.DingJsapiSignature;
import com.tiesheng.platform.config.ding.bean.DingUserInfo; import com.tiesheng.platform.config.ding.bean.DingUserInfo;
import com.tiesheng.platform.config.ding.bean.DingUserSimple;
import com.tiesheng.platform.config.wxmini.PlatformWxminiConfig; import com.tiesheng.platform.config.wxmini.PlatformWxminiConfig;
import com.tiesheng.platform.config.wxmp.PlatformWxmpConfig; import com.tiesheng.platform.config.wxmp.PlatformWxmpConfig;
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean; import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
@@ -50,6 +52,8 @@ public class LoginController {
TieshengLoginConfigurer tieshengLoginConfigurer; TieshengLoginConfigurer tieshengLoginConfigurer;
@Autowired @Autowired
GlobalConfig globalConfig; GlobalConfig globalConfig;
@Autowired
TsTokenConfig tsTokenConfig;
/** /**
@@ -60,6 +64,11 @@ public class LoginController {
@GetMapping("/unique/redirect") @GetMapping("/unique/redirect")
@OperationIgnore @OperationIgnore
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) { public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
if (tsTokenConfig.isValidLoginSign() && !dto.validSign()) {
tieshengLoginConfigurer.onSignError(response);
return;
}
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_redirect", TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_redirect",
dto.getNo(), dto.getPlatform(), dto.getInfo())); dto.getNo(), dto.getPlatform(), dto.getInfo()));
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response); tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
@@ -77,7 +86,7 @@ public class LoginController {
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) { public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_index", TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_index",
dto.getNo(), dto.getPlatform(), dto.getInfo())); dto.getNo(), dto.getPlatform(), dto.getInfo()));
if (tokenBean == null) { if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
throw new ApiException("登录失败"); throw new ApiException("登录失败");
} }
return ApiResp.respOK(tokenBean.toToken()); return ApiResp.respOK(tokenBean.toToken());
@@ -105,6 +114,7 @@ public class LoginController {
map.put("corpId", platformDingConfig.getConfigBean(service).getCorpId()); map.put("corpId", platformDingConfig.getConfigBean(service).getCorpId());
map.put("service", service); map.put("service", service);
map.put("extra", extra); map.put("extra", extra);
map.put("context", globalConfig.getContextPath());
String query = URLUtil.buildQuery(map, Charset.defaultCharset()); String query = URLUtil.buildQuery(map, Charset.defaultCharset());
String configUrl = globalConfig.buildPath("/ding/index.html?" + query); String configUrl = globalConfig.buildPath("/ding/index.html?" + query);
try { try {
@@ -122,8 +132,8 @@ public class LoginController {
@RequestMapping("/ding/oauth2/{service}") @RequestMapping("/ding/oauth2/{service}")
@OperationIgnore @OperationIgnore
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) { public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode()); DingUserSimple userSimple = platformDingConfig.getUserIdByCode(service, dto.getCode());
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId); DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, userSimple.getUserid());
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(dingUserInfo.getAppId(), TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(dingUserInfo.getAppId(),
dingUserInfo.getUserid(), "ding", JSON.toJSONString(dingUserInfo))); dingUserInfo.getUserid(), "ding", JSON.toJSONString(dingUserInfo)));
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response); tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
@@ -159,7 +169,7 @@ public class LoginController {
if (StrUtil.isEmpty(extra)) { if (StrUtil.isEmpty(extra)) {
extra = ""; extra = "";
} }
String configUrl = globalConfig.buildPath("/auth/wxmp/oauth2/" + service + "?extra=" + extra); String configUrl = globalConfig.buildPath("/login/wxmp/oauth2/" + service + "?extra=" + extra);
String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl, "snsapi_userinfo"); String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl, "snsapi_userinfo");
response.sendRedirect(authorizationUrl); response.sendRedirect(authorizationUrl);
} }

View File

@@ -1,6 +1,10 @@
package com.tiesheng.login.pojos; package com.tiesheng.login.pojos;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import java.util.Objects;
public class UniqueIndexDTO extends LoginToInfo { public class UniqueIndexDTO extends LoginToInfo {
@@ -8,6 +12,26 @@ public class UniqueIndexDTO extends LoginToInfo {
private String extra; private String extra;
private String info; private String info;
private String platform = "web"; private String platform = "web";
private Long timestamp;
private String sign;
/**
* 验证签名是否正确
*/
public boolean validSign() {
if (StrUtil.isEmpty(getNo()) || getTimestamp() == null) {
return false;
}
if ((DateUtil.currentSeconds() - getTimestamp()) > 60) {
return false;
}
String mySign = getNo() + getTimestamp();
for (int i = 0; i < 11; i++) {
mySign = SecureUtil.md5(mySign);
}
return Objects.equals(sign, mySign);
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// setter\getter // setter\getter
@@ -47,4 +71,20 @@ public class UniqueIndexDTO extends LoginToInfo {
public void setPlatform(String platform) { public void setPlatform(String platform) {
this.platform = platform; this.platform = platform;
} }
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
} }

View File

@@ -1,6 +1,6 @@
package com.tiesheng.login.service; package com.tiesheng.login.service;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.login.pojos.DoLoginInfo; import com.tiesheng.login.pojos.DoLoginInfo;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@@ -28,4 +28,9 @@ public interface TieshengLoginConfigurer {
void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response); void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response);
/**
* 签名错误的时候
*/
void onSignError(HttpServletResponse response);
} }

View File

@@ -1,6 +1,6 @@
package com.tiesheng.login.service.impl; package com.tiesheng.login.service.impl;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.login.pojos.DoLoginInfo; import com.tiesheng.login.pojos.DoLoginInfo;
import com.tiesheng.login.service.TieshengLoginConfigurer; import com.tiesheng.login.service.TieshengLoginConfigurer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -24,4 +24,9 @@ public class DefaultLoginConfigurer implements TieshengLoginConfigurer {
public void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response) { public void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
} }
@Override
public void onSignError(HttpServletResponse response) {
}
} }

View File

@@ -24,10 +24,10 @@
corpId: getQueryString("corpId"), corpId: getQueryString("corpId"),
onSuccess: function (result) { onSuccess: function (result) {
let search = window.location.search + "&code=" + result.code; let search = window.location.search + "&code=" + result.code;
window.location.href = "/auth/ding/oauth2/" + getQueryString("service") + search; window.location.replace(getQueryString("context") + "/login/ding/oauth2/" + getQueryString("service") + search);
}, },
onFail: function (err) { onFail: function (err) {
window.location.href = "./error.html?message=" + JSON.stringify(err); window.location.replace("./error.html?message=" + JSON.stringify(err));
} }
}) })

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>

View File

@@ -0,0 +1,16 @@
package com.tiesheng.message.config.aliyun;
import cn.hutool.json.JSONObject;
import com.tiesheng.message.pojos.AliyunTempParam;
public interface AliyunSmsHandler {
/**
* 数据处理
*
* @param obj
*/
AliyunTempParam handler(JSONObject obj);
}

View File

@@ -1,14 +1,18 @@
package com.tiesheng.message.config.aliyun; package com.tiesheng.message.config.aliyun;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.tiesheng.message.pojos.AliyunTempParam;
import com.tiesheng.message.pojos.MessageReqResp; import com.tiesheng.message.pojos.MessageReqResp;
import com.tiesheng.message.service.TieshengMessageSender; import com.tiesheng.message.service.TieshengMessageSender;
import com.tiesheng.util.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@@ -36,7 +40,9 @@ public class AliyunSmsSender implements TieshengMessageSender {
private String accessKeyId; private String accessKeyId;
private String accessKeySecret; private String accessKeySecret;
private String signName;
@Autowired(required = false)
AliyunSmsHandler aliyunSmsHandler;
/** /**
* 特殊字符替换 * 特殊字符替换
@@ -94,7 +100,16 @@ public class AliyunSmsSender implements TieshengMessageSender {
String signature = specialUrlEncode(digest); String signature = specialUrlEncode(digest);
queryMap.put("Signature", signature); queryMap.put("Signature", signature);
return HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000); String respBody = "";
try {
respBody = HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000);
} catch (Exception e) {
respBody = JSONUtil.createObj()
.putOpt("Code", "Error")
.putOpt("Message", "消息通道异常")
.toString();
}
return respBody;
} }
@@ -102,29 +117,28 @@ public class AliyunSmsSender implements TieshengMessageSender {
* 创建发送请求 * 创建发送请求
* *
* @param phoneNumbers 手机号,多个用,隔开 * @param phoneNumbers 手机号,多个用,隔开
* @param templateCode 短信模板 * @param tempParam 短信模板
* @param params 模板参数
* @return * @return
*/ */
public MessageReqResp sendSms(String phoneNumbers, String templateCode, JSONObject params) { public MessageReqResp sendSms(String phoneNumbers, AliyunTempParam tempParam) {
MessageReqResp reqResp = new MessageReqResp("阿里云短信"); MessageReqResp reqResp = new MessageReqResp("阿里云短信");
reqResp.setTarget(phoneNumbers); reqResp.setTarget(phoneNumbers);
reqResp.setResult(1); reqResp.setResult(1);
reqResp.setContent(JSONUtil.createObj() reqResp.setContent(JSONUtil.createObj()
.putOpt("PhoneNumbers", phoneNumbers) .putOpt("PhoneNumbers", phoneNumbers)
.putOpt("SignName", getSignName()) .putOpt("SignName", tempParam.getSignName())
.putOpt("TemplateCode", templateCode) .putOpt("TemplateCode", tempParam.getTemplateCode())
.putOpt("TemplateParam", params) .putOpt("TemplateParam", tempParam.getTemplateParam())
.toString()); .toString());
// 业务API参数 // 业务API参数
ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>(); ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>();
queryMap.put("PhoneNumbers", phoneNumbers); queryMap.put("PhoneNumbers", phoneNumbers);
queryMap.put("SignName", getSignName()); queryMap.put("SignName", tempParam.getSignName());
queryMap.put("TemplateCode", templateCode); queryMap.put("TemplateCode", tempParam.getTemplateCode());
if (params != null) { if (tempParam.getTemplateParam() != null) {
queryMap.put("TemplateParam", params.toString()); queryMap.put("TemplateParam", tempParam.getTemplateParam().toString());
} }
reqResp.setRespBody(request("SendSms", queryMap)); reqResp.setRespBody(request("SendSms", queryMap));
@@ -139,7 +153,21 @@ public class AliyunSmsSender implements TieshengMessageSender {
@Override @Override
public MessageReqResp send(String user, JSONObject body) { public MessageReqResp send(String user, JSONObject body) {
return sendSms(user, body.getStr("template_code"), body); boolean mobile = Validator.isMobile(user);
if (!mobile) {
return null;
}
if (aliyunSmsHandler == null) {
throw new ApiException("未注册短信参数处理器");
}
AliyunTempParam tempParam = aliyunSmsHandler.handler(body);
if (tempParam == null) {
throw new ApiException("未配置短信参数处理器");
}
return sendSms(user, tempParam);
} }
@Override @Override
@@ -149,7 +177,7 @@ public class AliyunSmsSender implements TieshengMessageSender {
@Override @Override
public boolean support() { public boolean support() {
return StrUtil.isAllNotEmpty(accessKeyId, accessKeySecret, signName); return StrUtil.isAllNotEmpty(accessKeyId, accessKeySecret);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -172,12 +200,5 @@ public class AliyunSmsSender implements TieshengMessageSender {
this.accessKeySecret = accessKeySecret; this.accessKeySecret = accessKeySecret;
} }
public String getSignName() {
return signName;
}
public void setSignName(String signName) {
this.signName = signName;
}
} }

View File

@@ -0,0 +1,38 @@
package com.tiesheng.message.pojos;
import cn.hutool.json.JSONObject;
public class AliyunTempParam {
private String signName;
private String templateCode;
private JSONObject templateParam;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getSignName() {
return signName;
}
public void setSignName(String signName) {
this.signName = signName;
}
public String getTemplateCode() {
return templateCode;
}
public void setTemplateCode(String templateCode) {
this.templateCode = templateCode;
}
public JSONObject getTemplateParam() {
return templateParam;
}
public void setTemplateParam(JSONObject templateParam) {
this.templateParam = templateParam;
}
}

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>

View File

@@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.TypeReference; import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
@@ -48,6 +48,40 @@ public class PlatformDingConfig {
return bean; return bean;
} }
/**
* 发送get请求
* 会自动增加accessToken在url上面
*
* @param service
* @return
*/
public <T> DingResponse<T> doRequest(String service, String url, JSONObject body, TypeReference<DingResponse<T>> typeReference) {
if (StrUtil.contains(url, "?")) {
url = url + "&access_token=" + getAccessToken(service);
} else {
url = url + "?access_token=" + getAccessToken(service);
}
HttpResponse execute;
if (body == null) {
execute = HttpUtil.createGet(url).execute();
} else {
execute = HttpUtil.createPost(url).body(body.toString()).execute();
}
if (execute.isOk()) {
DingResponse<T> bean = JSONUtil.toBean(execute.body(), typeReference, true);
if (!bean.isOk()) {
LogFactory.get().info(bean.getErrmsg());
}
return bean;
}
return null;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// 逻辑方法 // 逻辑方法
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -88,14 +122,15 @@ public class PlatformDingConfig {
DingConfigBean dingConfigBean = getConfigBean(service); DingConfigBean dingConfigBean = getConfigBean(service);
String jsapiTicket = TimedCacheHelper.getTimedCache().get(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), false); String jsapiTicket = TimedCacheHelper.getTimedCache().get(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), false);
if (StrUtil.isEmpty(jsapiTicket)) { if (StrUtil.isEmpty(jsapiTicket)) {
String response = HttpUtil.get("https://oapi.dingtalk.com/get_jsapi_ticket?access_token=" + getAccessToken(service)); DingResponse<String> respJson = doRequest(service, "https://oapi.dingtalk.com/get_jsapi_ticket", null,
LogFactory.get().info("getJsapiTicket: " + response); new TypeReference<DingResponse<String>>() {
JSONObject respJson = JSONUtil.parseObj(response); });
if (!Objects.equals(respJson.getStr("errcode"), "0")) { if (!respJson.isOk()) {
throw new ApiException(respJson.getStr("errmsg")); throw new ApiException(respJson.getErrmsg());
} }
jsapiTicket = respJson.getStr("ticket"); jsapiTicket = respJson.getTicket();
TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), jsapiTicket, respJson.getLong("expires_in")); TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(),
jsapiTicket, respJson.getExpiresIn());
} }
return jsapiTicket; return jsapiTicket;
} }
@@ -124,10 +159,11 @@ public class PlatformDingConfig {
* @return * @return
* @see <a href="https://open.dingtalk.com/document/isvapp-server/obtain-the-userid-of-a-user-by-using-the-log-free"></a> * @see <a href="https://open.dingtalk.com/document/isvapp-server/obtain-the-userid-of-a-user-by-using-the-log-free"></a>
*/ */
public String getUserIdByCode(String service, String code) { public DingUserSimple getUserIdByCode(String service, String code) {
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + getAccessToken(service)) DingResponse<DingUserSimple> resp = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo",
.body(JSONUtil.createObj().putOpt("code", code).toString()).execute().body(); JSONUtil.createObj().putOpt("code", code), new TypeReference<DingResponse<DingUserSimple>>() {
return JSONUtil.parseObj(response).getJSONObject("result").getStr("userid"); });
return resp.getResult();
} }
@@ -141,13 +177,12 @@ public class PlatformDingConfig {
*/ */
public DingUserInfo topapiV2UserGet(String service, String ddUserId) { public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
DingConfigBean dingConfigBean = getConfigBean(service); DingConfigBean dingConfigBean = getConfigBean(service);
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/get?access_token=" + getAccessToken(service))
.body(JSONUtil.createObj().putOpt("userid", ddUserId).toString()).execute().body();
JSONObject resultJson = JSONUtil.parseObj(response).getJSONObject("result");
DingUserInfo userInfo = JSONUtil.toBean(resultJson, DingUserInfo.class);
DingUserInfo userInfo = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/get",
JSONUtil.createObj().putOpt("userid", ddUserId), new TypeReference<DingResponse<DingUserInfo>>() {
}).getResult();
// 设置一下job_number // 设置一下job_number
userInfo.setJobNumber(resultJson.getStr("job_number")); userInfo.setJobNumber(userInfo.getJobNumber());
userInfo.setAppId(dingConfigBean.getAppKey()); userInfo.setAppId(dingConfigBean.getAppKey());
return userInfo; return userInfo;
} }
@@ -164,15 +199,10 @@ public class PlatformDingConfig {
if (StrUtil.isEmpty(token)) { if (StrUtil.isEmpty(token)) {
return new ArrayList<>(); return new ArrayList<>();
} }
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token=" + token)
.body(JSONUtil.createObj().putOpt("dept_id", deptId).toString()).execute().body();
DingResponse<List<DingDeptVo>> result = JSONUtil.toBean(response, new TypeReference<DingResponse<List<DingDeptVo>>>() {
}.getType(), true);
if (!result.isOk()) { return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/department/listsub",
result.setResult(new ArrayList<>()); JSONUtil.createObj().putOpt("dept_id", deptId), new TypeReference<DingResponse<List<DingDeptVo>>>() {
} }).getResult();
return result.getResult();
} }
@@ -188,19 +218,16 @@ public class PlatformDingConfig {
return DingUserListVo.fail(); return DingUserListVo.fail();
} }
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/list?access_token=" + token) return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
.body(JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100).toString()) JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100),
.execute().body(); new TypeReference<DingResponse<DingUserListVo>>() {
DingResponse<DingUserListVo> result = JSONUtil.toBean(response, new TypeReference<DingResponse<DingUserListVo>>() { }).getResult();
}.getType(), true);
if (!result.isOk()) {
result.setResult(DingUserListVo.fail());
}
return result.getResult();
} }
/** /**
* 同步钉钉的通讯录 * 同步钉钉的通讯录
* <br />
* PS如果需要钉钉用户手机号需要开通权限企业员工手机号信息
* *
* @param deptVo 为null时从第一级获取 * @param deptVo 为null时从第一级获取
* @param consumer 回调 * @param consumer 回调
@@ -239,18 +266,19 @@ public class PlatformDingConfig {
* @param content * @param content
* @param actionUrl * @param actionUrl
* @param userIds * @param userIds
* @return
*/ */
public void messageNotification(String service, String title, String content, String actionUrl, List<String> userIds) { public DingResponse<String> messageNotification(String service, String title, String markdown, String actionUrl, List<String> userIds) {
if (CollUtil.isEmpty(userIds)) { if (CollUtil.isEmpty(userIds)) {
return; return null;
} }
DingConfigBean configBean = getConfigBean(service); DingConfigBean configBean = getConfigBean(service);
JSONObject actionCard = new JSONObject(); JSONObject actionCard = new JSONObject();
actionCard.set("title", title); actionCard.set("title", title);
actionCard.set("markdown", "### " + title + "\n" + content); actionCard.set("markdown", markdown);
actionCard.set("single_title", "点击查看"); actionCard.set("single_title", "点击查看");
actionCard.set("single_url", actionUrl); actionCard.set("single_url", actionUrl);
@@ -258,17 +286,18 @@ public class PlatformDingConfig {
msg.set("msgtype", "action_card"); msg.set("msgtype", "action_card");
msg.set("action_card", actionCard); msg.set("action_card", actionCard);
HashMap<String, Object> body = new HashMap<>(10); JSONObject body = new JSONObject();
body.put("agent_id", configBean.getAgentId()); body.putOpt("agent_id", configBean.getAgentId());
body.put("userid_list", CollUtil.join(userIds, ",")); body.putOpt("userid_list", CollUtil.join(userIds, ","));
body.put("msg", msg); body.putOpt("msg", msg);
String resp = HttpUtil.post("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token=" + getAccessToken(service), return doRequest(service, "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", body,
JSONUtil.toJsonStr(body)); new TypeReference<DingResponse<String>>() {
});
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// setter\getter // setter\getter
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
public Map<String, DingConfigBean> getConfigs() { public Map<String, DingConfigBean> getConfigs() {
return configs; return configs;

View File

@@ -6,6 +6,8 @@ public class DingResponse<T> {
private String errcode; private String errcode;
private String errmsg; private String errmsg;
private String ticket;
private Long expiresIn;
private T result; private T result;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -43,4 +45,20 @@ public class DingResponse<T> {
public void setResult(T result) { public void setResult(T result) {
this.result = result; this.result = result;
} }
public String getTicket() {
return ticket;
}
public void setTicket(String ticket) {
this.ticket = ticket;
}
public Long getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(Long expiresIn) {
this.expiresIn = expiresIn;
}
} }

View File

@@ -6,10 +6,8 @@ import java.util.List;
/** /**
* @author hao * @author hao
*/ */
public class DingUserInfo { public class DingUserInfo extends DingUserSimple {
private String name;
private String userid;
private String avatar; private String avatar;
private String mobile; private String mobile;
private String email; private String email;
@@ -17,7 +15,6 @@ public class DingUserInfo {
private String nickname; private String nickname;
private String title; private String title;
private String remark; private String remark;
private String unionid;
private String appId; private String appId;
private List<String> deptIdList; private List<String> deptIdList;
private boolean leader; private boolean leader;
@@ -34,30 +31,6 @@ public class DingUserInfo {
// setter\getter // setter\getter
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUnionid() {
return unionid;
}
public void setUnionid(String unionid) {
this.unionid = unionid;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getAvatar() { public String getAvatar() {
return avatar; return avatar;
} }

View File

@@ -0,0 +1,32 @@
package com.tiesheng.platform.config.ding.bean;
public class DingUserSimple {
private String unionid;
private String name;
private String userid;
public String getUnionid() {
return unionid;
}
public void setUnionid(String unionid) {
this.unionid = unionid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
}

View File

@@ -3,6 +3,7 @@ package com.tiesheng.platform.config.wxmini;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean; import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
@@ -50,12 +51,13 @@ public class PlatformWxminiConfig {
*/ */
public String jscode2session(String service, String code) { public String jscode2session(String service, String code) {
WxConfigBean configBean = getConfigBean(service); WxConfigBean configBean = getConfigBean(service);
String body = HttpRequest.get("https://api.weixin.qq.com/sns/jscode2session" try (HttpResponse response = HttpRequest.get("https://api.weixin.qq.com/sns/jscode2session"
+ "?appid=" + configBean.getAppId() + "?appid=" + configBean.getAppId()
+ "&secret=" + configBean.getAppSecret() + "&secret=" + configBean.getAppSecret()
+ "&js_code=" + code + "&grant_type=authorization_code").execute().body(); + "&js_code=" + code + "&grant_type=authorization_code").execute()) {
JSONObject object = JSONUtil.parseObj(body); JSONObject object = JSONUtil.parseObj(response.body());
return object.getStr("openid"); return object.getStr("openid");
}
} }
/** /**
@@ -65,11 +67,12 @@ public class PlatformWxminiConfig {
*/ */
public String getAccessToken(String service) { public String getAccessToken(String service) {
WxConfigBean configBean = getConfigBean(service); WxConfigBean configBean = getConfigBean(service);
String body = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token" try (HttpResponse response = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token"
+ "?grant_type=client_credential&appid=" + configBean.getAppId() + "?grant_type=client_credential&appid=" + configBean.getAppId()
+ "&secret=" + configBean.getAppSecret()).execute().body(); + "&secret=" + configBean.getAppSecret()).execute()) {
JSONObject object = JSONUtil.parseObj(body); JSONObject object = JSONUtil.parseObj(response.body());
return object.getStr("access_token"); return object.getStr("access_token");
}
} }

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>

27
springboot-role/pom.xml Normal file
View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc2</version>
</parent>
<artifactId>springboot-role</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,316 @@
package com.tiesheng.role.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiesheng.role.pojos.dao.*;
import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO;
import com.tiesheng.role.pojos.dto.MenuListDTO;
import com.tiesheng.role.pojos.dto.OwnerMenuDTO;
import com.tiesheng.role.pojos.dto.OwnerPointDTO;
import com.tiesheng.role.pojos.vo.GroupTypeDTO;
import com.tiesheng.role.pojos.vo.RoleUserPageVO;
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
import com.tiesheng.role.service.CoreRoleService;
import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.IdDTO;
import com.tiesheng.util.pojos.PageDTO;
import com.tiesheng.util.pojos.TokenBean;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/role")
public class RoleController {
@Resource
CoreRoleService coreRoleService;
/**
* 角色列表
*
* @return
*/
@GetMapping("/group/list")
public ApiResp<List<CoreRoleGroup>> groupList(@Valid GroupTypeDTO dto) {
return ApiResp.respOK(coreRoleService.list(
new QueryWrapper<CoreRoleGroup>()
.eq("type", dto.getType())
.orderByAsc("sort")
));
}
/**
* 角色编辑
*
* @param roleGroup
* @return
*/
@PostMapping("/group/update")
public ApiResp<String> groupUpdate(@RequestBody CoreRoleGroup roleGroup) {
if (StrUtil.isNotEmpty(roleGroup.getId())) {
roleGroup.setType(null);
roleGroup.setIsSystem(null);
}
coreRoleService.saveOrUpdate(roleGroup);
return ApiResp.respOK("");
}
/**
* 角色-删除
*
* @return
*/
@PostMapping("/group/deleted")
public ApiResp<String> groupDeleted(@RequestBody @Valid IdDTO dto) {
CoreRoleGroup byId = coreRoleService.getById(dto.getId());
if (byId == null || byId.getIsDeleted() != 0) {
throw new ApiException("角色不存在或已删除");
}
if (byId.getIsSystem() == 1) {
throw new ApiException(StrUtil.format("该{}无法删除",
Objects.equals(byId.getType(), "role") ? "角色" : "职位"));
}
CoreRoleGroup coreServiceMenu = new CoreRoleGroup();
coreServiceMenu.setId(dto.getId());
coreServiceMenu.setIsDeleted(1);
coreRoleService.updateById(coreServiceMenu);
return ApiResp.respOK("");
}
/**
* 获取角色的权限
*
* @return
*/
@GetMapping("/group/rx/list")
public ApiResp<List<CoreRoleGroupRx>> groupRxList(@Valid IdDTO dto) {
List<CoreRoleGroupRx> list = coreRoleService.getGroupRxMapper().selectList(new QueryWrapper<CoreRoleGroupRx>()
.eq(CoreRoleGroupRx.IS_DELETED, 0)
.eq("group_id", dto.getId())
);
return ApiResp.respOK(list);
}
/**
* 橘色的权限编辑
*
* @return
*/
@PostMapping("/group/rx/update")
public ApiResp<String> groupRxUpdate(@RequestBody @Valid GroupRxUpdateDTO dto) {
coreRoleService.updateGroupRx(dto);
return ApiResp.respOK("");
}
/**
* 授权列表
*
* @return
*/
@GetMapping("/user/page")
public ApiResp<List<RoleUserPageVO>> userPage(PageDTO dto) {
QueryWrapper<CoreRoleUser> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("cru.is_deleted", 0);
dto.likeColumns(queryWrapper, "cru.ext1", "cru.ext2", "cru.ext3");
queryWrapper.orderByAsc("cru.user_id");
Page<RoleUserPageVO> page = dto.pageObj();
coreRoleService.getUserMapper().page(page, queryWrapper);
return ApiResp.respOK(page.getRecords(), page.getTotal());
}
/**
* 授权调整
*
* @return
*/
@PostMapping("/user/update")
public ApiResp<String> userUpdate(@RequestBody CoreRoleUser roleUser) {
if (StrUtil.isNotEmpty(roleUser.getId())) {
coreRoleService.getUserMapper().updateById(roleUser);
} else {
coreRoleService.getUserMapper().insert(roleUser);
}
return ApiResp.respOK("");
}
/**
* 授权-删除
*
* @return
*/
@PostMapping("/user/deleted")
public ApiResp<String> userDeleted(@RequestBody @Valid IdDTO dto) {
CoreRoleUser coreRoleUser = new CoreRoleUser();
coreRoleUser.setId(dto.getId());
coreRoleUser.setIsDeleted(1);
coreRoleService.getUserMapper().updateById(coreRoleUser);
return ApiResp.respOK("");
}
/**
* 获取服务列表
*
* @return
*/
@GetMapping("/server/list")
public ApiResp<List<CoreRoleServer>> list() {
return ApiResp.respOK(coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
.eq(CoreRoleServer.IS_DELETED, 0)
.eq("is_open", 1)
));
}
/**
* 修改服务
*
* @param coreService
* @return
*/
@PostMapping("/server/update")
public ApiResp<String> update(@RequestBody CoreRoleServer coreService) {
if (StrUtil.isNotEmpty(coreService.getId())) {
coreRoleService.getServerMapper().updateById(coreService);
} else {
coreRoleService.getServerMapper().insert(coreService);
}
return ApiResp.respOK("");
}
/**
* 权限-列出
*
* @return
*/
@GetMapping("/authority/list")
public ApiResp<List<ServiceMenuVO>> menuList(@Valid MenuListDTO dto) {
List<CoreRoleAuthority> list = coreRoleService.getAuthorityMapper().selectList(new QueryWrapper<CoreRoleAuthority>()
.eq(CoreRoleAuthority.IS_DELETED, 0)
.eq("service", dto.getService())
.eq(StrUtil.isNotEmpty(dto.getPlatform()), "platform", dto.getPlatform())
.orderByAsc("sort")
);
List<ServiceMenuVO> collect = coreRoleService.menuChildrenWrap(list, null);
return ApiResp.respOK(collect);
}
/**
* 权限-编辑
*
* @return
*/
@PostMapping("/authority/update")
public ApiResp<String> menuUpdate(@RequestBody CoreRoleAuthority serviceMenu) {
serviceMenu.setParent(StrUtil.emptyToDefault(serviceMenu.getParent(), null));
if (StrUtil.isEmpty(serviceMenu.getId())) {
coreRoleService.getAuthorityMapper().insert(serviceMenu);
} else {
serviceMenu.setNo(null);
coreRoleService.getAuthorityMapper().updateById(serviceMenu);
}
return ApiResp.respOK("");
}
/**
* 获取自己拥有的服务
*
* @return
*/
@GetMapping("/owner/server")
public ApiResp<List<CoreRoleServer>> ownerServer() {
TokenBean tokenBean = TsTokenConfig.get();
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId());
List<CoreRoleServer> roleServerList = coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
.in("id", allOwnerMenus.stream().map(CoreRoleAuthority::getService).collect(Collectors.toList()))
.eq(CoreRoleServer.IS_DELETED, 0)
.eq("is_open", 1)
);
return ApiResp.respOK(roleServerList);
}
/**
* 获取自己拥有的菜单
*
* @return
*/
@GetMapping("/owner/menu")
public ApiResp<List<ServiceMenuVO>> ownerMenu(@Valid OwnerMenuDTO dto) {
TokenBean tokenBean = TsTokenConfig.get();
List<ServiceMenuVO> ownerMenus = coreRoleService.getOwnerMenus(tokenBean.getId(), tokenBean.getRoleId(), dto);
return ApiResp.respOK(ownerMenus);
}
/**
* 获取自己拥有的功能点
*
* @return
*/
@GetMapping("/owner/point")
public ApiResp<List<CoreRoleAuthority>> ownerPoint(@Valid OwnerPointDTO dto) {
TokenBean tokenBean = TsTokenConfig.get();
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId());
String parentId;
if (StrUtil.isNotEmpty(dto.getParentNo())) {
CoreRoleAuthority selected = coreRoleService.getAuthorityMapper().selectOne(new QueryWrapper<CoreRoleAuthority>()
.eq("no", dto.getParentNo())
.eq("is_deleted", 0)
.last("limit 1")
);
parentId = selected == null ? "" : selected.getId();
} else {
parentId = "";
}
List<CoreRoleAuthority> collect = allOwnerMenus.stream()
.filter(it -> Objects.equals(it.getType(), "point"))
.filter(it -> it.getService().equals(dto.getService()))
.filter(it -> it.getPlatform().equals(dto.getPlatform()))
.filter(it -> {
if (StrUtil.isNotEmpty(parentId)) {
return parentId.equals(it.getParent());
}
return true;
}).collect(Collectors.toList());
return ApiResp.respOK(collect);
}
}

View File

@@ -0,0 +1,7 @@
package com.tiesheng.role.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
public interface CoreRoleAuthorityMapper extends BaseMapper<CoreRoleAuthority> {
}

View File

@@ -0,0 +1,7 @@
package com.tiesheng.role.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tiesheng.role.pojos.dao.CoreRoleGroup;
public interface CoreRoleGroupMapper extends BaseMapper<CoreRoleGroup> {
}

View File

@@ -0,0 +1,17 @@
package com.tiesheng.role.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tiesheng.role.pojos.dao.CoreRoleGroupRx;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CoreRoleGroupRxMapper extends BaseMapper<CoreRoleGroupRx> {
/**
* 批量插入数据
*
* @param coreRoleGroupRxs
* @return
*/
int batchInsert(@Param("list") List<CoreRoleGroupRx> coreRoleGroupRxs);
}

View File

@@ -0,0 +1,7 @@
package com.tiesheng.role.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tiesheng.role.pojos.dao.CoreRoleServer;
public interface CoreRoleServerMapper extends BaseMapper<CoreRoleServer> {
}

View File

@@ -0,0 +1,35 @@
package com.tiesheng.role.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
import com.tiesheng.role.pojos.dao.CoreRoleUser;
import com.tiesheng.role.pojos.vo.RoleUserPageVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CoreRoleUserMapper extends BaseMapper<CoreRoleUser> {
/**
* 分页查询
*
* @param page
* @param wrapper
* @return
*/
Page<RoleUserPageVO> page(Page<RoleUserPageVO> page, @Param("ew") QueryWrapper<CoreRoleUser> wrapper);
/**
* 获取用户所有的权限
*
* @param userId
* @return
*/
List<CoreRoleAuthority> getOwnerAuthorityLeafList(@Param("userId") String userId,
@Param("roleId") String roleId);
}

View File

@@ -0,0 +1,350 @@
package com.tiesheng.role.pojos.dao;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tiesheng.util.pojos.DaoBase;
import java.util.Date;
/**
* 角色-权限
*/
@TableName(value = "core_role_authority")
public class CoreRoleAuthority extends DaoBase {
/**
* 服务
*/
@TableField(value = "service")
private String service;
/**
* 编号
*/
@TableField(value = "`no`")
private String no;
/**
* 名称
*/
@TableField(value = "`name`")
private String name;
/**
* 排序
*/
@TableField(value = "sort")
private Integer sort;
/**
* 层级
*/
@TableField(value = "`level`")
private Integer level;
/**
* 父类ID
*/
@TableField(value = "parent")
private String parent;
/**
* 说明
*/
@TableField(value = "remark")
private String remark;
/**
* 是否启用
*/
@TableField(value = "is_open")
private Integer isOpen;
/**
* 类型group-分组menu-菜单项point-点
*/
@TableField(value = "`type`")
private String type;
/**
* 跳转地址
*/
@TableField(value = "link")
private String link;
/**
* 平台ding、web、mobile等
*/
@TableField(value = "platform")
private String platform;
/**
* 扩展1
*/
@TableField(value = "ext1")
private String ext1;
/**
* 扩展2
*/
@TableField(value = "ext2")
private String ext2;
/**
* 扩展3
*/
@TableField(value = "ext3")
private String ext3;
/**
* 获取服务
*
* @return service - 服务
*/
public String getService() {
return service;
}
/**
* 设置服务
*
* @param service 服务
*/
public void setService(String service) {
this.service = service;
}
/**
* 获取编号
*
* @return no - 编号
*/
public String getNo() {
return no;
}
/**
* 设置编号
*
* @param no 编号
*/
public void setNo(String no) {
this.no = no;
}
/**
* 获取名称
*
* @return name - 名称
*/
public String getName() {
return name;
}
/**
* 设置名称
*
* @param name 名称
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取排序
*
* @return sort - 排序
*/
public Integer getSort() {
return sort;
}
/**
* 设置排序
*
* @param sort 排序
*/
public void setSort(Integer sort) {
this.sort = sort;
}
/**
* 获取层级
*
* @return level - 层级
*/
public Integer getLevel() {
return level;
}
/**
* 设置层级
*
* @param level 层级
*/
public void setLevel(Integer level) {
this.level = level;
}
/**
* 获取父类ID
*
* @return parent - 父类ID
*/
public String getParent() {
return parent;
}
/**
* 设置父类ID
*
* @param parent 父类ID
*/
public void setParent(String parent) {
this.parent = parent;
}
/**
* 获取说明
*
* @return remark - 说明
*/
public String getRemark() {
return remark;
}
/**
* 设置说明
*
* @param remark 说明
*/
public void setRemark(String remark) {
this.remark = remark;
}
/**
* 获取是否启用
*
* @return is_open - 是否启用
*/
public Integer getIsOpen() {
return isOpen;
}
/**
* 设置是否启用
*
* @param isOpen 是否启用
*/
public void setIsOpen(Integer isOpen) {
this.isOpen = isOpen;
}
/**
* 获取类型group-分组menu-菜单项point-点
*
* @return type - 类型group-分组menu-菜单项point-点
*/
public String getType() {
return type;
}
/**
* 设置类型group-分组menu-菜单项point-点
*
* @param type 类型group-分组menu-菜单项point-点
*/
public void setType(String type) {
this.type = type;
}
/**
* 获取跳转地址
*
* @return link - 跳转地址
*/
public String getLink() {
return link;
}
/**
* 设置跳转地址
*
* @param link 跳转地址
*/
public void setLink(String link) {
this.link = link;
}
/**
* 获取平台ding、web、mobile等
*
* @return platform - 平台ding、web、mobile等
*/
public String getPlatform() {
return platform;
}
/**
* 设置平台ding、web、mobile等
*
* @param platform 平台ding、web、mobile等
*/
public void setPlatform(String platform) {
this.platform = platform;
}
/**
* 获取扩展1
*
* @return ext1 - 扩展1
*/
public String getExt1() {
return ext1;
}
/**
* 设置扩展1
*
* @param ext1 扩展1
*/
public void setExt1(String ext1) {
this.ext1 = ext1;
}
/**
* 获取扩展2
*
* @return ext2 - 扩展2
*/
public String getExt2() {
return ext2;
}
/**
* 设置扩展2
*
* @param ext2 扩展2
*/
public void setExt2(String ext2) {
this.ext2 = ext2;
}
/**
* 获取扩展3
*
* @return ext3 - 扩展3
*/
public String getExt3() {
return ext3;
}
/**
* 设置扩展3
*
* @param ext3 扩展3
*/
public void setExt3(String ext3) {
this.ext3 = ext3;
}
}

View File

@@ -0,0 +1,206 @@
package com.tiesheng.role.pojos.dao;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tiesheng.util.pojos.DaoBase;
import java.util.Date;
/**
* 角色-分组
*/
@TableName(value = "core_role_group")
public class CoreRoleGroup extends DaoBase {
/**
* 名称
*/
@TableField(value = "`name`")
private String name;
/**
* 说明
*/
@TableField(value = "remark")
private String remark;
/**
* 类型role-角色job-职位
*/
@TableField(value = "`type`")
private String type;
/**
* 是否系统
*/
@TableField(value = "is_system")
private Integer isSystem;
/**
* 排序
*/
@TableField(value = "sort")
private Integer sort;
/**
* 扩展1
*/
@TableField(value = "ext1")
private String ext1;
/**
* 扩展2
*/
@TableField(value = "ext2")
private String ext2;
/**
* 扩展3
*/
@TableField(value = "ext3")
private String ext3;
/**
* 获取名称
*
* @return name - 名称
*/
public String getName() {
return name;
}
/**
* 设置名称
*
* @param name 名称
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取说明
*
* @return remark - 说明
*/
public String getRemark() {
return remark;
}
/**
* 设置说明
*
* @param remark 说明
*/
public void setRemark(String remark) {
this.remark = remark;
}
/**
* 获取类型role-角色job-职位
*
* @return type - 类型role-角色job-职位
*/
public String getType() {
return type;
}
/**
* 设置类型role-角色job-职位
*
* @param type 类型role-角色job-职位
*/
public void setType(String type) {
this.type = type;
}
/**
* 获取 是否系统
*
* @return is_system - 是否系统
*/
public Integer getIsSystem() {
return isSystem;
}
/**
* 设置 是否系统
*
* @param isSystem 是否系统
*/
public void setIsSystem(Integer isSystem) {
this.isSystem = isSystem;
}
/**
* 获取排序
*
* @return sort - 排序
*/
public Integer getSort() {
return sort;
}
/**
* 设置排序
*
* @param sort 排序
*/
public void setSort(Integer sort) {
this.sort = sort;
}
/**
* 获取扩展1
*
* @return ext1 - 扩展1
*/
public String getExt1() {
return ext1;
}
/**
* 设置扩展1
*
* @param ext1 扩展1
*/
public void setExt1(String ext1) {
this.ext1 = ext1;
}
/**
* 获取扩展2
*
* @return ext2 - 扩展2
*/
public String getExt2() {
return ext2;
}
/**
* 设置扩展2
*
* @param ext2 扩展2
*/
public void setExt2(String ext2) {
this.ext2 = ext2;
}
/**
* 获取扩展3
*
* @return ext3 - 扩展3
*/
public String getExt3() {
return ext3;
}
/**
* 设置扩展3
*
* @param ext3 扩展3
*/
public void setExt3(String ext3) {
this.ext3 = ext3;
}
}

View File

@@ -0,0 +1,62 @@
package com.tiesheng.role.pojos.dao;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tiesheng.util.pojos.DaoBase;
import java.util.Date;
/**
* 角色-分组-关系
*/
@TableName(value = "core_role_group_rx")
public class CoreRoleGroupRx extends DaoBase {
/**
* 角色id
*/
@TableField(value = "group_id")
private String groupId;
/**
* 菜单id
*/
@TableField(value = "menu_id")
private String menuId;
/**
* 获取角色id
*
* @return group_id - 角色id
*/
public String getGroupId() {
return groupId;
}
/**
* 设置角色id
*
* @param groupId 角色id
*/
public void setGroupId(String groupId) {
this.groupId = groupId;
}
/**
* 获取菜单id
*
* @return menu_id - 菜单id
*/
public String getMenuId() {
return menuId;
}
/**
* 设置菜单id
*
* @param menuId 菜单id
*/
public void setMenuId(String menuId) {
this.menuId = menuId;
}
}

View File

@@ -0,0 +1,230 @@
package com.tiesheng.role.pojos.dao;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tiesheng.util.pojos.DaoBase;
import java.util.Date;
/**
* 角色-服务
*/
@TableName(value = "core_role_server")
public class CoreRoleServer extends DaoBase {
/**
* 名称
*/
@TableField(value = "`name`")
private String name;
/**
* 说明
*/
@TableField(value = "remark")
private String remark;
/**
* logo
*/
@TableField(value = "logo")
private String logo;
/**
* 排序
*/
@TableField(value = "sort")
private Integer sort;
/**
* 是否启用
*/
@TableField(value = "is_open")
private Integer isOpen;
/**
* 跳转地址
*/
@TableField(value = "link")
private String link;
/**
* 扩展1
*/
@TableField(value = "ext1")
private String ext1;
/**
* 扩展2
*/
@TableField(value = "ext2")
private String ext2;
/**
* 扩展3
*/
@TableField(value = "ext3")
private String ext3;
/**
* 获取名称
*
* @return name - 名称
*/
public String getName() {
return name;
}
/**
* 设置名称
*
* @param name 名称
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取说明
*
* @return remark - 说明
*/
public String getRemark() {
return remark;
}
/**
* 设置说明
*
* @param remark 说明
*/
public void setRemark(String remark) {
this.remark = remark;
}
/**
* 获取logo
*
* @return logo - logo
*/
public String getLogo() {
return logo;
}
/**
* 设置logo
*
* @param logo logo
*/
public void setLogo(String logo) {
this.logo = logo;
}
/**
* 获取排序
*
* @return sort - 排序
*/
public Integer getSort() {
return sort;
}
/**
* 设置排序
*
* @param sort 排序
*/
public void setSort(Integer sort) {
this.sort = sort;
}
/**
* 获取是否启用
*
* @return is_open - 是否启用
*/
public Integer getIsOpen() {
return isOpen;
}
/**
* 设置是否启用
*
* @param isOpen 是否启用
*/
public void setIsOpen(Integer isOpen) {
this.isOpen = isOpen;
}
/**
* 获取跳转地址
*
* @return link - 跳转地址
*/
public String getLink() {
return link;
}
/**
* 设置跳转地址
*
* @param link 跳转地址
*/
public void setLink(String link) {
this.link = link;
}
/**
* 获取扩展1
*
* @return ext1 - 扩展1
*/
public String getExt1() {
return ext1;
}
/**
* 设置扩展1
*
* @param ext1 扩展1
*/
public void setExt1(String ext1) {
this.ext1 = ext1;
}
/**
* 获取扩展2
*
* @return ext2 - 扩展2
*/
public String getExt2() {
return ext2;
}
/**
* 设置扩展2
*
* @param ext2 扩展2
*/
public void setExt2(String ext2) {
this.ext2 = ext2;
}
/**
* 获取扩展3
*
* @return ext3 - 扩展3
*/
public String getExt3() {
return ext3;
}
/**
* 设置扩展3
*
* @param ext3 扩展3
*/
public void setExt3(String ext3) {
this.ext3 = ext3;
}
}

View File

@@ -1,28 +1,40 @@
package com.tiesheng.core.pojos.dao; package com.tiesheng.role.pojos.dao;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.tiesheng.core.pojos.DaoBase; import com.tiesheng.util.pojos.DaoBase;
import java.util.Date; import java.util.Date;
/** /**
* 职位-用户 * 角色-用户
*/ */
@TableName(value = "core_job_user") @TableName(value = "core_role_user")
public class CoreJobUser extends DaoBase { public class CoreRoleUser extends DaoBase {
/** /**
* 用户id * 用户ID
*/ */
@TableField(value = "user_id") @TableField(value = "user_id")
private String userId; private String userId;
/** /**
* 用户 * 类型menu-菜单group-分组
*/ */
@TableField(value = "job_id") @TableField(value = "`type`")
private String jobId; private String type;
/**
* 类型关联的记录ID
*/
@TableField(value = "type_id")
private String typeId;
/**
* 过期时间无则不过期
*/
@TableField(value = "expire_time")
private Date expireTime;
/** /**
* 扩展1 * 扩展1
@@ -43,45 +55,75 @@ public class CoreJobUser extends DaoBase {
private String ext3; private String ext3;
/** /**
* 扩展文本 * 获取用户ID
*/
@TableField(value = "ext_text")
private String extText;
/**
* 获取用户id
* *
* @return user_id - 用户id * @return user_id - 用户ID
*/ */
public String getUserId() { public String getUserId() {
return userId; return userId;
} }
/** /**
* 设置用户id * 设置用户ID
* *
* @param userId 用户id * @param userId 用户ID
*/ */
public void setUserId(String userId) { public void setUserId(String userId) {
this.userId = userId; this.userId = userId;
} }
/** /**
* 获取用户 * 获取类型menu-菜单group-分组
* *
* @return job_id - 用户 * @return type - 类型menu-菜单group-分组
*/ */
public String getJobId() { public String getType() {
return jobId; return type;
} }
/** /**
* 设置用户 * 设置类型menu-菜单group-分组
* *
* @param jobId 用户 * @param type 类型menu-菜单group-分组
*/ */
public void setJobId(String jobId) { public void setType(String type) {
this.jobId = jobId; this.type = type;
}
/**
* 获取类型关联的记录ID
*
* @return type_id - 类型关联的记录ID
*/
public String getTypeId() {
return typeId;
}
/**
* 设置类型关联的记录ID
*
* @param typeId 类型关联的记录ID
*/
public void setTypeId(String typeId) {
this.typeId = typeId;
}
/**
* 获取过期时间无则不过期
*
* @return expire_time - 过期时间无则不过期
*/
public Date getExpireTime() {
return expireTime;
}
/**
* 设置过期时间无则不过期
*
* @param expireTime 过期时间无则不过期
*/
public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
} }
/** /**
@@ -137,22 +179,4 @@ public class CoreJobUser extends DaoBase {
public void setExt3(String ext3) { public void setExt3(String ext3) {
this.ext3 = ext3; this.ext3 = ext3;
} }
/**
* 获取扩展文本
*
* @return ext_text - 扩展文本
*/
public String getExtText() {
return extText;
}
/**
* 设置扩展文本
*
* @param extText 扩展文本
*/
public void setExtText(String extText) {
this.extText = extText;
}
} }

View File

@@ -0,0 +1,22 @@
package com.tiesheng.role.pojos.dto;
import com.tiesheng.util.pojos.IdDTO;
import java.util.List;
public class GroupRxUpdateDTO extends IdDTO {
private List<String> menuIds;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public List<String> getMenuIds() {
return menuIds;
}
public void setMenuIds(List<String> menuIds) {
this.menuIds = menuIds;
}
}

View File

@@ -0,0 +1,18 @@
package com.tiesheng.role.pojos.dto;
public class MenuListDTO extends ServiceDTO {
private String platform;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
}

View File

@@ -0,0 +1,21 @@
package com.tiesheng.role.pojos.dto;
import javax.validation.constraints.NotEmpty;
public class OwnerMenuDTO extends ServiceDTO {
@NotEmpty(message = "请选择一个平台")
private String platform;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public @NotEmpty(message = "请选择一个平台") String getPlatform() {
return platform;
}
public void setPlatform(@NotEmpty(message = "请选择一个平台") String platform) {
this.platform = platform;
}
}

View File

@@ -0,0 +1,18 @@
package com.tiesheng.role.pojos.dto;
public class OwnerPointDTO extends OwnerMenuDTO {
private String parentNo;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getParentNo() {
return parentNo;
}
public void setParentNo(String parentNo) {
this.parentNo = parentNo;
}
}

View File

@@ -0,0 +1,22 @@
package com.tiesheng.role.pojos.dto;
import javax.validation.constraints.NotEmpty;
public class ServiceDTO {
@NotEmpty(message = "请选择一个服务")
private String service;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getService() {
return service;
}
public void setService(String service) {
this.service = service;
}
}

View File

@@ -0,0 +1,22 @@
package com.tiesheng.role.pojos.vo;
import javax.validation.constraints.NotEmpty;
public class GroupTypeDTO {
@NotEmpty(message = "请选择一个类型")
private String type;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@@ -0,0 +1,20 @@
package com.tiesheng.role.pojos.vo;
import com.tiesheng.role.pojos.dao.CoreRoleUser;
public class RoleUserPageVO extends CoreRoleUser {
private String typeName;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
}

View File

@@ -0,0 +1,22 @@
package com.tiesheng.role.pojos.vo;
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
import java.util.List;
public class ServiceMenuVO extends CoreRoleAuthority {
private List<ServiceMenuVO> children;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public List<ServiceMenuVO> getChildren() {
return children;
}
public void setChildren(List<ServiceMenuVO> children) {
this.children = children;
}
}

View File

@@ -0,0 +1,153 @@
package com.tiesheng.role.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiesheng.role.mapper.*;
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
import com.tiesheng.role.pojos.dao.CoreRoleGroup;
import com.tiesheng.role.pojos.dao.CoreRoleGroupRx;
import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO;
import com.tiesheng.role.pojos.dto.MenuListDTO;
import com.tiesheng.role.pojos.dto.OwnerMenuDTO;
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
import com.tiesheng.util.service.TsServiceBase;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRoleGroup> {
@Resource
CoreRoleUserMapper coreRoleUserMapper;
@Resource
CoreRoleGroupRxMapper coreRoleGroupRxMapper;
@Resource
CoreRoleAuthorityMapper coreRoleAuthorityMapper;
@Resource
CoreRoleServerMapper coreRoleServerMapper;
public CoreRoleServerMapper getServerMapper() {
return coreRoleServerMapper;
}
public CoreRoleAuthorityMapper getAuthorityMapper() {
return coreRoleAuthorityMapper;
}
public CoreRoleUserMapper getUserMapper() {
return coreRoleUserMapper;
}
public CoreRoleGroupRxMapper getGroupRxMapper() {
return coreRoleGroupRxMapper;
}
/**
* 菜单封装
*
* @param coreServiceMenuList
* @param parent
* @return
*/
public List<ServiceMenuVO> menuChildrenWrap(List<CoreRoleAuthority> coreServiceMenuList, String parent) {
List<CoreRoleAuthority> distinctList = coreServiceMenuList.stream().distinct().collect(Collectors.toList());
List<ServiceMenuVO> list = new ArrayList<>();
for (CoreRoleAuthority coreServiceMenu : distinctList) {
if (!StrUtil.equals(parent, coreServiceMenu.getParent())) {
continue;
}
ServiceMenuVO menuVO = BeanUtil.copyProperties(coreServiceMenu, ServiceMenuVO.class);
menuVO.setChildren(menuChildrenWrap(distinctList, coreServiceMenu.getId()));
list.add(menuVO);
}
return list;
}
/**
* 更新角色的权限
*
* @param dto
*/
@Transactional(rollbackFor = Exception.class)
public void updateGroupRx(GroupRxUpdateDTO dto) {
coreRoleGroupRxMapper.delete(new QueryWrapper<CoreRoleGroupRx>()
.eq("group_id", dto.getId())
);
List<CoreRoleGroupRx> list = new ArrayList<>();
for (String menuId : dto.getMenuIds()) {
CoreRoleGroupRx coreRoleGroupRx = new CoreRoleGroupRx();
coreRoleGroupRx.setGroupId(dto.getId());
coreRoleGroupRx.setMenuId(menuId);
list.add(coreRoleGroupRx);
}
coreRoleGroupRxMapper.batchInsert(list);
}
/**
* 获取拥有的所有叶子权限
*
* @return
*/
public List<CoreRoleAuthority> getOwnerAuthorityLeafList(String userId, String roleId) {
return coreRoleUserMapper.getOwnerAuthorityLeafList(userId, roleId);
}
/**
* 获取自己拥有的所有菜单
*
* @param userId
* @param roleId
* @return
*/
public List<ServiceMenuVO> getOwnerMenus(String userId, String roleId, OwnerMenuDTO dto) {
List<CoreRoleAuthority> allOwnerMenus = getOwnerAuthorityLeafList(userId, roleId);
List<CoreRoleAuthority> allRoleAuthorityList = coreRoleAuthorityMapper.selectList(new QueryWrapper<CoreRoleAuthority>()
.eq(CoreRoleAuthority.IS_DELETED, 0)
.eq("service", dto.getService())
.eq("platform", dto.getPlatform())
.eq("is_open", 1)
);
Map<Object, CoreRoleAuthority> allAuthorityMap = CollUtil.fieldValueMap(allRoleAuthorityList, "id");
List<CoreRoleAuthority> ownerAuthorityList = new ArrayList<>();
for (CoreRoleAuthority roleAuthority : allOwnerMenus) {
ownerAuthorityList.add(roleAuthority);
String parentId = roleAuthority.getParent();
while (StrUtil.isNotEmpty(parentId)) {
CoreRoleAuthority parent = allAuthorityMap.get(parentId);
if (parent == null) {
parentId = "";
} else {
parentId = parent.getParent();
ownerAuthorityList.add(parent);
}
}
}
return menuChildrenWrap(ownerAuthorityList.stream()
.filter(it -> Objects.equals(it.getType(), "group") || Objects.equals(it.getType(), "menu"))
.collect(Collectors.toList()), null);
}
}

View File

@@ -0,0 +1,95 @@
create table core_role_authority
(
id varchar(50) not null
primary key,
create_time datetime not null,
update_time datetime not null,
is_deleted int(6) default 0 not null,
service varchar(50) not null comment '服务',
no varchar(50) not null comment '编号',
name varchar(50) not null comment '名称',
sort int(6) default 0 null comment '排序',
level int(6) default 0 null comment '层级',
parent varchar(50) null comment '父类ID',
remark varchar(500) null comment '说明',
is_open int(6) default 0 null comment '是否启用',
type varchar(20) default 'item' not null comment '类型group-分组menu-菜单项point-点',
link text null comment '跳转地址',
platform varchar(20) null comment '平台ding、web、mobile等',
ext1 varchar(500) null comment '扩展1',
ext2 varchar(500) null comment '扩展2',
ext3 varchar(500) null comment '扩展3'
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
comment '角色-权限';
create table core_role_group
(
id varchar(50) not null
primary key,
create_time datetime not null,
update_time datetime not null,
is_deleted int(6) default 0 not null,
name varchar(50) not null comment '名称',
remark varchar(500) null comment '说明',
type varchar(10) null comment '类型role-角色job-职位',
is_system int(2) default 0 not null comment ' 是否系统',
sort int(6) default 0 not null comment '排序',
ext1 varchar(500) null comment '扩展1',
ext2 varchar(500) null comment '扩展2',
ext3 varchar(500) null comment '扩展3'
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
comment '角色-分组';
create table core_role_group_rx
(
id varchar(50) not null
primary key,
create_time datetime not null,
update_time datetime not null,
is_deleted int(6) default 0 not null,
group_id varchar(50) not null comment '角色id',
menu_id varchar(50) not null comment '菜单id'
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
comment '角色-分组-关系';
create table core_role_server
(
id varchar(50) not null
primary key,
create_time datetime not null,
update_time datetime not null,
is_deleted int(6) default 0 not null,
name varchar(255) null comment '名称',
remark varchar(500) null comment '说明',
logo varchar(500) null comment 'logo',
sort int(6) default 0 null comment '排序',
is_open int(2) default 1 not null comment '是否启用',
link varchar(500) null comment '跳转地址',
ext1 varchar(500) null comment '扩展1',
ext2 varchar(500) null comment '扩展2',
ext3 varchar(500) null comment '扩展3'
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
comment '角色-服务';
create table core_role_user
(
id varchar(50) not null
primary key,
create_time datetime not null,
update_time datetime not null,
is_deleted int(6) default 0 not null,
user_id varchar(50) not null comment '用户ID',
type varchar(50) not null comment '类型menu-菜单job-职位',
type_id varchar(50) not null comment '类型关联的记录ID',
expire_time datetime null comment '过期时间,无则不过期',
ext1 varchar(500) null comment '扩展1',
ext2 varchar(500) null comment '扩展2',
ext3 varchar(500) null comment '扩展3'
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
comment '角色-用户';

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tiesheng.role.mapper.CoreRoleAuthorityMapper">
<resultMap id="BaseResultMap" type="com.tiesheng.role.pojos.dao.CoreRoleAuthority">
<!--@mbg.generated-->
<!--@Table core_role_authority-->
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
<result column="service" jdbcType="VARCHAR" property="service" />
<result column="no" jdbcType="VARCHAR" property="no" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="level" jdbcType="INTEGER" property="level" />
<result column="parent" jdbcType="VARCHAR" property="parent" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="is_open" jdbcType="INTEGER" property="isOpen" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="link" jdbcType="LONGVARCHAR" property="link" />
<result column="platform" jdbcType="VARCHAR" property="platform" />
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
<result column="ext3" jdbcType="VARCHAR" property="ext3" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, create_time, update_time, is_deleted, service, `no`, `name`, sort, `level`, parent,
remark, is_open, `type`, link, platform, ext1, ext2, ext3
</sql>
</mapper>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tiesheng.role.mapper.CoreRoleGroupMapper">
<resultMap id="BaseResultMap" type="com.tiesheng.role.pojos.dao.CoreRoleGroup">
<!--@mbg.generated-->
<!--@Table core_role_group-->
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="is_system" jdbcType="INTEGER" property="isSystem" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
<result column="ext3" jdbcType="VARCHAR" property="ext3" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, create_time, update_time, is_deleted, `name`, remark, `type`, is_system, sort,
ext1, ext2, ext3
</sql>
</mapper>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tiesheng.role.mapper.CoreRoleGroupRxMapper">
<resultMap id="BaseResultMap" type="com.tiesheng.role.pojos.dao.CoreRoleGroupRx">
<!--@mbg.generated-->
<!--@Table core_role_group_rx-->
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
<result column="group_id" jdbcType="VARCHAR" property="groupId" />
<result column="menu_id" jdbcType="VARCHAR" property="menuId" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, create_time, update_time, is_deleted, group_id, menu_id
</sql>
<insert id="batchInsert">
insert into core_role_group_rx(id, create_time, update_time, is_deleted, group_id, menu_id)
values
<foreach collection="list" separator="," item="item">
(uuid(), now(), now(), 0,
#{item.groupId},
#{item.menuId})
</foreach>
</insert>
</mapper>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tiesheng.role.mapper.CoreRoleServerMapper">
<resultMap id="BaseResultMap" type="com.tiesheng.role.pojos.dao.CoreRoleServer">
<!--@mbg.generated-->
<!--@Table core_role_server-->
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="logo" jdbcType="VARCHAR" property="logo" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="is_open" jdbcType="INTEGER" property="isOpen" />
<result column="link" jdbcType="VARCHAR" property="link" />
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
<result column="ext3" jdbcType="VARCHAR" property="ext3" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, create_time, update_time, is_deleted, `name`, remark, logo, sort, is_open, link,
ext1, ext2, ext3
</sql>
</mapper>

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tiesheng.role.mapper.CoreRoleUserMapper">
<resultMap id="BaseResultMap" type="com.tiesheng.role.pojos.dao.CoreRoleUser">
<!--@mbg.generated-->
<!--@Table core_role_user-->
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="type_id" jdbcType="VARCHAR" property="typeId" />
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
<result column="ext3" jdbcType="VARCHAR" property="ext3" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, create_time, update_time, is_deleted, user_id, `type`, type_id, expire_time,
ext1, ext2, ext3
</sql>
<select id="page" resultType="com.tiesheng.role.pojos.vo.RoleUserPageVO">
select *,
(case cru.type
when 'menu' then (select name from core_role_authority where id = cru.type_id and is_deleted = 0)
when 'job' then (select name from core_role_group where id = cru.type_id and is_deleted = 0)
else '' end) type_name
from core_role_user cru
${ew.customSqlSegment}
</select>
<select id="getOwnerAuthorityLeafList" resultType="com.tiesheng.role.pojos.dao.CoreRoleAuthority">
select *
from core_role_authority
where is_open = 1
and is_deleted = 0
and
id in (select type_id
from core_role_user
where type = 'menu'
and user_id = #{userId}
and is_deleted = 0
and (expire_time is null or expire_time > now())
union
select crgr.menu_id
from core_role_user cru
left join core_role_group_rx crgr on crgr.group_id = cru.type_id
where type = 'job'
and user_id = #{userId}
and cru.is_deleted = 0
and (cru.expire_time is null or cru.expire_time > now())
<if test="roleId != null and roleId != ''">
union
select menu_id
from core_role_group_rx
where group_id = #{roleId}
</if>
)
order by sort
</select>
</mapper>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>
@@ -36,6 +36,24 @@
<version>5.8.16</version> <version>5.8.16</version>
</dependency> </dependency>
<!-- MySql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<!-- fastJson --> <!-- fastJson -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>

View File

@@ -0,0 +1,44 @@
package com.tiesheng.util;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import java.util.Map;
public class CharacterUtils {
/**
* 移除特殊字符
*
* @param o 类
*/
public static void removeSymbol(Object o) {
removeSymbol(o, "\n|\r|\t| ");
}
/**
* 移除特殊字符
*
* @param o 类
* @param searchStr 规则
*/
public static void removeSymbol(Object o, String searchStr) {
JSONObject object = JSONUtil.parseObj(o, false);
for (Map.Entry<String, Object> entry : object) {
if (ObjectUtil.isEmpty(entry.getValue()) || StrUtil.equals("null", String.valueOf(entry.getValue()))) {
entry.setValue("");
continue;
}
if (StrUtil.isNotEmpty(entry.getKey())) {
entry.setValue(StrUtil.trim(StrUtil.replace(entry.getValue().toString(), searchStr, "")));
}
}
BeanUtil.copyProperties(object, o);
}
}

View File

@@ -26,7 +26,8 @@ public class ServletKit extends ServletUtil {
* @return * @return
*/ */
public static String getClientIP() { public static String getClientIP() {
return getClientIP(getRequest()); HttpServletRequest request = getRequest();
return getClientIP(request);
} }

View File

@@ -30,6 +30,7 @@ public class EncryptConfig {
*/ */
private String key = "WmdUzPJXbngVNiaSsQrihg=="; private String key = "WmdUzPJXbngVNiaSsQrihg==";
private Integer saltSize = 8; private Integer saltSize = 8;
private boolean body = false;
public EncryptConfig() { public EncryptConfig() {
sm4 = SmUtil.sm4(Base64.decode(getKey())); sm4 = SmUtil.sm4(Base64.decode(getKey()));
@@ -72,7 +73,7 @@ public class EncryptConfig {
* @return * @return
*/ */
public String passwdCreate(String inputPasswd, String salt) { public String passwdCreate(String inputPasswd, String salt) {
if (StrUtil.isEmpty(salt)) { if (StrUtil.isEmpty(salt) || StrUtil.length(salt) != getSaltSize()) {
salt = RandomUtil.randomString(saltSize); salt = RandomUtil.randomString(saltSize);
} }
if (!passwdComplexity(inputPasswd)) { if (!passwdComplexity(inputPasswd)) {
@@ -133,4 +134,12 @@ public class EncryptConfig {
public void setSaltSize(Integer saltSize) { public void setSaltSize(Integer saltSize) {
this.saltSize = saltSize; this.saltSize = saltSize;
} }
public boolean isBody() {
return body;
}
public void setBody(boolean body) {
this.body = body;
}
} }

View File

@@ -4,8 +4,9 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.comparator.VersionComparator; import cn.hutool.core.comparator.VersionComparator;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.http.HttpGlobalConfig;
import cn.hutool.log.LogFactory; import cn.hutool.log.LogFactory;
import com.tiesheng.util.exception.ApiException; import com.tiesheng.util.exception.ApiException;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -13,10 +14,12 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
@@ -31,10 +34,37 @@ public class GlobalConfig {
private String version; private String version;
private String uploadDir = System.getProperty("user.dir"); private String uploadDir = System.getProperty("user.dir");
/**
* 其他属性
*/
private HashMap<String, String> ext;
@PostConstruct
public void init() {
// 默认10s的超时时间
HttpGlobalConfig.setTimeout(10 * 1000);
// 最多重定向3次
HttpGlobalConfig.setMaxRedirectCount(3);
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// 逻辑方法 // 逻辑方法
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/**
* 获取扩展属性内容
*
* @param extkey
* @return
*/
public String getExtValue(String extkey) {
if (getExt() == null) {
return "";
}
return getExt().get(extkey);
}
public String getContextPath() { public String getContextPath() {
String context = SpringUtil.getProperty("server.servlet.context-path"); String context = SpringUtil.getProperty("server.servlet.context-path");
if (StrUtil.isEmpty(context)) { if (StrUtil.isEmpty(context)) {
@@ -87,7 +117,8 @@ public class GlobalConfig {
if (FileUtil.exist(folder)) { if (FileUtil.exist(folder)) {
File[] files = FileUtil.ls(folder); File[] files = FileUtil.ls(folder);
for (File file : files) { for (File file : files) {
versions.add(StrUtil.subAfter(file.getAbsolutePath(), htmlDir, true)); String normalize = FileUtil.normalize(file.getAbsolutePath());
versions.add(StrUtil.subAfter(normalize, htmlDir, true));
} }
} }
@@ -138,4 +169,12 @@ public class GlobalConfig {
public void setVersion(String version) { public void setVersion(String version) {
this.version = version; this.version = version;
} }
public HashMap<String, String> getExt() {
return ext;
}
public void setExt(HashMap<String, String> ext) {
this.ext = ext;
}
} }

View File

@@ -1,4 +1,4 @@
package com.tiesheng.login.config.token; package com.tiesheng.util.config;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
@@ -7,9 +7,9 @@ import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.jwt.JWT; import cn.hutool.jwt.JWT;
import cn.hutool.jwt.JWTValidator; import cn.hutool.jwt.JWTValidator;
import com.tiesheng.login.config.token.bean.TokenBean;
import com.tiesheng.util.ServletKit; import com.tiesheng.util.ServletKit;
import com.tiesheng.util.exception.ApiException; import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.TokenBean;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@@ -27,6 +27,7 @@ public class TsTokenConfig {
private String encryptKey = "%kIp9frQCu"; private String encryptKey = "%kIp9frQCu";
private Integer expireHours = 48; private Integer expireHours = 48;
private String[] ignorePaths; private String[] ignorePaths;
private boolean validLoginSign = false;
/** /**
@@ -94,8 +95,10 @@ public class TsTokenConfig {
String id = decode.getPayload("id").toString(); String id = decode.getPayload("id").toString();
String environmentType = decode.getPayload("environmentType").toString(); String environmentType = decode.getPayload("environmentType").toString();
String service = decode.getPayload("service").toString(); String service = decode.getPayload("service").toString();
String extra = decode.getPayload("extra").toString(); String extra = StrUtil.toStringOrNull(decode.getPayload("extra"));
String roleId = StrUtil.toStringOrNull(decode.getPayload("roleId"));
tokenBean = new TokenBean(id, environmentType, service); tokenBean = new TokenBean(id, environmentType, service);
tokenBean.setRoleId(roleId);
tokenBean.setExtra(extra); tokenBean.setExtra(extra);
} catch (Exception ignored) { } catch (Exception ignored) {
} }
@@ -148,4 +151,12 @@ public class TsTokenConfig {
public void setIgnorePaths(String[] ignorePaths) { public void setIgnorePaths(String[] ignorePaths) {
this.ignorePaths = ignorePaths; this.ignorePaths = ignorePaths;
} }
public boolean isValidLoginSign() {
return validLoginSign;
}
public void setValidLoginSign(boolean validLoginSign) {
this.validLoginSign = validLoginSign;
}
} }

View File

@@ -179,7 +179,7 @@ public class Searcher {
this.ioCount = 0; this.ioCount = 0;
// locate the segment index block based on the vector index // locate the segment index block based on the vector index
int sPtr = 0, ePtr = 0; int sPtr, ePtr;
int il0 = (int) ((ip >> 24) & 0xFF); int il0 = (int) ((ip >> 24) & 0xFF);
int il1 = (int) ((ip >> 16) & 0xFF); int il1 = (int) ((ip >> 16) & 0xFF);
int idx = il0 * VectorIndexCols * VectorIndexSize + il1 * VectorIndexSize; int idx = il0 * VectorIndexCols * VectorIndexSize + il1 * VectorIndexSize;

View File

@@ -1,4 +1,4 @@
package com.tiesheng.core.pojos; package com.tiesheng.util.pojos;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
@@ -9,6 +9,12 @@ import java.util.Date;
public class DaoBase { public class DaoBase {
public static final String ID = "id";
public static final String CREATE_TIME = "create_time";
public static final String UPDATE_TIME = "update_time";
public static final String IS_DELETED = "is_deleted";
public static final String LIMIT_1 = "limit 1";
@TableId(value = "id", type = IdType.ASSIGN_ID) @TableId(value = "id", type = IdType.ASSIGN_ID)
private String id; private String id;

View File

@@ -1,4 +1,4 @@
package com.tiesheng.core.pojos.dto; package com.tiesheng.util.pojos;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;

View File

@@ -1,4 +1,4 @@
package com.tiesheng.core.pojos.dto; package com.tiesheng.util.pojos;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

View File

@@ -1,9 +1,10 @@
package com.tiesheng.login.config.token.bean; package com.tiesheng.util.pojos;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.jwt.JWT; import cn.hutool.jwt.JWT;
import com.tiesheng.login.config.token.TsTokenConfig; import com.tiesheng.util.config.TsTokenConfig;
/** /**
* @author hao * @author hao
@@ -13,6 +14,7 @@ public class TokenBean {
private String id; private String id;
private String environmentType; private String environmentType;
private String service; private String service;
private String roleId;
private String extra; private String extra;
public TokenBean() { public TokenBean() {
@@ -22,6 +24,7 @@ public class TokenBean {
this.id = id; this.id = id;
this.environmentType = environmentType; this.environmentType = environmentType;
this.service = service; this.service = service;
this.roleId = "";
this.extra = ""; this.extra = "";
} }
@@ -34,9 +37,10 @@ public class TokenBean {
return JWT.create() return JWT.create()
.setExpiresAt(DateUtil.offsetHour(DateUtil.date(), tsTokenConfig.getExpireHours())) .setExpiresAt(DateUtil.offsetHour(DateUtil.date(), tsTokenConfig.getExpireHours()))
.setPayload("id", getId()) .setPayload("id", getId())
.setPayload("environmentType", getEnvironmentType()) .setPayload("environmentType", StrUtil.emptyToDefault(getEnvironmentType(), ""))
.setPayload("service", getService()) .setPayload("service", StrUtil.emptyToDefault(getService(), ""))
.setPayload("extra", getExtra()) .setPayload("roleId", StrUtil.emptyToDefault(getRoleId(), ""))
.setPayload("extra", StrUtil.emptyToDefault(getExtra(), ""))
.setKey(tsTokenConfig.getEncryptKey().getBytes()) .setKey(tsTokenConfig.getEncryptKey().getBytes())
.sign(); .sign();
} }
@@ -76,4 +80,12 @@ public class TokenBean {
public void setExtra(String extra) { public void setExtra(String extra) {
this.extra = extra; this.extra = extra;
} }
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
} }

View File

@@ -1,4 +1,4 @@
package com.tiesheng.core.service; package com.tiesheng.util.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>2.0.0.rc2</version>
</parent> </parent>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>
@@ -39,24 +39,6 @@
<artifactId>spring-boot-starter-aop</artifactId> <artifactId>spring-boot-starter-aop</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- MySql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
</dependency>
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>

View File

@@ -1,15 +0,0 @@
package com.tiesheng.core;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.ComponentScan;
/**
* @author hao
*/
@ComponentScan({
"com.tiesheng.core.**.*",
})
@MapperScan("com.tiesheng.core.mapper")
public class CoreAutoConfigurer {
}

View File

@@ -1,120 +0,0 @@
package com.tiesheng.core.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiesheng.core.pojos.dao.CoreJob;
import com.tiesheng.core.pojos.dto.IdDTO;
import com.tiesheng.core.pojos.dto.PageDTO;
import com.tiesheng.core.pojos.dto.job.JobUpdateDTO;
import com.tiesheng.core.pojos.dto.job.JobUpdateRxDTO;
import com.tiesheng.core.pojos.dto.job.JobUserAssignDTO;
import com.tiesheng.core.pojos.dto.job.JobUserOwner;
import com.tiesheng.core.service.CoreJobService;
import com.tiesheng.login.config.token.TsTokenConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @author hao
*/
@RestController
@RequestMapping("/job")
public class JobController {
@Autowired
CoreJobService coreJobService;
/**
* 获取职位列表
*
* @return
*/
@GetMapping("/list")
public ApiResp<List<CoreJob>> list(PageDTO dto) {
QueryWrapper<CoreJob> queryWrapper = new QueryWrapper<CoreJob>().eq("is_deleted", 0);
dto.likeColumns(queryWrapper, "name");
List<CoreJob> jobList = coreJobService.list(queryWrapper);
return ApiResp.respOK(jobList);
}
/**
* 添加、编辑职位
*
* @return
*/
@PostMapping("/update")
public ApiResp<String> update(@Valid @RequestBody JobUpdateDTO dto) {
CoreJob job = BeanUtil.copyProperties(dto, CoreJob.class);
if (!StrUtil.isEmpty(job.getId())) {
CoreJob byId = coreJobService.getById(job.getId());
if (byId != null && byId.getIsSystem() == 1) {
throw new ApiException("系统配置,无法编辑");
}
}
coreJobService.saveOrUpdate(job);
return ApiResp.respOK("");
}
/**
* 获取关系
*
* @param dto
* @return
*/
@GetMapping("/func/rx")
public ApiResp<List<String>> funcRx(@Valid IdDTO dto) {
List<String> list = coreJobService.getBaseMapper().getJobFunc(dto.getId(), null);
return ApiResp.respOK(list);
}
/**
* 更新职位关系
*
* @return
*/
@PostMapping("/func/rx")
public ApiResp<String> updateJobRx(@Valid @RequestBody JobUpdateRxDTO dto) {
coreJobService.updateJobRx(dto.getJobId(), StrUtil.split(dto.getPoints(), ","));
return ApiResp.respOK("");
}
/**
* 用户职位分配
*
* @return
*/
@PostMapping("/user/assign")
public ApiResp<String> userAssign(@Valid @RequestBody JobUserAssignDTO dto) {
coreJobService.userAssign(dto.getUserId(), dto.getJobId());
return ApiResp.respOK("");
}
/**
* 获取用户自己的
*
* @return
*/
@GetMapping("/user/owner")
public ApiResp<List<JobUserOwner>> userOwner() {
List<JobUserOwner> coreJobUsers = coreJobService.getJobUserMapper().list(TsTokenConfig.get().getId());
coreJobUsers.forEach(it -> {
List<String> list = coreJobService.getBaseMapper().getJobFunc(it.getJobId(), 1);
it.setPoints(list);
});
return ApiResp.respOK(coreJobUsers);
}
}

View File

@@ -1,11 +0,0 @@
package com.tiesheng.core.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tiesheng.core.pojos.dao.CoreConfigFunc;
import com.tiesheng.util.pojos.IdName;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CoreConfigFuncMapper extends BaseMapper<CoreConfigFunc> {
}

View File

@@ -1,36 +0,0 @@
package com.tiesheng.core.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tiesheng.core.pojos.dao.CoreJob;
import com.tiesheng.util.pojos.IdName;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CoreJobMapper extends BaseMapper<CoreJob> {
/**
* 清除职位的关联关系
*
* @param jobId
*/
void clearJobFunc(@Param("jobId") String jobId);
/**
* 更新关联关系
*
* @param pointList
*/
void updateJobFunc(@Param("list") List<IdName> pointList);
/**
* 获取关联的func
*
* @param jobId
* @return
*/
List<String> getJobFunc(@Param("jobId") String jobId, @Param("isUsed") Integer isUsed);
}

View File

@@ -1,18 +0,0 @@
package com.tiesheng.core.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tiesheng.core.pojos.dao.CoreJobUser;
import com.tiesheng.core.pojos.dto.job.JobUserOwner;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CoreJobUserMapper extends BaseMapper<CoreJobUser> {
/**
* 获取指定用户的职位和功能点
*
* @param userId
* @return
*/
List<JobUserOwner> list(@Param("userId") String userId);
}

View File

@@ -1,8 +0,0 @@
package com.tiesheng.core.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tiesheng.core.pojos.dao.CoreLogOperation;
public interface CoreLogOperationMapper extends BaseMapper<CoreLogOperation> {
}

View File

@@ -1,110 +0,0 @@
package com.tiesheng.core.pojos.dao;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tiesheng.core.pojos.DaoBase;
import java.util.Date;
/**
* 职位-功能点
*/
@TableName(value = "core_config_func")
public class CoreConfigFunc extends DaoBase {
/**
* 业务
*/
@TableField(value = "service")
private String service;
/**
* 名称
*/
@TableField(value = "`name`")
private String name;
/**
* 其他说明
*/
@TableField(value = "remark")
private String remark;
/**
* 是否启用
*/
@TableField(value = "is_used")
private Integer isUsed;
/**
* 获取业务
*
* @return service - 业务
*/
public String getService() {
return service;
}
/**
* 设置业务
*
* @param service 业务
*/
public void setService(String service) {
this.service = service;
}
/**
* 获取名称
*
* @return name - 名称
*/
public String getName() {
return name;
}
/**
* 设置名称
*
* @param name 名称
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取其他说明
*
* @return remark - 其他说明
*/
public String getRemark() {
return remark;
}
/**
* 设置其他说明
*
* @param remark 其他说明
*/
public void setRemark(String remark) {
this.remark = remark;
}
/**
* 获取是否启用
*
* @return is_used - 是否启用
*/
public Integer getIsUsed() {
return isUsed;
}
/**
* 设置是否启用
*
* @param isUsed 是否启用
*/
public void setIsUsed(Integer isUsed) {
this.isUsed = isUsed;
}
}

View File

@@ -1,86 +0,0 @@
package com.tiesheng.core.pojos.dao;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tiesheng.core.pojos.DaoBase;
import java.util.Date;
/**
* 职位
*/
@TableName(value = "core_job")
public class CoreJob extends DaoBase {
/**
* 名称
*/
@TableField(value = "`name`")
private String name;
/**
* 其他说明
*/
@TableField(value = "remark")
private String remark;
/**
* 是否系统
*/
@TableField(value = "is_system")
private Integer isSystem;
/**
* 获取名称
*
* @return name - 名称
*/
public String getName() {
return name;
}
/**
* 设置名称
*
* @param name 名称
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取其他说明
*
* @return remark - 其他说明
*/
public String getRemark() {
return remark;
}
/**
* 设置其他说明
*
* @param remark 其他说明
*/
public void setRemark(String remark) {
this.remark = remark;
}
/**
* 获取是否系统
*
* @return is_system - 是否系统
*/
public Integer getIsSystem() {
return isSystem;
}
/**
* 设置是否系统
*
* @param isSystem 是否系统
*/
public void setIsSystem(Integer isSystem) {
this.isSystem = isSystem;
}
}

View File

@@ -1,45 +0,0 @@
package com.tiesheng.core.pojos.dto.config;
public class ConfigFuncDTO {
private String id;
private String name;
private String remark;
private Integer isUsed;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Integer getIsUsed() {
return isUsed;
}
public void setIsUsed(Integer isUsed) {
this.isUsed = isUsed;
}
}

View File

@@ -1,40 +0,0 @@
package com.tiesheng.core.pojos.dto.job;
import javax.validation.constraints.NotEmpty;
public class JobUpdateDTO {
private String id;
@NotEmpty(message = "请输入职位名称")
private String name;
private String remark;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

View File

@@ -1,30 +0,0 @@
package com.tiesheng.core.pojos.dto.job;
import javax.validation.constraints.NotEmpty;
public class JobUpdateRxDTO {
@NotEmpty(message = "请选择职位")
private String jobId;
private String points;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public String getPoints() {
return points;
}
public void setPoints(String points) {
this.points = points;
}
}

View File

@@ -1,31 +0,0 @@
package com.tiesheng.core.pojos.dto.job;
import javax.validation.constraints.NotEmpty;
public class JobUserAssignDTO {
@NotEmpty(message = "请选择用户")
private String userId;
@NotEmpty(message = "请选择职位")
private String jobId;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
}

View File

@@ -1,40 +0,0 @@
package com.tiesheng.core.pojos.dto.job;
import com.tiesheng.util.pojos.IdName;
import java.util.List;
public class JobUserOwner {
private String jobId;
private String jobName;
private List<String> points;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public String getJobName() {
return jobName;
}
public void setJobName(String jobName) {
this.jobName = jobName;
}
public List<String> getPoints() {
return points;
}
public void setPoints(List<String> points) {
this.points = points;
}
}

View File

@@ -1,52 +0,0 @@
package com.tiesheng.core.service;
import com.tiesheng.core.mapper.CoreConfigEnumMapper;
import com.tiesheng.core.mapper.CoreConfigFuncMapper;
import com.tiesheng.core.mapper.CoreConfigSystemMapper;
import com.tiesheng.core.pojos.dao.CoreConfigFunc;
import com.tiesheng.core.pojos.dao.CoreConfigSystem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author hao
*/
@Service
public class CoreConfigService extends TsServiceBase<CoreConfigSystemMapper, CoreConfigSystem> {
@Autowired
CoreConfigEnumMapper coreConfigEnumMapper;
@Autowired
CoreConfigFuncMapper coreConfigFuncMapper;
public CoreConfigEnumMapper getEnumMapper() {
return coreConfigEnumMapper;
}
public CoreConfigFuncMapper getFuncMapper() {
return coreConfigFuncMapper;
}
/**
* 刷新功能点
*
* @param id
* @param service
* @param name
* @param remark
*/
public void refreshFunc(String id, String service, String name, String remark) {
CoreConfigFunc jobPoint = new CoreConfigFunc();
jobPoint.setId(id);
jobPoint.setService(service);
jobPoint.setName(name);
jobPoint.setRemark(remark);
try {
coreConfigFuncMapper.insert(jobPoint);
} catch (Exception e) {
coreConfigFuncMapper.updateById(jobPoint);
}
}
}

View File

@@ -1,97 +0,0 @@
package com.tiesheng.core.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiesheng.core.mapper.CoreJobMapper;
import com.tiesheng.core.mapper.CoreJobUserMapper;
import com.tiesheng.core.pojos.dao.CoreJob;
import com.tiesheng.core.pojos.dao.CoreJobUser;
import com.tiesheng.util.pojos.IdName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author hao
*/
@Service
public class CoreJobService extends TsServiceBase<CoreJobMapper, CoreJob> {
@Autowired
CoreJobUserMapper coreJobUserMapper;
public CoreJobUserMapper getJobUserMapper() {
return coreJobUserMapper;
}
/**
* 刷新职位
*
* @param name
* @param remark
* @param isSystem
*/
public void refresh(String id, String name, String remark, Integer isSystem) {
CoreJob coreJob = new CoreJob();
coreJob.setId(id);
coreJob.setName(name);
coreJob.setRemark(remark);
coreJob.setIsSystem(isSystem);
saveOrUpdate(coreJob);
}
/**
* 更新关联关系
*
* @param jobId
* @param points
*/
public void updateJobRx(String jobId, List<String> points) {
List<IdName> nameList = new ArrayList<>();
for (String s : points) {
IdName id = new IdName();
id.setId(IdUtil.getSnowflakeNextIdStr());
id.setName(jobId);
id.setExtra(s);
nameList.add(id);
}
if (StrUtil.isEmpty(jobId)) {
return;
}
getBaseMapper().clearJobFunc(jobId);
if (CollUtil.isNotEmpty(nameList)) {
getBaseMapper().updateJobFunc(nameList);
}
}
/**
* 分配职位
*
* @param userId
* @param jobId
*/
public void userAssign(String userId, String jobId) {
CoreJobUser jobUser = coreJobUserMapper.selectOne(new QueryWrapper<CoreJobUser>()
.eq("is_deleted", 0)
.eq("user_id", userId)
.eq("job_id", jobId)
);
if (jobUser == null) {
jobUser = new CoreJobUser();
}
jobUser.setUserId(userId);
jobUser.setJobId(jobId);
if (StrUtil.isEmpty(jobUser.getId())) {
coreJobUserMapper.insert(jobUser);
} else {
coreJobUserMapper.updateById(jobUser);
}
}
}

View File

@@ -1,10 +1,11 @@
package com.tiesheng.core; package com.tiesheng.web;
import com.tiesheng.core.service.TieshengWebConfigurer;
import com.tiesheng.database.DatabaseAutoConfigurer; import com.tiesheng.database.DatabaseAutoConfigurer;
import com.tiesheng.encrypt.EncryptAutoConfigurer;
import com.tiesheng.login.LoginAutoConfigurer; import com.tiesheng.login.LoginAutoConfigurer;
import com.tiesheng.message.MessageAutoConfigurer; import com.tiesheng.message.MessageAutoConfigurer;
import com.tiesheng.util.UtilAutoConfigurer; import com.tiesheng.util.UtilAutoConfigurer;
import com.tiesheng.web.service.TieshengWebConfigurer;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import java.lang.annotation.*; import java.lang.annotation.*;
@@ -18,9 +19,10 @@ import java.lang.annotation.*;
@Import({ @Import({
UtilAutoConfigurer.class, UtilAutoConfigurer.class,
MessageAutoConfigurer.class, MessageAutoConfigurer.class,
CoreAutoConfigurer.class, WebAutoConfigurer.class,
LoginAutoConfigurer.class, LoginAutoConfigurer.class,
DatabaseAutoConfigurer.class DatabaseAutoConfigurer.class,
EncryptAutoConfigurer.class,
}) })
public @interface EnableTieshengWeb { public @interface EnableTieshengWeb {

View File

@@ -0,0 +1,16 @@
package com.tiesheng.web;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.ComponentScan;
/**
* @author hao
*/
@ComponentScan({
"com.tiesheng.web.**.*",
"com.tiesheng.role.**.*",
})
@MapperScan(value = {"com.tiesheng.web.mapper", "com.tiesheng.role.mapper"})
public class WebAutoConfigurer {
}

View File

@@ -1,8 +1,8 @@
package com.tiesheng.core.config.exception; package com.tiesheng.web.config.exception;
import cn.hutool.core.exceptions.ValidateException; import cn.hutool.core.exceptions.ValidateException;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.tiesheng.core.service.TieshengWebConfigurer; import com.tiesheng.web.service.TieshengWebConfigurer;
import com.tiesheng.util.exception.ApiException; import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.exception.ApiRespEnum; import com.tiesheng.util.exception.ApiRespEnum;
import com.tiesheng.util.pojos.ApiResp; import com.tiesheng.util.pojos.ApiResp;

View File

@@ -1,4 +1,4 @@
package com.tiesheng.core.config.json; package com.tiesheng.web.config.json;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.tiesheng.util.CommonUtil; import com.tiesheng.util.CommonUtil;

View File

@@ -1,4 +1,4 @@
package com.tiesheng.core.config.mybatis; package com.tiesheng.web.config.mybatis;
import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;

Some files were not shown because too many files have changed in this diff Show More