GameAnswerController.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.api.games.controller;
  2. import com.api.common.JSONUtils;
  3. import com.api.core.controller.Ctrl;
  4. import com.api.core.response.Result;
  5. import com.api.core.response.ResultGenerator;
  6. import com.api.games.model.GameAnswer;
  7. import com.api.games.model.GameLog;
  8. import com.api.games.service.GameAnswerService;
  9. import com.github.pagehelper.PageHelper;
  10. import com.github.pagehelper.PageInfo;
  11. import org.springframework.web.bind.annotation.PostMapping;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RequestParam;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import tk.mybatis.mapper.entity.Condition;
  16. import tk.mybatis.mapper.entity.Example;
  17. import javax.annotation.Resource;
  18. import java.math.BigDecimal;
  19. import java.text.SimpleDateFormat;
  20. import java.util.List;
  21. import com.api.core.annotation.PowerEnable;
  22. import io.swagger.annotations.*;
  23. /**
  24. * Created by wanghuiwen on 2020/02/23.
  25. */
  26. @PowerEnable(name = "游戏答案",url = "/game/answer")
  27. @Api(value = "游戏答案", tags = {"游戏答案"})
  28. @RestController
  29. @RequestMapping("/game/answer")
  30. public class GameAnswerController extends Ctrl{
  31. @Resource
  32. private GameAnswerService gameAnswerService;
  33. @ApiOperation(value = "游戏答案添加", tags = {"游戏答案"}, notes = "游戏答案添加")
  34. @PostMapping(value="/add",name="游戏答案添加")
  35. public Result add(GameLog gameLog, @ApiParam String gameAnswer) {
  36. return gameAnswerService.add(gameLog,gameAnswer);
  37. }
  38. @PostMapping(value = "/add/real", name = "真正遊戲記錄添加")
  39. public Result realAdd(
  40. Long userId,
  41. Long gamePlayId,
  42. float realCorrectRate,
  43. float correctRate,
  44. float confidence,
  45. String startTime,
  46. String endTime,
  47. String version,
  48. String selected,
  49. String gameAnswer,
  50. String deviceId
  51. ){
  52. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  53. GameLog gameLog = new GameLog();
  54. gameLog.setUserId(userId);
  55. gameLog.setRealCorrectRate(new BigDecimal(realCorrectRate));
  56. gameLog.setCorrectRate(new BigDecimal(correctRate / 100));
  57. gameLog.setConfidence(new BigDecimal(confidence / 100));
  58. try {
  59. gameLog.setStartTime(simpleDateFormat.parse(startTime));
  60. gameLog.setEndTime(simpleDateFormat.parse(endTime));
  61. } catch (Exception e){
  62. e.printStackTrace();
  63. }
  64. gameLog.setVersion(version);
  65. gameLog.setSelected(selected);
  66. gameLog.setDeviceId(deviceId);
  67. return gameAnswerService.add(gamePlayId, gameLog, gameAnswer);
  68. }
  69. }