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 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 : 有效用户配置
 */
@RestController
@RequestMapping("/gameUser/config")
public class GameUserConfigController {

    @Autowired
    private IGameUserConfigService gameUserConfigService;

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

    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:gameUserConfig:list")
    public ResultVO<IPage<GameUserConfigListVO>> listOfPage(@Validated @RequestBody GameUserConfigListParam param) {
        return ResultVO.ok(gameUserConfigService.listOfPage(param));
    }

    @DeleteMapping(value = "/delete")
    @PreAuthorize(permissionKey = "manage:gameUserConfig:delete")
    public ResultVO<Boolean> deleteById(@RequestParam Long id) {
        return ResultVO.ok(gameUserConfigService.deleteById(id));
    }
}
