Quellcode durchsuchen

修复获取接包方信息时包括测试人员

郭超 vor 4 Jahren
Ursprung
Commit
24b887481e

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/dao/EvaluationAgencyDao.java

@@ -15,7 +15,7 @@ public interface EvaluationAgencyDao extends PagingAndSortingRepository<Evaluati
 
     EvaluationAgencyPO findByUserId(Long userId);
 
-    EvaluationAgencyPO findByUserIdAndIsDeleted(Long userId, int deletedStatus);
+    Optional<EvaluationAgencyPO> findByUserIdAndIsDeleted(Long userId, int deletedStatus);
 
     List<EvaluationAgencyPO> findByIsAuthentication(int isAuthentication);
 

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/dao/PersonalAuthenticationDao.java

@@ -17,7 +17,7 @@ public interface PersonalAuthenticationDao extends PagingAndSortingRepository<Pe
 
     PersonalAuthenticationPO findByUserId(Long userId);
 
-    PersonalAuthenticationPO findByUserIdAndIsDeleted(Long userId, int deletedStatus);
+    Optional<PersonalAuthenticationPO> findByUserIdAndIsDeleted(Long userId, int deletedStatus);
 
     List<PersonalAuthenticationPO> findByIsAuthentication(Integer isAuthentication);
 

+ 20 - 2
core/src/main/java/com/mooctest/crowd/domain/repository/EvaluationAgencyRepo.java

@@ -9,6 +9,7 @@ import com.mooctest.crowd.domain.exception.EvaluationAgencyResourceNotExist;
 import com.mooctest.crowd.domain.model.EvaluationAgencyAbilityPO;
 import com.mooctest.crowd.domain.model.EvaluationAgencyPO;
 import com.mooctest.crowd.domain.model.EvaluationAgencyResourcePO;
+import com.mooctest.crowd.domain.model.PersonalAuthenticationPO;
 import com.mooctest.crowd.domain.util.Converter;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -57,8 +58,25 @@ public class EvaluationAgencyRepo implements IEvaluationAgencyRepo {
 
     @Override
     public EvaluationAgency findAgencyByUserId(Long userId){
-        EvaluationAgencyPO evaluationAgencyPO = evaluationAgencyDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
-        return Converter.convert(EvaluationAgency.class, evaluationAgencyPO);
+        Optional<EvaluationAgencyPO> evaluationAgencyPOOptional = evaluationAgencyDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
+        if(evaluationAgencyPOOptional.isPresent()){
+            return Converter.convert(EvaluationAgency.class, evaluationAgencyPOOptional.get());
+        }
+        return null;
+    }
+
+    @Override
+    public String findAgencyNameByUserId(Long userId){
+        Optional<EvaluationAgencyPO> evaluationAgencyPOOptional = evaluationAgencyDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
+        if(evaluationAgencyPOOptional.isPresent()){
+            return evaluationAgencyPOOptional.get().getEvaluationAgencyName();
+        }else{
+            Optional<PersonalAuthenticationPO> personalAuthPOOptional = personalAuthDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
+            if(personalAuthPOOptional.isPresent()){
+                return personalAuthPOOptional.get().getRealName();
+            }
+        }
+        return null;
     }
 
     @Override

+ 2 - 0
core/src/main/java/com/mooctest/crowd/domain/repository/IEvaluationAgencyRepo.java

@@ -19,6 +19,8 @@ public interface IEvaluationAgencyRepo {
 
     EvaluationAgency findAgencyByUserId(Long userId);
 
+    String findAgencyNameByUserId(Long userId);
+
     List<EvaluationAgency> findAll();
 
     List<EvaluationAgency> findAllAuthenticatedReceivable();

+ 6 - 6
core/src/main/java/com/mooctest/crowd/domain/repository/UserRepo.java

@@ -397,9 +397,9 @@ public class UserRepo implements IUserRepo {
         userResult = getEvaluationInfo(userResult);
 
         /*获取个人认证的信息*/
-        PersonalAuthenticationPO personalAuthenticationPO = personalAuthenticationDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
-        if (personalAuthenticationPO != null) {
-            userResult.setPersonalAuthentication(Converter.convert(PersonalAuthentication.class, personalAuthenticationPO));
+        Optional<PersonalAuthenticationPO> personalAuthenticationPOOptional = personalAuthenticationDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
+        if (personalAuthenticationPOOptional.isPresent()) {
+            userResult.setPersonalAuthentication(Converter.convert(PersonalAuthentication.class, personalAuthenticationPOOptional.get()));
         }
 
         /*获取企业认证的信息*/
@@ -460,9 +460,9 @@ public class UserRepo implements IUserRepo {
 
     private User getEvaluationInfo(User userResult) {
         /*获取测评机构信息*/
-        EvaluationAgencyPO evaluationAgencyPO = evaluationAgencyDao.findByUserIdAndIsDeleted(userResult.getId(), DeletedStatus.isNotDeleted);
-        if (evaluationAgencyPO != null) {
-            EvaluationAgency evaluationAgencyResult = Converter.convert(EvaluationAgency.class, evaluationAgencyPO);
+        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);

+ 3 - 3
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -825,8 +825,8 @@ public class WebMediatorImpl implements ViewMediator {
 
             CrowdTaskVO crowdTaskVO = new CrowdTaskVO(crowdTestTask);
             if (crowdTestTask.getDistributionType() == 0) {
-                EvaluationAgencyPO agencyPO = agencyDao.findByUserId(crowdTestTask.getEvaluationAgencyId());
-                crowdTaskVO.setInstitution(agencyPO == null ? "该机构已注销" : agencyPO.getEvaluationAgencyName());
+                String agencyName = evaluationAgencyRepo.findAgencyNameByUserId(crowdTestTask.getEvaluationAgencyId());
+                crowdTaskVO.setInstitution(agencyName == null ? "该机构已注销" : agencyName);
             }
             taskVOList.add(crowdTaskVO);
         }
@@ -988,7 +988,7 @@ public class WebMediatorImpl implements ViewMediator {
 
                 // 判断是否为定向发布的任务,如果是则获取定向发布机构/人员的名称信息
                 if(crowdTestTask.getDistributionType().equals(DistributeType.DIRECT.getId())){
-                    taskVO.setAgencyName(evaluationAgencyRepo.findAgencyByUserId(crowdTestTask.getEvaluationAgencyId()).getEvaluationAgencyName());
+                    taskVO.setAgencyName(evaluationAgencyRepo.findAgencyNameByUserId(crowdTestTask.getEvaluationAgencyId()));
                 }
             }
             // 测评机构视图