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

    @Autowired
    private IGameVipService gameVipService;

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

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

    @PostMapping("/list")
    @PreAuthorize(permissionKey = "manage:gameVip:list")
    public ResultVO<IPage<GameVipListVO>> gameVipList(@RequestBody GameVipListParam param) {
        return ResultVO.ok(gameVipService.gameVipList(param));
    }

    @PostMapping("/add/batch")
    @PreAuthorize(permissionKey = "manage:gameVip:addBatch")
    public ResultVO<Boolean> addVipBatch(@Validated @RequestBody GameVipAddBatchParam param) {
        return ResultVO.ok(gameVipService.addBatch(param));
    }

}
