|
@@ -15,6 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
15
|
15
|
import org.springframework.web.bind.annotation.GetMapping;
|
16
|
16
|
import org.springframework.web.bind.annotation.RestController;
|
17
|
17
|
|
|
18
|
+import java.util.Arrays;
|
|
19
|
+import java.util.List;
|
|
20
|
+
|
18
|
21
|
@RestController
|
19
|
22
|
public class QuestionController {
|
20
|
23
|
|
|
@@ -25,22 +28,27 @@ public class QuestionController {
|
25
|
28
|
private UserService userService;
|
26
|
29
|
|
27
|
30
|
@GetMapping("question/pick")
|
28
|
|
- public MessageResult<QuestionVo> question(String openid, String pickOne, String pickTwo, String pickThird, String pickFourth){
|
29
|
|
- if (Util.isNull(openid) || Util.isNull(pickOne) || Util.isNull(pickTwo) || Util.isNull(pickThird) || Util.isNull(pickFourth)) {
|
|
31
|
+ public MessageResult<QuestionVo> question(String openid, String pick){
|
|
32
|
+ if (Util.isNull(pick)) {
|
30
|
33
|
return new MessageResult<QuestionVo>().failure(ErrorCode.PARAMETERS_ERROR);
|
31
|
34
|
}
|
32
|
35
|
QuestionVo questionVo = new QuestionVo();
|
33
|
|
- String pick = pickOne + pickTwo + pickThird;
|
|
36
|
+ String[] pickList = pick.split(",");
|
|
37
|
+ String pickLast = pickList[3];
|
|
38
|
+ String pickBegin = pickList[0] + pickList[1] + pickList[2];
|
34
|
39
|
EntityWrapper<Question> questionWrapper = new EntityWrapper<>();
|
35
|
|
- questionWrapper.eq("question_path", pick);
|
|
40
|
+ questionWrapper.eq("question_path", pickBegin);
|
36
|
41
|
Question question = questionService.selectOne(questionWrapper);
|
37
|
|
- EntityWrapper<User> userWrapper = new EntityWrapper<>();
|
38
|
|
- userWrapper.eq("openid", openid);
|
39
|
|
- User user = userService.selectOne(userWrapper);
|
40
|
42
|
BeanUtils.copyProperties(question, questionVo);
|
|
43
|
+ questionVo.setResultDestinationInfo(BusinessConstant.destinationMap.get(question.getResultOrder()));
|
41
|
44
|
questionVo.setResultDescribe(BusinessConstant.describeMap.get(Util.getRandomInt(1,16)));
|
42
|
|
- questionVo.setResultIdentity(BusinessConstant.Identity.getValue(pickFourth));
|
43
|
|
- questionVo.setNickname(user.getNickname());
|
|
45
|
+ questionVo.setResultIdentity(BusinessConstant.Identity.getValue(pickLast));
|
|
46
|
+ if (Util.isNotNull(openid)) {
|
|
47
|
+ EntityWrapper<User> userWrapper = new EntityWrapper<>();
|
|
48
|
+ userWrapper.eq("openid", openid);
|
|
49
|
+ User user = userService.selectOne(userWrapper);
|
|
50
|
+ questionVo.setNickname(user.getNickname());
|
|
51
|
+ }
|
44
|
52
|
return new MessageResult<QuestionVo>().ok(questionVo);
|
45
|
53
|
}
|
46
|
54
|
}
|