|
@@ -1,18 +1,35 @@
|
|
|
package com.xjrsoft.module.student.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.dev33.satoken.secure.BCrypt;
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.google.gson.JsonArray;
|
|
|
-import com.google.gson.JsonObject;
|
|
|
+import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
+import com.xjrsoft.common.enums.EnabledMark;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
|
+import com.xjrsoft.common.utils.RedisUtil;
|
|
|
+import com.xjrsoft.config.CommonPropertiesConfig;
|
|
|
+import com.xjrsoft.module.base.entity.BaseUserStudent;
|
|
|
+import com.xjrsoft.module.base.entity.WhitelistManagement;
|
|
|
+import com.xjrsoft.module.base.service.IBaseUserStudentService;
|
|
|
+import com.xjrsoft.module.base.service.IWhitelistManagementService;
|
|
|
+import com.xjrsoft.module.organization.entity.User;
|
|
|
+import com.xjrsoft.module.organization.entity.UserRoleRelation;
|
|
|
+import com.xjrsoft.module.organization.service.IUserRoleRelationService;
|
|
|
+import com.xjrsoft.module.organization.service.IUserService;
|
|
|
+import com.xjrsoft.module.student.dto.ActiveAccountDto;
|
|
|
import com.xjrsoft.module.student.dto.AddBaseNewStudentDto;
|
|
|
import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
|
|
|
import com.xjrsoft.module.student.dto.UpdateBaseNewStudentDto;
|
|
|
import com.xjrsoft.module.student.entity.BaseNewStudent;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentFamilyMember;
|
|
|
import com.xjrsoft.module.student.service.IBaseNewStudentService;
|
|
|
+import com.xjrsoft.module.student.service.IBaseStudentFamilyMemberService;
|
|
|
import com.xjrsoft.module.student.vo.BaseNewStudentPageVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseNewStudentScoreExcelVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseNewStudentTreeVo;
|
|
@@ -34,12 +51,13 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
|
|
|
/**
|
|
|
* @title: 新生维护信息
|
|
@@ -53,9 +71,14 @@ import java.util.Map;
|
|
|
@AllArgsConstructor
|
|
|
public class BaseNewStudentController {
|
|
|
|
|
|
-
|
|
|
+ private final IUserService userService;
|
|
|
private final IBaseNewStudentService baseNewStudentService;
|
|
|
-
|
|
|
+ private final IBaseStudentFamilyMemberService familyMemberService;
|
|
|
+ private final IWhitelistManagementService whitelistManagementService;
|
|
|
+ private final IUserRoleRelationService userRoleRelationService;
|
|
|
+ private final RedisUtil redisUtil;
|
|
|
+ private final IBaseUserStudentService userStudentService;
|
|
|
+ private final CommonPropertiesConfig propertiesConfig;
|
|
|
@GetMapping(value = "/page")
|
|
|
@ApiOperation(value="新生维护信息列表(分页)")
|
|
|
@SaCheckPermission("basenewstudent:detail")
|
|
@@ -188,4 +211,92 @@ public class BaseNewStudentController {
|
|
|
return RT.ok(result);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/active-account")
|
|
|
+ @ApiOperation(value = "激活账号")
|
|
|
+ public RT<Boolean> activeAccount(@Valid @RequestBody ActiveAccountDto dto) {
|
|
|
+ User user = userService.getById(dto.getId());
|
|
|
+ user.setMobile(dto.getMobile());
|
|
|
+ user.setEnabledMark(EnabledMark.ENABLED.getCode());
|
|
|
+ user.setModifyDate(LocalDateTime.now());
|
|
|
+ userService.updateById(user);
|
|
|
+ // 新增家庭成员信息
|
|
|
+ List<BaseStudentFamilyMember> list = familyMemberService.list(
|
|
|
+ new QueryWrapper<BaseStudentFamilyMember>().lambda()
|
|
|
+ .eq(BaseStudentFamilyMember::getName, dto.getParentName())
|
|
|
+ .eq(BaseStudentFamilyMember::getUserId, dto.getId())
|
|
|
+ .eq(BaseStudentFamilyMember::getMobile, dto.getParentMobile())
|
|
|
+ );
|
|
|
+ BaseStudentFamilyMember member;
|
|
|
+ if(list.isEmpty()){
|
|
|
+ member = new BaseStudentFamilyMember();
|
|
|
+ member.setUserId(user.getId());
|
|
|
+ member.setName(dto.getParentName());
|
|
|
+ member.setMobile(dto.getParentMobile());
|
|
|
+ member.setCreateDate(LocalDateTime.now());
|
|
|
+ member.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ familyMemberService.save(member);
|
|
|
+ }else{
|
|
|
+ member = list.get(0);
|
|
|
+ }
|
|
|
+ List<User> parents = userService.list(
|
|
|
+ new QueryWrapper<User>().lambda()
|
|
|
+ .eq(User::getUserName, dto.getParentMobile())
|
|
|
+ .eq(User::getName, dto.getParentName())
|
|
|
+ );
|
|
|
+ if(parents.isEmpty()){
|
|
|
+ User parentUser = new User() {{
|
|
|
+ setUserName(dto.getParentMobile());
|
|
|
+ setName(dto.getParentName());
|
|
|
+ setIsChangePassword(1);
|
|
|
+ setDeleteMark(0);
|
|
|
+ setEnabledMark(1);
|
|
|
+ setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
|
|
|
+ setMobile(dto.getParentMobile());
|
|
|
+ }};
|
|
|
+ userService.save(parentUser);
|
|
|
+
|
|
|
+ userRoleRelationService.save(new UserRoleRelation(){{
|
|
|
+ setUserId(parentUser.getId());
|
|
|
+ setRoleId(4L);
|
|
|
+ }});
|
|
|
+
|
|
|
+ BaseUserStudent userStudent = new BaseUserStudent();
|
|
|
+ userStudent.setStudentId(user.getId());
|
|
|
+ userStudent.setStudentNane(user.getName());
|
|
|
+ userStudent.setStudentIdentity(user.getCredentialNumber());
|
|
|
+ userStudent.setCreateDate(new Date());
|
|
|
+ userStudent.setUserId(parentUser.getId());
|
|
|
+ userStudent.setStatus(1);
|
|
|
+ userStudentService.save(userStudent);
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增白名单信息
|
|
|
+ List<WhitelistManagement> managementList = whitelistManagementService.list(
|
|
|
+ new QueryWrapper<WhitelistManagement>().lambda()
|
|
|
+ .eq(WhitelistManagement::getUserId, dto.getId())
|
|
|
+ );
|
|
|
+ if(managementList.isEmpty()){
|
|
|
+ WhitelistManagement whitelistManagement = new WhitelistManagement() {{
|
|
|
+ setName(user.getName());
|
|
|
+ setUserId(user.getId());
|
|
|
+ setCreateDate(new Date());
|
|
|
+ setCredentialNumber(user.getCredentialNumber());
|
|
|
+ setPhone(user.getMobile());
|
|
|
+ }};
|
|
|
+ whitelistManagementService.save(whitelistManagement);
|
|
|
+ }
|
|
|
+
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ List<User> userList = userService.list();
|
|
|
+ redisUtil.set(GlobalConstant.USER_CACHE_KEY, userList);
|
|
|
+
|
|
|
+ List<UserRoleRelation> userRoleRelationList = userRoleRelationService.list(Wrappers.lambdaQuery(UserRoleRelation.class));
|
|
|
+ redisUtil.set(GlobalConstant.USER_ROLE_RELATION_CACHE_KEY, userRoleRelationList);
|
|
|
+
|
|
|
+ whitelistManagementService.loadCaches();
|
|
|
+ });
|
|
|
+
|
|
|
+ return RT.ok(true);
|
|
|
+ }
|
|
|
+
|
|
|
}
|