|
@@ -25,7 +25,7 @@ import java.util.Optional;
|
|
|
@Component
|
|
|
public class UserRepo implements IUserRepo {
|
|
|
@Autowired
|
|
|
- private EvaluationAgencyDao agencyDao;
|
|
|
+ private EvaluationAgencyDao agencyDao;
|
|
|
|
|
|
@Autowired
|
|
|
private UserDao userDao;
|
|
@@ -76,7 +76,7 @@ public class UserRepo implements IUserRepo {
|
|
|
Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
if (!userPOOptional.isPresent()) {
|
|
|
throw new UserNotExistException("用户不存在");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
User user = getUserAndRoleAndPermissionByUserPO(userPOOptional.get());
|
|
|
return user;
|
|
|
}
|
|
@@ -87,7 +87,7 @@ public class UserRepo implements IUserRepo {
|
|
|
Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
if (!userPOOptional.isPresent()) {
|
|
|
throw new UserNotExistException("用户不存在");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
User user = getUserAndRoleAndPermissionByUserPO(userPOOptional.get());
|
|
|
return this.getEvaluationInfo(user);
|
|
|
}
|
|
@@ -98,7 +98,7 @@ public class UserRepo implements IUserRepo {
|
|
|
Optional<UserPO> userPOOptional = userDao.findById(userId);
|
|
|
if (!userPOOptional.isPresent()) {
|
|
|
throw new UserNotExistException("用户不存在");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return Converter.convert(User.class, userPOOptional.get());
|
|
|
}
|
|
|
}
|
|
@@ -108,7 +108,7 @@ public class UserRepo implements IUserRepo {
|
|
|
UserPO userPO = userDao.findByMobile(mobileNum);
|
|
|
if (userPO == null) {
|
|
|
throw new UserNotExistException("用户不存在");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
User user = getUserAndRoleAndPermissionByUserPO(userPO);
|
|
|
return user;
|
|
|
}
|
|
@@ -124,11 +124,12 @@ public class UserRepo implements IUserRepo {
|
|
|
|
|
|
/**
|
|
|
* 获取机构认证的申请
|
|
|
+ *
|
|
|
* @return
|
|
|
* @throws RoleNotFoundException
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<User> getApplyEvaluationAgencyByIsAuthenticated(){
|
|
|
+ public List<User> getApplyEvaluationAgencyByIsAuthenticated() {
|
|
|
List<UserPO> userPOList = new ArrayList<>();
|
|
|
evaluationAgencyDao.findByIsAuthentication(AuthenticationStatus.isNotAuthenticated).forEach(evaluationAgencyPO -> {
|
|
|
userPOList.add(userDao.findById(evaluationAgencyPO.getUserId()).get());
|
|
@@ -146,18 +147,18 @@ public class UserRepo implements IUserRepo {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ArrayList<UserPO> getAllUserInfo() throws RoleNotFoundException{
|
|
|
+ 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){
|
|
|
+ public UserTaskCount getUserTaskCountByUserId(Long userId) {
|
|
|
Optional<UserTaskCountPO> userTaskCountPO = userTaskCountDao.findByUserId(userId);
|
|
|
- if(!userTaskCountPO.isPresent()){
|
|
|
+ if (!userTaskCountPO.isPresent()) {
|
|
|
return null;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return Converter.convert(UserTaskCount.class, userTaskCountPO.get());
|
|
|
}
|
|
|
}
|
|
@@ -202,6 +203,7 @@ public class UserRepo implements IUserRepo {
|
|
|
|
|
|
/**
|
|
|
* 注册用户时默认为普通用户,分配角色后存入数据库
|
|
|
+ *
|
|
|
* @param user
|
|
|
* @return
|
|
|
*/
|
|
@@ -214,7 +216,7 @@ public class UserRepo implements IUserRepo {
|
|
|
// 存储从数据库中取出的User的Role数据
|
|
|
List<Role> roleListResult = new ArrayList<>();
|
|
|
|
|
|
- for(Role role : roleList){
|
|
|
+ for (Role role : roleList) {
|
|
|
RolePO rolePO = roleDao.findByName(role.getName());
|
|
|
Role roleConvert = Converter.convert(Role.class, rolePO);
|
|
|
|
|
@@ -233,6 +235,7 @@ public class UserRepo implements IUserRepo {
|
|
|
|
|
|
/**
|
|
|
* 保存用户相关的所有信息(包括测评机构信息、角色信息、权限信息)
|
|
|
+ *
|
|
|
* @param user
|
|
|
* @return
|
|
|
* @throws RoleNotFoundException
|
|
@@ -245,7 +248,8 @@ public class UserRepo implements IUserRepo {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- *保存用户信息(包括测评机构信息、角色信息、权限信息)
|
|
|
+ * 保存用户信息(包括测评机构信息、角色信息、权限信息)
|
|
|
+ *
|
|
|
* @param user
|
|
|
* @return
|
|
|
* @throws RoleNotFoundException
|
|
@@ -253,15 +257,15 @@ public class UserRepo implements IUserRepo {
|
|
|
private User saveRoleAndPermissionAndEvaluationAgencyByUser(User user) throws RoleNotFoundException {
|
|
|
UserPO userPO = userDao.save(Converter.convert(UserPO.class, user));
|
|
|
List<Role> roleList = user.getRoleList();
|
|
|
- if (roleList==null || roleList.size()==0){
|
|
|
+ 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 (roleList != null) {
|
|
|
+ for (Role role : roleList) {
|
|
|
if (userToRolePOList.stream().noneMatch(userToRolePO -> userToRolePO.getRoleId().equals(role.getId()))) {
|
|
|
UserToRolePO userToRolePO = new UserToRolePO();
|
|
|
userToRolePO.setRoleId(role.getId());
|
|
@@ -273,7 +277,7 @@ public class UserRepo implements IUserRepo {
|
|
|
|
|
|
/*机构认证保存机构信息*/
|
|
|
EvaluationAgency evaluationAgency = user.getEvaluationAgency();
|
|
|
- if(evaluationAgency != null){
|
|
|
+ if (evaluationAgency != null) {
|
|
|
EvaluationAgencyPO evaluationAgencyPO = Converter.convert(EvaluationAgencyPO.class, evaluationAgency);
|
|
|
evaluationAgencyPO.setUserId(userPO.getId());
|
|
|
evaluationAgencyPO = evaluationAgencyDao.save(evaluationAgencyPO);
|
|
@@ -297,54 +301,49 @@ public class UserRepo implements IUserRepo {
|
|
|
}
|
|
|
|
|
|
/*实名认证保存个人信息*/
|
|
|
- if(user.getPersonalAuthentication() != null){
|
|
|
- System.out.println("认证消息为==========="+user.getPersonalAuthentication());
|
|
|
+ if (user.getPersonalAuthentication() != null) {
|
|
|
PersonalAuthenticationPO authenticationPO = Converter.convert(PersonalAuthenticationPO.class, user.getPersonalAuthentication());
|
|
|
- System.out.println("认证消息为PO==========="+authenticationPO);
|
|
|
personalAuthenticationDao.save(authenticationPO);
|
|
|
}
|
|
|
|
|
|
/*企业认证保存企业信息*/
|
|
|
- if(user.getEnterpriseAuthentication() != null){
|
|
|
- if(user.getEnterpriseAuthentication().getIsDaOrEa().equals("研发机构")){
|
|
|
- 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);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+// 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());
|
|
|
- for(RoleToPermissionPO roleToPermissionPO : roleToPermissionPOList){
|
|
|
+ for (RoleToPermissionPO roleToPermissionPO : roleToPermissionPOList) {
|
|
|
Long permissionId = roleToPermissionPO.getPermissionId();
|
|
|
Optional<PermissionPO> permissionPOOptional = permissionDao.findById(permissionId);
|
|
|
- if(!permissionPOOptional.isPresent()){
|
|
|
+ if (!permissionPOOptional.isPresent()) {
|
|
|
throw new PermissionNotFoundException();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
PermissionPO permissionPO = permissionPOOptional.get();
|
|
|
- permissionResultList.add(Converter.convert(Permission.class,permissionPO));
|
|
|
+ permissionResultList.add(Converter.convert(Permission.class, permissionPO));
|
|
|
}
|
|
|
}
|
|
|
roleResult.setPermissionList(permissionResultList);
|
|
@@ -353,13 +352,14 @@ public class UserRepo implements IUserRepo {
|
|
|
|
|
|
/**
|
|
|
* 通过UsePOList获取用户-角色-权限信息
|
|
|
+ *
|
|
|
* @param userPOList
|
|
|
* @return
|
|
|
* @throws RoleNotFoundException
|
|
|
*/
|
|
|
private List<User> getUserAndRoleAndPermissionListByUserPOList(List<UserPO> userPOList) throws RoleNotFoundException {
|
|
|
List<User> userList = new ArrayList<>();
|
|
|
- for(UserPO userPO : userPOList){
|
|
|
+ for (UserPO userPO : userPOList) {
|
|
|
User userAndRole = getUserAndRoleAndPermissionByUserPO(userPO);
|
|
|
userList.add(userAndRole);
|
|
|
}
|
|
@@ -368,22 +368,23 @@ public class UserRepo implements IUserRepo {
|
|
|
|
|
|
/**
|
|
|
* 通过用户信息获取用户-角色-权限信息
|
|
|
+ *
|
|
|
* @param userPO
|
|
|
* @return
|
|
|
* @throws RoleNotFoundException
|
|
|
*/
|
|
|
- private User getUserAndRoleAndPermissionByUserPO(UserPO userPO) throws RoleNotFoundException{
|
|
|
+ private User getUserAndRoleAndPermissionByUserPO(UserPO userPO) throws RoleNotFoundException {
|
|
|
User userResult = Converter.convert(User.class, userPO);
|
|
|
List<UserToRolePO> userToRolePOList = userToRoleDao.findByUserId(userResult.getId());
|
|
|
List<Role> roleResultList = new ArrayList<>();
|
|
|
for (UserToRolePO userToRolePO : userToRolePOList) {
|
|
|
Optional<RolePO> rolePOOptional = roleDao.findById(userToRolePO.getRoleId());
|
|
|
- if(rolePOOptional.isPresent()){
|
|
|
+ if (rolePOOptional.isPresent()) {
|
|
|
RolePO rolePO = rolePOOptional.get();
|
|
|
// 权限
|
|
|
Role roleResult = getPermissionByRole(Converter.convert(Role.class, rolePO));
|
|
|
roleResultList.add(roleResult);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
throw new RoleNotFoundException();
|
|
|
}
|
|
|
}
|
|
@@ -392,24 +393,24 @@ public class UserRepo implements IUserRepo {
|
|
|
|
|
|
/*获取个人认证的信息*/
|
|
|
PersonalAuthenticationPO personalAuthenticationPO = personalAuthenticationDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if(personalAuthenticationPO != null){
|
|
|
+ if (personalAuthenticationPO != null) {
|
|
|
userResult.setPersonalAuthentication(Converter.convert(PersonalAuthentication.class, personalAuthenticationPO));
|
|
|
}
|
|
|
|
|
|
/*获取企业认证的信息*/
|
|
|
EnterpriseAuthenticationPO enterpriseAuthenticationPO = enterpriseAuthenticationDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if(enterpriseAuthenticationPO != null){
|
|
|
+ if (enterpriseAuthenticationPO != null) {
|
|
|
userResult.setEnterpriseAuthentication(Converter.convert(EnterpriseAuthentication.class, enterpriseAuthenticationPO));
|
|
|
}
|
|
|
|
|
|
/*获取区域管理员信息*/
|
|
|
List<RegionalManagerToRegionalPO> regionalManagerToRegionalPOList = regionalManagerToRegionalDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if(regionalManagerToRegionalPOList.size() > 0){
|
|
|
+ if (regionalManagerToRegionalPOList.size() > 0) {
|
|
|
List<RegionalManagerToRegional> regionalList = new ArrayList<>();
|
|
|
RegionalManager regionalManager = new RegionalManager();
|
|
|
regionalManager.setUserId(userPO.getId());
|
|
|
- for(RegionalManagerToRegionalPO regionalManagerToRegionalPO : regionalManagerToRegionalPOList){
|
|
|
- if(regionalManagerToRegionalPO != null){
|
|
|
+ for (RegionalManagerToRegionalPO regionalManagerToRegionalPO : regionalManagerToRegionalPOList) {
|
|
|
+ if (regionalManagerToRegionalPO != null) {
|
|
|
regionalManager.setId(regionalManagerToRegionalPO.getId());
|
|
|
/*获取区域管理员管理的区域信息*/
|
|
|
RegionalManagerToRegional regionalResult = Converter.convert(RegionalManagerToRegional.class, regionalManagerToRegionalPO);
|
|
@@ -423,7 +424,7 @@ public class UserRepo implements IUserRepo {
|
|
|
|
|
|
//获取系统管理员信息
|
|
|
SystemAdministratorToUserPO systemAdministratorToUserPO = systemAdministratorToUserDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if(systemAdministratorToUserPO != null){
|
|
|
+ if (systemAdministratorToUserPO != null) {
|
|
|
userResult.setSystemAdministratorToUser(Converter.convert(SystemAdministratorToUser.class, systemAdministratorToUserPO));
|
|
|
}
|
|
|
|
|
@@ -433,14 +434,14 @@ public class UserRepo implements IUserRepo {
|
|
|
private User getEvaluationInfo(User userResult) {
|
|
|
/*获取测评机构信息*/
|
|
|
EvaluationAgencyPO evaluationAgencyPO = evaluationAgencyDao.findByUserIdAndIsDeleted(userResult.getId(), DeletedStatus.isNotDeleted);
|
|
|
- if(evaluationAgencyPO != null){
|
|
|
+ if (evaluationAgencyPO != null) {
|
|
|
EvaluationAgency evaluationAgencyResult = Converter.convert(EvaluationAgency.class, evaluationAgencyPO);
|
|
|
|
|
|
/*获取测评机构能力*/
|
|
|
List<EvaluationAgencyAbilityPO> evaluationAgencyAbilityPOList = agencyAbilityDao.findByEvaluationAgencyIdAndIsDeleted(evaluationAgencyResult.getId(), DeletedStatus.isNotDeleted);
|
|
|
List<EvaluationAgencyAbility> evaluationAgencyAbilityList = new ArrayList<>();
|
|
|
- if(evaluationAgencyAbilityPOList.size() != 0){
|
|
|
- for(EvaluationAgencyAbilityPO evaluationAgencyAbilityPO : evaluationAgencyAbilityPOList){
|
|
|
+ if (evaluationAgencyAbilityPOList.size() != 0) {
|
|
|
+ for (EvaluationAgencyAbilityPO evaluationAgencyAbilityPO : evaluationAgencyAbilityPOList) {
|
|
|
EvaluationAgencyAbility evaluationAgencyAbility = Converter.convert(EvaluationAgencyAbility.class, evaluationAgencyAbilityPO);
|
|
|
evaluationAgencyAbilityList.add(evaluationAgencyAbility);
|
|
|
}
|
|
@@ -450,8 +451,8 @@ public class UserRepo implements IUserRepo {
|
|
|
/*获取测评机构资源*/
|
|
|
List<EvaluationAgencyResourcePO> evaluationAgencyResourcePOList = agencyResourceDao.findByEvaluationAgencyIdAndIsDeleted(evaluationAgencyResult.getId(), DeletedStatus.isNotDeleted);
|
|
|
List<EvaluationAgencyResource> evaluationAgencyResourceList = new ArrayList<>();
|
|
|
- if(evaluationAgencyResourcePOList.size() != 0){
|
|
|
- for(EvaluationAgencyResourcePO evaluationAgencyResourcePO : evaluationAgencyResourcePOList){
|
|
|
+ if (evaluationAgencyResourcePOList.size() != 0) {
|
|
|
+ for (EvaluationAgencyResourcePO evaluationAgencyResourcePO : evaluationAgencyResourcePOList) {
|
|
|
EvaluationAgencyResource evaluationAgencyResource = Converter.convert(EvaluationAgencyResource.class, evaluationAgencyResourcePO);
|
|
|
evaluationAgencyResourceList.add(evaluationAgencyResource);
|
|
|
}
|
|
@@ -462,21 +463,21 @@ public class UserRepo implements IUserRepo {
|
|
|
return userResult;
|
|
|
}
|
|
|
|
|
|
- public Role getRole(String roleName){
|
|
|
+ public Role getRole(String roleName) {
|
|
|
Role role = new Role();
|
|
|
BeanUtils.copyProperties(roleDao.findByName(roleName), role);
|
|
|
return role;
|
|
|
}
|
|
|
|
|
|
- public long getAllUserNum(){
|
|
|
+ public long getAllUserNum() {
|
|
|
return userDao.count();
|
|
|
}
|
|
|
|
|
|
- public long getAllAgencyNum(){
|
|
|
+ public long getAllAgencyNum() {
|
|
|
return evaluationAgencyDao.count();
|
|
|
}
|
|
|
|
|
|
- public long getAllResourceNum(){
|
|
|
+ public long getAllResourceNum() {
|
|
|
return agencyResourceDao.count();
|
|
|
}
|
|
|
}
|