|
@@ -1,13 +1,16 @@
|
|
package com.mooctest.crowd.site.controller;
|
|
package com.mooctest.crowd.site.controller;
|
|
|
|
|
|
import com.mooctest.crowd.domain.domainobject.Defect;
|
|
import com.mooctest.crowd.domain.domainobject.Defect;
|
|
|
|
+import com.mooctest.crowd.domain.domainobject.TestCase;
|
|
import com.mooctest.crowd.domain.domainobject.User;
|
|
import com.mooctest.crowd.domain.domainobject.User;
|
|
import com.mooctest.crowd.domain.env.Seriousness;
|
|
import com.mooctest.crowd.domain.env.Seriousness;
|
|
|
|
+import com.mooctest.crowd.domain.env.TestCaseExamStatus;
|
|
import com.mooctest.crowd.domain.util.Converter;
|
|
import com.mooctest.crowd.domain.util.Converter;
|
|
import com.mooctest.crowd.site.data.response.ResponseVO;
|
|
import com.mooctest.crowd.site.data.response.ResponseVO;
|
|
import com.mooctest.crowd.site.data.response.ServerCode;
|
|
import com.mooctest.crowd.site.data.response.ServerCode;
|
|
import com.mooctest.crowd.site.data.vo.TesterTaskVO;
|
|
import com.mooctest.crowd.site.data.vo.TesterTaskVO;
|
|
import com.mooctest.crowd.site.service.DefectService;
|
|
import com.mooctest.crowd.site.service.DefectService;
|
|
|
|
+import com.mooctest.crowd.site.service.TestCaseService;
|
|
import com.mooctest.crowd.site.service.UserService;
|
|
import com.mooctest.crowd.site.service.UserService;
|
|
import com.mooctest.crowd.site.util.RequestUtils;
|
|
import com.mooctest.crowd.site.util.RequestUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -29,10 +32,29 @@ public class TesterController {
|
|
private DefectService defectService;
|
|
private DefectService defectService;
|
|
@Autowired
|
|
@Autowired
|
|
private UserService userService;
|
|
private UserService userService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TestCaseService testCaseService;
|
|
|
|
|
|
@GetMapping(value = "/task/{userId}/{taskCode}")
|
|
@GetMapping(value = "/task/{userId}/{taskCode}")
|
|
public ResponseVO<TesterTaskVO> getTesterTaskInfo(HttpServletRequest request, @PathVariable("userId") Long userId, @PathVariable("taskCode") String taskCode){
|
|
public ResponseVO<TesterTaskVO> getTesterTaskInfo(HttpServletRequest request, @PathVariable("userId") Long userId, @PathVariable("taskCode") String taskCode){
|
|
|
|
+ List<TestCase> testCases = testCaseService.find(userId, RequestUtils.getUserId(request), taskCode, 0, 1000, null).getDatas();
|
|
List<Defect> defects = defectService.findUserDefects(userId, RequestUtils.getUserId(request), taskCode, 0, 1000).getDatas();
|
|
List<Defect> defects = defectService.findUserDefects(userId, RequestUtils.getUserId(request), taskCode, 0, 1000).getDatas();
|
|
|
|
+ TesterTaskVO.TestCaseCountInfoVO testCaseCountInfoVO = new TesterTaskVO.TestCaseCountInfoVO();
|
|
|
|
+ testCases.forEach(testCase -> {
|
|
|
|
+ testCaseCountInfoVO.setTestCaseCount(testCaseCountInfoVO.getTestCaseCount() + 1);
|
|
|
|
+ switch(testCase.getExamStatus()) {
|
|
|
|
+ case VALID:
|
|
|
|
+ testCaseCountInfoVO.setValidTestCaseCount(testCaseCountInfoVO.getValidTestCaseCount() + 1);
|
|
|
|
+ break;
|
|
|
|
+ case INVALID:
|
|
|
|
+ testCaseCountInfoVO.setInvalidTestCaseCount(testCaseCountInfoVO.getInvalidTestCaseCount() + 1);
|
|
|
|
+ break;
|
|
|
|
+ case WAIT:
|
|
|
|
+ testCaseCountInfoVO.setNoExamedTestCaseCount(testCaseCountInfoVO.getNoExamedTestCaseCount() + 1);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
List<TesterTaskVO.DefectInfoVO> defectInfoVOs = new ArrayList();
|
|
List<TesterTaskVO.DefectInfoVO> defectInfoVOs = new ArrayList();
|
|
Map<String, Integer> defectSeriCountMap = new LinkedHashMap() {{
|
|
Map<String, Integer> defectSeriCountMap = new LinkedHashMap() {{
|
|
put(Seriousness.VERY_HIGH.getName(), 0);
|
|
put(Seriousness.VERY_HIGH.getName(), 0);
|
|
@@ -49,18 +71,16 @@ public class TesterController {
|
|
defectInfoVO.setCommitTime(DateUtils.formatDate(new Date(defect.getCommitTime().getTime()), "yy-MM-dd HH:mm"));
|
|
defectInfoVO.setCommitTime(DateUtils.formatDate(new Date(defect.getCommitTime().getTime()), "yy-MM-dd HH:mm"));
|
|
defectInfoVOs.add(defectInfoVO);
|
|
defectInfoVOs.add(defectInfoVO);
|
|
defectSeriCountMap.put(seriName, defectSeriCountMap.get(seriName) + 1);
|
|
defectSeriCountMap.put(seriName, defectSeriCountMap.get(seriName) + 1);
|
|
|
|
+ testCaseCountInfoVO.setDefectCount(testCaseCountInfoVO.getDefectCount() + 1);
|
|
});
|
|
});
|
|
- List<Integer> defectSeriCounts = new ArrayList();
|
|
|
|
- for(String key: defectSeriCountMap.keySet()) {
|
|
|
|
- defectSeriCounts.add(defectSeriCountMap.get(key));
|
|
|
|
- }
|
|
|
|
User user = userService.getById(userId);
|
|
User user = userService.getById(userId);
|
|
TesterTaskVO.TesterInfoVO testerInfo = Converter.convert(TesterTaskVO.TesterInfoVO.class, user);
|
|
TesterTaskVO.TesterInfoVO testerInfo = Converter.convert(TesterTaskVO.TesterInfoVO.class, user);
|
|
testerInfo.setCreateTime(DateUtils.formatDate(new Date(user.getCreateTime().getTime()), "yyyy-MM-dd HH:mm"));
|
|
testerInfo.setCreateTime(DateUtils.formatDate(new Date(user.getCreateTime().getTime()), "yyyy-MM-dd HH:mm"));
|
|
TesterTaskVO testerTaskVO = new TesterTaskVO();
|
|
TesterTaskVO testerTaskVO = new TesterTaskVO();
|
|
testerTaskVO.setTester(testerInfo);
|
|
testerTaskVO.setTester(testerInfo);
|
|
testerTaskVO.setDefects(defectInfoVOs);
|
|
testerTaskVO.setDefects(defectInfoVOs);
|
|
- testerTaskVO.setDefectSeriCounts(defectSeriCounts);
|
|
|
|
|
|
+ testerTaskVO.setDefectSeriCounts(defectSeriCountMap);
|
|
|
|
+ testerTaskVO.setTestCaseCountInfo(testCaseCountInfoVO);
|
|
return new ResponseVO<>(ServerCode.SUCCESS, testerTaskVO);
|
|
return new ResponseVO<>(ServerCode.SUCCESS, testerTaskVO);
|
|
}
|
|
}
|
|
|
|
|