package com.zanxiang.game.module.manage.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zanxiang.erp.security.annotation.PreAuthorize;
import com.zanxiang.game.module.manage.pojo.params.GamePolicyConfigAddOrUpdateParam;
import com.zanxiang.game.module.manage.pojo.params.GamePolicyConfigListParam;
import com.zanxiang.game.module.manage.pojo.vo.GamePolicyConfigListVO;
import com.zanxiang.game.module.manage.service.IGamePolicyConfigService;
import com.zanxiang.module.util.pojo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author tianhua
 * @version 1.0
 * @description: 游戏策略配置控制器
 * @date 2023/11/29 13:55
 */
@Api(tags = "游戏策略配置")
@RestController
@RequestMapping("/game/policy/config")
@Slf4j
public class GamePolicyConfigController {

    @Autowired
    private IGamePolicyConfigService gamePolicyConfigService;

    @ApiOperation(value = "游戏策略配置新增或修改")
    @PostMapping("/add/or/update")
    @PreAuthorize(permissionKey = "manage:gamePolicy:addOrUpdate")
    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody GamePolicyConfigAddOrUpdateParam param) {
        return ResultVO.ok(gamePolicyConfigService.addOrUpdate(param));
    }

    @ApiOperation(value = "游戏策略配置删除")
    @DeleteMapping("/deleteById/{id}")
    @PreAuthorize(permissionKey = "manage:gamePolicy:delete")
    public ResultVO<Boolean> deleteById(@PathVariable("id") Long id) {
        return ResultVO.ok(gamePolicyConfigService.deleteById(id));
    }

    @ApiOperation(value = "游戏策略配置列表")
    @PostMapping("/listOfPage")
    @PreAuthorize(permissionKey = "manage:gamePolicy:listOfPage")
    public ResultVO<IPage<GamePolicyConfigListVO>> listOfPage(@RequestBody GamePolicyConfigListParam param) {
        return ResultVO.ok(gamePolicyConfigService.listOfPage(param));
    }


}
