|
@@ -7,6 +7,7 @@ import com.mooctest.crowd.domain.exception.RoleNotFoundException;
|
|
|
import com.mooctest.crowd.domain.exception.UserNotExistException;
|
|
|
import com.mooctest.crowd.domain.model.*;
|
|
|
import com.mooctest.crowd.domain.util.Converter;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -22,171 +23,215 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
|
public class UserRepo implements IUserRepo {
|
|
|
- @Autowired
|
|
|
- private EvaluationAgencyDao agencyDao;
|
|
|
- @Autowired
|
|
|
- private TestTypeDao testTypeDao;
|
|
|
+ @Autowired
|
|
|
+ private EvaluationAgencyDao agencyDao;
|
|
|
+ @Autowired
|
|
|
+ private TestTypeDao testTypeDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private UserDao userDao;
|
|
|
+ @Autowired
|
|
|
+ private UserDao userDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RoleDao roleDao;
|
|
|
+ @Autowired
|
|
|
+ private RoleDao roleDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PermissionDao permissionDao;
|
|
|
+ @Autowired
|
|
|
+ private PermissionDao permissionDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private UserToRoleDao userToRoleDao;
|
|
|
+ @Autowired
|
|
|
+ private UserToRoleDao userToRoleDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private UserTaskCountDao userTaskCountDao;
|
|
|
+ @Autowired
|
|
|
+ private UserTaskCountDao userTaskCountDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RoleToPermissionDao roleToPermissionDao;
|
|
|
+ @Autowired
|
|
|
+ private RoleToPermissionDao roleToPermissionDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private EvaluationAgencyDao evaluationAgencyDao;
|
|
|
+ @Autowired
|
|
|
+ private EvaluationAgencyDao evaluationAgencyDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RegionalManagerToRegionalDao regionalManagerToRegionalDao;
|
|
|
+ @Autowired
|
|
|
+ private RegionalManagerToRegionalDao regionalManagerToRegionalDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private AgencyResourceDao agencyResourceDao;
|
|
|
+ @Autowired
|
|
|
+ private AgencyResourceDao agencyResourceDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private AgencyAbilityDao agencyAbilityDao;
|
|
|
+ @Autowired
|
|
|
+ private AgencyAbilityDao agencyAbilityDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private EvaluationAgencyRepo resourceRepo;
|
|
|
+ @Autowired
|
|
|
+ private EvaluationAgencyRepo resourceRepo;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PersonalAuthenticationDao personalAuthenticationDao;
|
|
|
+ @Autowired
|
|
|
+ private PersonalAuthenticationDao personalAuthenticationDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private EnterpriseAuthenticationDao enterpriseAuthenticationDao;
|
|
|
+ @Autowired
|
|
|
+ private EnterpriseAuthenticationDao enterpriseAuthenticationDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SystemAdministratorToUserDao systemAdministratorToUserDao;
|
|
|
+ @Autowired
|
|
|
+ private SystemAdministratorToUserDao systemAdministratorToUserDao;
|
|
|
|
|
|
- private Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
|
+ private Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public User getByID(Long userId) throws UserNotExistException, RoleNotFoundException {
|
|
|
+ Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
+ if (!userPOOptional.isPresent()) {
|
|
|
+ throw new UserNotExistException("用户不存在");
|
|
|
+ } else {
|
|
|
+ User user = getUserAndRoleAndPermissionByUserPO(userPOOptional.get());
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public User getByIDJustInfo(Long userId) throws UserNotExistException, RoleNotFoundException {
|
|
|
+ Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
+ if (!userPOOptional.isPresent()) {
|
|
|
+ throw new UserNotExistException("用户不存在");
|
|
|
+ } else {
|
|
|
+ return Converter.convert(User.class, userPOOptional.get());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
- public User getByID(Long userId) throws UserNotExistException, RoleNotFoundException {
|
|
|
+ public User getInfoAndRolesByID(Long userId) throws UserNotExistException {
|
|
|
Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
if (!userPOOptional.isPresent()) {
|
|
|
throw new UserNotExistException("用户不存在");
|
|
|
} else {
|
|
|
- User user = getUserAndRoleAndPermissionByUserPO(userPOOptional.get());
|
|
|
+ User user = getUserAndRoleByUserPO(userPOOptional.get());
|
|
|
return user;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public User getInfoAndRolesAndRegionalMangerByID(Long userId) throws UserNotExistException {
|
|
|
+ Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
+ if (!userPOOptional.isPresent()) {
|
|
|
+ throw new UserNotExistException("用户不存在");
|
|
|
+ } else {
|
|
|
+ User user = getUserInfoAndRolesAndRegionalManger(userPOOptional.get());
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
- public User getByUserIDJustAgencyInfo(Long userId) throws UserNotExistException, RoleNotFoundException {
|
|
|
+ public User getInfoAndPersonalAuthByID(Long userId) throws UserNotExistException {
|
|
|
Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
if (!userPOOptional.isPresent()) {
|
|
|
throw new UserNotExistException("用户不存在");
|
|
|
} else {
|
|
|
- User user = getUserAndRoleAndPermissionByUserPO(userPOOptional.get());
|
|
|
- return this.getEvaluationInfo(user);
|
|
|
+ User user = Converter.convert(User.class, userPOOptional.get());
|
|
|
+ this.getPersonalAuthInfo(user);
|
|
|
+ return user;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public User getByIDJustInfo(Long userId) throws UserNotExistException, RoleNotFoundException {
|
|
|
- Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
- if (!userPOOptional.isPresent()){
|
|
|
- throw new UserNotExistException("用户不存在");
|
|
|
- } else {
|
|
|
- return Converter.convert(User.class, userPOOptional.get());
|
|
|
- }
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public User getInfoAndEvaluationAgencyByID(Long userId) throws UserNotExistException {
|
|
|
+ Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
+ if (!userPOOptional.isPresent()) {
|
|
|
+ throw new UserNotExistException("用户不存在");
|
|
|
+ } else {
|
|
|
+ User user = getInfoAndEvaluationAgency(userPOOptional.get());
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private User getInfoAndEvaluationAgency(UserPO userPO) {
|
|
|
+ User user = Converter.convert(User.class, userPO);
|
|
|
+ this.getEvaluationAgency(user);
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
+ private User getInfoAndPersonalAuth(UserPO userPO) {
|
|
|
+ User user = Converter.convert(User.class, userPO);
|
|
|
+ this.getEvaluationAgency(user);
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
+ private User getUserInfoAndRolesAndRegionalManger(UserPO userPO) throws RoleNotFoundException {
|
|
|
+ User userResult = this.getUserInfoAndRoles(userPO);
|
|
|
+ this.getRegionalInfo(userResult);
|
|
|
+ return userResult;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public User getInfoAndRolesAndRegionalMangerByID(Long userId) throws UserNotExistException {
|
|
|
- Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
- if (!userPOOptional.isPresent()){
|
|
|
- throw new UserNotExistException("用户不存在");
|
|
|
- } else {
|
|
|
- User user = getUserAndRoleByUserPO(userPOOptional.get());
|
|
|
- return user;
|
|
|
- }
|
|
|
+ private User getUserAndRoleByUserPO(UserPO userPO) throws RoleNotFoundException {
|
|
|
+ return this.getUserInfoAndRoles(userPO);
|
|
|
}
|
|
|
|
|
|
- private User getUserAndRoleByUserPO(UserPO userPO) throws RoleNotFoundException {
|
|
|
+ @NotNull
|
|
|
+ private User getUserInfoAndRoles(UserPO userPO) {
|
|
|
User userResult = Converter.convert(User.class, userPO);
|
|
|
Map<Long, Role> roleMap = roleDao.findAll().stream().collect(Collectors.toMap(rolePO -> rolePO.getId(), rolePO -> Converter.convert(Role.class, rolePO)));
|
|
|
List<UserToRolePO> userToRolePOList = userToRoleDao.findByUserId(userResult.getId());
|
|
|
List<Role> roleList = userToRolePOList.stream().map(userToRolePO -> roleMap.get(userToRolePO.getRoleId())).collect(Collectors.toList());
|
|
|
userResult.setRoleList(roleList);
|
|
|
- this.getRegionalInfo(userPO, userResult);
|
|
|
return userResult;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public User getByMobileNum(String mobileNum) throws UserNotExistException, RoleNotFoundException {
|
|
|
- UserPO userPO = userDao.findByMobile(mobileNum);
|
|
|
- if (userPO == null) {
|
|
|
- throw new UserNotExistException("用户不存在");
|
|
|
- } else {
|
|
|
- User user = getUserAndRoleAndPermissionByUserPO(userPO);
|
|
|
- return user;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<User> getByIdList(List<Long> ids) throws RoleNotFoundException {
|
|
|
- Iterable<UserPO> allUserPOById = userDao.findAllById(ids);
|
|
|
- ArrayList<UserPO> userPOArrayList = Lists.newArrayList(allUserPOById);
|
|
|
- List<User> allUserResult = getUserAndRoleAndPermissionListByUserPOList(userPOArrayList);
|
|
|
- return allUserResult;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取机构认证的申请
|
|
|
- *
|
|
|
- * @return
|
|
|
- * @throws RoleNotFoundException
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<User> getApplyEvaluationAgencyByIsAuthenticated() {
|
|
|
- List<UserPO> userPOList = new ArrayList<>();
|
|
|
- evaluationAgencyDao.findByIsAuthentication(AuthenticationStatus.isNotAuthenticated).forEach(evaluationAgencyPO -> {
|
|
|
- userPOList.add(userDao.findById(evaluationAgencyPO.getUserId()).get());
|
|
|
- });
|
|
|
- List<User> allUserResult = getUserAndRoleAndPermissionListByUserPOList(userPOList);
|
|
|
- return allUserResult;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<User> getAllUser() throws RoleNotFoundException {
|
|
|
- Iterable<UserPO> allUserPO = userDao.findAll();
|
|
|
- ArrayList<UserPO> userPOArrayList = Lists.newArrayList(allUserPO);
|
|
|
- List<User> userListByIds = getUserAndRoleAndPermissionListByUserPOList(userPOArrayList);
|
|
|
- return userListByIds;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ArrayList<UserPO> getAllUserInfo() throws RoleNotFoundException {
|
|
|
- Iterable<UserPO> allUserPO = userDao.findAll();
|
|
|
- ArrayList<UserPO> userPOArrayList = Lists.newArrayList(allUserPO);
|
|
|
- return userPOArrayList;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public UserTaskCount getUserTaskCountByUserId(Long userId) {
|
|
|
- Optional<UserTaskCountPO> userTaskCountPO = userTaskCountDao.findByUserId(userId);
|
|
|
- if (!userTaskCountPO.isPresent()) {
|
|
|
- return null;
|
|
|
- } else {
|
|
|
- return Converter.convert(UserTaskCount.class, userTaskCountPO.get());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //add
|
|
|
+ @Override
|
|
|
+ public User getByMobileNum(String mobileNum) throws UserNotExistException, RoleNotFoundException {
|
|
|
+ UserPO userPO = userDao.findByMobile(mobileNum);
|
|
|
+ if (userPO == null) {
|
|
|
+ throw new UserNotExistException("用户不存在");
|
|
|
+ } else {
|
|
|
+ User user = getUserAndRoleAndPermissionByUserPO(userPO);
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<User> getByIdList(List<Long> ids) throws RoleNotFoundException {
|
|
|
+ Iterable<UserPO> allUserPOById = userDao.findAllById(ids);
|
|
|
+ ArrayList<UserPO> userPOArrayList = Lists.newArrayList(allUserPOById);
|
|
|
+ List<User> allUserResult = getUserAndRoleAndPermissionListByUserPOList(userPOArrayList);
|
|
|
+ return allUserResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取机构认证的申请
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws RoleNotFoundException
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<User> getApplyEvaluationAgencyByIsAuthenticated() {
|
|
|
+ List<UserPO> userPOList = new ArrayList<>();
|
|
|
+ evaluationAgencyDao.findByIsAuthentication(AuthenticationStatus.isNotAuthenticated).forEach(evaluationAgencyPO -> {
|
|
|
+ userPOList.add(userDao.findById(evaluationAgencyPO.getUserId()).get());
|
|
|
+ });
|
|
|
+ List<User> allUserResult = getUserAndRoleAndPermissionListByUserPOList(userPOList);
|
|
|
+ return allUserResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<User> getAllUser() throws RoleNotFoundException {
|
|
|
+ Iterable<UserPO> allUserPO = userDao.findAll();
|
|
|
+ ArrayList<UserPO> userPOArrayList = Lists.newArrayList(allUserPO);
|
|
|
+ List<User> userListByIds = getUserAndRoleAndPermissionListByUserPOList(userPOArrayList);
|
|
|
+ return userListByIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ArrayList<UserPO> getAllUserInfo() throws RoleNotFoundException {
|
|
|
+ Iterable<UserPO> allUserPO = userDao.findAll();
|
|
|
+ ArrayList<UserPO> userPOArrayList = Lists.newArrayList(allUserPO);
|
|
|
+ return userPOArrayList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UserTaskCount getUserTaskCountByUserId(Long userId) {
|
|
|
+ Optional<UserTaskCountPO> userTaskCountPO = userTaskCountDao.findByUserId(userId);
|
|
|
+ if (!userTaskCountPO.isPresent()) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ return Converter.convert(UserTaskCount.class, userTaskCountPO.get());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //add
|
|
|
// @Override
|
|
|
// public User getByEvaluationAgencyByUserId(Long userId) throws UserNotExistException, RoleNotFoundException {
|
|
|
//
|
|
@@ -207,323 +252,361 @@ public class UserRepo implements IUserRepo {
|
|
|
//
|
|
|
// }
|
|
|
|
|
|
- @Override
|
|
|
- public void removeUser(User user) {
|
|
|
- UserPO userPO = Converter.convert(UserPO.class, user);
|
|
|
- userDao.delete(userPO);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void removeUserList(List<User> userList) {
|
|
|
- List<UserPO> userPOList = new ArrayList<>();
|
|
|
- for (User user : userList) {
|
|
|
- UserPO userPO = Converter.convert(UserPO.class, user);
|
|
|
- userPOList.add(userPO);
|
|
|
- }
|
|
|
- userDao.deleteAll(userPOList);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 注册用户时默认为普通用户,分配角色后存入数据库
|
|
|
- *
|
|
|
- * @param user
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public User saveUserAndRole(User user) {
|
|
|
- UserPO userPO = userDao.save(Converter.convert(UserPO.class, user));
|
|
|
- User saveResultUser = Converter.convert(User.class, userPO);
|
|
|
- List<Role> roleList = user.getRoleList();
|
|
|
-
|
|
|
- // 存储从数据库中取出的User的Role数据
|
|
|
- List<Role> roleListResult = new ArrayList<>();
|
|
|
-
|
|
|
- for (Role role : roleList) {
|
|
|
- RolePO rolePO = roleDao.findByName(role.getName());
|
|
|
- Role roleConvert = Converter.convert(Role.class, rolePO);
|
|
|
-
|
|
|
- UserToRolePO userToRolePO = new UserToRolePO();
|
|
|
- userToRolePO.setRoleId(roleConvert.getId());
|
|
|
- userToRolePO.setUserId(saveResultUser.getId());
|
|
|
- userToRolePO.setCreateTime(currentTime);
|
|
|
- userToRoleDao.save(userToRolePO);
|
|
|
-
|
|
|
- Role roleResult = getPermissionByRole(roleConvert);
|
|
|
- roleListResult.add(roleResult);
|
|
|
+ @Override
|
|
|
+ public void removeUser(User user) {
|
|
|
+ UserPO userPO = Converter.convert(UserPO.class, user);
|
|
|
+ userDao.delete(userPO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void removeUserList(List<User> userList) {
|
|
|
+ List<UserPO> userPOList = new ArrayList<>();
|
|
|
+ for (User user : userList) {
|
|
|
+ UserPO userPO = Converter.convert(UserPO.class, user);
|
|
|
+ userPOList.add(userPO);
|
|
|
+ }
|
|
|
+ userDao.deleteAll(userPOList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注册用户时默认为普通用户,分配角色后存入数据库
|
|
|
+ *
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public User saveUserAndRole(User user) {
|
|
|
+ UserPO userPO = userDao.save(Converter.convert(UserPO.class, user));
|
|
|
+ User saveResultUser = Converter.convert(User.class, userPO);
|
|
|
+ List<Role> roleList = user.getRoleList();
|
|
|
+
|
|
|
+ // 存储从数据库中取出的User的Role数据
|
|
|
+ List<Role> roleListResult = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Role role : roleList) {
|
|
|
+ RolePO rolePO = roleDao.findByName(role.getName());
|
|
|
+ Role roleConvert = Converter.convert(Role.class, rolePO);
|
|
|
+
|
|
|
+ UserToRolePO userToRolePO = new UserToRolePO();
|
|
|
+ userToRolePO.setRoleId(roleConvert.getId());
|
|
|
+ userToRolePO.setUserId(saveResultUser.getId());
|
|
|
+ userToRolePO.setCreateTime(currentTime);
|
|
|
+ userToRoleDao.save(userToRolePO);
|
|
|
+
|
|
|
+ Role roleResult = getPermissionByRole(roleConvert);
|
|
|
+ roleListResult.add(roleResult);
|
|
|
// roleListResult.add(roleConvert);
|
|
|
- }
|
|
|
- saveResultUser.setRoleList(roleListResult);
|
|
|
- return saveResultUser;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存用户相关的所有信息(包括测评机构信息、角色信息、权限信息)
|
|
|
- *
|
|
|
- * @param user
|
|
|
- * @return
|
|
|
- * @throws RoleNotFoundException
|
|
|
- */
|
|
|
- @Override
|
|
|
- public User saveUser(User user) throws RoleNotFoundException {
|
|
|
- User userAndRoleByUser = saveRoleAndPermissionAndEvaluationAgencyByUser(user);
|
|
|
- return userAndRoleByUser;
|
|
|
- }
|
|
|
+ }
|
|
|
+ saveResultUser.setRoleList(roleListResult);
|
|
|
+ return saveResultUser;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存用户相关的所有信息(包括测评机构信息、角色信息、权限信息)
|
|
|
+ *
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ * @throws RoleNotFoundException
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public User saveUser(User user) throws RoleNotFoundException {
|
|
|
+ User userAndRoleByUser = saveRoleAndPermissionAndEvaluationAgencyByUser(user);
|
|
|
+ return userAndRoleByUser;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public User saveUserJustInfo(User user) {
|
|
|
+ UserPO userPO = userDao.save(Converter.convert(UserPO.class, user));
|
|
|
+ return Converter.convert(User.class, userPO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存机构认证信息
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public User saveEvaluationAgencyByUser(User user) {
|
|
|
+ this.saveEvaluationAgencyInfo(user);
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存个人认证信息
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public User savePersonalAuthByUser(User user) {
|
|
|
+ this.savePersonalAuth(user);
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存用户信息(包括测评机构信息、角色信息、权限信息)
|
|
|
+ *
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ * @throws RoleNotFoundException
|
|
|
+ */
|
|
|
+ private User saveRoleAndPermissionAndEvaluationAgencyByUser(User user) throws RoleNotFoundException {
|
|
|
+ UserPO userPO = userDao.save(Converter.convert(UserPO.class, user));
|
|
|
+ User userResult = Converter.convert(User.class, userPO);
|
|
|
+ List<Role> roleList = userResult.getRoleList();
|
|
|
+
|
|
|
+ // 新注册用户默认给
|
|
|
+ if (roleList == null || roleList.size() == 0) {
|
|
|
+ UserToRolePO u2r = new UserToRolePO();
|
|
|
+ u2r.setUserId(userResult.getId());
|
|
|
+ u2r.setRoleId(1L);
|
|
|
+ userToRoleDao.save(u2r);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<UserToRolePO> userToRolePOList = userToRoleDao.findByUserId(userResult.getId());
|
|
|
+ if (roleList != null) {
|
|
|
+ for (Role role : roleList) {
|
|
|
+ if (userToRolePOList.stream().noneMatch(userToRolePO -> userToRolePO.getRoleId().equals(role.getId()))) {
|
|
|
+ UserToRolePO userToRolePO = new UserToRolePO();
|
|
|
+ userToRolePO.setRoleId(role.getId());
|
|
|
+ userToRolePO.setUserId(userResult.getId());
|
|
|
+ userToRoleDao.save(userToRolePO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*机构认证保存机构信息*/
|
|
|
+ this.saveEvaluationAgencyInfo(userResult);
|
|
|
+
|
|
|
+ /*实名认证保存个人信息*/
|
|
|
+ this.savePersonalAuth(user);
|
|
|
+
|
|
|
+ return getByID(userPO.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void savePersonalAuth(User user) {
|
|
|
+ if (user.getPersonalAuthentication() != null) {
|
|
|
+ PersonalAuthenticationPO authenticationPO = Converter.convert(PersonalAuthenticationPO.class, user.getPersonalAuthentication());
|
|
|
+ personalAuthenticationDao.save(authenticationPO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存机构认证信息
|
|
|
+ * @param user
|
|
|
+ */
|
|
|
+ private void saveEvaluationAgencyInfo(User user) {
|
|
|
+ EvaluationAgency evaluationAgency = user.getEvaluationAgency();
|
|
|
+ if (evaluationAgency != null) {
|
|
|
+ EvaluationAgencyPO evaluationAgencyPO = Converter.convert(EvaluationAgencyPO.class, evaluationAgency);
|
|
|
+ evaluationAgencyPO.setUserId(user.getId());
|
|
|
+ evaluationAgencyPO = evaluationAgencyDao.save(evaluationAgencyPO);
|
|
|
+ // 资源能力信息
|
|
|
+ evaluationAgencyPO = evaluationAgencyDao.save(evaluationAgencyPO);
|
|
|
+// List<EvaluationAgencyResource> resources = evaluationAgency.getEvaluationAgencyResourceList();
|
|
|
+// List<EvaluationAgencyAbility> abilities = evaluationAgency.getEvaluationAgencyAbilityList();
|
|
|
+// if (resources != null) {
|
|
|
+// for (EvaluationAgencyResource resource : resources) {
|
|
|
+// resource.setEvaluationAgencyId(evaluationAgencyPO.getId());
|
|
|
+// resourceRepo.saveEvaluationAgencyResource(resource);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (abilities != null) {
|
|
|
+// for (EvaluationAgencyAbility ability : abilities) {
|
|
|
+// ability.setEvaluationAgencyId(evaluationAgencyPO.getId());
|
|
|
+// resourceRepo.saveEvaluationAgencyAbility(ability);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过角色获取角色和权限信息
|
|
|
+ *
|
|
|
+ * @param roleResult
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Role getPermissionByRole(Role roleResult) {
|
|
|
+ List<Permission> permissionResultList = new ArrayList<>();
|
|
|
+ List<RoleToPermissionPO> roleToPermissionPOList = roleToPermissionDao.findAllByRoleId(roleResult.getId());
|
|
|
+ List<Long> permissionIds = roleToPermissionPOList.stream().map(RoleToPermissionPO::getPermissionId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (PermissionPO permissionPO : permissionDao.findAllById(permissionIds)) {
|
|
|
+ permissionResultList.add(Converter.convert(Permission.class, permissionPO));
|
|
|
+ }
|
|
|
+ roleResult.setPermissionList(permissionResultList);
|
|
|
+ return roleResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过UsePOList获取用户-角色-权限信息
|
|
|
+ *
|
|
|
+ * @param userPOList
|
|
|
+ * @return
|
|
|
+ * @throws RoleNotFoundException
|
|
|
+ */
|
|
|
+ private List<User> getUserAndRoleAndPermissionListByUserPOList(List<UserPO> userPOList) throws RoleNotFoundException {
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
+ for (UserPO userPO : userPOList) {
|
|
|
+ User userAndRole = getUserAndRoleAndPermissionByUserPO(userPO);
|
|
|
+ userList.add(userAndRole);
|
|
|
+ }
|
|
|
+ return userList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过用户信息获取用户-角色-权限信息
|
|
|
+ *
|
|
|
+ * @param userPO
|
|
|
+ * @return
|
|
|
+ * @throws RoleNotFoundException
|
|
|
+ */
|
|
|
+ private User getUserAndRoleAndPermissionByUserPO(UserPO userPO) throws RoleNotFoundException {
|
|
|
+ User userResult = Converter.convert(User.class, userPO);
|
|
|
+ Map<Long, Role> roleMap = roleDao.findAll().stream().collect(Collectors.toMap(rolePO -> rolePO.getId(), rolePO -> Converter.convert(Role.class, rolePO)));
|
|
|
+ List<UserToRolePO> userToRolePOList = userToRoleDao.findByUserId(userResult.getId());
|
|
|
+ List<Role> roleResultList = new ArrayList<>();
|
|
|
+ for (UserToRolePO userToRolePO : userToRolePOList) {
|
|
|
+ Role role = roleMap.get(userToRolePO.getRoleId());
|
|
|
+ Role roleResult = getPermissionByRole(role);
|
|
|
+ roleResultList.add(roleResult);
|
|
|
+// roleResultList.add(role);
|
|
|
+ }
|
|
|
+ userResult.setRoleList(roleResultList);
|
|
|
|
|
|
+ // 获取认证信息
|
|
|
+ userResult = this.getAuthentication(userResult);
|
|
|
+ return userResult;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 保存用户信息(包括测评机构信息、角色信息、权限信息)
|
|
|
- *
|
|
|
+ * 获取认证信息
|
|
|
* @param user
|
|
|
* @return
|
|
|
- * @throws RoleNotFoundException
|
|
|
*/
|
|
|
- private User saveRoleAndPermissionAndEvaluationAgencyByUser(User user) throws RoleNotFoundException {
|
|
|
- UserPO userPO = userDao.save(Converter.convert(UserPO.class, user));
|
|
|
- List<Role> roleList = user.getRoleList();
|
|
|
- Map<Long, String> collect = roleList.stream().collect(Collectors.toMap(Role::getId, Role::getName, (v1,v2) -> v2));
|
|
|
-
|
|
|
- if (roleList == null || roleList.size() == 0) {
|
|
|
- UserToRolePO u2r = new UserToRolePO();
|
|
|
- u2r.setUserId(userPO.getId());
|
|
|
- u2r.setRoleId(1L);
|
|
|
- userToRoleDao.save(u2r);
|
|
|
- }
|
|
|
- List<UserToRolePO> userToRolePOList = userToRoleDao.findByUserId(userPO.getId());
|
|
|
- if (roleList != null) {
|
|
|
- for (Role role : roleList) {
|
|
|
- if (userToRolePOList.stream().noneMatch(userToRolePO -> userToRolePO.getRoleId().equals(role.getId()))) {
|
|
|
- UserToRolePO userToRolePO = new UserToRolePO();
|
|
|
- userToRolePO.setRoleId(role.getId());
|
|
|
- userToRolePO.setUserId(userPO.getId());
|
|
|
- userToRoleDao.save(userToRolePO);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*机构认证保存机构信息*/
|
|
|
- EvaluationAgency evaluationAgency = user.getEvaluationAgency();
|
|
|
- if (evaluationAgency != null) {
|
|
|
- EvaluationAgencyPO evaluationAgencyPO = Converter.convert(EvaluationAgencyPO.class, evaluationAgency);
|
|
|
- evaluationAgencyPO.setUserId(userPO.getId());
|
|
|
- System.out.println(evaluationAgencyPO + "xxxxxxxxxxxxxxxxxxxxxxxx");
|
|
|
- evaluationAgencyPO = evaluationAgencyDao.save(evaluationAgencyPO);
|
|
|
- List<EvaluationAgencyResource> resources = evaluationAgency.getEvaluationAgencyResourceList();
|
|
|
- List<EvaluationAgencyAbility> abilities = evaluationAgency.getEvaluationAgencyAbilityList();
|
|
|
- if (resources != null) {
|
|
|
- for (EvaluationAgencyResource resource : resources) {
|
|
|
- resource.setEvaluationAgencyId(evaluationAgencyPO.getId());
|
|
|
- resourceRepo.saveEvaluationAgencyResource(resource);
|
|
|
- }
|
|
|
- }
|
|
|
- if (abilities != null) {
|
|
|
- for (EvaluationAgencyAbility ability : abilities) {
|
|
|
- ability.setEvaluationAgencyId(evaluationAgencyPO.getId());
|
|
|
- resourceRepo.saveEvaluationAgencyAbility(ability);
|
|
|
- }
|
|
|
- }
|
|
|
-// // save测评机构资源
|
|
|
-// EvaluationAgencyResource evaluationAgencyResource = evaluationAgency.getEvaluationAgencyResource();
|
|
|
-// if(evaluationAgencyResource != null){
|
|
|
-// EvaluationAgencyResourcePO evaluationAgencyResourcePO = Converter.convert(EvaluationAgencyResourcePO.class, evaluationAgencyResource);
|
|
|
-// evaluationAgencyResourcePO.setEvaluationAgencyId(evaluationAgencyPO.getId());
|
|
|
-// evaluationAgencyResourceDao.save(evaluationAgencyResourcePO);
|
|
|
-// }
|
|
|
- }
|
|
|
-
|
|
|
- /*实名认证保存个人信息*/
|
|
|
- if (user.getPersonalAuthentication() != null) {
|
|
|
- PersonalAuthenticationPO authenticationPO = Converter.convert(PersonalAuthenticationPO.class, user.getPersonalAuthentication());
|
|
|
- personalAuthenticationDao.save(authenticationPO);
|
|
|
- }
|
|
|
-
|
|
|
- /*企业认证保存企业信息*/
|
|
|
-// if (user.getEnterpriseAuthentication() != null) {
|
|
|
-//// if (user.getEnterpriseAuthentication().getType().contains("研发机构")) {
|
|
|
-//// System.out.println("认证消息为===========" + user.getPersonalAuthentication());
|
|
|
-//// EnterpriseAuthenticationPO authenticationPO = Converter.convert(EnterpriseAuthenticationPO.class, user.getEnterpriseAuthentication());
|
|
|
-//// System.out.println("认证消息为PO===========" + authenticationPO);
|
|
|
-//// enterpriseAuthenticationDao.save(authenticationPO);
|
|
|
-//// }
|
|
|
-//// else if (user.getEnterpriseAuthentication().getIsDaOrEa().equals("评测机构")) {
|
|
|
-// EvaluationAgencyPO evaluationAgencyPO = new EvaluationAgencyPO();
|
|
|
-// evaluationAgencyPO.setUserId(user.getId());
|
|
|
-// evaluationAgencyPO.setAddress(user.getEnterpriseAuthentication().getAddress());
|
|
|
-// evaluationAgencyPO.setEvaluationAgencyName(user.getEnterpriseAuthentication().getEnterpriseName());
|
|
|
-// evaluationAgencyPO.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
|
|
-// agencyDao.save(evaluationAgencyPO);
|
|
|
-//// }
|
|
|
-// }
|
|
|
-
|
|
|
- return getByID(userPO.getId());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过角色获取角色和权限信息
|
|
|
- *
|
|
|
- * @param roleResult
|
|
|
- * @return
|
|
|
- */
|
|
|
- private Role getPermissionByRole(Role roleResult) {
|
|
|
- List<Permission> permissionResultList = new ArrayList<>();
|
|
|
- List<RoleToPermissionPO> roleToPermissionPOList = roleToPermissionDao.findAllByRoleId(roleResult.getId());
|
|
|
- List<Long> permissionIds = roleToPermissionPOList.stream().map(RoleToPermissionPO::getPermissionId).collect(Collectors.toList());
|
|
|
-
|
|
|
- for (PermissionPO permissionPO : permissionDao.findAllById(permissionIds)) {
|
|
|
- permissionResultList.add(Converter.convert(Permission.class, permissionPO));
|
|
|
- }
|
|
|
- roleResult.setPermissionList(permissionResultList);
|
|
|
- return roleResult;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过UsePOList获取用户-角色-权限信息
|
|
|
- *
|
|
|
- * @param userPOList
|
|
|
- * @return
|
|
|
- * @throws RoleNotFoundException
|
|
|
- */
|
|
|
- private List<User> getUserAndRoleAndPermissionListByUserPOList(List<UserPO> userPOList) throws RoleNotFoundException {
|
|
|
- List<User> userList = new ArrayList<>();
|
|
|
- for (UserPO userPO : userPOList) {
|
|
|
- User userAndRole = getUserAndRoleAndPermissionByUserPO(userPO);
|
|
|
- userList.add(userAndRole);
|
|
|
- }
|
|
|
- return userList;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过用户信息获取用户-角色-权限信息
|
|
|
- *
|
|
|
- * @param userPO
|
|
|
- * @return
|
|
|
- * @throws RoleNotFoundException
|
|
|
- */
|
|
|
- private User getUserAndRoleAndPermissionByUserPO(UserPO userPO) throws RoleNotFoundException {
|
|
|
- User userResult = Converter.convert(User.class, userPO);
|
|
|
- Map<Long, Role> roleMap = roleDao.findAll().stream().collect(Collectors.toMap(rolePO -> rolePO.getId(), rolePO -> Converter.convert(Role.class, rolePO)));
|
|
|
- List<UserToRolePO> userToRolePOList = userToRoleDao.findByUserId(userResult.getId());
|
|
|
- List<Role> roleResultList = new ArrayList<>();
|
|
|
- for (UserToRolePO userToRolePO : userToRolePOList) {
|
|
|
- Role role = roleMap.get(userToRolePO.getRoleId());
|
|
|
- Role roleResult = getPermissionByRole(role);
|
|
|
- roleResultList.add(roleResult);
|
|
|
-
|
|
|
-// roleResultList.add(role);
|
|
|
- }
|
|
|
- userResult.setRoleList(roleResultList);
|
|
|
-
|
|
|
- /*获取机构认证的信息*/
|
|
|
- userResult = getEvaluationInfo(userResult);
|
|
|
-
|
|
|
- /*获取个人认证的信息*/
|
|
|
- Optional<PersonalAuthenticationPO> personalAuthenticationPOOptional = personalAuthenticationDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if (personalAuthenticationPOOptional.isPresent()) {
|
|
|
- userResult.setPersonalAuthentication(Converter.convert(PersonalAuthentication.class, personalAuthenticationPOOptional.get()));
|
|
|
- }
|
|
|
+ @NotNull
|
|
|
+ private User getAuthentication(User user) {
|
|
|
+ /*获取机构认证的信息*/
|
|
|
+// user = getEvaluationInfo(user);
|
|
|
|
|
|
/*获取企业认证的信息*/
|
|
|
- EnterpriseAuthenticationPO enterpriseAuthenticationPO = enterpriseAuthenticationDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if (enterpriseAuthenticationPO != null) {
|
|
|
- userResult.setEnterpriseAuthentication(Converter.convert(EnterpriseAuthentication.class, enterpriseAuthenticationPO));
|
|
|
- }
|
|
|
+ this.getEvaluationAgency(user);
|
|
|
+
|
|
|
+ /*获取个人认证的信息*/
|
|
|
+ this.getPersonalAuthInfo(user);
|
|
|
+
|
|
|
+ // 获取个人能力
|
|
|
+ this.getPersonalAbility(user);
|
|
|
+
|
|
|
+ // 获取区域管理员信息
|
|
|
+ this.getRegionalInfo(user);
|
|
|
+
|
|
|
+ //获取系统管理员信息
|
|
|
+ SystemAdministratorToUserPO systemAdministratorToUserPO = systemAdministratorToUserDao.findByUserIdAndIsDeleted(user.getId(), DeletedStatus.isNotDeleted);
|
|
|
+ if (systemAdministratorToUserPO != null) {
|
|
|
+ user.setSystemAdministratorToUser(Converter.convert(SystemAdministratorToUser.class, systemAdministratorToUserPO));
|
|
|
+ }
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取个人认证的信息
|
|
|
+ * @param user
|
|
|
+ */
|
|
|
+ private void getPersonalAuthInfo(User user) {
|
|
|
+ Optional<PersonalAuthenticationPO> personalAuthenticationPOOptional = personalAuthenticationDao.findByUserIdAndIsDeleted(user.getId(), DeletedStatus.isNotDeleted);
|
|
|
+ if (personalAuthenticationPOOptional.isPresent()) {
|
|
|
+ user.setPersonalAuthentication(Converter.convert(PersonalAuthentication.class, personalAuthenticationPOOptional.get()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getEvaluationAgency(User user) {
|
|
|
+ Optional<EvaluationAgencyPO> evaluationAgencyPOOptional = evaluationAgencyDao.findByUserIdAndIsDeleted(user.getId(), DeletedStatus.isNotDeleted);
|
|
|
+ if (evaluationAgencyPOOptional.isPresent()) {
|
|
|
+ user.setEvaluationAgency(Converter.convert(EvaluationAgency.class, evaluationAgencyPOOptional.get()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private void getPersonalAbility(User user) {
|
|
|
+ Map<String, String> typeMap = testTypeDao.findAll().stream().collect(Collectors.toMap(testTypePO -> testTypePO.getCode(), testTypePO -> testTypePO.getName()));
|
|
|
//获取用户能力
|
|
|
- String abilityName="";
|
|
|
- List<String> codeList=new ArrayList<>();
|
|
|
- List<String> abailities = new ArrayList<>();
|
|
|
- if(userPO.getPersonalCompetence()!=null&&!userPO.getPersonalCompetence().trim().equals("")){
|
|
|
- codeList= Arrays.asList(userPO.getPersonalCompetence().split(","));
|
|
|
- }
|
|
|
-
|
|
|
- if(abailities!=null&&!codeList.isEmpty()){
|
|
|
-
|
|
|
- for (int i = 0; i < abailities.size(); i++) {
|
|
|
- abilityName = testTypeDao.findByCode(codeList.get(i)).get().getName();
|
|
|
- abailities.add(abilityName);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- userResult.setPersonAbilities(abailities);
|
|
|
- this.getRegionalInfo(userPO, userResult);
|
|
|
-
|
|
|
- //获取系统管理员信息
|
|
|
- SystemAdministratorToUserPO systemAdministratorToUserPO = systemAdministratorToUserDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if (systemAdministratorToUserPO != null) {
|
|
|
- userResult.setSystemAdministratorToUser(Converter.convert(SystemAdministratorToUser.class, systemAdministratorToUserPO));
|
|
|
- }
|
|
|
-
|
|
|
- return userResult;
|
|
|
- }
|
|
|
-
|
|
|
- private void getRegionalInfo(UserPO userPO, User userResult) {
|
|
|
- /*获取区域管理员信息*/
|
|
|
- List<RegionalManagerToRegionalPO> regionalManagerToRegionalPOList = regionalManagerToRegionalDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if (regionalManagerToRegionalPOList.size() > 0) {
|
|
|
- List<RegionalManagerToRegional> regionalList = new ArrayList<>();
|
|
|
- RegionalManager regionalManager = new RegionalManager();
|
|
|
- regionalManager.setUserId(userPO.getId());
|
|
|
- for (RegionalManagerToRegionalPO regionalManagerToRegionalPO : regionalManagerToRegionalPOList) {
|
|
|
- if (regionalManagerToRegionalPO != null) {
|
|
|
- regionalManager.setId(regionalManagerToRegionalPO.getId());
|
|
|
- /*获取区域管理员管理的区域信息*/
|
|
|
- RegionalManagerToRegional regionalResult = Converter.convert(RegionalManagerToRegional.class, regionalManagerToRegionalPO);
|
|
|
- regionalList.add(regionalResult);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- regionalManager.setRegionalList(regionalList);
|
|
|
- userResult.setRegionalManager(regionalManager);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private User getEvaluationInfo(User userResult) {
|
|
|
- /*获取测评机构信息*/
|
|
|
- Optional<EvaluationAgencyPO> evaluationAgencyPOOptional = evaluationAgencyDao.findByUserIdAndIsDeleted(userResult.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if (evaluationAgencyPOOptional.isPresent()) {
|
|
|
- EvaluationAgency evaluationAgencyResult = Converter.convert(EvaluationAgency.class, evaluationAgencyPOOptional.get());
|
|
|
-
|
|
|
- /*获取测评机构能力*/
|
|
|
- List<EvaluationAgencyAbilityPO> evaluationAgencyAbilityPOList = agencyAbilityDao.findByEvaluationAgencyIdAndIsDeleted(evaluationAgencyResult.getId(), DeletedStatus.isNotDeleted);
|
|
|
- List<EvaluationAgencyAbility> evaluationAgencyAbilityList = new ArrayList<>();
|
|
|
- if (evaluationAgencyAbilityPOList.size() != 0) {
|
|
|
- for (EvaluationAgencyAbilityPO evaluationAgencyAbilityPO : evaluationAgencyAbilityPOList) {
|
|
|
- EvaluationAgencyAbility evaluationAgencyAbility = Converter.convert(EvaluationAgencyAbility.class, evaluationAgencyAbilityPO);
|
|
|
- evaluationAgencyAbilityList.add(evaluationAgencyAbility);
|
|
|
- }
|
|
|
- }
|
|
|
- evaluationAgencyResult.setEvaluationAgencyAbilityList(evaluationAgencyAbilityList);
|
|
|
-
|
|
|
- /*获取测评机构资源*/
|
|
|
- List<EvaluationAgencyResourcePO> evaluationAgencyResourcePOList = agencyResourceDao.findByEvaluationAgencyIdAndIsDeleted(evaluationAgencyResult.getId(), DeletedStatus.isNotDeleted);
|
|
|
- List<EvaluationAgencyResource> evaluationAgencyResourceList = new ArrayList<>();
|
|
|
- if (evaluationAgencyResourcePOList.size() != 0) {
|
|
|
- for (EvaluationAgencyResourcePO evaluationAgencyResourcePO : evaluationAgencyResourcePOList) {
|
|
|
- EvaluationAgencyResource evaluationAgencyResource = Converter.convert(EvaluationAgencyResource.class, evaluationAgencyResourcePO);
|
|
|
- evaluationAgencyResourceList.add(evaluationAgencyResource);
|
|
|
- }
|
|
|
- }
|
|
|
- evaluationAgencyResult.setEvaluationAgencyResourceList(evaluationAgencyResourceList);
|
|
|
- userResult.setEvaluationAgency(evaluationAgencyResult);
|
|
|
+ List<String> codeList = new ArrayList<>();
|
|
|
+ if (user.getPersonalCompetence() != null && !user.getPersonalCompetence().trim().equals("")) {
|
|
|
+ codeList = Arrays.asList(user.getPersonalCompetence().split(","));
|
|
|
}
|
|
|
- return userResult;
|
|
|
- }
|
|
|
-
|
|
|
- public Role getRole(String roleName) {
|
|
|
- Role role = new Role();
|
|
|
- BeanUtils.copyProperties(roleDao.findByName(roleName), role);
|
|
|
- return role;
|
|
|
- }
|
|
|
-
|
|
|
- public long getAllUserNum() {
|
|
|
- return userDao.count();
|
|
|
- }
|
|
|
-
|
|
|
- public long getAllAgencyNum() {
|
|
|
- return evaluationAgencyDao.count();
|
|
|
+ user.setPersonAbilities(codeList.stream().map(typeCode -> typeMap.get(typeCode)).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
- public long getAllResourceNum() {
|
|
|
- return agencyResourceDao.count();
|
|
|
- }
|
|
|
+ private void getRegionalInfo(User user) {
|
|
|
+ /*获取区域管理员信息*/
|
|
|
+ List<RegionalManagerToRegionalPO> regionalManagerToRegionalPOList = regionalManagerToRegionalDao.findByUserIdAndIsDeleted(user.getId(), DeletedStatus.isNotDeleted);
|
|
|
+ if (regionalManagerToRegionalPOList.size() > 0) {
|
|
|
+ List<RegionalManagerToRegional> regionalList = new ArrayList<>();
|
|
|
+ RegionalManager regionalManager = new RegionalManager();
|
|
|
+ regionalManager.setUserId(user.getId());
|
|
|
+ for (RegionalManagerToRegionalPO regionalManagerToRegionalPO : regionalManagerToRegionalPOList) {
|
|
|
+ if (regionalManagerToRegionalPO != null) {
|
|
|
+ regionalManager.setId(regionalManagerToRegionalPO.getId());
|
|
|
+ /*获取区域管理员管理的区域信息*/
|
|
|
+ RegionalManagerToRegional regionalResult = Converter.convert(RegionalManagerToRegional.class, regionalManagerToRegionalPO);
|
|
|
+ regionalList.add(regionalResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ regionalManager.setRegionalList(regionalList);
|
|
|
+ user.setRegionalManager(regionalManager);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private User getEvaluationInfo(User userResult) {
|
|
|
+ /*获取测评机构信息*/
|
|
|
+ Optional<EvaluationAgencyPO> evaluationAgencyPOOptional = evaluationAgencyDao.findByUserIdAndIsDeleted(userResult.getId(), DeletedStatus.isNotDeleted);
|
|
|
+ if (evaluationAgencyPOOptional.isPresent()) {
|
|
|
+ EvaluationAgency evaluationAgencyResult = Converter.convert(EvaluationAgency.class, evaluationAgencyPOOptional.get());
|
|
|
+
|
|
|
+ /*获取测评机构能力*/
|
|
|
+ List<EvaluationAgencyAbilityPO> evaluationAgencyAbilityPOList = agencyAbilityDao.findByEvaluationAgencyIdAndIsDeleted(evaluationAgencyResult.getId(), DeletedStatus.isNotDeleted);
|
|
|
+ List<EvaluationAgencyAbility> evaluationAgencyAbilityList = new ArrayList<>();
|
|
|
+ if (evaluationAgencyAbilityPOList.size() != 0) {
|
|
|
+ for (EvaluationAgencyAbilityPO evaluationAgencyAbilityPO : evaluationAgencyAbilityPOList) {
|
|
|
+ EvaluationAgencyAbility evaluationAgencyAbility = Converter.convert(EvaluationAgencyAbility.class, evaluationAgencyAbilityPO);
|
|
|
+ evaluationAgencyAbilityList.add(evaluationAgencyAbility);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ evaluationAgencyResult.setEvaluationAgencyAbilityList(evaluationAgencyAbilityList);
|
|
|
+
|
|
|
+ /*获取测评机构资源*/
|
|
|
+ List<EvaluationAgencyResourcePO> evaluationAgencyResourcePOList = agencyResourceDao.findByEvaluationAgencyIdAndIsDeleted(evaluationAgencyResult.getId(), DeletedStatus.isNotDeleted);
|
|
|
+ List<EvaluationAgencyResource> evaluationAgencyResourceList = new ArrayList<>();
|
|
|
+ if (evaluationAgencyResourcePOList.size() != 0) {
|
|
|
+ for (EvaluationAgencyResourcePO evaluationAgencyResourcePO : evaluationAgencyResourcePOList) {
|
|
|
+ EvaluationAgencyResource evaluationAgencyResource = Converter.convert(EvaluationAgencyResource.class, evaluationAgencyResourcePO);
|
|
|
+ evaluationAgencyResourceList.add(evaluationAgencyResource);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ evaluationAgencyResult.setEvaluationAgencyResourceList(evaluationAgencyResourceList);
|
|
|
+ userResult.setEvaluationAgency(evaluationAgencyResult);
|
|
|
+ }
|
|
|
+ return userResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Role getRole(String roleName) {
|
|
|
+ Role role = new Role();
|
|
|
+ BeanUtils.copyProperties(roleDao.findByName(roleName), role);
|
|
|
+ return role;
|
|
|
+ }
|
|
|
+
|
|
|
+ public long getAllUserNum() {
|
|
|
+ return userDao.count();
|
|
|
+ }
|
|
|
+
|
|
|
+ public long getAllAgencyNum() {
|
|
|
+ return evaluationAgencyDao.count();
|
|
|
+ }
|
|
|
+
|
|
|
+ public long getAllResourceNum() {
|
|
|
+ return agencyResourceDao.count();
|
|
|
+ }
|
|
|
}
|