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.GameUserConfigAddUpdateParam;
import com.zanxiang.game.module.manage.pojo.params.GameUserConfigListParam;
import com.zanxiang.game.module.manage.pojo.vo.GameUserConfigListVO;
import com.zanxiang.game.module.manage.service.IGameUserConfigService;
import com.zanxiang.module.util.pojo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author : lingfeng
 * @time : 2023-08-09
 * @description : 有效用户配置
 */
@Api(tags = {"有效创角配置接口"})
@RestController
@RequestMapping("/gameUser/config")
public class GameUserConfigController {

    @Autowired
    private IGameUserConfigService gameUserConfigService;

    @ApiOperation(value = "新增或修改有效创角配置")
    @PostMapping(value = "/add/or/update")
    @PreAuthorize(permissionKey = "manage:gameUserConfig:addOrUpdate")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody GameUserConfigAddUpdateParam param) {
        return ResultVO.ok(gameUserConfigService.addOrUpdate(param));
    }

    @ApiOperation(value = "有效创角配置列表查询")
    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:gameUserConfig:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameUserConfigListVO.class)})
    public ResultVO<IPage<GameUserConfigListVO>> listOfPage(@Validated @RequestBody GameUserConfigListParam param) {
        return ResultVO.ok(gameUserConfigService.listOfPage(param));
    }

    @ApiOperation(value = "有效创角配置服删除")
    @DeleteMapping(value = "/delete")
    @PreAuthorize(permissionKey = "manage:gameUserConfig:delete")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
    public ResultVO<Boolean> deleteById(@RequestParam Long id) {
        return ResultVO.ok(gameUserConfigService.deleteById(id));
    }
}
