Przeglądaj źródła

修复报空bug.

xuxuan 5 lat temu
rodzic
commit
207daf0dac

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

@@ -14,6 +14,7 @@ import org.springframework.stereotype.Component;
 
 import java.sql.Timestamp;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
 
@@ -414,10 +415,12 @@ public class UserRepo implements IUserRepo {
         }
         //获取用户能力
         List<String> abailities = new ArrayList<>();
-         String []abilities=userPO.getPersonalCompetence().split(",");
-        if(abilities!=null) {
-            for (int i = 0; i < abilities.length; i++) {
-                String abilityName = testTypeDao.findByCode(abilities[i]).get().getName();
+         if(userPO.getPersonalCompetence()!=null){
+             abailities= Arrays.asList(userPO.getPersonalCompetence().split(","));
+         }
+        {
+            for (int i = 0; i < abailities.size(); i++) {
+                String abilityName = testTypeDao.findByCode(abailities.get(i)).get().getName();
                 abailities.add(abilityName);
             }
         }

+ 3 - 3
site/src/main/java/com/mooctest/crowd/site/controller/AgencyController.java

@@ -135,9 +135,9 @@ public class AgencyController extends BaseSearchController {
      * @return
      */
     @LoginRequired
-    @RequestMapping(value = "/user/{agencyId}/agency", method = RequestMethod.GET)
-    public ResponseVO getAgencyInfo(@PathVariable("agencyId") Long anencyId) {
-        return     new ResponseVO(ServerCode.SUCCESS ,agencyService.getDetailById(anencyId));
+    @RequestMapping(value = "/user/{userId}/agency", method = RequestMethod.GET)
+    public ResponseVO getAgencyInfo(@PathVariable("userId") Long userId) {
+        return     new ResponseVO(ServerCode.SUCCESS ,agencyService.getDetailById(userId));
     }
 
     @RequestMapping(value = "/agency/list", method = RequestMethod.GET)

+ 16 - 15
site/src/main/java/com/mooctest/crowd/site/service/impl/AgencyServiceImpl.java

@@ -25,10 +25,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -65,7 +62,7 @@ public class AgencyServiceImpl implements AgencyService {
     private UserTaskCountDao userTaskCountDao;
 
     @Override
-    public EvaluationAgencyVO getDetailById(long agencyId) {
+    public EvaluationAgencyVO getDetailById(long  userId) {
         /*
         先根据机构id查询出机构信息,再从task-to-user表里面找到这个机构的接的任务的数量。
          */
@@ -73,20 +70,24 @@ public class AgencyServiceImpl implements AgencyService {
 
         List<String> agencyAbilities = new ArrayList<>();//机构能力list
         //根据compentence[]从test——type表利查询对应的能力名称
-
-        Optional<EvaluationAgencyPO> agencyPO = agencyDao.findById(agencyId);
-        if (!agencyPO.isPresent()) {
+        EvaluationAgencyPO agencyPO = agencyDao.findByUserId(userId);
+        if (agencyPO==null) {
             throw new HttpBadRequestException("机构不存在!");
         }
-        EvaluationAgency evaluationAgency = new EvaluationAgency(agencyPO.get());
-        Optional<UserPO> userPO = userDao.findById(evaluationAgency.getUserId());
-        String userCompetence = userPO.get().getPersonalCompetence();
+        EvaluationAgency evaluationAgency = new EvaluationAgency(agencyPO);
+        Optional<UserPO> userPO = userDao.findById(userId);
+        String userCompetence="";
+        if(userPO.get().getPersonalCompetence()!=null) {
+             userCompetence = userPO.get().getPersonalCompetence();
+        }
         //将 userConpetence按逗号分搁
-        String compentence[] = userCompetence.split(",");//JKCS,JRXCE,KKXCS,WDXCS
-        if(compentence!=null) {
-            for (int i = 0; i < compentence.length; i++) {
+        List<String> compentenceList=new ArrayList<>();
+        System.out.println(userCompetence+"sasssss");
+        if (userCompetence!=null&&!userCompetence.trim().equals("")){
+            compentenceList= Arrays.asList(userCompetence.split(",")); //JKCS,JRXCE,KKXCS,WDXCS
+            for (int i = 0; i < compentenceList.size(); i++) {
                 //查询对应code的测试类型的名称比如接口测试,兼用型测试等。
-                Optional<TestTypePO> testTypePO = testTypeDao.findByCode(compentence[i]);
+                Optional<TestTypePO> testTypePO = testTypeDao.findByCode(compentenceList.get(i));
                 agencyAbilities.add(testTypePO.get().getName());
             }
         }