|
|
@@ -8,10 +8,7 @@ import com.mooctest.crowd.domain.exception.UserNotExistException;
|
|
|
import com.mooctest.crowd.domain.repository.EvaluationAgencyRepo;
|
|
|
import com.mooctest.crowd.domain.repository.UserRepo;
|
|
|
import com.mooctest.crowd.site.anticorruption.UserAntiCorruption;
|
|
|
-import com.mooctest.crowd.site.command.AgencyResourceCommand;
|
|
|
-import com.mooctest.crowd.site.command.AgencyUpdateCommand;
|
|
|
-import com.mooctest.crowd.site.command.ApplyAgencyAuthCommand;
|
|
|
-import com.mooctest.crowd.site.command.GenerateAgencyCommand;
|
|
|
+import com.mooctest.crowd.site.command.*;
|
|
|
import com.mooctest.crowd.site.data.dto.UserDTO;
|
|
|
import com.mooctest.crowd.site.data.vo.AgencyVO;
|
|
|
import com.mooctest.crowd.site.data.vo.EvolutionAgencyVO;
|
|
|
@@ -94,7 +91,14 @@ public class AgencyServiceImpl implements AgencyService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public UserDTO updateAgencyInfo(Long userId, AgencyUpdateCommand command) {
|
|
|
+ public AgencyVO updateAgencyInfo(Long userId, ApplyAgencyAuthCommand command) {
|
|
|
+ User user = userRepo.getByID(userId);
|
|
|
+ user.getEvaluationAgency().updateAuthInfo(command.toAgency());
|
|
|
+ return new AgencyVO(userRepo.saveUser(user).getEvaluationAgency());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AgencyVO upadteResourceAndAbility(Long userId, AgencyResourceAbilityUpdateCommand command) {
|
|
|
User user = userRepo.getByID(userId);
|
|
|
EvaluationAgency agency = user.getEvaluationAgency();
|
|
|
evaluationAgencyRepo.moveEvaluationAgencyAbility(agency.getEvaluationAgencyAbilityList());
|
|
|
@@ -102,7 +106,7 @@ public class AgencyServiceImpl implements AgencyService {
|
|
|
agency.setEvaluationAgencyAbilityList(command.getEvaluationAgencyAbilityList().stream().map(EvaluationAgencyAbility::new).collect(Collectors.toList()));
|
|
|
agency.setEvaluationAgencyResourceList(command.getEvaluationAgencyResourceList().stream().map(AgencyResourceCommand::toAgencyResource).collect(Collectors.toList()));
|
|
|
user.setEvaluationAgency(agency);
|
|
|
- return mediator.renderUser(userRepo.saveUser(user));
|
|
|
+ return new AgencyVO(userRepo.saveUser(user).getEvaluationAgency());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -111,7 +115,7 @@ public class AgencyServiceImpl implements AgencyService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public UserDTO passAuth(Long userId, Long operatorId) {
|
|
|
+ public AgencyVO passAuth(Long userId, Long operatorId) {
|
|
|
User operator = userRepo.getByID(operatorId);
|
|
|
if (operator.getRoleList().stream().noneMatch(role -> role.getName().equals("SystemAdministrator")))
|
|
|
throw new UnauthorizedException("无权限进行此操作");
|
|
|
@@ -120,7 +124,7 @@ public class AgencyServiceImpl implements AgencyService {
|
|
|
throw new BaseException("该用户未申请机构认证!");
|
|
|
user.getEvaluationAgency().passAuthentication();
|
|
|
user.getRoleList().add(userRepo.getRole("evaluationAgency"));
|
|
|
- return mediator.renderUser(userRepo.saveUser(user));
|
|
|
+ return new AgencyVO(userRepo.saveUser(user).getEvaluationAgency());
|
|
|
}
|
|
|
|
|
|
@Override
|