Skip to content

Commit 85c6087

Browse files
author
zhuoda
committed
v3.6.0 三级等保重磅更新:1、【新增】双因子方式登录;2、【新增】定期修改密码;3、【新增】最大活跃时间;4、【新增】敏感数据脱敏;5、【新增】登录锁定配置;6、【新增】密码复杂度配置;7、【新增】三级等保可配置
1 parent 50f5324 commit 85c6087

File tree

160 files changed

+4091
-1537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+4091
-1537
lines changed

smart-admin-api/pom.xml

+37-8
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2020
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2121
<java.version>1.8</java.version>
22-
<springboot.version>2.7.5</springboot.version>
22+
<springboot.version>2.7.18</springboot.version>
2323
<spring-mock.version>2.0.8</spring-mock.version>
2424
<mybatis-plus.version>3.5.2</mybatis-plus.version>
25+
<mysql-connector-j.version>8.0.33</mysql-connector-j.version>
2526
<p6spy.version>3.9.1</p6spy.version>
2627
<springdoc-openapi-ui.version>1.7.0</springdoc-openapi-ui.version>
2728
<knife4j.version>4.3.0</knife4j.version>
@@ -42,7 +43,7 @@
4243
<poi.version>5.2.4</poi.version>
4344
<ooxml-schemas.version>1.4</ooxml-schemas.version>
4445
<aws-java-sdk.version>1.11.842</aws-java-sdk.version>
45-
<log4j-spring-boot.version>2.17.2</log4j-spring-boot.version>
46+
<log4j-spring-boot.version>2.23.1</log4j-spring-boot.version>
4647
<hutool.version>5.7.22</hutool.version>
4748
<velocity-engine-core.version>2.3</velocity-engine-core.version>
4849
<jjwt.version>0.9.1</jjwt.version>
@@ -52,8 +53,12 @@
5253
<ip2region.version>2.7.0</ip2region.version>
5354
<bcprov.version>1.59</bcprov.version>
5455
<jackson-datatype-jsr310.version>2.13.4</jackson-datatype-jsr310.version>
56+
<jackson-dataformat-yaml.version>2.16.1</jackson-dataformat-yaml.version>
5557
<smartdb.version>1.2.0</smartdb.version>
5658
<redisson.version>3.25.0</redisson.version>
59+
<snakeyaml.version>2.2</snakeyaml.version>
60+
<freemarker.version>2.3.33</freemarker.version>
61+
<jsoup.version>1.18.1</jsoup.version>
5762
</properties>
5863

5964
<dependencyManagement>
@@ -81,6 +86,12 @@
8186
</exclusions>
8287
</dependency>
8388

89+
<dependency>
90+
<groupId>com.mysql</groupId>
91+
<artifactId>mysql-connector-j</artifactId>
92+
<version>${mysql-connector-j.version}</version>
93+
</dependency>
94+
8495
<dependency>
8596
<groupId>com.baomidou</groupId>
8697
<artifactId>mybatis-plus-boot-starter</artifactId>
@@ -201,12 +212,6 @@
201212
<version>${commons-text.version}</version>
202213
</dependency>
203214

204-
<dependency>
205-
<groupId>org.apache.logging.log4j</groupId>
206-
<artifactId>log4j-spring-boot</artifactId>
207-
<version>${log4j-spring-boot.version}</version>
208-
</dependency>
209-
210215
<dependency>
211216
<groupId>cn.hutool</groupId>
212217
<artifactId>hutool-all</artifactId>
@@ -309,6 +314,12 @@
309314
<version>${jackson-datatype-jsr310.version}</version>
310315
</dependency>
311316

317+
<dependency>
318+
<groupId>com.fasterxml.jackson.dataformat</groupId>
319+
<artifactId>jackson-dataformat-yaml</artifactId>
320+
<version>${jackson-dataformat-yaml.version}</version>
321+
</dependency>
322+
312323
<dependency>
313324
<groupId>net.1024lab</groupId>
314325
<artifactId>smartdb</artifactId>
@@ -341,6 +352,24 @@
341352
<version>${redisson.version}</version>
342353
</dependency>
343354

355+
<dependency>
356+
<groupId>org.yaml</groupId>
357+
<artifactId>snakeyaml</artifactId>
358+
<version>${snakeyaml.version}</version>
359+
</dependency>
360+
361+
<dependency>
362+
<groupId>org.jsoup</groupId>
363+
<artifactId>jsoup</artifactId>
364+
<version>${jsoup.version}</version>
365+
</dependency>
366+
367+
<dependency>
368+
<groupId>org.freemarker</groupId>
369+
<artifactId>freemarker</artifactId>
370+
<version>${freemarker.version}</version>
371+
</dependency>
372+
344373
</dependencies>
345374

346375
</dependencyManagement>

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/interceptor/AdminInterceptor.java

-8
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ public class AdminInterceptor implements HandlerInterceptor {
5050
@Resource
5151
private SystemEnvironment systemEnvironment;
5252

53-
@Value("${sa-token.active-timeout}")
54-
private long tokenActiveTimeout;
55-
5653
@Override
5754
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
5855

@@ -158,11 +155,6 @@ private void checkActiveTimeout(RequestEmployee requestEmployee, boolean debugNu
158155
return;
159156
}
160157

161-
// 小于1 ,也不需要检测
162-
if (tokenActiveTimeout < 1) {
163-
return;
164-
}
165-
166158
StpUtil.checkActiveTimeout();
167159
StpUtil.updateLastActiveToNow();
168160
}

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/goods/domain/form/GoodsQueryForm.java

+3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package net.lab1024.sa.admin.module.business.goods.domain.form;
22

3+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
34
import io.swagger.v3.oas.annotations.media.Schema;
45
import lombok.Data;
56
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
67
import net.lab1024.sa.base.common.domain.PageParam;
8+
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
79
import net.lab1024.sa.base.common.swagger.SchemaEnum;
810
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
911
import org.hibernate.validator.constraints.Length;
@@ -32,6 +34,7 @@ public class GoodsQueryForm extends PageParam {
3234
private Integer goodsStatus;
3335

3436
@Schema(description = "产地")
37+
@JsonDeserialize(using = DictValueVoDeserializer.class)
3538
private String place;
3639

3740
@Schema(description = "上架状态")

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/goods/service/GoodsService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public List<GoodsExcelVO> getAllGoods() {
199199
GoodsExcelVO.builder()
200200
.goodsStatus(SmartEnumUtil.getEnumDescByValue(e.getGoodsStatus(), GoodsStatusEnum.class))
201201
.categoryName(categoryQueryService.queryCategoryName(e.getCategoryId()))
202-
.place(dictCacheService.selectValueNameByValueCode(e.getPlace()))
202+
.place(Arrays.stream(e.getPlace().split(",")).map(code -> dictCacheService.selectValueNameByValueCode(code)).collect(Collectors.joining(",")))
203203
.price(e.getPrice())
204204
.goodsName(e.getGoodsName())
205205
.remark(e.getRemark())

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/dao/NoticeDao.java

+10
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,14 @@ List<NoticeEmployeeVO> queryEmployeeNotViewNotice(Page<?> page,
114114
*/
115115
void updateViewRecord(@Param("noticeId")Long noticeId, @Param("employeeId")Long requestEmployeeId,@Param("ip") String ip, @Param("userAgent")String userAgent);
116116

117+
/**
118+
* 更新 浏览量
119+
*
120+
* @param noticeId 通知 id
121+
* @param pageViewCountIncrement 页面浏览量的增量
122+
* @param userViewCountIncrement 用户浏览量的增量
123+
*/
124+
void updateViewCount(@Param("noticeId")Long noticeId,@Param("pageViewCountIncrement") Integer pageViewCountIncrement, @Param("userViewCountIncrement")Integer userViewCountIncrement);
125+
126+
117127
}

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/service/NoticeEmployeeService.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public class NoticeEmployeeService {
5252
public ResponseDTO<PageResult<NoticeEmployeeVO>> queryList(Long requestEmployeeId, NoticeEmployeeQueryForm noticeEmployeeQueryForm) {
5353
Page<?> page = SmartPageUtil.convert2PageQuery(noticeEmployeeQueryForm);
5454

55-
//获取请求人的 部门及其子部门
5655
List<Long> employeeDepartmentIdList = Lists.newArrayList();
5756
EmployeeEntity employeeEntity = employeeService.getById(requestEmployeeId);
58-
if (employeeEntity.getDepartmentId() != null) {
57+
// 如果不是管理员 则获取请求人的 部门及其子部门
58+
if (!employeeEntity.getAdministratorFlag() && employeeEntity.getDepartmentId() != null) {
5959
employeeDepartmentIdList = departmentService.selfAndChildrenIdList(employeeEntity.getDepartmentId());
6060
}
6161

@@ -106,8 +106,15 @@ public ResponseDTO<NoticeDetailVO> view(Long requestEmployeeId, Long noticeId, S
106106
long viewCount = noticeDao.viewRecordCount(noticeId, requestEmployeeId);
107107
if (viewCount == 0) {
108108
noticeDao.insertViewRecord(noticeId, requestEmployeeId, ip, userAgent, 1);
109+
// 该员工对于这个通知是第一次查看 页面浏览量+1 用户浏览量+1
110+
noticeDao.updateViewCount(noticeId, 1, 1);
111+
noticeDetailVO.setPageViewCount(noticeDetailVO.getPageViewCount() + 1);
112+
noticeDetailVO.setUserViewCount(noticeDetailVO.getUserViewCount() + 1);
109113
} else {
110114
noticeDao.updateViewRecord(noticeId, requestEmployeeId, ip, userAgent);
115+
// 该员工对于这个通知不是第一次查看 页面浏览量+1 用户浏览量+0
116+
noticeDao.updateViewCount(noticeId, 1, 0);
117+
noticeDetailVO.setPageViewCount(noticeDetailVO.getPageViewCount() + 1);
111118
}
112119

113120
return ResponseDTO.ok(noticeDetailVO);

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/department/manager/DepartmentCacheManager.java

+29-9
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,15 @@ public List<DepartmentTreeVO> buildTree(List<DepartmentVO> voList) {
141141
return treeVOList;
142142
}
143143

144-
/**
144+
/**
145145
* 构建所有根节点的下级树形结构
146-
*
146+
* 返回值为层序遍历结果
147+
* [由于departmentDao中listAll给出数据根据Sort降序 所以同一层中Sort值较大的优先遍历]
147148
*/
148-
private void recursiveBuildTree(List<DepartmentTreeVO> nodeList, List<DepartmentVO> allDepartmentList) {
149+
private List<Long> recursiveBuildTree(List<DepartmentTreeVO> nodeList, List<DepartmentVO> allDepartmentList) {
149150
int nodeSize = nodeList.size();
150-
for (int i = 0; i < nodeSize; i++) {
151+
List<Long> childIdList = new ArrayList<>();
152+
for(int i = 0; i < nodeSize; i++) {
151153
int preIndex = i - 1;
152154
int nextIndex = i + 1;
153155
DepartmentTreeVO node = nodeList.get(i);
@@ -158,16 +160,34 @@ private void recursiveBuildTree(List<DepartmentTreeVO> nodeList, List<Department
158160
node.setNextId(nodeList.get(nextIndex).getDepartmentId());
159161
}
160162

161-
ArrayList<Long> selfAndAllChildrenIdList = Lists.newArrayList();
162-
selfAndAllChildrenIdList.add(node.getDepartmentId());
163-
node.setSelfAndAllChildrenIdList(selfAndAllChildrenIdList);
164-
165163
List<DepartmentTreeVO> children = getChildren(node.getDepartmentId(), allDepartmentList);
164+
165+
List<Long> tempChildIdList = new ArrayList<>();
166166
if (CollectionUtils.isNotEmpty(children)) {
167167
node.setChildren(children);
168-
this.recursiveBuildTree(children, allDepartmentList);
168+
tempChildIdList = this.recursiveBuildTree(children, allDepartmentList);
169169
}
170+
171+
if(CollectionUtils.isEmpty(node.getSelfAndAllChildrenIdList())) {
172+
node.setSelfAndAllChildrenIdList(
173+
new ArrayList<>()
174+
);
175+
}
176+
node.getSelfAndAllChildrenIdList().add(node.getDepartmentId());
177+
178+
if(CollectionUtils.isNotEmpty(tempChildIdList)) {
179+
node.getSelfAndAllChildrenIdList().addAll(tempChildIdList);
180+
childIdList.addAll(tempChildIdList);
181+
}
182+
183+
}
184+
185+
// 保证本层遍历顺序
186+
for(int i = nodeSize - 1; i >= 0; i--) {
187+
childIdList.add(0, nodeList.get(i).getDepartmentId());
170188
}
189+
190+
return childIdList;
171191
}
172192

173193

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/department/service/DepartmentService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public ResponseDTO<String> deleteDepartment(Long departmentId) {
9292
}
9393

9494
// 是否有未删除员工
95-
int employeeNum = employeeDao.countByDepartmentId(departmentId);
95+
int employeeNum = employeeDao.countByDepartmentId(departmentId, Boolean.FALSE);
9696
if (employeeNum > 0) {
9797
return ResponseDTO.userErrorParam("请先删除部门员工");
9898
}

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/controller/EmployeeController.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import net.lab1024.sa.base.common.domain.PageResult;
1111
import net.lab1024.sa.base.common.domain.ResponseDTO;
1212
import net.lab1024.sa.base.common.util.SmartRequestUtil;
13+
import net.lab1024.sa.base.module.support.apiencrypt.annotation.ApiDecrypt;
14+
import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService;
1315
import org.springframework.web.bind.annotation.*;
1416

1517
import javax.annotation.Resource;
@@ -23,7 +25,7 @@
2325
* @Date 2021-12-09 22:57:49
2426
* @Wechat zhuoda1024
2527
26-
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
28+
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
2729
*/
2830
@RestController
2931
@Tag(name = AdminSwaggerTagConst.System.SYSTEM_EMPLOYEE)
@@ -32,6 +34,9 @@ public class EmployeeController {
3234
@Resource
3335
private EmployeeService employeeService;
3436

37+
@Resource
38+
private Level3ProtectConfigService level3ProtectConfigService;
39+
3540
@PostMapping("/employee/query")
3641
@Operation(summary = "员工管理查询 @author 卓大")
3742
public ResponseDTO<PageResult<EmployeeVO>> query(@Valid @RequestBody EmployeeQueryForm query) {
@@ -89,9 +94,17 @@ public ResponseDTO<String> batchUpdateDepartment(@Valid @RequestBody EmployeeBat
8994

9095
@Operation(summary = "修改密码 @author 卓大")
9196
@PostMapping("/employee/update/password")
97+
@ApiDecrypt
9298
public ResponseDTO<String> updatePassword(@Valid @RequestBody EmployeeUpdatePasswordForm updatePasswordForm) {
9399
updatePasswordForm.setEmployeeId(SmartRequestUtil.getRequestUserId());
94-
return employeeService.updatePassword(updatePasswordForm);
100+
return employeeService.updatePassword(SmartRequestUtil.getRequestUser(), updatePasswordForm);
101+
}
102+
103+
@Operation(summary = "获取密码复杂度 @author 卓大")
104+
@GetMapping("/employee/getPasswordComplexityEnabled")
105+
@ApiDecrypt
106+
public ResponseDTO<Boolean> getPasswordComplexityEnabled() {
107+
return ResponseDTO.ok(level3ProtectConfigService.isPasswordComplexityEnabled());
95108
}
96109

97110
@Operation(summary = "重置员工密码 @author 卓大")

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/dao/EmployeeDao.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ EmployeeEntity getByActualName(@Param("actualName") String actualName,
6969
* 获取某个部门员工数
7070
*
7171
*/
72-
Integer countByDepartmentId(@Param("departmentId") Long departmentId);
72+
Integer countByDepartmentId(@Param("departmentId") Long departmentId, @Param("deletedFlag") Boolean deletedFlag);
7373

7474
/**
7575
* 获取一批员工

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/domain/entity/EmployeeEntity.java

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public class EmployeeEntity {
5353
*/
5454
private String phone;
5555

56+
/**
57+
* 邮箱
58+
*/
59+
private String email;
60+
5661
/**
5762
* 部门id
5863
*/

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/domain/form/EmployeeAddForm.java

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public class EmployeeAddForm {
5151
@Pattern(regexp = SmartVerificationUtil.PHONE_REGEXP, message = "手机号格式不正确")
5252
private String phone;
5353

54+
@Schema(description = "邮箱")
55+
private String email;
56+
5457
@Schema(description = "角色列表")
5558
private List<Long> roleIdList;
5659

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/domain/form/EmployeeUpdatePasswordForm.java

-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ public class EmployeeUpdatePasswordForm {
2424

2525
@Schema(description = "原密码")
2626
@NotBlank(message = "原密码不能为空哦")
27-
@Pattern(regexp = SmartVerificationUtil.PWD_REGEXP, message = "原密码请输入6-15位(数字|大小写字母|小数点)")
2827
private String oldPassword;
2928

3029
@Schema(description = "新密码")
3130
@NotBlank(message = "新密码不能为空哦")
32-
@Pattern(regexp = SmartVerificationUtil.PWD_REGEXP, message = "新密码请输入6-15位(数字|大小写字母|小数点)")
3331
private String newPassword;
3432
}

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/domain/vo/EmployeeVO.java

+3
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,7 @@ public class EmployeeVO {
6262
@Schema(description = "职务名称")
6363
private String positionName;
6464

65+
@Schema(description = "邮箱")
66+
private String email;
67+
6568
}

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/manager/EmployeeManager.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ public void updateEmployee(EmployeeEntity employee, List<Long> roleIdList) {
6060
// 保存员工 获得id
6161
employeeDao.updateById(employee);
6262

63-
if (CollectionUtils.isNotEmpty(roleIdList)) {
64-
List<RoleEmployeeEntity> roleEmployeeList = roleIdList.stream().map(e -> new RoleEmployeeEntity(e, employee.getEmployeeId())).collect(Collectors.toList());
65-
this.updateEmployeeRole(employee.getEmployeeId(), roleEmployeeList);
63+
// 若为空,则删除所有角色
64+
if (CollectionUtils.isEmpty(roleIdList)) {
65+
roleEmployeeDao.deleteByEmployeeId(employee.getEmployeeId());
66+
return;
6667
}
68+
69+
List<RoleEmployeeEntity> roleEmployeeList = roleIdList.stream().map(e -> new RoleEmployeeEntity(e, employee.getEmployeeId())).collect(Collectors.toList());
70+
this.updateEmployeeRole(employee.getEmployeeId(), roleEmployeeList);
6771
}
6872

6973
/**

0 commit comments

Comments
 (0)