|
@@ -1,14 +1,16 @@
|
1
|
1
|
package com.yingying.tourist.web;
|
2
|
2
|
|
3
|
3
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
4
|
+import com.yingying.tourist.business.BusinessConstant;
|
|
5
|
+import com.yingying.tourist.common.Util;
|
4
|
6
|
import com.yingying.tourist.domain.Question;
|
|
7
|
+import com.yingying.tourist.exception.ErrorCode;
|
5
|
8
|
import com.yingying.tourist.result.MessageResult;
|
6
|
9
|
import com.yingying.tourist.service.QuestionService;
|
7
|
10
|
import com.yingying.tourist.vo.QuestionVo;
|
8
|
11
|
import org.springframework.beans.BeanUtils;
|
9
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
10
|
13
|
import org.springframework.web.bind.annotation.GetMapping;
|
11
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
12
|
14
|
import org.springframework.web.bind.annotation.RestController;
|
13
|
15
|
|
14
|
16
|
@RestController
|
|
@@ -18,13 +20,18 @@ public class QuestionController {
|
18
|
20
|
private QuestionService questionService;
|
19
|
21
|
|
20
|
22
|
@GetMapping("question/pick")
|
21
|
|
- public MessageResult<QuestionVo> question(String pickOne, String pickTwo, String pickThird,String pickFourth){
|
|
23
|
+ public MessageResult<QuestionVo> question(String pickOne, String pickTwo, String pickThird, String pickFourth){
|
|
24
|
+ if (Util.isNull(pickOne) || Util.isNull(pickTwo) || Util.isNull(pickThird) || Util.isNull(pickFourth)) {
|
|
25
|
+ return new MessageResult<QuestionVo>().failure(ErrorCode.PARAMETERS_ERROR);
|
|
26
|
+ }
|
|
27
|
+ QuestionVo questionVo = new QuestionVo();
|
22
|
28
|
String pick = pickOne + pickTwo + pickThird;
|
23
|
29
|
EntityWrapper<Question> wrapper = new EntityWrapper<>();
|
24
|
|
- wrapper.eq("questionPath", pick);
|
|
30
|
+ wrapper.eq("question_path", pick);
|
25
|
31
|
Question question = questionService.selectOne(wrapper);
|
26
|
|
- QuestionVo questionVo = new QuestionVo();
|
27
|
32
|
BeanUtils.copyProperties(question, questionVo);
|
|
33
|
+ questionVo.setResultDescribe(BusinessConstant.describeMap.get(Util.getRandomInt(1,16)));
|
|
34
|
+ questionVo.setResultIdentity(BusinessConstant.Identity.getValue(pickFourth));
|
28
|
35
|
return new MessageResult<QuestionVo>().ok(questionVo);
|
29
|
36
|
}
|
30
|
37
|
}
|