package com.zanxiang.game.data.serve.controller;

import com.zanxiang.erp.security.annotation.PreAuthorize;
import com.zanxiang.game.data.serve.pojo.dto.GameUserConfigCreateOrUpdateDTO;
import com.zanxiang.game.data.serve.pojo.dto.GameUserConfigListDTO;
import com.zanxiang.game.data.serve.pojo.vo.GameUserConfigListVO;
import com.zanxiang.game.data.serve.service.IGameUserConfigService;
import com.zanxiang.game.data.serve.utils.Page;
import com.zanxiang.module.util.pojo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * packageName com.zanxiang.game.data.serve.controller
 *
 * @author ZhangXianyu
 * @date 2024/4/18
 * @description 有效创角配置管理
 */
@RestController
@RequestMapping("/gameUserConfig")
@Slf4j
public class GameUserConfigController {

    @Resource
    private IGameUserConfigService gameUserConfigService;

    @PreAuthorize(permissionKey = "roleManage:validRoleConfig:list")
    @PostMapping(value = "/list")
    public ResultVO<Page<GameUserConfigListVO>> validRoleConfigList(@Validated @RequestBody GameUserConfigListDTO dto) {
        return ResultVO.ok(gameUserConfigService.validRoleConfigList(dto));
    }

    @PreAuthorize(permissionKey = "roleManage:validRoleConfig:create")
    @PostMapping(value = "/create")
    public ResultVO<Boolean> create(@Validated @RequestBody GameUserConfigCreateOrUpdateDTO dto) {
        return ResultVO.ok(gameUserConfigService.create(dto));
    }
    @PreAuthorize(permissionKey = "roleManage:validRoleConfig:update")
    @PostMapping(value = "/update")
    public ResultVO<Boolean> update(@Validated @RequestBody GameUserConfigCreateOrUpdateDTO dto) {
        return ResultVO.ok(gameUserConfigService.update(dto));
    }

    @PreAuthorize(permissionKey = "roleManage:validRoleConfig:delete")
    @PostMapping(value = "/delete")
    public ResultVO<Boolean> delete(@RequestParam("id") Long id) {
        return ResultVO.ok(gameUserConfigService.delete(id));
    }

}