2024-04-09 17:06:54 +00:00
|
|
|
|
package com.example.catchTheLetters.controller;
|
|
|
|
|
|
|
|
|
|
import com.example.catchTheLetters.entity.Level;
|
2024-04-10 07:03:57 +00:00
|
|
|
|
import com.example.catchTheLetters.model.vo.RankVo;
|
2024-04-09 17:06:54 +00:00
|
|
|
|
import com.example.catchTheLetters.entity.ScoreInfo;
|
2024-04-10 16:05:24 +00:00
|
|
|
|
import com.example.catchTheLetters.service.LevelService;
|
2024-04-09 17:06:54 +00:00
|
|
|
|
import com.example.catchTheLetters.utils.R;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
2024-04-10 16:05:24 +00:00
|
|
|
|
import jakarta.annotation.Resource;
|
2024-04-09 17:06:54 +00:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
2024-04-10 16:05:24 +00:00
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2024-04-09 17:06:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* 关卡控制器
|
2024-04-10 07:15:36 +00:00
|
|
|
|
*
|
2024-04-09 17:06:54 +00:00
|
|
|
|
* @author spyn
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Api(tags = "关卡API")
|
|
|
|
|
@RequestMapping("/level")
|
|
|
|
|
public class LevelController {
|
2024-04-10 16:05:24 +00:00
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private LevelService levelService;
|
|
|
|
|
|
2024-04-09 17:06:54 +00:00
|
|
|
|
@ApiOperation(value = "关卡列表(只返回ID、名称和类型)")
|
|
|
|
|
@GetMapping("/list")
|
2024-04-10 16:05:24 +00:00
|
|
|
|
public R<List<Level>> list() {
|
|
|
|
|
return levelService.list();
|
2024-04-09 17:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "关卡详情")
|
|
|
|
|
@GetMapping("/detail")
|
|
|
|
|
@ApiParam(name = "id", value = "关卡ID")
|
2024-04-12 01:51:21 +00:00
|
|
|
|
public R<Level> detail(String id) {
|
2024-04-10 16:05:24 +00:00
|
|
|
|
return levelService.levelDetail(id);
|
2024-04-09 17:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "关卡创建(web前端管理员提交)")
|
|
|
|
|
@PostMapping("/create")
|
|
|
|
|
public R create(@RequestBody Level level) {
|
2024-04-12 01:51:21 +00:00
|
|
|
|
return levelService.LevelCreate(level) ? R.ok() : R.fail();
|
2024-04-09 17:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "关卡修改(web前端管理员提交)")
|
|
|
|
|
@PostMapping("/update")
|
|
|
|
|
public R update(@RequestBody Level level) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "关卡删除(web前端管理员提交)")
|
|
|
|
|
@PostMapping("/delete")
|
2024-04-12 01:51:21 +00:00
|
|
|
|
public R delete(String id) {
|
2024-04-09 17:06:54 +00:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取某个关卡排行榜数据")
|
|
|
|
|
@GetMapping("/rank")
|
|
|
|
|
@ApiParam(name = "id", value = "关卡ID")
|
2024-04-12 01:51:21 +00:00
|
|
|
|
public R<RankVo> rank(String id, @RequestHeader(value = "token", required = false)String token) {
|
|
|
|
|
return R.ok(levelService.getRankInfo(id, token));
|
2024-04-09 17:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "关卡结算(游戏结束时提交,一定要鉴别token)")
|
|
|
|
|
@PostMapping("/settle")
|
2024-04-11 15:13:12 +00:00
|
|
|
|
public R<ScoreInfo> settle(@RequestBody ScoreInfo scoreInfo, @RequestHeader("token")String token) {
|
|
|
|
|
return levelService.settle(scoreInfo, token);
|
2024-04-09 17:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|