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.GameVipAddBatchParam;
import com.zanxiang.game.module.manage.pojo.params.GameVipAddParam;
import com.zanxiang.game.module.manage.pojo.params.GameVipListParam;
import com.zanxiang.game.module.manage.pojo.vo.GameVipListVO;
import com.zanxiang.game.module.manage.service.IGameVipService;
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.*;

import java.util.List;

/**
 * @author tianhua
 * @version 1.0
 * @description: TODO
 * @date 2023/11/20 14:27
 */
@Api(tags = {"游戏vip档位"})
@RestController
@RequestMapping("/game/vip")
@Slf4j
public class GameVipController {

    @Autowired
    private IGameVipService gameVipService;

    @ApiOperation(value = "档位修改或新增")
    @PostMapping("/add/or/update")
    @PreAuthorize(permissionKey = "manage:gameVip:addOrUpdate")
    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody GameVipAddParam param) {
        return ResultVO.ok(gameVipService.addOrUpdate(param));
    }

    @ApiOperation(value = "删除vip档位")
    @DeleteMapping("/delete/{ids}")
    @PreAuthorize(permissionKey = "manage:gameVip:delete")
    public ResultVO<Boolean> deleteById(@PathVariable("ids") List<Long> ids) {
        return ResultVO.ok(gameVipService.deleteById(ids));
    }

    @ApiOperation(value = "游戏VIP档位列表")
    @PostMapping("/list")
    @PreAuthorize(permissionKey = "manage:gameVip:list")
    public ResultVO<IPage<GameVipListVO>> gameVipList(@RequestBody GameVipListParam param) {
        return ResultVO.ok(gameVipService.gameVipList(param));
    }

    @ApiOperation(value = "批量添加VIP档位")
    @PostMapping("/add/batch")
    @PreAuthorize(permissionKey = "manage:gameVip:addBatch")
    public ResultVO<Boolean> addVipBatch(@Validated @RequestBody GameVipAddBatchParam param) {
        return ResultVO.ok(gameVipService.addBatch(param));
    }

}
