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.GameAppletShellAddUpdateParam;
import com.zanxiang.game.module.manage.pojo.params.GameAppletShellListParam;
import com.zanxiang.game.module.manage.pojo.vo.GameAppletShellListVO;
import com.zanxiang.game.module.manage.service.IGameAppletShellService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : lingfeng
 * @time : 2023-07-10
 * @description : 壳包控制接口
 */
@RestController
@RequestMapping("/applet/shell")
@Slf4j
public class GameAppletShellController {

    @Autowired
    private IGameAppletShellService gameAppletShellService;

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

    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:appletShell:list")
    public ResultVO<IPage<GameAppletShellListVO>> list(@Validated @RequestBody GameAppletShellListParam param) {
        return ResultVO.ok(gameAppletShellService.listOfPage(param));
    }
}
