95 Commits

Author SHA1 Message Date
zhuoda
f127f02c96 v3.18.0 【新增】新增消息管理;【新增】完善企业demo;【新增】完善相关数据权限;【新增】菜单管理下级功能 2025-04-10 21:30:13 +08:00
zhuoda
6583f5f90d v3.18.0 【新增】新增消息管理;【新增】完善企业demo;【新增】完善相关数据权限;【新增】菜单管理下级功能 2025-04-10 21:27:09 +08:00
1024创新实验室
d6a53f03b7 v3.18.0 【新增】新增消息管理;【新增】完善企业demo;【新增】完善相关数据权限;【新增】菜单管理下级功能 2025-04-10 13:22:28 +00:00
zhuoda
caf8e3aa25 v3.18.0 【新增】新增消息管理;【新增】完善企业demo;【新增】完善相关数据权限;【新增】菜单管理下级功能 2025-04-10 21:21:37 +08:00
zhoumingfa
97cfdf1f57 完善企业管理demo 2025-04-08 22:00:30 +08:00
zhoumingfa
8bb9f173eb 完善数据字典管理,更新相应的权限字符串 2025-04-08 20:28:59 +08:00
zhuoda
7ea97f8433 v3.17.0 【新增】新增菜单展开1个配置;【新增】移除表格固定高度;【新增】App登录token模式 2025-04-08 20:19:41 +08:00
zhoumingfa
e7927bb948 更正前端权限插件的判断 2025-04-08 19:52:47 +08:00
zhoumingfa
79fc04d8cb 菜单管理新增添加下级功能 2025-04-08 19:52:07 +08:00
zhoumingfa
393cb325c7 解决代码生成的查询条件列表拖拽报错问题 2025-04-08 17:30:20 +08:00
1024创新实验室
33c93ae365 v3.16.0 【新增】优化代码生成 字典和文件预览;【新增】代码生成 菜单SQL;【新增】登录页面GIF炫酷图片;
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-04-06 14:15:37 +00:00
1024创新实验室
3c2c3cf81b v3.16.0 【新增】优化代码生成 字典和文件预览;【新增】代码生成 菜单SQL;【新增】登录页面GIF炫酷图片;
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-04-06 13:01:35 +00:00
zhuoda
ec8fb1d69d v3.16.0 【新增】优化代码生成 字典和文件预览;【新增】代码生成 菜单SQL;【新增】登录页面GIF炫酷图片 2025-04-06 20:59:16 +08:00
zhuoda
d4f1806491 v3.16.0 【新增】优化代码生成 字典和文件预览;【新增】代码生成 菜单SQL;【新增】登录页面GIF炫酷图片; 2025-04-06 20:28:10 +08:00
zhuoda
ce0551696a v3.16.0 【新增】优化代码生成 字典和文件预览;【新增】代码生成 菜单SQL;【新增】登录页面GIF炫酷图片; 2025-04-06 20:25:06 +08:00
1024创新实验室
1abe2ee05e !64 优化代码生成模块,使其适配当前版本
Merge pull request !64 from 大熊/master
2025-04-05 08:41:51 +00:00
zhuoda
cead60b406 v3.15.0【新增】升级SaToken到最新版本;【新增】重磅优化 数据字典;【新增】升级wangEditor-next;【新增】优化缓存 2025-04-03 22:30:18 +08:00
1024创新实验室
9445ad3cf6 v3.15.0【新增】升级SaToken到最新版本;【新增】重磅优化 数据字典;【新增】升级wangEditor-next;
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-04-03 14:19:45 +00:00
1024创新实验室
dd31f3e8a5 v3.15.0【新增】升级SaToken到最新版本;【新增】重磅优化 数据字典;【新增】升级wangEditor-next;
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-04-03 14:19:17 +00:00
zhoumingfa
486aa13cfd 更新代码生成的菜单SQL模板 2025-04-03 18:29:30 +08:00
zhoumingfa
ade82f8aa2 修改前端页面部分细节 2025-04-01 20:08:10 +08:00
zhoumingfa
66aac47a43 优化代码生成模块,使其适配当前版本 2025-04-01 17:44:29 +08:00
zhoumingfa
23c4889723 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	smart-admin-web-javascript/src/views/business/erp/goods/goods-list.vue
#	smart-admin-web-typescript/src/views/business/erp/goods/goods-list.vue
2025-03-31 23:37:57 +08:00
zhoumingfa
4062d5a4bb 优化代码生成,添加字典预览与文件预览,使其适配当前版本 2025-03-31 23:29:58 +08:00
zhuoda
fc2f3f2e23 v3.15.0【新增】升级SaToken到最新版本;【新增】重磅优化 数据字典;【新增】升级wangEditor-next;【新增】优化缓存实现redis与caffeine 2025-03-31 23:24:07 +08:00
zhuoda
4683e31290 v3.15.0【新增】升级SaToken到最新版本;【新增】重磅优化 数据字典;【新增】升级wangEditor-next;【新增】优化缓存实现redis与caffeine 2025-03-31 23:19:41 +08:00
zhoumingfa
5136148ce1 解决:java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "tables" "TABLES" 2025-03-31 23:15:16 +08:00
1024创新实验室
558d5c86ff !62 Bug修复及细节优化
Merge pull request !62 from 大熊/master
2025-03-29 15:49:56 +00:00
zhoumingfa
45b5ba6795 优化前端字典预览组件 2025-03-28 21:21:02 +08:00
zhoumingfa
b72f58a0bb 1、若干个细节修改;2、更新SQL脚本,t_dict_key 的 key_code 值错误 2025-03-28 21:19:27 +08:00
zhoumingfa
5fb1456080 接口解密中的 fastjson 解析对象统一改为使用 jackson 2025-03-28 21:12:59 +08:00
zhoumingfa
a6607c063b 修复缓存实现配置为 redis 时抛异常的问题 2025-03-28 20:57:48 +08:00
1024创新实验室
580a783d25 !61 refactor(smart-admin): 统一使用“登录”替代“登陆”,确保术语准确性
Merge pull request !61 from CoderKK/master
2025-03-24 11:56:37 +00:00
1024创新实验室
a66d97a408 update README.md.
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-03-24 11:54:02 +00:00
CoderKK
684cb3f71c refactor(smart-admin): 统一使用“登录”替代“登陆”,确保术语准确性 2025-03-20 11:42:23 +08:00
1024创新实验室
109689be69 update README.md.
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-03-19 06:18:36 +00:00
1024创新实验室
30901ed00f !60 refactor(smart-admin-api-java17-springboot3): 移除 Dao 接口中的冗余注解
Merge pull request !60 from CoderKK/master
2025-03-15 02:11:05 +00:00
1024创新实验室
e5edc82beb v3.14.0 更新;【新增】EasyExcel重磅升级为FastExcel;【新增】使用最强Argon2算法作为密码存储;【新增】大家吐槽的数据字典改为可重复;【新增】前端布局再增加多种样式;
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-03-12 13:06:22 +00:00
1024创新实验室
ff868d1b2e v3.14.0 更新;【新增】EasyExcel重磅升级为FastExcel;【新增】使用最强Argon2算法作为密码存储;【新增】大家吐槽的数据字典改为可重复;【新增】前端布局再增加多种样式;
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-03-12 13:05:46 +00:00
zhuoda
7ef9000c62 v3.14.0 更新;【新增】EasyExcel重磅升级为FastExcel;【新增】使用最强Argon2算法作为密码存储;【新增】大家吐槽的数据字典改为可重复;【新增】前端布局再增加多种样式;【优化】升级SaToken到最新版本;【优化】token使用Sa-Token的Bearer类型;【优化】优化其他 2025-03-12 20:18:45 +08:00
zhuoda
c295073037 v3.14.0 更新;【新增】EasyExcel重磅升级为FastExcel;【新增】使用最强Argon2算法作为密码存储;【新增】大家吐槽的数据字典改为可重复;【新增】前端布局再增加多种样式;【优化】升级SaToken到最新版本;【优化】token使用Sa-Token的Bearer类型;【优化】优化其他 2025-03-12 20:18:10 +08:00
zhuoda
eeb9c569de v3.14.0 更新;【新增】EasyExcel重磅升级为FastExcel;【新增】使用最强Argon2算法作为密码存储;【新增】大家吐槽的数据字典改为可重复;【新增】前端布局再增加多种样式;【优化】升级SaToken到最新版本;【优化】token使用Sa-Token的Bearer类型;【优化】优化其他 2025-03-12 20:17:39 +08:00
1024创新实验室
5553aac514 update README.md.
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-03-11 13:04:53 +00:00
1024创新实验室
30787815c8 通知
Signed-off-by: 1024创新实验室 <1024lab@sina.com>
2025-03-11 13:04:21 +00:00
CoderKK
92fd908619 refactor(smart-admin-api-java17-springboot3): 移除 Dao 接口中的冗余注解
- 删除了 Dao.java.vm 文件中的 @Component 注解- 优化了代码结构,减少了不必要的导入
2025-03-11 16:37:15 +08:00
1024创新实验室
b1cbad8362 !59 Bug修复与功能优化
Merge pull request !59 from 大熊/master
2025-03-11 07:26:56 +00:00
1024创新实验室
ad7ad667c8 !58 修复:登录失败锁定不生效 、账号删除后依然能登录、用户名枚举漏洞
Merge pull request !58 from 憨涛子/master
2025-03-11 07:26:43 +00:00
1024创新实验室
8b40637e98 !57 优化响应工具类 SmartResponseUtil 替换魔法值和移除不必要的异常捕获
Merge pull request !57 from CoderKK/master
2025-03-11 07:26:34 +00:00
1024创新实验室
5da35dfe85 !56 通过props-multiple设置单文件/多文件上传
Merge pull request !56 from 总督/master
2025-03-11 07:26:25 +00:00
SillyBoy
55fc58da3d 更新:文件类型检测白名单 2025-03-09 18:05:38 +08:00
SillyBoy
bb68f050bf 修复:java8 spring-security-crypto 需要低版本 2025-03-09 15:51:02 +08:00
SillyBoy
2dd72e404a 优化:添加编辑部门允许负责人为空 2025-03-01 19:38:33 +08:00
SillyBoy
34fdf59432 优化:使用更加安全的编码保存用户密码 2025-03-01 18:44:30 +08:00
zhoumingfa
66147e47da 修改DictSelect组件onChange事件 2025-02-23 23:20:49 +08:00
zhoumingfa
3ac76495ae 修改DictSelect组件onChange事件 2025-02-23 23:09:10 +08:00
zhoumingfa
0c156e23b2 更新SQL脚本 2025-02-23 22:26:20 +08:00
zhoumingfa
d0e9eef9c2 格式与细节修改 2025-02-23 22:25:47 +08:00
zhoumingfa
e44b116184 优化枚举与字典相关组件,增加禁用与隐藏选项属性 2025-02-23 22:23:18 +08:00
SillyBoy
57747d9082 修复:用户名枚举漏洞 2025-02-22 19:15:05 +08:00
zhoumingfa
81b7b2a3a4 1、优化与完善个人中心的资料更新;2、修改员工DAO层的方法参数 2025-02-21 16:17:44 +08:00
zhoumingfa
a100b1ab12 优化公告管理,修改创建人查询的错误等等其他显示问题 2025-02-21 16:00:54 +08:00
zhoumingfa
2c70db1498 更正前端权限插件的判断 2025-02-20 23:00:34 +08:00
zhoumingfa
9a6d758fc7 优化数据范围组件,解决了以部门in的情况下数据权限为本人时最终查看的数据还是部门全部数据的问题 2025-02-20 22:59:30 +08:00
SillyBoy
c4b95654fe 修复:账号删除后依然能登录 2025-02-19 10:44:13 +08:00
zhoumingfa
ac0f1ae2b9 Merge branch 'master' of https://gitee.com/DxrHelloWorld/smart-admin
 Conflicts:
	smart-admin-api-java17-springboot3/sa-base/src/main/resources/code-generator-template/java/dao/Dao.java.vm
	smart-admin-web-typescript/src/api/system/employee-api.ts
2025-02-16 00:07:11 +08:00
SillyBoy
8d635bb80b 修复:登录失败锁定不生效 2025-02-13 15:59:04 +08:00
zhuoda
cdbb854e6c 更新V3.13.0版本:【新增】顶部菜单模式;【优化】因kaptcha有漏洞,弃用;【优化】三级等保默认值 2025-01-19 18:05:34 +08:00
CoderKK
ae753844c7 refactor(sa-base): 优化响应工具类 SmartResponseUtil
- 使用常量 MediaType.APPLICATION_JSON_VALUE 替代硬编码的 "application/json"- 使用 UTF_8 常量替代 "utf-8" 字符串
- 移除不必要的异常捕获
- 优化文件下载头信息设置方法
2025-01-15 10:47:55 +08:00
knight322
e988867b17 通过props-multiple设置单文件/多文件上传,原先未启用 2025-01-14 15:42:45 +08:00
zhuoda
db5e0062a0 v3.12【新增】标签页Chome模式;【优化】优化很多细节 2025-01-08 20:12:46 +08:00
1024创新实验室
29064c176f !48 修复代码生成缺少SaCheckPermission引入问题
Merge pull request !48 from 檀淮南/N/A
2025-01-05 08:48:09 +00:00
1024创新实验室
b7c71189e1 !47 修复二级菜单展开后,菜单长度样式超长的问题
Merge pull request !47 from 檀淮南/N/A
2025-01-05 08:47:51 +00:00
1024创新实验室
55fb01174f !51 修复初始化无法获取到 urls 问题
Merge pull request !51 from 丶老实人/N/A
2025-01-05 08:47:11 +00:00
1024创新实验室
1943431df0 !52 fix(system): 修复菜单模态框中显示状态和禁用状态字段、功能点状态名称错误以及点击名称切换错误的问题
Merge pull request !52 from Smile/master
2025-01-05 08:46:51 +00:00
1024创新实验室
bbc382bc38 !54 Fix bug:unexpected token
Merge pull request !54 from RabbitQ/N/A
2025-01-05 08:46:29 +00:00
Turbolisten
31f0041f74 update java17-TokenConfig.java
Signed-off-by: Turbolisten <188029906@qq.com>
2024-12-24 01:43:26 +00:00
RabbitQ
36ebb16574 Fix bug:unexpected token
java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "tables" "TABLES"
    at line 7, column 40.


Signed-off-by: RabbitQ <15024835320@163.com>
2024-12-16 03:41:43 +00:00
mijunl
23b75137bb fix(system): 修复菜单模态框中显示状态和禁用状态字段、功能点状态名称错误以及点击名称切换错误的问题 2024-12-04 11:07:56 +08:00
丶老实人
e3888cef9b 修复初始化无法获取到 urls 问题
Signed-off-by: 丶老实人 <120765338@qq.com>
2024-12-03 15:01:15 +00:00
1024Lab-佩弦
7b681e44a8 【功能优化】:新增标签页样式Naive 2024-12-01 19:48:55 +08:00
1024Lab-佩弦
83d970095b 【功能优化】:新增标签页样式Naive 2024-12-01 19:33:25 +08:00
lipeng
a3a7cf63a8 【功能优化】:新增标签页样式Naive 2024-11-28 16:30:17 +08:00
檀淮南
fff3ec203f 修复代码生成缺少SaCheckPermission引入问题
Signed-off-by: 檀淮南 <coder_nai@163.com>
2024-11-27 12:16:58 +00:00
檀淮南
a53acc504e 修复二级菜单展开后,菜单长度样式超长的问题
Signed-off-by: 檀淮南 <coder_nai@163.com>
2024-11-27 01:19:14 +00:00
zhuoda
64ebe2bfdb v3.11.0 【优化】SaTokenConfig与三级等保配置关联;【优化】smart-app去掉无用请求; 2024-11-24 20:03:04 +08:00
zhuoda
69ea81b020 v3.11.0 【优化】SaTokenConfig与三级等保配置关联;【优化】smart-app去掉无用请求; 2024-11-24 20:02:24 +08:00
zhuoda
cb39dedfd5 v3.11.0 【优化】SaTokenConfig与三级等保配置关联;【优化】smart-app去掉无用请求; 2024-11-24 20:02:08 +08:00
1024创新实验室
b27b004edc !44 修复bug:三级等保配置初始化后最低活跃频率会被全局配置覆盖
Merge pull request !44 from 憨涛子/master
2024-11-24 08:14:30 +00:00
zhuoda
b3b20bc029 v3.10.1 【紧急优化】smart-app 查询用户消息相关业务 2024-11-21 18:57:39 +08:00
zhoumingfa
145895703d 更改前端的根据部门id查询员工接口地址与后端一致 2024-11-14 17:15:18 +08:00
zhoumingfa
7b712bae71 修改员工SQL 2024-11-13 00:34:42 +08:00
zhoumingfa
69ff0a9631 解决代码生成配置中的插入和更新表单配置显示有误 2024-11-12 22:59:21 +08:00
zhoumingfa
364ca94973 优化表格列设置 2024-11-12 22:55:11 +08:00
zhoumingfa
33a8ab3280 1、代码生成器模块的菜单SQL改为不缓存;2、格式修改 2024-10-25 14:44:50 +08:00
SillyBoy
dab0afdb59 修复bug:三级等保配置初始化后最低活跃频率会被全局配置覆盖 2024-10-22 18:10:01 +08:00
597 changed files with 13415 additions and 6179 deletions

View File

@@ -12,8 +12,8 @@
- 前端JavaScript/TypeScript + Vue3 + Vite5 + Pinia + Ant Design Vue 4.X
- 移动端uniapp (vue3版本) + uni-ui + 同时支持APP、小程序、H5
- 后端Java8/17 + SpringBoot2/3 + Sa Token + Mybatis-plus + 多种数据库
- 电脑在线预览:[https://preview.smartadmin.vip](https://preview.smartadmin.vip)
- 官方文档:[https://smartadmin.vip](https://smartadmin.vip)
- 电脑在线预览:[https://preview.smartadmin.vip](https://preview.smartadmin.vip)
- 移动端在线预览:[https://app.smartadmin.vip](https://app.smartadmin.vip/#/pages/login/login)
### **理念与思想**

View File

@@ -1,35 +0,0 @@
HELP.md
target/
velocity.log
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
.DS_Store
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/

View File

@@ -2,7 +2,7 @@
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>
<groupId>net.1024lab</groupId>
<groupId>net.lab1024</groupId>
<artifactId>sa-parent</artifactId>
<version>3.0.0</version>
<packaging>pom</packaging>
@@ -21,6 +21,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<springboot.version>3.3.1</springboot.version>
<spring-mock.version>2.0.8</spring-mock.version>
<spring-security-crypto.version>6.4.3</spring-security-crypto.version>
<mybatis-plus.version>3.5.7</mybatis-plus.version>
<p6spy.version>3.9.1</p6spy.version>
<knife4j.version>4.4.0</knife4j.version>
@@ -29,15 +30,15 @@
<google-linkedhashmap.version>1.4.2</google-linkedhashmap.version>
<google-guava.version>20.0</google-guava.version>
<user-agent-utils.version>1.21</user-agent-utils.version>
<kaptcha.version>2.3.2</kaptcha.version>
<reflections.version>0.9.11</reflections.version>
<commons-io.version>2.15.0</commons-io.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-collections4.version>4.4</commons-collections4.version>
<commons-compress.version>1.26.0</commons-compress.version>
<commons-codec.version>1.13</commons-codec.version>
<commons-text.version>1.9</commons-text.version>
<xerces.version>2.12.0</xerces.version>
<easy-excel.version>3.3.2</easy-excel.version>
<fast-excel.version>1.0.0</fast-excel.version>
<poi.version>5.2.4</poi.version>
<ooxml-schemas.version>1.4</ooxml-schemas.version>
<aws-java-sdk.version>1.11.842</aws-java-sdk.version>
@@ -47,9 +48,9 @@
<jjwt.version>0.9.1</jjwt.version>
<jwks-rsa.version>0.9.0</jwks-rsa.version>
<velocity-tools.version>3.1</velocity-tools.version>
<sa-token.version>1.37.0</sa-token.version>
<sa-token.version>1.41.0</sa-token.version>
<ip2region.version>2.7.0</ip2region.version>
<bcprov.version>1.59</bcprov.version>
<bcprov.version>1.80</bcprov.version>
<jackson-datatype-jsr310.version>2.13.4</jackson-datatype-jsr310.version>
<jackson-dataformat-yaml.version>2.16.1</jackson-dataformat-yaml.version>
<smartdb.version>1.2.0</smartdb.version>
@@ -57,6 +58,7 @@
<snakeyaml.version>2.2</snakeyaml.version>
<freemarker.version>2.3.33</freemarker.version>
<jsoup.version>1.18.1</jsoup.version>
<tika.version>3.1.0</tika.version>
</properties>
<dependencyManagement>
@@ -84,6 +86,12 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>${spring-security-crypto.version}</version>
</dependency>
<dependency>
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
@@ -127,18 +135,6 @@
<version>${user-agent-utils.version}</version>
</dependency>
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>${kaptcha.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
@@ -169,6 +165,12 @@
<version>${commons-collections4.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>${commons-compress.version}</version>
</dependency>
<dependency>
<artifactId>commons-codec</artifactId>
<groupId>commons-codec</groupId>
@@ -248,18 +250,18 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<artifactId>bcprov-jdk18on</artifactId>
<version>${bcprov.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>${easy-excel.version}</version>
<groupId>cn.idev.excel</groupId>
<artifactId>fastexcel</artifactId>
<version>${fast-excel.version}</version>
<exclusions>
<exclusion>
<artifactId>poi-ooxml-schemas</artifactId>
<groupId>org.apache.poi</groupId>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
</exclusions>
</dependency>
@@ -331,6 +333,12 @@
<version>${freemarker.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>${tika.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@@ -420,4 +428,4 @@
</profile>
</profiles>
</project>
</project>

View File

@@ -2,7 +2,7 @@
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>net.1024lab</groupId>
<groupId>net.lab1024</groupId>
<artifactId>sa-parent</artifactId>
<version>3.0.0</version>
<relativePath>../pom.xml</relativePath>
@@ -18,7 +18,7 @@
<dependencies>
<dependency>
<groupId>net.1024lab</groupId>
<groupId>net.lab1024</groupId>
<artifactId>sa-base</artifactId>
<version>3.0.0</version>
</dependency>

View File

@@ -51,6 +51,8 @@ public class AdminSwaggerTagConst extends SwaggerTagConst {
public static final String SYSTEM_POSITION = "系统-职务管理";
public static final String SYSTEM_MESSAGE = "系统-消息";
}

View File

@@ -3,8 +3,7 @@ package net.lab1024.sa.admin.interceptor;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.exception.SaTokenException;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.strategy.SaStrategy;
import cn.hutool.core.util.StrUtil;
import cn.dev33.satoken.strategy.SaAnnotationStrategy;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -14,14 +13,9 @@ import net.lab1024.sa.admin.module.system.login.service.LoginService;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.code.SystemErrorCode;
import net.lab1024.sa.base.common.code.UserErrorCode;
import net.lab1024.sa.base.common.constant.StringConst;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.SystemEnvironment;
import net.lab1024.sa.base.common.enumeration.SystemEnvironmentEnum;
import net.lab1024.sa.base.common.enumeration.UserTypeEnum;
import net.lab1024.sa.base.common.util.SmartRequestUtil;
import net.lab1024.sa.base.common.util.SmartResponseUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
@@ -47,9 +41,6 @@ public class AdminInterceptor implements HandlerInterceptor {
@Resource
private LoginService loginService;
@Resource
private SystemEnvironment systemEnvironment;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
@@ -68,17 +59,7 @@ public class AdminInterceptor implements HandlerInterceptor {
// --------------- 第一步: 根据token 获取用户 ---------------
String tokenValue = StpUtil.getTokenValue();
boolean debugNumberTokenFlag = isDevDebugNumberToken(tokenValue);
String loginId = null;
if (debugNumberTokenFlag) {
//开发、测试环境,且为数字的话,则表明为 调试临时用户,即需要调用 sa-token switch
loginId = UserTypeEnum.ADMIN_EMPLOYEE.getValue() + StringConst.COLON + tokenValue;
StpUtil.switchTo(loginId);
} else {
loginId = (String) StpUtil.getLoginIdByToken(tokenValue);
}
String loginId = (String) StpUtil.getLoginIdByToken(tokenValue);
RequestEmployee requestEmployee = loginService.getLoginEmployee(loginId, request);
// --------------- 第二步: 校验 登录 ---------------
@@ -86,7 +67,7 @@ public class AdminInterceptor implements HandlerInterceptor {
Method method = ((HandlerMethod) handler).getMethod();
NoNeedLogin noNeedLogin = ((HandlerMethod) handler).getMethodAnnotation(NoNeedLogin.class);
if (noNeedLogin != null) {
checkActiveTimeout(requestEmployee, debugNumberTokenFlag);
checkActiveTimeout(requestEmployee);
return true;
}
@@ -96,13 +77,13 @@ public class AdminInterceptor implements HandlerInterceptor {
}
// 检测token 活跃频率
checkActiveTimeout(requestEmployee, debugNumberTokenFlag);
checkActiveTimeout(requestEmployee);
// --------------- 第三步: 校验 权限 ---------------
SmartRequestUtil.setRequestUser(requestEmployee);
if (SaStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class)) {
if (SaAnnotationStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class)) {
return true;
}
@@ -111,7 +92,7 @@ public class AdminInterceptor implements HandlerInterceptor {
return true;
}
SaStrategy.instance.checkMethodAnnotation.accept(method);
SaAnnotationStrategy.instance.checkMethodAnnotation.accept(method);
} catch (SaTokenException e) {
/*
@@ -143,13 +124,7 @@ public class AdminInterceptor implements HandlerInterceptor {
/**
* 检测token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结
*/
private void checkActiveTimeout(RequestEmployee requestEmployee, boolean debugNumberTokenFlag) {
// 对于开发环境的 数字 debug token ,不需要检测活跃有效期
if (debugNumberTokenFlag) {
return;
}
private void checkActiveTimeout(RequestEmployee requestEmployee) {
// 用户不在线,也不用检测
if (requestEmployee == null) {
return;
@@ -160,29 +135,9 @@ public class AdminInterceptor implements HandlerInterceptor {
}
/**
* 是否为开发使用的 debug token
*
* @param token
* @return
*/
private boolean isDevDebugNumberToken(String token) {
if (!StrUtil.isNumeric(token)) {
return false;
}
return systemEnvironment.getCurrentEnvironment() == SystemEnvironmentEnum.DEV
|| systemEnvironment.getCurrentEnvironment() == SystemEnvironmentEnum.TEST;
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
// 清除上下文
SmartRequestUtil.remove();
// 开发环境,关闭 sa token 的临时切换用户
if (systemEnvironment.getCurrentEnvironment() == SystemEnvironmentEnum.DEV) {
StpUtil.endSwitch();
}
}
}

View File

@@ -1,24 +0,0 @@
package net.lab1024.sa.admin.listener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
/**
* admin 应用启动加载
*
* @Author 1024创新实验室-主任:卓大
* @Date 2021-08-26 18:46:32
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Slf4j
@Component
public class AdminStartupRunner implements CommandLineRunner {
@Override
public void run(String... args) {
}
}

View File

@@ -18,7 +18,6 @@ import java.util.List;
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Component
@Mapper
public interface CategoryDao extends BaseMapper<CategoryEntity> {

View File

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import net.lab1024.sa.admin.module.business.category.constant.CategoryTypeEnum;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
@@ -15,11 +16,13 @@ import java.time.LocalDateTime;
* @Date 2021/08/05 21:26:58
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Data
@TableName("t_category")
public class CategoryEntity {
public class CategoryEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
private Long categoryId;

View File

@@ -3,6 +3,7 @@ package net.lab1024.sa.admin.module.business.category.domain.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
@@ -12,10 +13,12 @@ import java.util.List;
* @Date 2021/08/05 21:26:58
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Data
public class CategoryTreeVO {
public class CategoryTreeVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "类目id")
private Long categoryId;

View File

@@ -21,7 +21,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface GoodsDao extends BaseMapper<GoodsEntity> {
/**

View File

@@ -7,7 +7,7 @@ import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
import net.lab1024.sa.base.common.json.deserializer.DictDataDeserializer;
import net.lab1024.sa.base.common.swagger.SchemaEnum;
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
@@ -39,7 +39,7 @@ public class GoodsAddForm {
@Schema(description = "产地")
@NotBlank(message = "产地 不能为空 ")
@JsonDeserialize(using = DictValueVoDeserializer.class)
@JsonDeserialize(using = DictDataDeserializer.class)
private String place;
@Schema(description = "商品价格")

View File

@@ -1,6 +1,6 @@
package net.lab1024.sa.admin.module.business.goods.domain.form;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;

View File

@@ -5,7 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
import net.lab1024.sa.base.common.domain.PageParam;
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
import net.lab1024.sa.base.common.json.deserializer.DictDataDeserializer;
import net.lab1024.sa.base.common.swagger.SchemaEnum;
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
import org.hibernate.validator.constraints.Length;
@@ -17,7 +17,7 @@ import org.hibernate.validator.constraints.Length;
* @Date 2021-10-25 20:26:54
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Data
public class GoodsQueryForm extends PageParam {
@@ -34,7 +34,7 @@ public class GoodsQueryForm extends PageParam {
private Integer goodsStatus;
@Schema(description = "产地")
@JsonDeserialize(using = DictValueVoDeserializer.class)
@JsonDeserialize(using = DictDataDeserializer.class)
private String place;
@Schema(description = "上架状态")

View File

@@ -1,6 +1,7 @@
package net.lab1024.sa.admin.module.business.goods.domain.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

View File

@@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
import net.lab1024.sa.base.common.json.serializer.DictValueVoSerializer;
import net.lab1024.sa.base.common.swagger.SchemaEnum;
import java.math.BigDecimal;
@@ -32,7 +31,6 @@ public class GoodsVO {
private Integer goodsStatus;
@Schema(description = "产地")
@JsonSerialize(using = DictValueVoSerializer.class)
private String place;
@Schema(description = "商品价格")

View File

@@ -1,6 +1,6 @@
package net.lab1024.sa.admin.module.business.goods.service;
import com.alibaba.excel.EasyExcel;
import cn.idev.excel.FastExcel;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
@@ -26,7 +26,6 @@ import net.lab1024.sa.base.common.util.SmartEnumUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import net.lab1024.sa.base.module.support.datatracer.constant.DataTracerTypeEnum;
import net.lab1024.sa.base.module.support.datatracer.service.DataTracerService;
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
import net.lab1024.sa.base.module.support.dict.service.DictService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
@@ -60,7 +59,7 @@ public class GoodsService {
private DataTracerService dataTracerService;
@Resource
private DictCacheService dictCacheService;
private DictService dictService;
/**
* 添加商品
@@ -174,7 +173,7 @@ public class GoodsService {
public ResponseDTO<String> importGoods(MultipartFile file) {
List<GoodsImportForm> dataList;
try {
dataList = EasyExcel.read(file.getInputStream()).head(GoodsImportForm.class)
dataList = FastExcel.read(file.getInputStream()).head(GoodsImportForm.class)
.sheet()
.doReadSync();
} catch (IOException e) {
@@ -194,12 +193,13 @@ public class GoodsService {
*/
public List<GoodsExcelVO> getAllGoods() {
List<GoodsEntity> goodsEntityList = goodsDao.selectList(null);
String dictCode = "GOODS_PLACE";
return goodsEntityList.stream()
.map(e ->
GoodsExcelVO.builder()
.goodsStatus(SmartEnumUtil.getEnumDescByValue(e.getGoodsStatus(), GoodsStatusEnum.class))
.categoryName(categoryQueryService.queryCategoryName(e.getCategoryId()))
.place(Arrays.stream(e.getPlace().split(",")).map(code -> dictCacheService.selectValueNameByValueCode(code)).collect(Collectors.joining(",")))
.place(Arrays.stream(e.getPlace().split(",")).map(code -> dictService.getDictDataLabel(dictCode, code)).collect(Collectors.joining(",")))
.price(e.getPrice())
.goodsName(e.getGoodsName())
.remark(e.getRemark())

View File

@@ -1,5 +1,6 @@
package net.lab1024.sa.admin.module.business.oa.bank;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
@@ -35,24 +36,28 @@ public class BankController {
@Operation(summary = "分页查询银行信息 @author 善逸")
@PostMapping("/oa/bank/page/query")
@SaCheckPermission("oa:bank:query")
public ResponseDTO<PageResult<BankVO>> queryByPage(@RequestBody @Valid BankQueryForm queryForm) {
return bankService.queryByPage(queryForm);
}
@Operation(summary = "根据企业ID查询银行信息列表 @author 善逸")
@GetMapping("/oa/bank/query/list/{enterpriseId}")
@SaCheckPermission("oa:bank:query")
public ResponseDTO<List<BankVO>> queryList(@PathVariable Long enterpriseId) {
return bankService.queryList(enterpriseId);
}
@Operation(summary = "查询银行信息详情 @author 善逸")
@GetMapping("/oa/bank/get/{bankId}")
@SaCheckPermission("oa:bank:query")
public ResponseDTO<BankVO> getDetail(@PathVariable Long bankId) {
return bankService.getDetail(bankId);
}
@Operation(summary = "新建银行信息 @author 善逸")
@PostMapping("/oa/bank/create")
@SaCheckPermission("oa:bank:add")
public ResponseDTO<String> createBank(@RequestBody @Valid BankCreateForm createVO) {
RequestUser requestUser = SmartRequestUtil.getRequestUser();
createVO.setCreateUserId(requestUser.getUserId());
@@ -62,12 +67,14 @@ public class BankController {
@Operation(summary = "编辑银行信息 @author 善逸")
@PostMapping("/oa/bank/update")
@SaCheckPermission("oa:bank:update")
public ResponseDTO<String> updateBank(@RequestBody @Valid BankUpdateForm updateVO) {
return bankService.updateBank(updateVO);
}
@Operation(summary = "删除银行信息 @author 善逸")
@GetMapping("/oa/bank/delete/{bankId}")
@SaCheckPermission("oa:bank:delete")
public ResponseDTO<String> deleteBank(@PathVariable Long bankId) {
return bankService.deleteBank(bankId);
}

View File

@@ -21,7 +21,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface BankDao extends BaseMapper<BankEntity> {
/**

View File

@@ -100,6 +100,7 @@ public class EnterpriseController {
@Operation(summary = "按照类型查询企业 @author 开云")
@GetMapping("/oa/enterprise/query/list")
@SaCheckPermission("oa:enterprise:query")
public ResponseDTO<List<EnterpriseListVO>> queryList(@RequestParam(value = "type", required = false) Integer type) {
return enterpriseService.queryList(type);
}
@@ -114,12 +115,14 @@ public class EnterpriseController {
@Operation(summary = "查询企业全部员工 @author 罗伊")
@PostMapping("/oa/enterprise/employee/list")
@SaCheckPermission("oa:enterprise:queryEmployee")
public ResponseDTO<List<EnterpriseEmployeeVO>> employeeList(@RequestBody @Valid List<Long> enterpriseIdList) {
return ResponseDTO.ok(enterpriseService.employeeList(enterpriseIdList));
}
@Operation(summary = "分页查询企业员工 @author 卓大")
@PostMapping("/oa/enterprise/employee/queryPage")
@SaCheckPermission("oa:enterprise:queryEmployee")
public ResponseDTO<PageResult<EnterpriseEmployeeVO>> queryPageEmployeeList(@RequestBody @Valid EnterpriseEmployeeQueryForm queryForm) {
return ResponseDTO.ok(enterpriseService.queryPageEmployeeList(queryForm));
}

View File

@@ -23,7 +23,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface EnterpriseDao extends BaseMapper<EnterpriseEntity> {
/**

View File

@@ -22,7 +22,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface EnterpriseEmployeeDao extends BaseMapper<EnterpriseEmployeeEntity> {

View File

@@ -1,6 +1,6 @@
package net.lab1024.sa.admin.module.business.oa.enterprise.domain.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
/**

View File

@@ -1,5 +1,6 @@
package net.lab1024.sa.admin.module.business.oa.invoice;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
@@ -38,18 +39,21 @@ public class InvoiceController {
@Operation(summary = "分页查询发票信息 @author 善逸")
@PostMapping("/oa/invoice/page/query")
@SaCheckPermission("oa:invoice:query")
public ResponseDTO<PageResult<InvoiceVO>> queryByPage(@RequestBody @Valid InvoiceQueryForm queryForm) {
return invoiceService.queryByPage(queryForm);
}
@Operation(summary = "查询发票信息详情 @author 善逸")
@GetMapping("/oa/invoice/get/{invoiceId}")
@SaCheckPermission("oa:invoice:query")
public ResponseDTO<InvoiceVO> getDetail(@PathVariable Long invoiceId) {
return invoiceService.getDetail(invoiceId);
}
@Operation(summary = "新建发票信息 @author 善逸")
@PostMapping("/oa/invoice/create")
@SaCheckPermission("oa:invoice:add")
public ResponseDTO<String> createInvoice(@RequestBody @Valid InvoiceAddForm createVO) {
RequestUser requestUser = SmartRequestUtil.getRequestUser();
createVO.setCreateUserId(requestUser.getUserId());
@@ -57,21 +61,24 @@ public class InvoiceController {
return invoiceService.createInvoice(createVO);
}
@OperateLog
@Operation(summary = "编辑发票信息 @author 善逸")
@PostMapping("/oa/invoice/update")
@OperateLog
@SaCheckPermission("oa:invoice:update")
public ResponseDTO<String> updateInvoice(@RequestBody @Valid InvoiceUpdateForm updateVO) {
return invoiceService.updateInvoice(updateVO);
}
@Operation(summary = "删除发票信息 @author 善逸")
@GetMapping("/invoice/delete/{invoiceId}")
@SaCheckPermission("oa:invoice:delete")
public ResponseDTO<String> deleteInvoice(@PathVariable Long invoiceId) {
return invoiceService.deleteInvoice(invoiceId);
}
@Operation(summary = "查询列表 @author lidoudou")
@GetMapping("/oa/invoice/query/list/{enterpriseId}")
@SaCheckPermission("oa:invoice:query")
public ResponseDTO<List<InvoiceVO>> queryList(@PathVariable Long enterpriseId) {
return invoiceService.queryList(enterpriseId);
}

View File

@@ -21,7 +21,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface InvoiceDao extends BaseMapper<InvoiceEntity> {
/**

View File

@@ -27,7 +27,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface NoticeDao extends BaseMapper<NoticeEntity> {
// ================================= 数据范围相关 【子表】 =================================

View File

@@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface NoticeTypeDao extends BaseMapper<NoticeTypeEntity> {
}

View File

@@ -28,7 +28,7 @@ public class NoticeQueryForm extends PageParam {
private String documentNumber;
@Schema(description = "创建人")
private Long createUserId;
private String createUserName;
@Schema(description = "删除标识")
private Boolean deletedFlag;

View File

@@ -208,6 +208,10 @@ public class NoticeService {
}
NoticeUpdateFormVO updateFormVO = SmartBeanUtil.copy(noticeEntity, NoticeUpdateFormVO.class);
NoticeTypeVO noticeType = noticeTypeService.getByNoticeTypeId(noticeEntity.getNoticeTypeId());
updateFormVO.setNoticeTypeName(noticeType.getNoticeTypeName());
updateFormVO.setPublishFlag(updateFormVO.getPublishTime() != null && updateFormVO.getPublishTime().isBefore(LocalDateTime.now()));
if (!updateFormVO.getAllVisibleFlag()) {
List<NoticeVisibleRangeVO> noticeVisibleRangeList = noticeDao.queryVisibleRange(noticeId);
List<Long> employeeIdList = noticeVisibleRangeList.stream().filter(e -> NoticeVisibleRangeDataTypeEnum.EMPLOYEE.getValue().equals(e.getDataType()))

View File

@@ -5,7 +5,7 @@ import net.lab1024.sa.base.common.enumeration.BaseEnum;
/**
* 数据范围 种类
* 数据可见范围类型
*
* @Author 1024创新实验室: 罗伊
* @Date 2020/11/28 20:59:17

View File

@@ -25,7 +25,7 @@ public class DataScopeSqlConfig {
/**
* join sql 具体实现类
*/
private Class joinSqlImplClazz;
private Class<?> joinSqlImplClazz;
private String joinSql;

View File

@@ -5,7 +5,7 @@ import lombok.Builder;
import lombok.Data;
/**
* 数据范围
* 数据可见范围
*
* @Author 1024创新实验室: 罗伊
* @Date 2020/11/28 20:59:17

View File

@@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @Date 2020/11/28 20:59:17
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Slf4j
@Service
@@ -46,6 +46,11 @@ public class DataScopeSqlConfigService {
private static final String DEPARTMENT_PARAM = "#departmentIds";
/**
* 用于拼接查看本人数据范围的 SQL
*/
private static final String CREATE_USER_ID_EQUALS = "create_user_id = ";
private final ConcurrentHashMap<String, DataScopeSqlConfig> dataScopeMethodMap = new ConcurrentHashMap<>();
@Resource
@@ -84,7 +89,6 @@ public class DataScopeSqlConfigService {
/**
* 根据调用的方法获取,此方法的配置信息
*
*/
public DataScopeSqlConfig getSqlConfig(String method) {
return this.dataScopeMethodMap.get(method);
@@ -94,14 +98,23 @@ public class DataScopeSqlConfigService {
* 组装需要拼接的sql
*/
public String getJoinSql(Map<String, Object> paramMap, DataScopeSqlConfig sqlConfigDTO) {
DataScopeTypeEnum dataScopeTypeEnum = sqlConfigDTO.getDataScopeType();
String joinSql = sqlConfigDTO.getJoinSql();
Long employeeId = SmartRequestUtil.getRequestUserId();
if (employeeId == null) {
return "";
}
DataScopeTypeEnum dataScopeTypeEnum = sqlConfigDTO.getDataScopeType();
DataScopeViewTypeEnum viewTypeEnum = dataScopeViewService.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
// 数据权限设置为仅本人可见时 直接返回 create_user_id = employeeId
if (DataScopeViewTypeEnum.ME == viewTypeEnum) {
return CREATE_USER_ID_EQUALS + employeeId;
}
String joinSql = sqlConfigDTO.getJoinSql();
if (DataScopeWhereInTypeEnum.CUSTOM_STRATEGY == sqlConfigDTO.getDataScopeWhereInType()) {
Class strategyClass = sqlConfigDTO.getJoinSqlImplClazz();
Class<?> strategyClass = sqlConfigDTO.getJoinSqlImplClazz();
if (strategyClass == null) {
log.warn("data scope custom strategy class is null");
return "";
@@ -111,11 +124,10 @@ public class DataScopeSqlConfigService {
log.warn("data scope custom strategy class{} ,bean is null", sqlConfigDTO.getJoinSqlImplClazz());
return "";
}
DataScopeViewTypeEnum viewTypeEnum = dataScopeViewService.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
return powerStrategy.getCondition(viewTypeEnum,paramMap, sqlConfigDTO);
return powerStrategy.getCondition(viewTypeEnum, paramMap, sqlConfigDTO);
}
if (DataScopeWhereInTypeEnum.EMPLOYEE == sqlConfigDTO.getDataScopeWhereInType()) {
List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(dataScopeTypeEnum, employeeId);
List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(viewTypeEnum, employeeId);
if (CollectionUtils.isEmpty(canViewEmployeeIds)) {
return "";
}
@@ -124,7 +136,7 @@ public class DataScopeSqlConfigService {
return sql;
}
if (DataScopeWhereInTypeEnum.DEPARTMENT == sqlConfigDTO.getDataScopeWhereInType()) {
List<Long> canViewDepartmentIds = dataScopeViewService.getCanViewDepartmentId(dataScopeTypeEnum, employeeId);
List<Long> canViewDepartmentIds = dataScopeViewService.getCanViewDepartmentId(viewTypeEnum, employeeId);
if (CollectionUtils.isEmpty(canViewDepartmentIds)) {
return "";
}

View File

@@ -44,10 +44,9 @@ public class DataScopeViewService {
private DepartmentService departmentService;
/**
* 获取某人可以查看的所有人员信息
* 获取某人可以查看的所有人员数据
*/
public List<Long> getCanViewEmployeeId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
public List<Long> getCanViewEmployeeId(DataScopeViewTypeEnum viewType, Long employeeId) {
if (DataScopeViewTypeEnum.ME == viewType) {
return this.getMeEmployeeIdList(employeeId);
}
@@ -57,16 +56,17 @@ public class DataScopeViewService {
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
return this.getDepartmentAndSubEmployeeIdList(employeeId);
}
// 可以查看所有员工数据
return Lists.newArrayList();
}
/**
* 获取某人可以查看的所有部门信息
* 获取某人可以查看的所有部门数据
*/
public List<Long> getCanViewDepartmentId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
public List<Long> getCanViewDepartmentId(DataScopeViewTypeEnum viewType, Long employeeId) {
if (DataScopeViewTypeEnum.ME == viewType) {
return this.getMeDepartmentIdList(employeeId);
// 数据可见范围类型为本人时 不可以查看任何部门数据
return Lists.newArrayList(0L);
}
if (DataScopeViewTypeEnum.DEPARTMENT == viewType) {
return this.getMeDepartmentIdList(employeeId);
@@ -74,6 +74,7 @@ public class DataScopeViewService {
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
return this.getDepartmentAndSubIdList(employeeId);
}
// 可以查看所有部门数据
return Lists.newArrayList();
}
@@ -91,10 +92,16 @@ public class DataScopeViewService {
* 根据员工id 获取各数据范围最大的可见范围 map<dataScopeType,viewType></>
*/
public DataScopeViewTypeEnum getEmployeeDataScopeViewType(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
if (employeeId == null) {
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
if (employeeEntity == null || employeeEntity.getEmployeeId() == null) {
return DataScopeViewTypeEnum.ME;
}
// 如果是超级管理员 则可查看全部
if (employeeEntity.getAdministratorFlag()) {
return DataScopeViewTypeEnum.ALL;
}
List<Long> roleIdList = roleEmployeeDao.selectRoleIdByEmployeeId(employeeId);
//未设置角色 默认本人
if (CollectionUtils.isEmpty(roleIdList)) {

View File

@@ -18,7 +18,6 @@ import java.util.List;
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Component
@Mapper
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {

View File

@@ -3,6 +3,8 @@ package net.lab1024.sa.admin.module.system.department.domain.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import lombok.Data;
import java.time.LocalDateTime;
@@ -34,6 +36,7 @@ public class DepartmentEntity {
/**
* 负责人员工 id
*/
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Long managerId;
/**

View File

@@ -3,6 +3,7 @@ package net.lab1024.sa.admin.module.system.department.domain.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
@@ -12,10 +13,12 @@ import java.time.LocalDateTime;
* @Date 2022-01-12 20:37:48
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Data
public class DepartmentVO {
public class DepartmentVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "部门id")
private Long departmentId;

View File

@@ -57,11 +57,11 @@ public class EmployeeController {
return employeeService.updateEmployee(employeeUpdateForm);
}
@Operation(summary = "更新登录人信息 @author 善逸")
@PostMapping("/employee/update/login")
public ResponseDTO<String> updateByLogin(@Valid @RequestBody EmployeeUpdateForm employeeUpdateForm) {
employeeUpdateForm.setEmployeeId(SmartRequestUtil.getRequestUserId());
return employeeService.updateEmployee(employeeUpdateForm);
@Operation(summary = "更新员工个人中心信息 @author 善逸")
@PostMapping("/employee/update/center")
public ResponseDTO<String> updateCenter(@Valid @RequestBody EmployeeUpdateCenterForm updateCenterForm) {
updateCenterForm.setEmployeeId(SmartRequestUtil.getRequestUserId());
return employeeService.updateCenter(updateCenterForm);
}
@Operation(summary = "更新登录人头像 @author 善逸")
@@ -117,7 +117,7 @@ public class EmployeeController {
@Operation(summary = "查询员工-根据部门id @author 卓大")
@GetMapping("/employee/getAllEmployeeByDepartmentId/{departmentId}")
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(@PathVariable Long departmentId) {
return employeeService.getAllEmployeeByDepartmentId(departmentId, Boolean.FALSE);
return employeeService.getAllEmployeeByDepartmentId(departmentId);
}
@Operation(summary = "查询所有员工 @author 卓大")

View File

@@ -22,7 +22,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
/**
* 查询员工列表
@@ -34,31 +33,30 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
*/
List<EmployeeVO> selectEmployeeByDisabledAndDeleted(@Param("disabledFlag") Boolean disabledFlag, @Param("deletedFlag") Boolean deletedFlag);
/**
* 更新单个
*/
void updateDisableFlag(@Param("employeeId") Long employeeId, @Param("disabledFlag") Boolean disabledFlag);
/**
* 通过登录名查询
*/
EmployeeEntity getByLoginName(@Param("loginName") String loginName,
@Param("disabledFlag") Boolean disabledFlag);
EmployeeEntity getByLoginName(@Param("loginName") String loginName, @Param("deletedFlag") Boolean deletedFlag);
/**
* 通过姓名查询
*/
EmployeeEntity getByActualName(@Param("actualName") String actualName,
@Param("disabledFlag") Boolean disabledFlag
);
EmployeeEntity getByActualName(@Param("actualName") String actualName, @Param("deletedFlag") Boolean deletedFlag);
/**
* 通过手机号查询
*/
EmployeeEntity getByPhone(@Param("phone") String phone, @Param("disabledFlag") Boolean disabledFlag);
EmployeeEntity getByPhone(@Param("phone") String phone, @Param("deletedFlag") Boolean deletedFlag);
/**
* 通过邮箱账号查询
*/
EmployeeEntity getByEmail(@Param("email") String email, @Param("deletedFlag") Boolean deletedFlag);
/**
* 获取所有员工
@@ -67,7 +65,6 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
/**
* 获取某个部门员工数
*
*/
Integer countByDepartmentId(@Param("departmentId") Long departmentId, @Param("deletedFlag") Boolean deletedFlag);
@@ -76,39 +73,35 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
*/
List<EmployeeVO> getEmployeeByIds(@Param("employeeIds") Collection<Long> employeeIds);
/**
* 查询单个员工信息
*/
EmployeeVO getEmployeeById(@Param("employeeId") Long employeeId);
/**
* 获取某个部门的员工
*/
List<EmployeeEntity> selectByDepartmentId(@Param("departmentId") Long departmentId, @Param("disabledFlag") Boolean disabledFlag);
List<EmployeeEntity> selectByDepartmentId(@Param("departmentId") Long departmentId, @Param("deletedFlag") Boolean deletedFlag);
/**
* 查询某些部门下用户名是xxx的员工
*/
List<EmployeeEntity> selectByActualName(@Param("departmentIdList") List<Long> departmentIdList, @Param("actualName") String actualName, @Param("disabledFlag") Boolean disabledFlag);
List<EmployeeEntity> selectByActualName(@Param("departmentIdList") List<Long> departmentIdList, @Param("actualName") String actualName, @Param("deletedFlag") Boolean deletedFlag);
/**
* 获取某批部门的员工Id
*/
List<Long> getEmployeeIdByDepartmentIdList(@Param("departmentIds") List<Long> departmentIds, @Param("disabledFlag") Boolean disabledFlag);
List<Long> getEmployeeIdByDepartmentIdList(@Param("departmentIds") List<Long> departmentIds, @Param("deletedFlag") Boolean deletedFlag);
/**
* 获取所有
*/
List<Long> getEmployeeId(@Param("leaveFlag") Boolean leaveFlag, @Param("disabledFlag") Boolean disabledFlag);
List<Long> getEmployeeId(@Param("leaveFlag") Boolean leaveFlag, @Param("deletedFlag") Boolean deletedFlag);
/**
* 获取某个部门的员工Id
*/
List<Long> getEmployeeIdByDepartmentId(@Param("departmentId") Long departmentId, @Param("disabledFlag") Boolean disabledFlag);
List<Long> getEmployeeIdByDepartmentId(@Param("departmentId") Long departmentId, @Param("deletedFlag") Boolean deletedFlag);
/**
* 员工重置密码

View File

@@ -51,17 +51,19 @@ public class EmployeeAddForm {
@Pattern(regexp = SmartVerificationUtil.PHONE_REGEXP, message = "手机号格式不正确")
private String phone;
@Schema(description = "邮箱")
@Schema(description = "邮箱账号")
@NotNull(message = "邮箱账号不能为空")
@Pattern(regexp = SmartVerificationUtil.EMAIL, message = "邮箱账号格式不正确")
private String email;
@Schema(description = "职务级别ID")
private Long positionId;
@Schema(description = "角色列表")
private List<Long> roleIdList;
@Schema(description = "备注")
@Length(max = 30, message = "备注最多200字符")
@Length(max = 200, message = "备注最多200字符")
private String remark;
@Schema(description = "职务级别ID")
private Long positionId;
}

View File

@@ -0,0 +1,56 @@
package net.lab1024.sa.admin.module.system.employee.domain.form;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import net.lab1024.sa.base.common.enumeration.GenderEnum;
import net.lab1024.sa.base.common.swagger.SchemaEnum;
import net.lab1024.sa.base.common.util.SmartVerificationUtil;
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
import org.hibernate.validator.constraints.Length;
/**
* 更新员工个人中心信息
*
* @Author 1024创新实验室: 开云
* @Date 2021-12-20 21:06:49
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Data
public class EmployeeUpdateCenterForm {
@Schema(hidden = true)
private Long employeeId;
@Schema(description = "姓名")
@NotNull(message = "姓名不能为空")
@Length(max = 30, message = "姓名最多30字符")
private String actualName;
@SchemaEnum(GenderEnum.class)
@CheckEnum(value = GenderEnum.class, message = "性别错误")
private Integer gender;
@Schema(description = "手机号")
@NotNull(message = "手机号不能为空")
@Pattern(regexp = SmartVerificationUtil.PHONE_REGEXP, message = "手机号格式不正确")
private String phone;
@Schema(description = "邮箱账号")
@NotNull(message = "邮箱账号不能为空")
@Pattern(regexp = SmartVerificationUtil.EMAIL, message = "邮箱账号格式不正确")
private String email;
@Schema(description = "职务级别ID")
private Long positionId;
@Schema(description = "头像")
private String avatar;
@Schema(description = "备注")
@Length(max = 200, message = "备注最多200字符")
private String remark;
}

View File

@@ -168,19 +168,14 @@ public class EmployeeService {
return ResponseDTO.userErrorParam("部门不存在");
}
EmployeeEntity existEntity = employeeDao.getByLoginName(employeeUpdateForm.getLoginName(), null);
if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) {
return ResponseDTO.userErrorParam("登录名重复");
// 检查唯一性
ResponseDTO<String> checkResponse = checkUniqueness(employeeId, employeeUpdateForm.getLoginName(), employeeUpdateForm.getPhone(), employeeUpdateForm.getEmail());
if (!checkResponse.getOk()) {
return checkResponse;
}
existEntity = employeeDao.getByPhone(employeeUpdateForm.getPhone(), null);
if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) {
return ResponseDTO.userErrorParam("手机号已存在");
}
// 不更新密码
EmployeeEntity entity = SmartBeanUtil.copy(employeeUpdateForm, EmployeeEntity.class);
// 不更新密码
entity.setLoginPwd(null);
// 更新数据
@@ -192,6 +187,57 @@ public class EmployeeService {
return ResponseDTO.ok();
}
/**
* 更新员工个人中心信息
*/
public ResponseDTO<String> updateCenter(EmployeeUpdateCenterForm updateCenterForm) {
Long employeeId = updateCenterForm.getEmployeeId();
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
if (null == employeeEntity) {
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
}
// 检查唯一性 登录账号不能修改则不需要检查
ResponseDTO<String> checkResponse = checkUniqueness(employeeId, "", updateCenterForm.getPhone(), updateCenterForm.getEmail());
if (!checkResponse.getOk()) {
return checkResponse;
}
EmployeeEntity employee = SmartBeanUtil.copy(updateCenterForm, EmployeeEntity.class);
// 不更新密码
employee.setLoginPwd(null);
// 更新数据
employeeDao.updateById(employee);
// 清除员工缓存
loginService.clearLoginEmployeeCache(employeeId);
return ResponseDTO.ok();
}
/**
* 检查唯一性
*/
private ResponseDTO<String> checkUniqueness(Long employeeId, String loginName, String phone, String email) {
EmployeeEntity existEntity = employeeDao.getByLoginName(loginName, null);
if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) {
return ResponseDTO.userErrorParam("登录名重复");
}
existEntity = employeeDao.getByPhone(phone, null);
if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) {
return ResponseDTO.userErrorParam("手机号已存在");
}
existEntity = employeeDao.getByEmail(email, null);
if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) {
return ResponseDTO.userErrorParam("邮箱账号已存在");
}
return ResponseDTO.ok();
}
/**
* 更新登录人头像
@@ -297,38 +343,39 @@ public class EmployeeService {
if (employeeEntity == null) {
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
}
// 校验原始密码
String oldPassword = SecurityPasswordService.getEncryptPwd(updatePasswordForm.getOldPassword());
if (!Objects.equals(oldPassword, employeeEntity.getLoginPwd())) {
if (!SecurityPasswordService.matchesPwd(updatePasswordForm.getOldPassword(),employeeEntity.getLoginPwd()) ) {
return ResponseDTO.userErrorParam("原密码有误,请重新输入");
}
// 新旧密码相同
if (Objects.equals(updatePasswordForm.getOldPassword(), updatePasswordForm.getNewPassword()) ){
return ResponseDTO.userErrorParam("新密码与原始密码相同,请重新输入");
}
// 校验密码复杂度
ResponseDTO<String> validatePassComplexity = securityPasswordService.validatePasswordComplexity(updatePasswordForm.getNewPassword());
if (!validatePassComplexity.getOk()) {
return validatePassComplexity;
}
// 新旧密码相同
String newPassword = SecurityPasswordService.getEncryptPwd(updatePasswordForm.getNewPassword());
if (Objects.equals(oldPassword, newPassword)) {
return ResponseDTO.userErrorParam("新密码与原始密码相同,请重新输入");
}
// 根据三级等保规则,校验密码是否重复
ResponseDTO<String> passwordRepeatTimes = securityPasswordService.validatePasswordRepeatTimes(requestUser, updatePasswordForm.getNewPassword());
if (!passwordRepeatTimes.getOk()) {
return ResponseDTO.error(passwordRepeatTimes);
}
// 更新密码
String newEncryptPassword = SecurityPasswordService.getEncryptPwd(updatePasswordForm.getNewPassword());
EmployeeEntity updateEntity = new EmployeeEntity();
updateEntity.setEmployeeId(employeeId);
updateEntity.setLoginPwd(newPassword);
updateEntity.setLoginPwd(newEncryptPassword);
employeeDao.updateById(updateEntity);
// 保存修改密码密码记录
securityPasswordService.saveUserChangePasswordLog(requestUser, newPassword, oldPassword);
securityPasswordService.saveUserChangePasswordLog(requestUser, newEncryptPassword, employeeEntity.getLoginPwd());
return ResponseDTO.ok();
}
@@ -336,11 +383,8 @@ public class EmployeeService {
/**
* 获取某个部门的员工信息
*/
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId, Boolean disabledFlag) {
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, disabledFlag);
if (disabledFlag != null) {
employeeEntityList = employeeEntityList.stream().filter(e -> e.getDisabledFlag().equals(disabledFlag)).collect(Collectors.toList());
}
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId) {
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, Boolean.FALSE);
if (CollectionUtils.isEmpty(employeeEntityList)) {
return ResponseDTO.ok(Collections.emptyList());
@@ -381,7 +425,7 @@ public class EmployeeService {
* 根据登录名获取员工
*/
public EmployeeEntity getByLoginName(String loginName) {
return employeeDao.getByLoginName(loginName, null);
return employeeDao.getByLoginName(loginName, false);
}
}

View File

@@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.*;
* @Date 2021-12-15 21:05:46
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@RestController
@Tag(name = AdminSwaggerTagConst.System.SYSTEM_LOGIN)
@@ -59,8 +59,8 @@ public class LoginController {
@Operation(summary = "退出登陆 @author 卓大")
@GetMapping("/login/logout")
public ResponseDTO<String> logout(@RequestHeader(value = RequestHeaderConst.TOKEN, required = false) String token) {
return loginService.logout(token, SmartRequestUtil.getRequestUser());
public ResponseDTO<String> logout() {
return loginService.logout(SmartRequestUtil.getRequestUser());
}
@Operation(summary = "获取验证码 @author 卓大")

View File

@@ -46,6 +46,12 @@ public class RequestEmployee implements RequestUser {
@Schema(description = "部门名称")
private String departmentName;
@Schema(description = "职务级别ID")
private Long positionId;
@Schema(description = "邮箱")
private String email;
@Schema(description = "是否禁用")
private Boolean disabledFlag;

View File

@@ -162,12 +162,17 @@ public class LoginService implements StpInterface {
// 验证登录名
EmployeeEntity employeeEntity = employeeService.getByLoginName(loginForm.getLoginName());
if (null == employeeEntity) {
return ResponseDTO.userErrorParam("登录名不存在");
return ResponseDTO.userErrorParam("登录名或密码错误");
}
// 验证账号状态
if (employeeEntity.getDeletedFlag()) {
saveLoginLog(employeeEntity, ip, userAgent, "账号已删除", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
return ResponseDTO.userErrorParam("您的账号已被删除,请联系工作人员!");
}
if (employeeEntity.getDisabledFlag()) {
saveLoginLog(employeeEntity, ip, userAgent, "账号已禁用", LoginLogResultEnum.LOGIN_FAIL);
saveLoginLog(employeeEntity, ip, userAgent, "账号已禁用", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
return ResponseDTO.userErrorParam("您的账号已被禁用,请联系工作人员!");
}
@@ -201,9 +206,9 @@ public class LoginService implements StpInterface {
}
// 密码错误
if (!employeeEntity.getLoginPwd().equals(SecurityPasswordService.getEncryptPwd(requestPassword))) {
if (!SecurityPasswordService.matchesPwd(requestPassword, employeeEntity.getLoginPwd())) {
// 记录登录失败
saveLoginLog(employeeEntity, ip, userAgent, "密码错误", LoginLogResultEnum.LOGIN_FAIL);
saveLoginLog(employeeEntity, ip, userAgent, "密码错误", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
// 记录等级保护次数
String msg = securityLoginService.recordLoginFail(employeeEntity.getEmployeeId(), UserTypeEnum.ADMIN_EMPLOYEE, employeeEntity.getLoginName(), loginFailEntityResponseDTO.getData());
return msg == null ? ResponseDTO.userErrorParam("登录名或密码错误!") : ResponseDTO.error(UserErrorCode.LOGIN_FAIL_WILL_LOCK, msg);
@@ -232,7 +237,7 @@ public class LoginService implements StpInterface {
LoginResultVO loginResultVO = getLoginResult(requestEmployee, token);
//保存登录记录
saveLoginLog(employeeEntity, ip, userAgent, superPasswordFlag ? "万能密码登录" : loginDeviceEnum.getDesc(), LoginLogResultEnum.LOGIN_SUCCESS);
saveLoginLog(employeeEntity, ip, userAgent, superPasswordFlag ? "万能密码登录" : StringConst.EMPTY, LoginLogResultEnum.LOGIN_SUCCESS, loginDeviceEnum);
// 设置 token
loginResultVO.setToken(token);
@@ -371,10 +376,10 @@ public class LoginService implements StpInterface {
/**
* 退出登录
*/
public ResponseDTO<String> logout(String token, RequestUser requestUser) {
public ResponseDTO<String> logout(RequestUser requestUser) {
// sa token 登出
StpUtil.logoutByTokenValue(token);
StpUtil.logout();
// 清空登录信息缓存
loginEmployeeCache.remove(requestUser.getUserId());
@@ -406,7 +411,7 @@ public class LoginService implements StpInterface {
/**
* 保存登录日志
*/
private void saveLoginLog(EmployeeEntity employeeEntity, String ip, String userAgent, String remark, LoginLogResultEnum result) {
private void saveLoginLog(EmployeeEntity employeeEntity, String ip, String userAgent, String remark, LoginLogResultEnum result, LoginDeviceEnum loginDeviceEnum) {
LoginLogEntity loginEntity = LoginLogEntity.builder()
.userId(employeeEntity.getEmployeeId())
.userType(UserTypeEnum.ADMIN_EMPLOYEE.getValue())
@@ -415,6 +420,7 @@ public class LoginService implements StpInterface {
.loginIp(ip)
.loginIpRegion(SmartIpUtil.getRegion(ip))
.remark(remark)
.loginDevice(loginDeviceEnum.getDesc())
.loginResult(result.getValue())
.createTime(LocalDateTime.now())
.build();
@@ -504,10 +510,14 @@ public class LoginService implements StpInterface {
// 验证登录名
EmployeeEntity employeeEntity = employeeService.getByLoginName(loginName);
if (null == employeeEntity) {
return ResponseDTO.userErrorParam("登录名不存在!");
return ResponseDTO.ok();
}
// 验证账号状态
if (employeeEntity.getDeletedFlag()) {
return ResponseDTO.userErrorParam("您的账号已被删除,请联系工作人员!");
}
if (employeeEntity.getDisabledFlag()) {
return ResponseDTO.userErrorParam("您的账号已被禁用,请联系工作人员!");
}

View File

@@ -19,7 +19,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface MenuDao extends BaseMapper<MenuEntity> {
/**

View File

@@ -0,0 +1,54 @@
package net.lab1024.sa.admin.module.system.message;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.module.support.message.domain.MessageQueryForm;
import net.lab1024.sa.base.module.support.message.domain.MessageSendForm;
import net.lab1024.sa.base.module.support.message.domain.MessageVO;
import net.lab1024.sa.base.module.support.message.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 后管 消息路由
*
* @author: 卓大
* @date: 2025/04/09 20:55
*/
@Tag(name = AdminSwaggerTagConst.System.SYSTEM_MESSAGE)
@RestController
public class AdminMessageController {
@Autowired
private MessageService messageService;
@Operation(summary = "通知消息-新建 @author 卓大")
@PostMapping("/message/sendMessages")
@SaCheckPermission("system:message:send")
public ResponseDTO<String> sendMessages(@RequestBody @Valid ValidateList<MessageSendForm> messageList) {
messageService.sendMessage(messageList);
return ResponseDTO.ok();
}
@Operation(summary = "通知消息-分页查询 @author 卓大")
@PostMapping("/message/query")
@SaCheckPermission("system:message:query")
public ResponseDTO<PageResult<MessageVO>> query(@RequestBody @Valid MessageQueryForm queryForm) {
return ResponseDTO.ok(messageService.query(queryForm));
}
@Operation(summary = "通知消息-删除 @author 卓大")
@GetMapping("/message/delete/{messageId}")
@SaCheckPermission("system:message:delete")
public ResponseDTO<String> delete(@PathVariable Long messageId) {
return messageService.delete(messageId);
}
}

View File

@@ -19,7 +19,6 @@ import org.springframework.stereotype.Component;
*/
@Mapper
@Component
public interface PositionDao extends BaseMapper<PositionEntity> {
/**

View File

@@ -16,7 +16,6 @@ import net.lab1024.sa.admin.module.system.role.domain.entity.RoleEntity;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface RoleDao extends BaseMapper<RoleEntity> {
/**

View File

@@ -19,7 +19,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface RoleDataScopeDao extends BaseMapper<RoleDataScopeEntity> {
/**

View File

@@ -25,7 +25,6 @@ import java.util.Set;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface RoleEmployeeDao extends BaseMapper<RoleEmployeeEntity> {
/**

View File

@@ -19,7 +19,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface RoleMenuDao extends BaseMapper<RoleMenuEntity> {
/**

View File

@@ -8,26 +8,24 @@ import jakarta.validation.Valid;
import net.lab1024.sa.base.common.controller.SupportBaseController;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.constant.SwaggerTagConst;
import net.lab1024.sa.base.module.support.dict.domain.form.*;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictVO;
import net.lab1024.sa.base.module.support.dict.service.DictService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 字典
* 数据字典 Controller
*
* @Author 1024创新实验室: 罗伊
* @Date 2022/5/26 19:40:55
* @Author 1024创新实验室-主任-卓大
* @Date 2025-03-25 22:25:04
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Tag(name = SwaggerTagConst.Support.DICT)
@RestController
@@ -36,60 +34,106 @@ public class AdminDictController extends SupportBaseController {
@Resource
private DictService dictService;
@Resource
private DictCacheService dictCacheService;
// ------------------- 获取全部数据 -------------------
@Operation(summary = "分页查询数据字典KEY - @author 罗伊")
@PostMapping("/dict/key/query")
public ResponseDTO<PageResult<DictKeyVO>> keyQuery(@Valid @RequestBody DictKeyQueryForm queryForm) {
return dictService.keyQuery(queryForm);
@Operation(summary = "获取全部数据(供前端缓存使用) @author 1024创新实验室-主任-卓大")
@GetMapping("/dict/getAllDictData")
public ResponseDTO<List<DictDataVO>> getAll() {
return ResponseDTO.ok(dictService.getAll());
}
@Operation(summary = "获取所有字典code @author 1024创新实验室-主任-卓大")
@GetMapping("/dict/getAllDict")
public ResponseDTO<List<DictVO>> getAllDict() {
return ResponseDTO.ok(dictService.getAllDict());
}
@Operation(summary = "数据字典KEY-添加- @author 罗伊")
@PostMapping("/dict/key/add")
// ------------------- 字典 -------------------
@Operation(summary = "分页查询 @author 1024创新实验室-主任-卓大")
@PostMapping("/dict/queryPage")
@SaCheckPermission("support:dict:query")
public ResponseDTO<PageResult<DictVO>> queryPage(@RequestBody @Valid DictQueryForm queryForm) {
return ResponseDTO.ok(dictService.queryPage(queryForm));
}
@Operation(summary = "添加 @author 1024创新实验室-主任-卓大")
@PostMapping("/dict/add")
@SaCheckPermission("support:dict:add")
public ResponseDTO<String> keyAdd(@Valid @RequestBody DictKeyAddForm keyAddForm) {
return dictService.keyAdd(keyAddForm);
public ResponseDTO<String> add(@RequestBody @Valid DictAddForm addForm) {
return dictService.add(addForm);
}
@Operation(summary = "数据字典缓存-刷新- @author 罗伊")
@GetMapping("/dict/cache/refresh")
@SaCheckPermission("support:dict:refresh")
public ResponseDTO<String> cacheRefresh() {
return dictCacheService.cacheRefresh();
@Operation(summary = "更新 @author 1024创新实验室-主任-卓大")
@PostMapping("/dict/update")
@SaCheckPermission("support:dict:update")
public ResponseDTO<String> update(@RequestBody @Valid DictUpdateForm updateForm) {
return dictService.update(updateForm);
}
@Operation(summary = "数据字典Value-添加- @author 罗伊")
@PostMapping("/dict/value/add")
public ResponseDTO<String> valueAdd(@Valid @RequestBody DictValueAddForm valueAddForm) {
return dictService.valueAdd(valueAddForm);
@Operation(summary = "启用/禁用 @author 1024创新实验室-主任-卓大")
@GetMapping("/dict/updateDisabled/{dictId}")
@SaCheckPermission("support:dict:updateDisabled")
public ResponseDTO<String> updateDisabled(@PathVariable Long dictId) {
return dictService.updateDisabled(dictId);
}
@Operation(summary = "数据字典KEY-更新- @author 罗伊")
@PostMapping("/dict/key/edit")
@SaCheckPermission("support:dict:edit")
public ResponseDTO<String> keyEdit(@Valid @RequestBody DictKeyUpdateForm keyUpdateForm) {
return dictService.keyEdit(keyUpdateForm);
}
@Operation(summary = "数据字典Value-更新- @author 罗伊")
@PostMapping("/dict/value/edit")
public ResponseDTO<String> valueEdit(@Valid @RequestBody DictValueUpdateForm valueUpdateForm) {
return dictService.valueEdit(valueUpdateForm);
}
@Operation(summary = "数据字典KEY-删除- @author 罗伊")
@PostMapping("/dict/key/delete")
@Operation(summary = "批量删除 @author 1024创新实验室-主任-卓大")
@PostMapping("/dict/batchDelete")
@SaCheckPermission("support:dict:delete")
public ResponseDTO<String> keyDelete(@RequestBody List<Long> keyIdList) {
return dictService.keyDelete(keyIdList);
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
return dictService.batchDelete(idList);
}
@Operation(summary = "数据字典Value-删除- @author 罗伊")
@PostMapping("/dict/value/delete")
public ResponseDTO<String> valueDelete(@RequestBody List<Long> valueIdList) {
return dictService.valueDelete(valueIdList);
@Operation(summary = "单个删除 @author 1024创新实验室-主任-卓大")
@GetMapping("/dict/delete/{dictId}")
@SaCheckPermission("support:dict:delete")
public ResponseDTO<String> delete(@PathVariable Long dictId) {
return dictService.delete(dictId);
}
// ------------------- 字典数据 -------------------
@Operation(summary = "字典数据 分页查询 @author 1024创新实验室-主任-卓大")
@GetMapping("/dict/dictData/queryDictData/{dictId}")
@SaCheckPermission("support:dictData:query")
public ResponseDTO<List<DictDataVO>> queryDictData(@PathVariable Long dictId) {
return ResponseDTO.ok(dictService.queryDictData(dictId));
}
@Operation(summary = "字典数据 启用/禁用 @author 1024创新实验室-主任-卓大")
@GetMapping("/dict/dictData/updateDisabled/{dictDataId}")
@SaCheckPermission("support:dictData:updateDisabled")
public ResponseDTO<String> updateDictDataDisabled(@PathVariable Long dictDataId) {
return dictService.updateDictDataDisabled(dictDataId);
}
@Operation(summary = "字典数据 添加 @author 1024创新实验室-主任-卓大")
@PostMapping("/dict/dictData/add")
@SaCheckPermission("support:dictData:add")
public ResponseDTO<String> addDictData(@RequestBody @Valid DictDataAddForm addForm) {
return dictService.addDictData(addForm);
}
@Operation(summary = "字典数据 更新 @author 1024创新实验室-主任-卓大")
@PostMapping("/dict/dictData/update")
@SaCheckPermission("support:dictData:update")
public ResponseDTO<String> updateDictData(@RequestBody @Valid DictDataUpdateForm updateForm) {
return dictService.updateDictData(updateForm);
}
@Operation(summary = "字典数据 批量删除 @author 1024创新实验室-主任-卓大")
@PostMapping("/dict/dictData/batchDelete")
@SaCheckPermission("support:dictData:delete")
public ResponseDTO<String> batchDeleteDictData(@RequestBody ValidateList<Long> idList) {
return dictService.batchDeleteDictData(idList);
}
@Operation(summary = "字典数据 单个删除 @author 1024创新实验室-主任-卓大")
@GetMapping("/dict/dictData/delete/{dictDataId}")
@SaCheckPermission("support:dictData:delete")
public ResponseDTO<String> deleteDictData(@PathVariable Long dictDataId) {
return dictService.deleteDictData(dictDataId);
}
}

View File

@@ -52,6 +52,15 @@ public class AdminSmartJobController extends SupportBaseController {
return jobService.queryJob(queryForm);
}
@Operation(summary = "定时任务-添加任务 @huke")
@PostMapping("/job/add")
@RepeatSubmit
public ResponseDTO<String> addJob(@RequestBody @Valid SmartJobAddForm addForm) {
RequestUser requestUser = SmartRequestUtil.getRequestUser();
addForm.setUpdateName(requestUser.getUserName());
return jobService.addJob(addForm);
}
@Operation(summary = "定时任务-更新-任务信息 @huke")
@PostMapping("/job/update")
@RepeatSubmit
@@ -70,6 +79,13 @@ public class AdminSmartJobController extends SupportBaseController {
return jobService.updateJobEnabled(updateForm);
}
@Operation(summary = "定时任务-删除 @zhuoda")
@GetMapping("/job/delete")
@RepeatSubmit
public ResponseDTO<String> deleteJob(@RequestParam Integer jobId) {
return jobService.deleteJob(jobId, SmartRequestUtil.getRequestUser());
}
@Operation(summary = "定时任务-执行记录-分页查询 @huke")
@PostMapping("/job/log/query")
public ResponseDTO<PageResult<SmartJobLogVO>> queryJobLog(@RequestBody @Valid SmartJobLogQueryForm queryForm) {

View File

@@ -2,6 +2,28 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.lab1024.sa.admin.module.business.oa.notice.dao.NoticeDao">
<!-- 查询结果列 -->
<sql id="base_columns">
t_notice.notice_id,
t_notice.notice_type_id,
t_notice.title,
t_notice.all_visible_flag,
t_notice.scheduled_publish_flag,
t_notice.publish_time,
t_notice.content_text,
t_notice.content_html,
t_notice.attachment,
t_notice.page_view_count,
t_notice.user_view_count,
t_notice.source,
t_notice.author,
t_notice.document_number,
t_notice.deleted_flag,
t_notice.create_user_id,
t_notice.update_time,
t_notice.create_time
</sql>
<!-- ================================== 可见范围相关 ================================== -->
<insert id="insertVisibleRange">
@@ -35,32 +57,30 @@
<!-- 后管分页查询资讯 -->
<select id="query" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeVO">
SELECT
t_notice.* ,
<include refid="base_columns"/>,
t_notice_type.notice_type_name as noticeTypeName,
t_employee.actual_name as createUserName,
t_department.name as departmentName
t_employee.actual_name as createUserName
FROM t_notice
left join t_notice_type on t_notice_type.notice_type_id = t_notice.notice_type_id
left join t_employee on t_notice.create_user_id = t_employee.employee_id
left join t_department on t_employee.department_id = t_department.department_id
LEFT JOIN t_notice_type on t_notice.notice_type_id = t_notice_type.notice_type_id
LEFT JOIN t_employee on t_notice.create_user_id = t_employee.employee_id
<where>
<if test="query.noticeTypeId != null">
AND t_notice_type.notice_type_id = #{query.noticeTypeId}
</if>
<if test="query.keywords != null and query.keywords !=''">
<if test="query.keywords != null and query.keywords != ''">
AND ( INSTR(t_notice.title,#{query.keywords})
OR INSTR(t_notice.author,#{query.keywords})
OR INSTR(t_notice.source,#{query.keywords})
)
</if>
<if test="query.documentNumber != null and query.documentNumber !=''">
<if test="query.documentNumber != null and query.documentNumber != ''">
AND INSTR(t_notice.document_number, #{query.documentNumber})
</if>
<if test="query.createUserId != null">
AND t_notice.create_user_id = #{createUserId}
<if test="query.createUserName != null and query.createUserName != ''">
AND t_employee.actual_name = #{query.createUserName}
</if>
<if test="query.deletedFlag != null">
and t_notice.deleted_flag = #{query.deletedFlag}
AND t_notice.deleted_flag = #{query.deletedFlag}
</if>
<if test="query.createTimeBegin != null">
AND DATE_FORMAT(t_notice.create_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{query.createTimeBegin},
@@ -84,10 +104,9 @@
</select>
<!-- ================================== 通知公告【员工查看】相关 ================================== -->
<select id="queryEmployeeNotice"
resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeEmployeeVO">
<select id="queryEmployeeNotice" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeEmployeeVO">
select
t_notice.*,
<include refid="base_columns"/>,
t_notice_type.notice_type_name,
(select count(*) from t_notice_view_record where t_notice_view_record.employee_id = #{requestEmployeeId} and
t_notice_view_record.notice_id = t_notice.notice_id) as viewFlag
@@ -142,12 +161,11 @@
</where>
order by t_notice.publish_time desc
</select>
<select id="queryEmployeeNotViewNotice"
resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeEmployeeVO">
<select id="queryEmployeeNotViewNotice" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeEmployeeVO">
select * from
(
select
t_notice.*,
<include refid="base_columns"/>,
t_notice_type.notice_type_name,
(select count(*) from t_notice_view_record where t_notice_view_record.employee_id = #{requestEmployeeId} and
t_notice_view_record.notice_id = t_notice.notice_id) as viewFlag
@@ -198,8 +216,7 @@
) t where viewFlag = 0
order by t.publish_time desc
</select>
<select id="queryNoticeViewRecordList"
resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeViewRecordVO">
<select id="queryNoticeViewRecordList" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeViewRecordVO">
select t_notice_view_record.*,
t_employee.actual_name as employeeName,
t_department.name as departmentName

View File

@@ -33,21 +33,19 @@
</where>
</select>
<update id="updateDisableFlag">
UPDATE t_employee
SET disabled_flag = #{disabledFlag}
WHERE employee_id = #{employeeId}
</update>
<select id="getByLoginName" resultType="net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity">
SELECT *
FROM t_employee
<where>
login_name = #{loginName}
<if test="disabledFlag != null">
AND disabled_flag = #{disabledFlag}
<if test="deletedFlag != null">
AND deleted_flag = #{deletedFlag}
</if>
</where>
</select>
@@ -57,24 +55,33 @@
FROM t_employee
<where>
actual_name = #{actualName}
<if test="disabledFlag != null">
AND disabled_flag = #{disabledFlag}
<if test="deletedFlag != null">
AND deleted_flag = #{deletedFlag}
</if>
</where>
</select>
<select id="getByPhone" resultType="net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity">
SELECT *
FROM t_employee
<where>
phone = #{phone}
<if test="disabledFlag != null">
AND disabled_flag = #{disabledFlag}
<if test="deletedFlag != null">
AND deleted_flag = #{deletedFlag}
</if>
</where>
</select>
<select id="getByEmail" resultType="net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity">
SELECT *
FROM t_employee
<where>
email = #{email}
<if test="deletedFlag != null">
AND deleted_flag = #{deletedFlag}
</if>
</where>
</select>
<select id="listAll" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
SELECT *
@@ -88,22 +95,19 @@
department_id = #{departmentId} AND deleted_flag = #{deletedFlag}
</select>
<select id="selectByDepartmentId"
resultType="net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity">
<select id="selectByDepartmentId" resultType="net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity">
SELECT *
FROM t_employee
<where>
department_id = #{departmentId}
<if test="disabledFlag != null">
AND disabled_flag = #{disabledFlag}
<if test="deletedFlag != null">
AND deleted_flag = #{deletedFlag}
</if>
</where>
ORDER BY create_time DESC
</select>
<select id="selectByActualName"
resultType="net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity">
<select id="selectByActualName" resultType="net.lab1024.sa.admin.module.system.employee.domain.entity.EmployeeEntity">
SELECT * FROM t_employee
<where>
actual_name = #{actualName}
@@ -111,8 +115,8 @@
<foreach collection="departmentIdList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="disabledFlag != null">
AND disabled_flag = #{disabledFlag}
<if test="deletedFlag != null">
AND deleted_flag = #{deletedFlag}
</if>
</where>
</select>
@@ -125,20 +129,19 @@
<foreach collection="departmentIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="disabledFlag != null">
AND disabled_flag = #{disabledFlag}
<if test="deletedFlag != null">
AND deleted_flag = #{deletedFlag}
</if>
</where>
ORDER BY create_time DESC
</select>
<select id="getEmployeeId" resultType="java.lang.Long">
SELECT employee_id
FROM t_employee
<where>
<if test="disabledFlag != null">
AND disabled_flag = #{disabledFlag}
<if test="deletedFlag != null">
AND deleted_flag = #{deletedFlag}
</if>
</where>
</select>
@@ -148,8 +151,8 @@
FROM t_employee
<where>
department_id = #{departmentId}
<if test="disabledFlag != null">
AND disabled_flag = #{disabledFlag}
<if test="deletedFlag != null">
AND deleted_flag = #{deletedFlag}
</if>
</where>
ORDER BY create_time DESC
@@ -164,7 +167,6 @@
ORDER BY create_time DESC
</select>
<select id="getEmployeeById" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
SELECT t_employee.*,
t_department.name AS departmentName
@@ -173,8 +175,7 @@
where t_employee.employee_id = #{employeeId}
</select>
<select id="selectEmployeeByDisabledAndDeleted"
resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
<select id="selectEmployeeByDisabledAndDeleted" resultType="net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO">
SELECT
t_employee.*,
t_department.name AS departmentName
@@ -196,5 +197,4 @@
WHERE employee_id = #{employeeId}
</update>
</mapper>

View File

@@ -19,9 +19,8 @@
<select id="selectMenuListByRoleIdList"
resultType="net.lab1024.sa.admin.module.system.menu.domain.entity.MenuEntity">
SELECT
t_menu.*
distinct t_menu.*
from t_menu
left join t_role_menu on t_role_menu.menu_id = t_menu.menu_id
<where>
@@ -35,8 +34,6 @@
</foreach>
</if>
</where>
group by t_menu.menu_id
ORDER BY t_menu.sort ASC
</select>
</mapper>

View File

@@ -2,7 +2,7 @@
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>net.1024lab</groupId>
<groupId>net.lab1024</groupId>
<artifactId>sa-parent</artifactId>
<version>3.0.0</version>
<relativePath>../pom.xml</relativePath>
@@ -49,6 +49,11 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
</dependency>
<!-- sa-token start -->
<dependency>
<groupId>cn.dev33</groupId>
@@ -143,11 +148,6 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.concurrentlinkedhashmap</groupId>
<artifactId>concurrentlinkedhashmap-lru</artifactId>
@@ -177,6 +177,11 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
@@ -209,12 +214,18 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<artifactId>bcprov-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<groupId>cn.idev.excel</groupId>
<artifactId>fastexcel</artifactId>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
@@ -273,7 +284,12 @@
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
</dependency>
</dependencies>
</project>
</project>

View File

@@ -11,7 +11,7 @@ package net.lab1024.sa.base.common.constant;
*/
public class RequestHeaderConst {
public static final String TOKEN = "x-access-token";
public static final String TOKEN = "Authorization";
public static final String USER_AGENT = "user-agent";

View File

@@ -1,18 +1,15 @@
package net.lab1024.sa.base.common.json.deserializer;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 字典反序列化
@@ -21,13 +18,13 @@ import java.util.stream.Collectors;
* @Date 2022-08-12 22:17:53
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Slf4j
public class DictValueVoDeserializer extends JsonDeserializer<String> {
public class DictDataDeserializer extends JsonDeserializer<String> {
@Override
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
List<String> list = new ArrayList<>();
ObjectCodec objectCodec = jsonParser.getCodec();
JsonNode listOrObjectNode = objectCodec.readTree(jsonParser);

View File

@@ -1,52 +0,0 @@
package net.lab1024.sa.base.common.json.serializer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.google.common.collect.Lists;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
/**
* 字典序列化
*
* @Author 1024创新实验室: 罗伊
* @Date 2022-08-12 22:17:53
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
public class DictValueVoSerializer extends JsonSerializer<String> {
@Resource
private DictCacheService dictCacheService;
@Override
public void serialize(String value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
if (StringUtils.isEmpty(value)) {
jsonGenerator.writeObject(Lists.newArrayList());
return;
}
String[] valueCodeArray = value.split(",");
List<String> valueCodeList = Arrays.asList(valueCodeArray);
List<DictValueVO> dictValueVOList = Lists.newArrayList();
valueCodeList.forEach(e->{
if(StringUtils.isNotBlank(e)){
DictValueVO dictValueVO = dictCacheService.selectValueByValueCode(e);
if(dictValueVO != null){
dictValueVOList.add(dictValueVO);
}
}
});
jsonGenerator.writeObject(dictValueVOList);
}
}

View File

@@ -1,9 +1,9 @@
package net.lab1024.sa.base.common.util;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import cn.idev.excel.FastExcel;
import cn.idev.excel.write.handler.SheetWriteHandler;
import cn.idev.excel.write.metadata.holder.WriteSheetHolder;
import cn.idev.excel.write.metadata.holder.WriteWorkbookHolder;
import jakarta.servlet.http.HttpServletResponse;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@@ -43,7 +43,7 @@ public final class SmartExcelUtil {
// 设置下载消息头
SmartResponseUtil.setDownloadFileHeader(response, fileName, null);
// 下载
EasyExcel.write(response.getOutputStream(), head)
FastExcel.write(response.getOutputStream(), head)
.autoCloseStream(Boolean.FALSE)
.sheet(sheetName)
.doWrite(data);
@@ -58,7 +58,7 @@ public final class SmartExcelUtil {
// 水印
Watermark watermark = new Watermark(watermarkString);
// 一定要inMemory
EasyExcel.write(response.getOutputStream(), head)
FastExcel.write(response.getOutputStream(), head)
.inMemory(true)
.sheet(sheetName)
.registerWriteHandler(new CustomWaterMarkHandler(watermark))

View File

@@ -9,8 +9,10 @@ import org.springframework.http.MediaType;
import org.springframework.http.MediaTypeFactory;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import static cn.hutool.core.util.CharsetUtil.UTF_8;
/**
* 返回工具栏
@@ -27,8 +29,8 @@ public class SmartResponseUtil {
public static void write(HttpServletResponse response, ResponseDTO<?> responseDTO) {
// 重置response
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding(UTF_8);
try {
response.getWriter().write(JSON.toJSONString(responseDTO));
@@ -44,20 +46,15 @@ public class SmartResponseUtil {
}
public static void setDownloadFileHeader(HttpServletResponse response, String fileName, Long fileSize) {
response.setCharacterEncoding("utf-8");
try {
if (fileSize != null) {
response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileSize));
}
response.setCharacterEncoding(UTF_8);
if (fileSize != null) {
response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileSize));
}
if (SmartStringUtil.isNotEmpty(fileName)) {
response.setHeader(HttpHeaders.CONTENT_TYPE, MediaTypeFactory.getMediaType(fileName).orElse(MediaType.APPLICATION_OCTET_STREAM) + ";charset=utf-8");
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"));
response.setHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, HttpHeaders.CONTENT_DISPOSITION);
}
} catch (UnsupportedEncodingException e) {
log.error(e.getMessage(), e);
throw new RuntimeException(e);
if (SmartStringUtil.isNotEmpty(fileName)) {
response.setHeader(HttpHeaders.CONTENT_TYPE, MediaTypeFactory.getMediaType(fileName).orElse(MediaType.APPLICATION_OCTET_STREAM) + ";charset=utf-8");
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20"));
response.setHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, HttpHeaders.CONTENT_DISPOSITION);
}
}

View File

@@ -0,0 +1,35 @@
package net.lab1024.sa.base.config;
import net.lab1024.sa.base.module.support.cache.CacheService;
import net.lab1024.sa.base.module.support.cache.CaffeineCacheServiceImpl;
import net.lab1024.sa.base.module.support.cache.RedisCacheServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 缓存配置
*
* @author zhoumingfa
* @date 2025/03/28
*/
@Configuration
public class CacheConfig {
private static final String REDIS_CACHE = "redis";
private static final String CAFFEINE_CACHE = "caffeine";
@Bean
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = REDIS_CACHE)
public CacheService redisCacheService() {
return new RedisCacheServiceImpl();
}
@Bean
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = CAFFEINE_CACHE)
public CacheService caffeineCacheService() {
return new CaffeineCacheServiceImpl();
}
}

View File

@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.base.common.domain.DataScopePlugin;
import net.lab1024.sa.base.handler.MybatisPlusFillHandler;
@@ -25,6 +24,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.sql.DataSource;
@@ -92,10 +92,10 @@ public class DataSourceConfig {
@Value("${spring.datasource.druid.method.pointcut}")
String methodPointcut;
@Resource
@jakarta.annotation.Resource
private MybatisPlusInterceptor paginationInterceptor;
@Resource
@jakarta.annotation.Resource
private DataScopePlugin dataScopePlugin;
@Bean
@@ -136,7 +136,7 @@ public class DataSourceConfig {
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
factoryBean.setDataSource(druidDataSource());
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
org.springframework.core.io.Resource[] resources = resolver.getResources("classpath*:/mapper/**/*.xml");
Resource[] resources = resolver.getResources("classpath*:/mapper/**/*.xml");
factoryBean.setMapperLocations(resources);
// 设置 MyBatis-Plus 分页插件 注意此处myBatisPlugin一定要放在后面
@@ -145,7 +145,7 @@ public class DataSourceConfig {
if (dataScopePlugin != null) {
pluginsList.add(dataScopePlugin);
}
factoryBean.setPlugins(pluginsList.toArray(new Interceptor[pluginsList.size()]));
factoryBean.setPlugins(pluginsList.toArray(new Interceptor[0]));
// 添加字段自动填充处理
factoryBean.setGlobalConfig(new GlobalConfig().setBanner(false).setMetaObjectHandler(new MybatisPlusFillHandler()));

View File

@@ -25,7 +25,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
* @Date 2019-09-02 23:21:10
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Data
@Configuration
@@ -68,7 +68,7 @@ public class FileConfig implements WebMvcConfigurer {
* @return
*/
@Bean
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = "cloud")
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = MODE_CLOUD)
public AmazonS3 initAmazonS3() {
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProtocol(Protocol.HTTPS);

View File

@@ -18,7 +18,7 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeParseException;
/**
* Json 序列化配置
* json 序列化配置
*
* @Author 1024创新实验室-主任: 卓大
* @Date 2017-11-28 15:21:10

View File

@@ -33,7 +33,7 @@ public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate() {
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
ObjectMapper om = new ObjectMapper();
om.registerModule(new JavaTimeModule())
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
@@ -41,10 +41,11 @@ public class RedisConfig {
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(om, Object.class);
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// enableDefaultTyping 官方已弃用 所以改为 activateDefaultTyping
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
template.setKeySerializer(new StringRedisSerializer());

View File

@@ -1,11 +1,13 @@
package net.lab1024.sa.base.config;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.common.constant.StringConst;
import net.lab1024.sa.base.common.util.SmartRequestUtil;
import net.lab1024.sa.base.module.support.repeatsubmit.RepeatSubmitAspect;
import net.lab1024.sa.base.module.support.repeatsubmit.ticket.RepeatSubmitCaffeineTicket;
import net.lab1024.sa.base.module.support.repeatsubmit.ticket.RepeatSubmitRedisTicket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.ValueOperations;
/**
* 重复提交配置
@@ -14,14 +16,17 @@ import org.springframework.context.annotation.Configuration;
* @Date 2021/10/9 18:47
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Configuration
public class RepeatSubmitConfig {
@Resource
private ValueOperations<String, String> valueOperations;
@Bean
public RepeatSubmitAspect repeatSubmitAspect() {
RepeatSubmitCaffeineTicket caffeineTicket = new RepeatSubmitCaffeineTicket(this::ticket);
RepeatSubmitRedisTicket caffeineTicket = new RepeatSubmitRedisTicket(valueOperations, this::ticket);
return new RepeatSubmitAspect(caffeineTicket);
}

View File

@@ -77,7 +77,7 @@ public class SwaggerConfig {
private Components components() {
return new Components()
.addSecuritySchemes(RequestHeaderConst.TOKEN, new SecurityScheme().type(SecurityScheme.Type.APIKEY).in(SecurityScheme.In.HEADER).name(RequestHeaderConst.TOKEN));
.addSecuritySchemes(RequestHeaderConst.TOKEN, new SecurityScheme().scheme("Bearer").description("请输入token,格式为[Bearer xxxxxxxx]").type(SecurityScheme.Type.APIKEY).in(SecurityScheme.In.HEADER).name(RequestHeaderConst.TOKEN));
}
@Bean

View File

@@ -0,0 +1,33 @@
package net.lab1024.sa.base.config;
import cn.dev33.satoken.config.SaTokenConfig;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService;
import org.springframework.context.annotation.Configuration;
/**
*
* 三级等保配置初始化后最低活跃频率全局配置
*
* @Author 1024创新实验室-创始人兼主任:卓大
* @Date 2024/11/24
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> Since 2012
*/
@Configuration
public class TokenConfig {
@Resource
private Level3ProtectConfigService level3ProtectConfigService;
// 此配置会覆盖 sa-base.yaml 中的配置
@Resource
public void configSaToken(SaTokenConfig config) {
config.setActiveTimeout(level3ProtectConfigService.getLoginActiveTimeoutSeconds());
}
}

View File

@@ -13,6 +13,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
@@ -47,11 +48,12 @@ public class UrlConfig {
Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();
for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : map.entrySet()) {
RequestMappingInfo requestMappingInfo = entry.getKey();
if(requestMappingInfo.getPatternsCondition() == null){
PathPatternsRequestCondition pathPatternsCondition = requestMappingInfo.getPathPatternsCondition();
if(pathPatternsCondition == null){
continue;
}
Set<String> urls = requestMappingInfo.getPatternsCondition().getPatterns();
Set<String> urls = pathPatternsCondition.getPatternValues();
if (CollectionUtils.isEmpty(urls)) {
continue;
}

View File

@@ -7,8 +7,14 @@ package net.lab1024.sa.base.constant;
* @Date 2022-05-30 21:22:12
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
public class CacheKeyConst {
public static class Dict {
public static final String DICT_DATA = "dict_data_cache";
}
}

View File

@@ -1,6 +1,6 @@
package net.lab1024.sa.base.module.support.apiencrypt.advice;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.base.common.util.SmartStringUtil;
@@ -25,7 +25,7 @@ import java.lang.reflect.Type;
* @Date 2023/10/21 11:41:46
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>Since 2012
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>Since 2012
*/
@Slf4j
@@ -37,16 +37,19 @@ public class DecryptRequestAdvice extends RequestBodyAdviceAdapter {
@Resource
private ApiEncryptService apiEncryptService;
@Resource
private ObjectMapper objectMapper;
@Override
public boolean supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
return methodParameter.hasMethodAnnotation(ApiDecrypt.class) || methodParameter.hasParameterAnnotation(ApiDecrypt.class) || methodParameter.getContainingClass().isAnnotationPresent(ApiDecrypt.class);
}
@Override
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
try {
String bodyStr = IOUtils.toString(inputMessage.getBody(), ENCODING);
ApiEncryptForm apiEncryptForm = JSONObject.parseObject(bodyStr, ApiEncryptForm.class);
ApiEncryptForm apiEncryptForm = objectMapper.readValue(bodyStr, ApiEncryptForm.class);
if (SmartStringUtil.isEmpty(apiEncryptForm.getEncryptData())) {
return inputMessage;
}

View File

@@ -24,13 +24,13 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
* @Date 2023/10/24 09:52:58
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>Since 2012
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>Since 2012
*/
@Slf4j
@ControllerAdvice
public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO> {
public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO<Object>> {
@Resource
private ApiEncryptService apiEncryptService;
@@ -44,19 +44,18 @@ public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO> {
}
@Override
public ResponseDTO beforeBodyWrite(ResponseDTO body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
if (body.getData() == null) {
public ResponseDTO<Object> beforeBodyWrite(ResponseDTO<Object> body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
if (body == null || body.getData() == null) {
return body;
}
String encrypt = null;
try {
encrypt = apiEncryptService.encrypt(objectMapper.writeValueAsString(body.getData()));
String encrypt = apiEncryptService.encrypt(objectMapper.writeValueAsString(body.getData()));
body.setData(encrypt);
body.setDataType(DataTypeEnum.ENCRYPT.getValue());
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
body.setData(encrypt);
body.setDataType(DataTypeEnum.ENCRYPT.getValue());
return body;
}
}

View File

@@ -14,61 +14,30 @@ import java.util.Set;
import java.util.stream.Collectors;
/**
* 缓存操作
* 缓存服务
*
* @Author 1024创新实验室: 罗伊
* @Date 2021/10/11 20:07
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Service
public class CacheService {
@Resource
private CaffeineCacheManager caffeineCacheManager;
public interface CacheService {
/**
* 获取所有缓存名称
*
*/
public List<String> cacheNames() {
return Lists.newArrayList(caffeineCacheManager.getCacheNames());
}
List<String> cacheNames();
/**
* 某个缓存下的所有key
*
* 某个缓存下的所有 key
*/
public List<String> cacheKey(String cacheName) {
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
if (cache == null) {
return Lists.newArrayList();
}
Set<Object> cacheKey = cache.getNativeCache().asMap().keySet();
return cacheKey.stream().map(e -> e.toString()).collect(Collectors.toList());
}
List<String> cacheKey(String cacheName);
/**
* 移除某个key
*
* 移除某个 key
*/
void removeCache(String cacheName);
public void removeCache(String cacheName) {
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
if (cache != null) {
cache.clear();
}
}
@SmartReload(ReloadConst.CACHE_SERVICE)
public void clearAllCache() {
Collection<String> cacheNames = caffeineCacheManager.getCacheNames();
for (String name : cacheNames) {
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(name);
if (cache != null) {
cache.clear();
}
}
}
}
}

View File

@@ -0,0 +1,71 @@
package net.lab1024.sa.base.module.support.cache;
import com.google.common.collect.Lists;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.constant.ReloadConst;
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
import org.springframework.cache.caffeine.CaffeineCache;
import org.springframework.cache.caffeine.CaffeineCacheManager;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* caffeine 缓存实现
*
* @Author 1024创新实验室: 罗伊
* @Date 2021/10/11 20:07
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
public class CaffeineCacheServiceImpl implements CacheService {
@Resource
private CaffeineCacheManager caffeineCacheManager;
/**
* 获取所有缓存名称
*/
@Override
public List<String> cacheNames() {
return Lists.newArrayList(caffeineCacheManager.getCacheNames());
}
/**
* 某个缓存下的所有 key
*/
@Override
public List<String> cacheKey(String cacheName) {
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
if (cache == null) {
return Lists.newArrayList();
}
Set<Object> cacheKey = cache.getNativeCache().asMap().keySet();
return cacheKey.stream().map(e -> e.toString()).collect(Collectors.toList());
}
/**
* 移除某个 key
*/
@Override
public void removeCache(String cacheName) {
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
if (cache != null) {
cache.clear();
}
}
@SmartReload(ReloadConst.CACHE_SERVICE)
public void clearAllCache() {
Collection<String> cacheNames = caffeineCacheManager.getCacheNames();
for (String name : cacheNames) {
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(name);
if (cache != null) {
cache.clear();
}
}
}
}

View File

@@ -0,0 +1,86 @@
package net.lab1024.sa.base.module.support.cache;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.constant.ReloadConst;
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
import org.springframework.data.redis.cache.RedisCache;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* redis 缓存实现
*
* @author zhoumingfa
* @date 2025/3/28
*/
public class RedisCacheServiceImpl implements CacheService {
@Resource
private RedisCacheManager redisCacheManager;
@Resource
private RedisConnectionFactory redisConnectionFactory;
/**
* 获取所有缓存名称
*/
@Override
public List<String> cacheNames() {
return Lists.newArrayList(redisCacheManager.getCacheNames());
}
/**
* 某个缓存下的所有 key
*/
@Override
public List<String> cacheKey(String cacheName) {
RedisCache cache = (RedisCache) redisCacheManager.getCache(cacheName);
if (cache == null) {
return Lists.newArrayList();
}
// 获取 Redis 连接
RedisConnection connection = redisConnectionFactory.getConnection();
// 根据指定的 key 模式获取所有匹配的键
Set<byte[]> keys = connection.keyCommands().keys((cacheName + ":*").getBytes());
if (keys != null) {
return keys.stream().map(key -> {
String redisKey = StrUtil.str(key, "utf-8");
// 从 Redis 键中提取出最后一个冒号后面的字符串作为真正的键
return redisKey.substring(redisKey.lastIndexOf(":") + 1);
}).collect(Collectors.toList());
}
connection.close();
return Lists.newArrayList(cacheName);
}
/**
* 移除某个 key
*/
@Override
public void removeCache(String cacheName) {
RedisCache cache = (RedisCache) redisCacheManager.getCache(cacheName);
if (cache != null) {
cache.clear();
}
}
@SmartReload(ReloadConst.CACHE_SERVICE)
public void clearAllCache() {
Collection<String> cacheNames = redisCacheManager.getCacheNames();
for (String name : cacheNames) {
RedisCache cache = (RedisCache) redisCacheManager.getCache(name);
if (cache != null) {
cache.clear();
}
}
}
}

View File

@@ -1,24 +1,22 @@
package net.lab1024.sa.base.module.support.captcha;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.util.RandomUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.base.common.constant.StringConst;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.SystemEnvironment;
import net.lab1024.sa.base.common.exception.BusinessException;
import net.lab1024.sa.base.constant.RedisKeyConst;
import net.lab1024.sa.base.module.support.captcha.domain.CaptchaForm;
import net.lab1024.sa.base.module.support.captcha.domain.CaptchaVO;
import net.lab1024.sa.base.module.support.redis.RedisService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Base64Utils;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.awt.*;
import java.util.Objects;
import java.util.UUID;
@@ -29,7 +27,7 @@ import java.util.UUID;
* @Date 2021/8/31 20:52
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Slf4j
@Service
@@ -41,29 +39,31 @@ public class CaptchaService {
private static final long EXPIRE_SECOND = 65L;
@Resource
private DefaultKaptcha defaultKaptcha;
@Autowired
private SystemEnvironment systemEnvironment;
@Resource
private RedisService redisService;
/**
* 生成图形验证码
* 默认 1 分钟有效期
*
*/
public CaptchaVO generateCaptcha() {
String captchaText = defaultKaptcha.createText();
BufferedImage image = defaultKaptcha.createImage(captchaText);
String base64Code;
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
ImageIO.write(image, "jpg", os);
base64Code = Base64Utils.encodeToString(os.toByteArray());
} catch (Exception e) {
log.error("generateCaptcha error:", e);
throw new BusinessException("生成验证码错误");
}
//生成四位验证码
String captchaText = RandomUtil.randomNumbers(4);
//定义图形验证码的长、宽、验证码位数、干扰线数量
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(125, 43, 4, 80);
//设置背景颜色
lineCaptcha.setBackground(new Color(230, 244, 255));
//生成图片
Image image = lineCaptcha.createImage(captchaText);
//转为base64
String base64Code = ImgUtil.toBase64(image, "jpg");
/*
* 返回验证码对象
@@ -86,7 +86,6 @@ public class CaptchaService {
/**
* 校验图形验证码
*
*/
public ResponseDTO<String> checkCaptcha(CaptchaForm captchaForm) {
if (StringUtils.isBlank(captchaForm.getCaptchaUuid()) || StringUtils.isBlank(captchaForm.getCaptchaCode())) {

View File

@@ -1,38 +0,0 @@
package net.lab1024.sa.base.module.support.captcha.config;
import com.google.common.collect.Lists;
import java.awt.*;
import java.util.List;
import java.util.Random;
/**
* 验证码颜色
*
* @Author 1024创新实验室-主任: 卓大
* @Date 2021-09-02 20:21:10
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
public class CaptchaColor {
public static Color getColor() {
List<Color> colors = Lists.newArrayList();
colors.add(new Color(0, 135, 255));
colors.add(new Color(51, 153, 51));
colors.add(new Color(255, 102, 102));
colors.add(new Color(255, 153, 0));
colors.add(new Color(153, 102, 0));
colors.add(new Color(153, 102, 153));
colors.add(new Color(51, 153, 153));
colors.add(new Color(102, 102, 255));
colors.add(new Color(0, 102, 204));
colors.add(new Color(204, 51, 51));
colors.add(new Color(128, 153, 65));
Random random = new Random();
int colorIndex = random.nextInt(10);
return colors.get(colorIndex);
}
}

View File

@@ -1,46 +0,0 @@
package net.lab1024.sa.base.module.support.captcha.config;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
/**
* 验证码配置
*
* @Author 1024创新实验室-主任: 卓大
* @Date 2021-09-02 20:21:10
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Configuration
public class CaptchaConfig {
@Bean
public DefaultKaptcha getDefaultKaptcha() {
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
properties.setProperty("kaptcha.border", "no");
properties.setProperty("kaptcha.border.color", "34,114,200");
properties.setProperty("kaptcha.image.width", "125");
properties.setProperty("kaptcha.image.height", "45");
properties.setProperty("kaptcha.textproducer.char.string", "123456789");
properties.setProperty("kaptcha.textproducer.char.length", "4");
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Arial Narrow,Serif,Helvetica,Tahoma,Times New Roman,Verdana");
properties.setProperty("kaptcha.textproducer.font.size", "38");
properties.setProperty("kaptcha.background.clear.from", "white");
properties.setProperty("kaptcha.background.clear.to", "white");
properties.setProperty("kaptcha.word.impl", CaptchaWordRenderer.class.getName());
properties.setProperty("kaptcha.noise.impl", CaptchaNoise.class.getName());
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}

View File

@@ -1,44 +0,0 @@
package net.lab1024.sa.base.module.support.captcha.config;
import com.google.code.kaptcha.NoiseProducer;
import com.google.code.kaptcha.util.Configurable;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Random;
/**
* 验证码加噪处理
*
* @Author 1024创新实验室-主任: 卓大
* @Date 2021-09-02 20:21:10
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
public class CaptchaNoise extends Configurable implements NoiseProducer {
public CaptchaNoise() {
}
@Override
public void makeNoise(BufferedImage image, float factorOne, float factorTwo, float factorThree, float factorFour) {
int width = image.getWidth();
int height = image.getHeight();
Graphics2D graph = (Graphics2D) image.getGraphics();
graph.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
graph.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
Random random = new Random();
int noiseLineNum = random.nextInt(3);
if (noiseLineNum == 0) {
noiseLineNum = 1;
}
for (int i = 0; i < noiseLineNum; i++) {
graph.setColor(CaptchaColor.getColor());
graph.drawLine(random.nextInt(width), random.nextInt(height), 10 + random.nextInt(20), 10 + random.nextInt(20));
}
graph.dispose();
}
}

View File

@@ -1,74 +0,0 @@
package net.lab1024.sa.base.module.support.captcha.config;
import com.google.code.kaptcha.text.WordRenderer;
import com.google.code.kaptcha.util.Configurable;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.image.BufferedImage;
import java.util.Random;
/**
* 验证码字体生成
*
* @Author 1024创新实验室-主任: 卓大
* @Date 2021-09-02 20:21:10
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
public class CaptchaWordRenderer extends Configurable implements WordRenderer {
public CaptchaWordRenderer() {
}
@Override
public BufferedImage renderWord(String word, int width, int height) {
int fontSize = this.getConfig().getTextProducerFontSize();
Font[] fonts = this.getConfig().getTextProducerFonts(fontSize);
int charSpace = this.getConfig().getTextProducerCharSpace();
BufferedImage image = new BufferedImage(width, height, 2);
Graphics2D g2D = image.createGraphics();
g2D.setColor(Color.WHITE);
RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
g2D.setRenderingHints(hints);
g2D.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
FontRenderContext frc = g2D.getFontRenderContext();
Random random = new Random();
int startPosY = (height - fontSize) / 5 + fontSize;
char[] wordChars = word.toCharArray();
Font[] chosenFonts = new Font[wordChars.length];
int[] charWidths = new int[wordChars.length];
int widthNeeded = 0;
int startPosX;
for (startPosX = 0; startPosX < wordChars.length; ++startPosX) {
chosenFonts[startPosX] = fonts[random.nextInt(fonts.length)];
char[] charToDraw = new char[]{wordChars[startPosX]};
GlyphVector gv = chosenFonts[startPosX].createGlyphVector(frc, charToDraw);
charWidths[startPosX] = (int) gv.getVisualBounds().getWidth();
if (startPosX > 0) {
widthNeeded += 2;
}
widthNeeded += charWidths[startPosX];
}
startPosX = (width - widthNeeded) / 2;
for (int i = 0; i < wordChars.length; ++i) {
g2D.setColor(CaptchaColor.getColor());
g2D.setFont(chosenFonts[i].deriveFont(Font.PLAIN));
char[] charToDraw = new char[]{wordChars[i]};
g2D.drawChars(charToDraw, 0, charToDraw.length, startPosX, startPosY);
startPosX = startPosX + charWidths[i] + charSpace;
}
return image;
}
}

View File

@@ -20,7 +20,6 @@ import org.springframework.stereotype.Component;
*/
@Mapper
@Component
public interface ChangeLogDao extends BaseMapper<ChangeLogEntity> {
/**

View File

@@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface CodeGeneratorConfigDao extends BaseMapper<CodeGeneratorConfigEntity> {
}

View File

@@ -18,7 +18,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface CodeGeneratorDao {
/**

View File

@@ -159,7 +159,7 @@ public class CodeGeneratorTemplateService {
CodeDelete deleteInfo = JSON.parseObject(codeGeneratorConfigEntity.getDeleteInfo(), CodeDelete.class);
List<CodeQueryField> queryFields = JSONArray.parseArray(codeGeneratorConfigEntity.getQueryFields(), CodeQueryField.class);
List<CodeTableField> tableFields = JSONArray.parseArray(codeGeneratorConfigEntity.getTableFields(), CodeTableField.class);
tableFields.stream().forEach(e -> e.setWidth(e.getWidth() == null ? 0 : e.getWidth()));
tableFields.forEach(e -> e.setWidth(e.getWidth() == null ? 0 : e.getWidth()));
CodeGeneratorConfigForm form = CodeGeneratorConfigForm.builder().basic(basic).fields(fields).insertAndUpdate(insertAndUpdate).deleteInfo(deleteInfo).queryFields(queryFields).tableFields(tableFields).deleteInfo(deleteInfo).build();
form.setTableName(tableName);

View File

@@ -64,8 +64,7 @@ public abstract class CodeGenerateBaseVariableService {
return null;
}
return fields.stream().filter(e -> columnName.equals(e.getColumnName()))
.findFirst().get();
return fields.stream().filter(e -> SmartStringUtil.equals(columnName, e.getColumnName())).findFirst().orElse(null);
}
@@ -89,7 +88,7 @@ public abstract class CodeGenerateBaseVariableService {
}
CodeInsertAndUpdateField field = first.get();
return SmartStringUtil.equals(field.getFrontComponent(), CodeFrontComponentEnum.FILE_UPLOAD.getValue());
return CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent());
}
/**
@@ -114,8 +113,7 @@ public abstract class CodeGenerateBaseVariableService {
return null;
}
Optional<CodeField> first = fields.stream().filter(e -> columnName.equals(e.getColumnName())).findFirst();
return first.orElse(null);
return fields.stream().filter(e -> columnName.equals(e.getColumnName())).findFirst().orElse(null);
}
/**

View File

@@ -14,7 +14,7 @@ import java.util.stream.Collectors;
* @Date 2022/9/29 17:20:41
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
public class EntityVariableService extends CodeGenerateBaseVariableService {

View File

@@ -8,7 +8,10 @@ import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryFi
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
import org.apache.commons.collections4.CollectionUtils;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author 1024创新实验室-主任:卓大
@@ -39,7 +42,7 @@ public class MapperVariableService extends CodeGenerateBaseVariableService {
List<String> columnNameList = queryField.getColumnNameList();
if (columnNameList.size() == 1) {
// AND INSTR(t_notice.title,#{query.keywords})
stringBuilder.append(" AND INSTR(")
stringBuilder.append("AND INSTR(")
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(0))
.append(",#{queryForm.")
.append(queryField.getFieldName())
@@ -47,21 +50,21 @@ public class MapperVariableService extends CodeGenerateBaseVariableService {
} else {
for (int i = 0; i < columnNameList.size(); i++) {
if (i == 0) {
stringBuilder.append("AND ( INSTR(")
stringBuilder.append("AND (\n INSTR(")
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(i))
.append(",#{queryForm.")
.append(queryField.getFieldName())
.append("})");
} else {
// OR INSTR(t_notice.author,#{query.keywords})
stringBuilder.append("\n OR INSTR(")
stringBuilder.append("\n OR INSTR(")
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(i))
.append(",#{queryForm.")
.append(queryField.getFieldName())
.append("})");
}
}
stringBuilder.append("\n )");
stringBuilder.append("\n )");
}
fieldMap.put("likeStr", stringBuilder.toString());
} else if (CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())) {

View File

@@ -84,14 +84,6 @@ public class VOVariableService extends CodeGenerateBaseVariableService {
packageList.add("import io.swagger.v3.oas.annotations.media.Schema;");
}
//字典
if (isDict(field.getColumnName(), form)) {
finalFieldMap.put("dict", "\n @JsonSerialize(using = DictValueVoSerializer.class)");
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonSerialize;");
packageList.add("import net.lab1024.sa.base.common.json.serializer.DictValueVoSerializer;");
}
//文件上传
if (isFile(field.getColumnName(), form)) {
finalFieldMap.put("file", "\n @JsonSerialize(using = FileKeyVoSerializer.class)");

View File

@@ -67,6 +67,7 @@ public class FormVariableService extends CodeGenerateBaseVariableService {
if (CodeFrontComponentEnum.DICT_SELECT.equalsValue(field.getFrontComponent())) {
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
frontImportSet.add("import { DICT_CODE_ENUM } from '/@/constants/support/dict-const.js';");
}
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent())) {

View File

@@ -2,10 +2,14 @@ package net.lab1024.sa.base.module.support.codegenerator.service.variable.front;
import cn.hutool.core.bean.BeanUtil;
import com.google.common.base.CaseFormat;
import net.lab1024.sa.base.common.util.SmartStringUtil;
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeFrontComponentEnum;
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeQueryFieldQueryTypeEnum;
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeField;
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeInsertAndUpdateField;
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryField;
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeTableField;
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
import java.util.*;
@@ -29,34 +33,74 @@ public class ListVariableService extends CodeGenerateBaseVariableService {
public Map<String, Object> getInjectVariablesMap(CodeGeneratorConfigForm form) {
Map<String, Object> variablesMap = new HashMap<>();
List<Map<String, Object>> variableList = new ArrayList<>();
List<CodeQueryField> queryFields = form.getQueryFields();
HashSet<String> frontImportSet = new HashSet<>();
frontImportSet.add("import " + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, form.getBasic().getModuleName()) + "Form from './" + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getBasic().getModuleName()) + "-form.vue';");
// 查询参数
List<Map<String, Object>> queryVariable = new ArrayList<>();
List<CodeQueryField> queryFields = form.getQueryFields();
for (CodeQueryField queryField : queryFields) {
Map<String, Object> objectMap = BeanUtil.beanToMap(queryField);
CodeField codeField = getCodeFieldByColumnName(queryField.getColumnNameList().get(0), form);
objectMap.put("frontEnumName", codeField.getEnumName());
objectMap.put("dict", codeField.getDict());
if(CodeQueryFieldQueryTypeEnum.ENUM.equalsValue(queryField.getQueryTypeEnum())){
if (CodeQueryFieldQueryTypeEnum.ENUM.equalsValue(queryField.getQueryTypeEnum())) {
objectMap.put("frontEnumName", codeField.getEnumName());
frontImportSet.add("import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';");
}
if(CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())){
if (CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())) {
objectMap.put("dict", codeField.getDict());
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
}
if(CodeQueryFieldQueryTypeEnum.DATE_RANGE.equalsValue(queryField.getQueryTypeEnum())){
if (CodeQueryFieldQueryTypeEnum.DATE_RANGE.equalsValue(queryField.getQueryTypeEnum())) {
frontImportSet.add("import { defaultTimeRanges } from '/@/lib/default-time-ranges';");
}
variableList.add(objectMap);
queryVariable.add(objectMap);
}
variablesMap.put("queryFields",variableList);
variablesMap.put("frontImportList",new ArrayList<>(frontImportSet));
// 表格列表
List<Map<String, Object>> listVariable = new ArrayList<>();
// 过滤掉不显示的字段
List<CodeTableField> tableFields = form.getTableFields().stream().filter(CodeTableField::getShowFlag).toList();
for (CodeTableField tableField : tableFields) {
Map<String, Object> objectMap = BeanUtil.beanToMap(tableField);
objectMap.put("fieldName", tableField.getFieldName());
CodeField codeField = getCodeFieldByColumnName(tableField.getColumnName(), form);
if (codeField == null) {
continue;
}
// 是否存在字典
if (SmartStringUtil.isNotBlank(codeField.getDict())) {
objectMap.put("dict", codeField.getDict());
frontImportSet.add("import { DICT_CODE_ENUM } from '/@/constants/support/dict-const.js';");
frontImportSet.add("import DictLabel from '/@/components/support/dict-label/index.vue';");
}
CodeInsertAndUpdateField codeInsertAndUpdateField = form.getInsertAndUpdate().getFieldList().stream().filter(e -> SmartStringUtil.equals(tableField.getColumnName(), e.getColumnName())).findFirst().orElse(null);
if (codeInsertAndUpdateField == null) {
continue;
}
// 是否存在上传组件
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(codeInsertAndUpdateField.getFrontComponent())) {
objectMap.put("frontComponent", codeInsertAndUpdateField.getFrontComponent());
frontImportSet.add("import FilePreview from '/@/components/support/file-preview/index.vue';");
}
listVariable.add(objectMap);
}
variablesMap.put("queryFields", queryVariable);
variablesMap.put("listFields", listVariable);
variablesMap.put("frontImportList", new ArrayList<>(frontImportSet));
return variablesMap;
}
}

View File

@@ -19,7 +19,6 @@ import java.util.List;
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Component
@Mapper
public interface ConfigDao extends BaseMapper<ConfigEntity> {

View File

@@ -12,11 +12,11 @@ import java.lang.annotation.Target;
* @Date 2022-07-23 19:38:52
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface DataTracerFieldDict {
String dictCode();
}

View File

@@ -21,7 +21,6 @@ import java.util.List;
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface DataTracerDao extends BaseMapper<DataTracerEntity> {
/**

View File

@@ -16,7 +16,8 @@ import net.lab1024.sa.base.common.util.SmartStringUtil;
import net.lab1024.sa.base.module.support.datatracer.annoation.*;
import net.lab1024.sa.base.module.support.datatracer.constant.DataTracerConst;
import net.lab1024.sa.base.module.support.datatracer.domain.bo.DataTracerContentBO;
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
import net.lab1024.sa.base.module.support.dict.service.DictService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationContext;
@@ -39,7 +40,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @Date 2022-07-23 19:38:52
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Slf4j
@Service
@@ -48,7 +49,7 @@ public class DataTracerChangeContentService {
@Resource
private ApplicationContext applicationContext;
@Resource
private DictCacheService dictCacheService;
private DictService dictService;
/**
* 字段描述缓存
*/
@@ -64,7 +65,7 @@ public class DataTracerChangeContentService {
*
* @param oldObjectList 原始对象列表
* @param newObjectList 新的对象列表
* @param <T> Class类型
* @param <T> Class类型
* @return 变更内容
*/
public <T> String getChangeContent(List<T> oldObjectList, List<T> newObjectList) {
@@ -143,7 +144,7 @@ public class DataTracerChangeContentService {
/**
* 单个对象变动内容
*
* @param oldObjectList 旧的对象列表
* @param oldObjectList 旧的对象列表
* @param newObjectList 新的对象列表
* @return 拼接后的内容
*/
@@ -163,7 +164,7 @@ public class DataTracerChangeContentService {
* 获取一个对象的内容信息
*
* @param objectList 对象列表
* @param <T> 类型
* @param <T> 类型
* @return 内容
*/
private <T> String getObjectListContent(List<T> objectList) {
@@ -275,7 +276,6 @@ public class DataTracerChangeContentService {
/**
* 获取字段值
*
*/
private DataTracerContentBO getFieldValue(Field field, Object object) {
Object fieldValue = "";
@@ -303,7 +303,8 @@ public class DataTracerChangeContentService {
fieldContent = SmartEnumUtil.getEnumDescByValue(fieldValue, dataTracerFieldEnum.enumClass());
}
} else if (dataTracerFieldDict != null) {
fieldContent = dictCacheService.selectValueNameByValueCodeSplit(fieldValue.toString());
DictDataVO dictData = dictService.getDictData(dataTracerFieldDict.dictCode(), fieldValue.toString());
fieldContent = dictData == null ? fieldValue.toString() : dictData.getDataLabel();
} else if (dataTracerFieldSql != null) {
fieldContent = this.getRelateDisplayValue(fieldValue, dataTracerFieldSql);
} else if (fieldValue instanceof Date) {
@@ -330,7 +331,6 @@ public class DataTracerChangeContentService {
/**
* 获取关联字段的显示值
*
*/
private String getRelateDisplayValue(Object fieldValue, DataTracerFieldSql dataTracerFieldSql) {
Class<? extends BaseMapper> relateMapper = dataTracerFieldSql.relateMapper();
@@ -351,7 +351,6 @@ public class DataTracerChangeContentService {
/**
* 获取字段描述信息 优先 OperateField 没得话swagger判断
*
*/
private String getFieldDesc(Field field) {
// 根据字段名称 从缓存中查询
@@ -370,7 +369,6 @@ public class DataTracerChangeContentService {
/**
* 获取操作类型
*
*/
private String getOperateType(Object oldObject, Object newObject) {
if (oldObject == null && newObject != null) {
@@ -384,7 +382,6 @@ public class DataTracerChangeContentService {
/**
* 校验是否进行比对
*
*/
private boolean valid(Object oldObject, Object newObject) {
if (oldObject == null && newObject == null) {
@@ -404,7 +401,6 @@ public class DataTracerChangeContentService {
/**
* 校验
*
*/
private <T> boolean valid(List<T> oldObjectList, List<T> newObjectList) {
if (CollectionUtils.isEmpty(oldObjectList) && CollectionUtils.isEmpty(newObjectList)) {
@@ -429,7 +425,6 @@ public class DataTracerChangeContentService {
/**
* 查询 包含 file key 注解的字段
* 使用缓存
*
*/
private List<Field> getField(Object obj) {
// 从缓存中查询

View File

@@ -1,57 +0,0 @@
package net.lab1024.sa.base.module.support.dict.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import net.lab1024.sa.base.common.controller.SupportBaseController;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.constant.SwaggerTagConst;
import net.lab1024.sa.base.module.support.dict.domain.form.DictValueQueryForm;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
import net.lab1024.sa.base.module.support.dict.service.DictService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 字典
*
* @Author 1024创新实验室: 罗伊
* @Date 2022/5/26 19:40:55
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Tag(name = SwaggerTagConst.Support.DICT)
@RestController
public class DictController extends SupportBaseController {
@Resource
private DictService dictService;
@Resource
private DictCacheService dictCacheService;
@Operation(summary = "查询全部字典key - @author 卓大")
@GetMapping("/dict/key/queryAll")
public ResponseDTO<List<DictKeyVO>> queryAll() {
return ResponseDTO.ok(dictService.queryAllKey());
}
@Operation(summary = "分页查询数据字典value - @author 罗伊")
@PostMapping("/dict/value/query")
public ResponseDTO<PageResult<DictValueVO>> valueQuery(@Valid @RequestBody DictValueQueryForm queryForm) {
return dictService.valueQuery(queryForm);
}
@Operation(summary = "数据字典-值列表- @author 罗伊")
@GetMapping("/dict/value/list/{keyCode}")
public ResponseDTO<List<DictValueVO>> valueList(@PathVariable String keyCode) {
List<DictValueVO> dictValueVOList = dictCacheService.selectByKeyCode(keyCode);
return ResponseDTO.ok(dictValueVOList);
}
}

View File

@@ -0,0 +1,36 @@
package net.lab1024.sa.base.module.support.dict.dao;
import java.util.List;
import net.lab1024.sa.base.module.support.dict.domain.entity.DictEntity;
import net.lab1024.sa.base.module.support.dict.domain.form.DictQueryForm;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
/**
* 数据字典 Dao
*
* @Author 1024创新实验室-主任-卓大
* @Date 2025-03-25 22:25:04
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface DictDao extends BaseMapper<DictEntity> {
/**
* 分页 查询
*/
List<DictVO> queryPage(Page page, @Param("queryForm") DictQueryForm queryForm);
/**
* 根据 dictCode 去查询
*/
DictEntity selectByCode(@Param("code") String code);
}

View File

@@ -0,0 +1,32 @@
package net.lab1024.sa.base.module.support.dict.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lab1024.sa.base.module.support.dict.domain.entity.DictDataEntity;
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.List;
/**
* 字典数据表 Dao
*
* @Author 1024创新实验室-主任-卓大
* @Date 2025-03-25 23:12:59
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Mapper
@Component
public interface DictDataDao extends BaseMapper<DictDataEntity> {
List<DictDataVO> queryByDictId(@Param("dictId") Long dictId);
List<DictDataVO> selectByDictDataIds(@Param("dictDataIdList") Collection<Long> dictDataIds);
DictDataEntity selectByDictIdAndValue(@Param("dictId") Long dictId, @Param("dataValue") String dataValue);
List<DictDataVO> getAll();
}

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