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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
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 : 游戏分类标签
 */
@Api(tags = {"游戏分类标签管理接口"})
@RestController
@RequestMapping("/game/tag")
@Slf4j
public class GameTagController {

    @Autowired
    private IGameTagService gameTagService;

    @ApiOperation(value = "查询游戏标签列表")
    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:gameTag:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameTagVO.class)})
    public ResultVO<IPage<GameTagVO>> list(@Validated @RequestBody GameTagListParam param) {
        return ResultVO.ok(gameTagService.list(param));
    }

    @ApiOperation(value = "游戏标签分类添加或修改")
    @PostMapping(value = "/add/or/update")
    @PreAuthorize(permissionKey = "manage:gameTag:addOrUpdate")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody GameTagAddUpdateParam param) {
        return ResultVO.ok(gameTagService.addOrUpdate(param));
    }

    @ApiOperation(value = "游戏标签分类删除")
    @DeleteMapping(value = "/delete/by/id")
    @PreAuthorize(permissionKey = "manage:gameTag:deleteById")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
    public ResultVO<Boolean> deleteById(@RequestParam Long id) {
        return ResultVO.ok(gameTagService.deleteById(id));
    }
}
