|
|
@@ -13,21 +13,27 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
|
import com.xjrsoft.common.enums.RoleEnum;
|
|
|
import com.xjrsoft.common.enums.YesOrNoEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
+import com.xjrsoft.common.utils.RedisUtil;
|
|
|
+import com.xjrsoft.config.CommonPropertiesConfig;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.entity.BaseGrade;
|
|
|
import com.xjrsoft.module.base.entity.BaseMajorSet;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseGradeMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseMajorSetMapper;
|
|
|
+import com.xjrsoft.module.organization.entity.User;
|
|
|
import com.xjrsoft.module.organization.entity.UserDeptRelation;
|
|
|
import com.xjrsoft.module.organization.entity.UserRoleRelation;
|
|
|
+import com.xjrsoft.module.organization.mapper.UserDeptRelationMapper;
|
|
|
import com.xjrsoft.module.organization.mapper.UserRoleRelationMapper;
|
|
|
import com.xjrsoft.module.organization.service.IUserDeptRelationService;
|
|
|
+import com.xjrsoft.module.organization.service.IUserService;
|
|
|
import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
|
|
|
import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
|
|
|
import com.xjrsoft.module.student.dto.UpdateBaseStudentUserDto;
|
|
|
@@ -70,6 +76,7 @@ import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.DateTimeParseException;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@@ -95,6 +102,10 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
|
|
|
private final BaseStudentMapper baseStudentMapper;
|
|
|
|
|
|
private final IUserDeptRelationService userDeptRelationService;
|
|
|
+ private final RedisUtil redisUtil;
|
|
|
+ private final UserDeptRelationMapper userDeptRelationMapper;
|
|
|
+ private final IUserService userService;
|
|
|
+ private final CommonPropertiesConfig propertiesConfig;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -103,11 +114,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
|
|
|
BaseStudentUser baseStudentUser = BeanUtil.toBean(dto, BaseStudentUser.class);
|
|
|
|
|
|
// 用户身份证后6位作为默认密码
|
|
|
- if (baseStudentUser.getCredentialNumber() != null && baseStudentUser.getCredentialNumber().length() > 6) {
|
|
|
- String str = baseStudentUser.getCredentialNumber();
|
|
|
- String lastSix = str.substring(str.length() - 6);
|
|
|
- baseStudentUser.setPassword(BCrypt.hashpw(lastSix, BCrypt.gensalt()));
|
|
|
- }
|
|
|
+ baseStudentUser.setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
|
|
|
studentbaseManagerBaseStudentUserMapper.insert(baseStudentUser);
|
|
|
for (BaseStudent baseStudent : baseStudentUser.getBaseStudentList()) {
|
|
|
baseStudent.setUserId(baseStudentUser.getId());
|
|
|
@@ -155,7 +162,13 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
|
|
|
userRoleRelation.setUserId(baseStudentUser.getId());
|
|
|
userRoleRelation.setRoleId(RoleEnum.STUDENT.getCode());
|
|
|
userRoleRelationMapper.insert(userRoleRelation);
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ List<User> list = userService.list();
|
|
|
+ redisUtil.set(GlobalConstant.USER_CACHE_KEY, list);
|
|
|
|
|
|
+ List<UserDeptRelation> deptRelationList = userDeptRelationMapper.selectList(Wrappers.lambdaQuery(UserDeptRelation.class));
|
|
|
+ redisUtil.set(GlobalConstant.USER_DEPT_RELATION_CACHE_KEY, deptRelationList);
|
|
|
+ });
|
|
|
return true;
|
|
|
}
|
|
|
|