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.PayBoxAddUpdateParam;
import com.zanxiang.game.module.manage.pojo.params.PayBoxListParam;
import com.zanxiang.game.module.manage.pojo.vo.PayBoxListVO;
import com.zanxiang.game.module.manage.service.IPayBoxService;
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("/pay/box")
public class PayBoxController {

    @Autowired
    private IPayBoxService payBoxService;

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

    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:payBox:list")
    public ResultVO<IPage<PayBoxListVO>> list(@Validated @RequestBody PayBoxListParam param) {
        return ResultVO.ok(payBoxService.pageList(param));
    }

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

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