mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 18:26:23 +00:00
提交上阵
This commit is contained in:
@@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 玩家
|
||||
* 玩家宠物
|
||||
*/
|
||||
@Api(value = "JNGameDemo - API", tags = {"PET - API"})
|
||||
@RestController
|
||||
|
@@ -0,0 +1,68 @@
|
||||
package cn.jisol.game.controller.game;
|
||||
|
||||
import cn.jisol.game.controller.argsresolver.CurrentPlayer;
|
||||
import cn.jisol.game.entity.game.Player;
|
||||
import cn.jisol.game.entity.game.PlayerPet;
|
||||
import cn.jisol.game.entity.game.PlayerTactical;
|
||||
import cn.jisol.game.service.PlayerPetService;
|
||||
import cn.jisol.game.service.PlayerTacticalService;
|
||||
import cn.jisol.ngame.util.NewsContext;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 玩家阵法
|
||||
*/
|
||||
@Api(value = "JNGameDemo - API", tags = {"PET - API"})
|
||||
@RestController
|
||||
@RequestMapping("/game/tactical")
|
||||
@ResponseBody
|
||||
public class GPlayerTacticalController {
|
||||
|
||||
@Autowired
|
||||
PlayerTacticalService playerTacticalService;
|
||||
|
||||
//获取玩家阵法
|
||||
@ApiImplicitParams({})
|
||||
@ApiOperation(value = "获取玩家阵法")
|
||||
@GetMapping("/get")
|
||||
public NewsContext<PlayerTactical> getInfo(@CurrentPlayer Player player){
|
||||
|
||||
PlayerTactical info = playerTacticalService.getById(player.getPlayerId());
|
||||
|
||||
//如果没有阵法则创建一个
|
||||
if(Objects.isNull(info)){
|
||||
try{
|
||||
info = PlayerTactical.builder().playerId(player.getPlayerId()).build();
|
||||
playerTacticalService.saveOrUpdate(info);
|
||||
}catch (Exception ignored){}
|
||||
assert playerTacticalService != null;
|
||||
info = playerTacticalService.getById(player.getPlayerId());
|
||||
}
|
||||
|
||||
return NewsContext.onSuccess("获取成功",info);
|
||||
|
||||
}
|
||||
|
||||
//设置玩家上阵
|
||||
@ApiImplicitParams({})
|
||||
@ApiOperation(value = "设置玩家上阵")
|
||||
@GetMapping("/set")
|
||||
public NewsContext<PlayerTactical> setInfo(@CurrentPlayer Player player, @RequestBody PlayerTactical tactical){
|
||||
|
||||
tactical.setPlayerId(player.getPlayerId());
|
||||
if(Objects.isNull(tactical.getTacticalData())) return NewsContext.onFail("上阵失败 没有上阵信息");
|
||||
playerTacticalService.saveOrUpdate(tactical);
|
||||
|
||||
return NewsContext.onSuccess("上阵成功",tactical);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package cn.jisol.game.entity.game;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 玩家阵法
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@TableName("`player_tactical`")
|
||||
public class PlayerTactical {
|
||||
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long playerId; //玩家Id
|
||||
private String tacticalData; //阵法数据
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package cn.jisol.game.mapper;
|
||||
|
||||
import cn.jisol.game.entity.game.PlayerPet;
|
||||
import cn.jisol.game.entity.game.PlayerTactical;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public interface PlayerTacticalMapper extends BaseMapper<PlayerTactical> {
|
||||
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package cn.jisol.game.service;
|
||||
|
||||
import cn.jisol.game.entity.game.PlayerPet;
|
||||
import cn.jisol.game.entity.game.PlayerTactical;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface PlayerTacticalService extends IService<PlayerTactical> {
|
||||
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package cn.jisol.game.service.impl;
|
||||
|
||||
import cn.jisol.game.entity.game.PlayerPet;
|
||||
import cn.jisol.game.entity.game.PlayerTactical;
|
||||
import cn.jisol.game.mapper.PlayerPetMapper;
|
||||
import cn.jisol.game.mapper.PlayerTacticalMapper;
|
||||
import cn.jisol.game.service.PlayerPetService;
|
||||
import cn.jisol.game.service.PlayerTacticalService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PlayerTacticalServiceImpl extends ServiceImpl<PlayerTacticalMapper, PlayerTactical> implements PlayerTacticalService {
|
||||
|
||||
}
|
Reference in New Issue
Block a user