Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1

This commit is contained in:
xzb 2022-10-13 14:22:39 +08:00
commit 92c25f77fd
3 changed files with 31 additions and 72 deletions

View File

@ -1,6 +1,8 @@
package club.joylink.rtss.controller.paper;
import club.joylink.rtss.constants.RoleEnum;
import club.joylink.rtss.controller.advice.Role;
import club.joylink.rtss.services.paper.PagerQuestionService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
@ -18,19 +20,28 @@ import java.util.List;
/**
* 题库教师管理接口
* 题库管理接口
*/
@RestController
@RequestMapping(path = "/api/question/org")
@RequestMapping(path = "/api/question")
public class PagerQuestionBankController {
@Autowired
private PagerQuestionService questionBankService;
/**
* 管理查询题库
*/
@Role(value = RoleEnum.SuperAdmin)
@GetMapping(path = "/paging")
public PageVO<PaperQuestionVO> pagingQueryQuestions(QuestionQueryVO queryVO) {
queryVO.setOrgId(queryVO.getOrgId());
return questionBankService.pagingQueryQuestions(queryVO,true);
}
/**
* 分页查询题目
*/
@GetMapping(path = "/paging")
@GetMapping(path = "/org/paging")
public PageVO<PaperQuestionVO> pagingQueryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) {
queryVO.setOrgId(loginInfo.getTopOrgId());
return questionBankService.pagingQueryQuestions(queryVO,false);
@ -39,7 +50,7 @@ public class PagerQuestionBankController {
/**
* 查询题目列表
*/
@GetMapping(path = "")
@GetMapping(path = "/org")
public List<PaperQuestionVO> queryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) {
queryVO.setOrgId(loginInfo.getTopOrgId());
return questionBankService.queryQuestions(queryVO,false);
@ -48,7 +59,7 @@ public class PagerQuestionBankController {
/**
* 获取题目信息
*/
@GetMapping(path = "/{questionId}")
@GetMapping(path = "/org/{questionId}")
public PaperQuestionVO getQuestion(@PathVariable Long questionId) {
return questionBankService.getQuestion(questionId, false);
}
@ -56,7 +67,7 @@ public class PagerQuestionBankController {
/**
* 添加题目
*/
@PostMapping(path = "")
@PostMapping(path = "/org")
public void addQuestion(@Validated @RequestBody PaperQuestionVO questionVO, @RequestAttribute LoginUserInfoVO loginInfo) {
questionVO.setOrgId(loginInfo.getTopOrgId());
questionBankService.saveOrUpdate(questionVO, loginInfo.getAccountVO());
@ -65,7 +76,7 @@ public class PagerQuestionBankController {
/**
* 导入项目或单位试题库
*/
@PostMapping(path = "/import")
@PostMapping(path = "/org/import")
public void importProjectQuestion(@Validated @RequestBody List<PaperQuestionVO> questions, @RequestAttribute LoginUserInfoVO loginInfo) {
questionBankService.importProjectQuestion(questions, loginInfo.getTopOrgId(), loginInfo.getAccountVO());
@ -74,9 +85,8 @@ public class PagerQuestionBankController {
/**
* 根据companyId 查询所有的标签
*
* @return
*/
@GetMapping(path = "/lable")
@GetMapping(path = "/org/lable")
public Collection<String> findAllLable(@RequestAttribute LoginUserInfoVO loginInfo) {
return this.questionBankService.findAllLable(loginInfo.getTopOrgId());
}
@ -84,10 +94,8 @@ public class PagerQuestionBankController {
/**
* 根据标签查询所有的题型
*
* @param queryVO
* @return
*/
@PostMapping(path = "/lable/question")
@PostMapping(path = "/org/lable/question")
public List<PaperQuestionVO> findByLable(@RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PagerLableQueryVO queryVO) {
return this.questionBankService.queryQuestionsForRaceLable(loginInfo.getTopOrgId(),queryVO);
@ -97,12 +105,8 @@ public class PagerQuestionBankController {
/**
* 更新题目
*
* @param questionId
* @param loginInfo
* @param questionVO
* @param user
*/
@PutMapping(path = "/{questionId}")
@PutMapping(path = "/org/{questionId}")
public void updateQuestion(@PathVariable Long questionId, @RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PaperQuestionVO questionVO, @RequestAttribute AccountVO user) {
questionVO.setId(questionId);
questionVO.setOrgId(loginInfo.getTopOrgId());
@ -112,7 +116,7 @@ public class PagerQuestionBankController {
/**
* 删除题目
*/
@DeleteMapping(path = "")
@DeleteMapping(path = "/org")
public void deleteQuestion(@RequestBody List<Long> questionId) {
questionBankService.deleteQuestion(questionId);
}

View File

@ -1,40 +0,0 @@
package club.joylink.rtss.controller.paper;
import club.joylink.rtss.services.paper.PagerQuestionService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.pager.question.PagerLableQueryVO;
import club.joylink.rtss.vo.client.pager.question.PaperQuestionVO;
import club.joylink.rtss.vo.client.pager.question.QuestionQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Collection;
import java.util.List;
/**
* 题库管理接口
*/
@RestController
@RequestMapping(path = "/api/question/manage")
public class PagerQuestionBankManageController {
@Autowired
private PagerQuestionService questionBankService;
/**
* 分页查询题目
*/
@GetMapping(path = "/paging")
public PageVO<PaperQuestionVO> pagingQueryQuestions(QuestionQueryVO queryVO) {
queryVO.setOrgId(queryVO.getOrgId());
return questionBankService.pagingQueryQuestions(queryVO,true);
}
}

View File

@ -39,7 +39,7 @@ public class PagerQuestionService {
/**
* 查询列表
* @param queryVO  
* @param isPaging  
* @param isPaging 是否分页
* @param companyIdCanNull 是否允许公司组织id可以为空true=管理使用false = 组织使用
* @return
*/
@ -69,6 +69,7 @@ public class PagerQuestionService {
/**
* 获取题库分页列表
* @param queryVO  
* @param companyIdCanNull  
* @return
*/
public PageVO<PaperQuestionVO> pagingQueryQuestions(QuestionQueryVO queryVO,boolean companyIdCanNull) {
@ -81,6 +82,7 @@ public class PagerQuestionService {
/**
* 获取题型列表
* @param queryVO  
* @param companyIdCanNull  
* @return
*/
public List<PaperQuestionVO> queryQuestions(QuestionQueryVO queryVO,boolean companyIdCanNull) {
@ -123,19 +125,12 @@ public class PagerQuestionService {
}else if(Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() > 2 ,"多选题答案最少需要2个");
}
// List<Integer> sourceOptionList = Lists.newArrayList();
// sourceOptionList.addAll(optionList);
// optionList.removeAll(newAnswerList);
// if(CollectionUtils.isEmpty(optionList)){
// return true;
// }
Collections.sort(answerIds);
String answerStr = Joiner.on(",").skipNulls().join(answerIds);
if(Objects.equals(answerStr,vo.getQuestionAnswer())){
return true;
}
log.info("检查题目[{}]答案,获取原答案[{}],正确答案[{}] ",questionId, answerStr,vo.getQuestionAnswer());
// log.info("检查题目[{}]答案,获取原答案[{}],正确答案[{}] 有[{}]没有答对",questionId, Joiner.on(",").join(answerIds),Joiner.on(",").join(sourceOptionList),Joiner.on(",").join(optionList));
return false;
}
@ -145,7 +140,7 @@ public class PagerQuestionService {
*
*/
public Collection<String> findAllLable(Long companyId){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(companyId),"组织id不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(companyId),"组织id不能为空");
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
/*boolean isDefault = Project.isDefault(projectCode);
@ -176,7 +171,7 @@ public class PagerQuestionService {
if(Objects.equals(false,isDefault)){
idList = this.queryFromProjectCode(projectCode);
}*/
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(companyId),"组织id不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(companyId),"组织id不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(queryVO.allNotNullOrEmpty(),"查询内容不能为空");
int isDel = BusinessConsts.DBLogicDelete.NORMAL.ordinal();
List<PaperQuestionWithBLOBs> list = this.questionDAO.findFromAndRaceLable(companyId,isDel,queryVO.getLables(),queryVO.getTypes());
@ -189,7 +184,7 @@ public class PagerQuestionService {
* @param accountVO  
*/
public void saveOrUpdate(PaperQuestionVO questionVO, AccountVO accountVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(questionVO.getOrgId()),"组织id不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(questionVO.getOrgId()),"组织id不能为空");
this.checkQuestionType(questionVO,"题库目前只支持单选,多选和判断");
if (questionVO.isSelect() || questionVO.isJudge()) {
this.checkQuestionTypeForSelectAndJudge(questionVO,"单选或判断题正确答案有且只有一个!");
@ -234,7 +229,7 @@ public class PagerQuestionService {
@Transactional
public void importProjectQuestion(List<PaperQuestionVO> questions, Long companyId, AccountVO accountVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(companyId),"组织id不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(companyId),"组织id不能为空");
questions.forEach(questionVO -> {
String topic = questionVO.getTopic();
this.checkQuestionType(questionVO,String.format("题库目前只支持单选,多选和判断,题序[%s]",questionVO.getId()));