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 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
 */
@RestController
@RequestMapping("/game/policy/config")
@Slf4j
public class GamePolicyConfigController {

    @Autowired
    private IGamePolicyConfigService gamePolicyConfigService;

    @PostMapping("/add/or/update")
    @PreAuthorize(permissionKey = "manage:gamePolicy:addOrUpdate")
    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody GamePolicyConfigAddOrUpdateParam param) {
        return ResultVO.ok(gamePolicyConfigService.addOrUpdate(param));
    }

    @DeleteMapping("/deleteById/{id}")
    @PreAuthorize(permissionKey = "manage:gamePolicy:delete")
    public ResultVO<Boolean> deleteById(@PathVariable("id") Long id) {
        return ResultVO.ok(gamePolicyConfigService.deleteById(id));
    }

    @PostMapping("/listOfPage")
    @PreAuthorize(permissionKey = "manage:gamePolicy:listOfPage")
    public ResultVO<IPage<GamePolicyConfigListVO>> listOfPage(@RequestBody GamePolicyConfigListParam param) {
        return ResultVO.ok(gamePolicyConfigService.listOfPage(param));
    }


}
