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.*;
import com.zanxiang.game.module.manage.pojo.vo.CpVO;
import com.zanxiang.game.module.manage.pojo.vo.RoleGiftRecordListVO;
import com.zanxiang.game.module.manage.pojo.vo.RoleMailRecordListVO;
import com.zanxiang.game.module.manage.service.ICpService;
import com.zanxiang.game.module.manage.service.IRoleGiftRecordService;
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.*;

import java.util.List;

@Api(tags = {"角色礼包记录"})
@RestController
@RequestMapping("/role/gift/record")
@Slf4j
public class RoleGiftController {

    @Autowired
    private IRoleGiftRecordService roleGiftRecordService;

    @ApiOperation(value = "礼包记录新增或者更新")
    @PostMapping(value = "/add/or/update")
    @PreAuthorize(permissionKey = "manage:roleGift:addOrUpdate")
    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody RoleGiftRecordAddParam param) {
        return ResultVO.ok(roleGiftRecordService.addOrUpdate(param));
    }

    @ApiOperation(value = "礼包记录列表查询")
    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:roleGift:list")
    public ResultVO<IPage<RoleGiftRecordListVO>> list(@Validated @RequestBody RoleGiftRecordListParam param) {
        return ResultVO.ok(roleGiftRecordService.listOfPage(param));
    }

    @ApiOperation(value = "礼包记录删除")
    @DeleteMapping(value = "/delete/{ids}")
    @PreAuthorize(permissionKey = "manage:roleGift:delete")
    public ResultVO<Boolean> deleteById(@PathVariable List<Long> ids) {
        return ResultVO.ok(roleGiftRecordService.deleteByIds(ids));
    }
}
