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.GamePayStrategyAddUpdateParam;
import com.zanxiang.game.module.manage.pojo.params.GamePayStrategyListParam;
import com.zanxiang.game.module.manage.pojo.vo.GamePayStrategyListVO;
import com.zanxiang.game.module.manage.service.IGamePayStrategyService;
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 : 2022-11-25
 * @description : 支付策略管理
 */
@Api(tags = "支付策略管理")
@RestController
@RequestMapping("/game/pay/strategy")
public class GamePayStrategyController {

    @Autowired
    private IGamePayStrategyService gamePayStrategyService;

    @ApiOperation(value = "游戏支付策略新增或者更新")
    @PostMapping(value = "/add/or/update")
    @PreAuthorize(permissionKey = "manage:gamePayStrategy:addOrUpdate")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody GamePayStrategyAddUpdateParam param) {
        return ResultVO.ok(gamePayStrategyService.addOrUpdate(param));
    }

    @ApiOperation(value = "游戏支付策略列表查询")
    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:gamePayStrategy:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GamePayStrategyListVO.class)})
    public ResultVO<IPage<GamePayStrategyListVO>> pageList(@Validated @RequestBody GamePayStrategyListParam param) {
        return ResultVO.ok(gamePayStrategyService.pageList(param));
    }

    @ApiOperation(value = "游戏支付策略删除")
    @DeleteMapping(value = "/delete")
    @PreAuthorize(permissionKey = "manage:gamePayStrategy:delete")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
    public ResultVO<Boolean> deleteById(@RequestParam Long id) {
        return ResultVO.ok(gamePayStrategyService.deleteById(id));
    }

    @ApiOperation(value = "游戏支付策略状态变更")
    @PatchMapping(value = "/status/update")
    @PreAuthorize(permissionKey = "manage:gamePayStrategy:statusUpdate")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
    public ResultVO<Boolean> statusUpdate(@RequestParam Long id, @RequestParam Integer status) {
        return ResultVO.ok(gamePayStrategyService.statusUpdate(id, status));
    }
}
