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.UserRechargeWhiteAddParam;
import com.zanxiang.game.module.manage.pojo.params.UserRechargeWhiteListParam;
import com.zanxiang.game.module.manage.pojo.vo.UserRechargeWhiteVO;
import com.zanxiang.game.module.manage.service.IUserRechargeWhiteService;
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.Map;

/**
 * @author : lingfeng
 * @time : 2025-05-13
 * @description :
 */
@RestController
@RequestMapping("/user/recharge/white")
@Slf4j
public class UserRechargeWhiteController {

    @Autowired
    private IUserRechargeWhiteService userRechargeWhiteService;

    @GetMapping(value = "/game/list")
    @PreAuthorize(permissionKey = "manage:userRechargeWhite:gameList")
    public ResultVO<Map<Long, String>> chatGameMap() {
        return ResultVO.ok(userRechargeWhiteService.rechargeWhiteGameMap());
    }

    @PutMapping(value = "/add")
    @PreAuthorize(permissionKey = "manage:userRechargeWhite:add")
    public ResultVO<Boolean> addRechargeWhite(@RequestBody @Validated UserRechargeWhiteAddParam param) {
        return ResultVO.ok(userRechargeWhiteService.addRechargeWhite(param));
    }

    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:userRechargeWhite:listOfPage")
    public ResultVO<IPage<UserRechargeWhiteVO>> listOfPage(@Validated @RequestBody UserRechargeWhiteListParam param) {
        return ResultVO.ok(userRechargeWhiteService.listOfPage(param));
    }

    @DeleteMapping(value = "/del")
    @PreAuthorize(permissionKey = "manage:userRechargeWhite:del")
    public ResultVO<Boolean> delRechargeWhite(@RequestParam Long id) {
        return ResultVO.ok(userRechargeWhiteService.delRechargeWhite(id));
    }
}
