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 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 : 支付策略管理
 */
@RestController
@RequestMapping("/game/pay/strategy")
public class GamePayStrategyController {

    @Autowired
    private IGamePayStrategyService gamePayStrategyService;

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

    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:gamePayStrategy:list")
    public ResultVO<IPage<GamePayStrategyListVO>> pageList(@Validated @RequestBody GamePayStrategyListParam param) {
        return ResultVO.ok(gamePayStrategyService.pageList(param));
    }

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

    @PatchMapping(value = "/status/update")
    @PreAuthorize(permissionKey = "manage:gamePayStrategy:statusUpdate")
    public ResultVO<Boolean> statusUpdate(@RequestParam Long id, @RequestParam Integer status) {
        return ResultVO.ok(gamePayStrategyService.statusUpdate(id, status));
    }
}
