123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package com.api.games.controller;
- import com.api.common.JSONUtils;
- import com.api.core.controller.Ctrl;
- import com.api.core.response.Result;
- import com.api.core.response.ResultGenerator;
- import com.api.games.model.GameAnswer;
- import com.api.games.model.GameLog;
- import com.api.games.service.GameAnswerService;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import tk.mybatis.mapper.entity.Condition;
- import tk.mybatis.mapper.entity.Example;
- import javax.annotation.Resource;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.List;
- import com.api.core.annotation.PowerEnable;
- import io.swagger.annotations.*;
- /**
- * Created by wanghuiwen on 2020/02/23.
- */
- @PowerEnable(name = "游戏答案",url = "/game/answer")
- @Api(value = "游戏答案", tags = {"游戏答案"})
- @RestController
- @RequestMapping("/game/answer")
- public class GameAnswerController extends Ctrl{
- @Resource
- private GameAnswerService gameAnswerService;
- @ApiOperation(value = "游戏答案添加", tags = {"游戏答案"}, notes = "游戏答案添加")
- @PostMapping(value="/add",name="游戏答案添加")
- public Result add(GameLog gameLog, @ApiParam String gameAnswer) {
- return gameAnswerService.add(gameLog,gameAnswer);
- }
- @PostMapping(value = "/add/real", name = "真正遊戲記錄添加")
- public Result realAdd(
- Long userId,
- Long gamePlayId,
- float realCorrectRate,
- float correctRate,
- float confidence,
- String startTime,
- String endTime,
- String version,
- String selected,
- String gameAnswer,
- String deviceId
- ){
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- GameLog gameLog = new GameLog();
- gameLog.setUserId(userId);
- gameLog.setRealCorrectRate(new BigDecimal(realCorrectRate));
- gameLog.setCorrectRate(new BigDecimal(correctRate / 100));
- gameLog.setConfidence(new BigDecimal(confidence / 100));
- try {
- gameLog.setStartTime(simpleDateFormat.parse(startTime));
- gameLog.setEndTime(simpleDateFormat.parse(endTime));
- } catch (Exception e){
- e.printStackTrace();
- }
- gameLog.setVersion(version);
- gameLog.setSelected(selected);
- gameLog.setDeviceId(deviceId);
- return gameAnswerService.add(gamePlayId, gameLog, gameAnswer);
- }
- }
|