package shop.alien.store.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.CommonPushReview;
import shop.alien.store.service.CommonPushReviewService;

@Api(tags = {"推送审核管理"})
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/commonPushReview")
@RequiredArgsConstructor
public class CommonPushReviewController {

    private final CommonPushReviewService commonPushReviewService;

    @ApiOperation("新增推送审核记录")
    @ApiOperationSupport(order = 1)
    @PostMapping("/add")
    public R<String> add(@RequestBody CommonPushReview review) {
        return commonPushReviewService.add(review);
    }

    @ApiOperation("根据主键删除（逻辑删除）")
    @ApiOperationSupport(order = 2)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "query", required = true)
    })
    @GetMapping("/deleteById")
    public R<String> deleteById(@RequestParam Long id) {
        return commonPushReviewService.deleteById(id);
    }

    @ApiOperation("更新推送审核记录")
    @ApiOperationSupport(order = 3)
    @PostMapping("/update")
    public R<String> update(@RequestBody CommonPushReview review) {
        return commonPushReviewService.update(review);
    }

    @ApiOperation("根据主键查询")
    @ApiOperationSupport(order = 4)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "query", required = true)
    })
    @GetMapping("/getById")
    public R<CommonPushReview> getById(@RequestParam Long id) {
        return commonPushReviewService.getInfoById(id);
    }

    @ApiOperation("分页列表")
    @ApiOperationSupport(order = 5)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "pushTaskId", value = "推送任务ID", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "reviewStatus", value = "审核状态", dataType = "Integer", paramType = "query")
    })
    @GetMapping("/list")
    public R<IPage<CommonPushReview>> list(
            @RequestParam Integer pageNum,
            @RequestParam Integer pageSize,
            @RequestParam(required = false) Long pushTaskId,
            @RequestParam(required = false) Integer reviewStatus) {
        return commonPushReviewService.list(pageNum, pageSize, pushTaskId, reviewStatus);
    }
}
