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.GamePayWayAddUpdateParam;
import com.zanxiang.game.module.manage.pojo.params.GamePayWayListParam;
import com.zanxiang.game.module.manage.pojo.vo.GamePayWayListVO;
import com.zanxiang.game.module.manage.service.IGamePayWayService;
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/way")
public class GamePayWayController {

    @Autowired
    private IGamePayWayService gamePayWayService;

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

    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:gamePayWay:list")
    public ResultVO<IPage<GamePayWayListVO>> pageList(@Validated @RequestBody GamePayWayListParam param) {
        return ResultVO.ok(gamePayWayService.pageList(param));
    }

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

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