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.GameTagAddUpdateParam;
import com.zanxiang.game.module.manage.pojo.params.GameTagListParam;
import com.zanxiang.game.module.manage.pojo.vo.GameTagVO;
import com.zanxiang.game.module.manage.service.IGameTagService;
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.*;

/**
 * @author : lingfeng
 * @time : 2022-06-23
 * @description : 游戏分类标签
 */
@RestController
@RequestMapping("/game/tag")
@Slf4j
public class GameTagController {

    @Autowired
    private IGameTagService gameTagService;

    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:gameTag:list")
    public ResultVO<IPage<GameTagVO>> list(@Validated @RequestBody GameTagListParam param) {
        return ResultVO.ok(gameTagService.list(param));
    }

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

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