package com.playlet.web.controller.app;

import com.github.pagehelper.PageInfo;
import com.playlet.common.core.controller.BaseController;
import com.playlet.common.core.domain.Result;
import com.playlet.common.core.page.TableDataInfo;
import com.playlet.system.domain.PlayletItem;
import com.playlet.system.domain.PlayletRevenueRecord;
import com.playlet.system.pojo.vo.RevenueRecordStatisticsVO;
import com.playlet.system.service.IPlayletRevenueRecordService;
import com.playlet.web.service.app.PlayletRevenueRecordAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Date: 2024-03-17
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 短剧任务收益Controller
 */
@Controller
@Api(tags = "短剧*短剧收益")
@RequestMapping("/app/record")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletRevenueRecordAppController extends BaseController {

    private final PlayletRevenueRecordAppService service;

    @ResponseBody
    @PostMapping("/getRecordList")
    @ApiOperation(value = "分页查询短剧收益基础列表")
    public Result<PageInfo<PlayletRevenueRecord>> recordList(@RequestBody PlayletRevenueRecord playletRevenueRecord,
                                                             @RequestParam(value = "pageNum") Integer pageNum,
                                                             @RequestParam(value = "pageSize") Integer pageSize) {
        return Result.success(service.getItemPage(playletRevenueRecord, pageNum, pageSize));
    }

    @ResponseBody
    @PostMapping("/statistics/time")
    @ApiOperation(value = "短剧收益时间统计")
    public Result<PlayletRevenueRecord> statisticsTime(@RequestBody PlayletRevenueRecord playletRevenueRecord) {
        return Result.success(service.statisticsTime(playletRevenueRecord));
    }

    @ResponseBody
    @PostMapping("/statistics")
    @ApiOperation(value = "短剧收益统计")
    public Result<RevenueRecordStatisticsVO> statistics(@RequestBody PlayletRevenueRecord playletRevenueRecord) {
        return Result.success(service.statistics(playletRevenueRecord));
    }

    @ResponseBody
    @PostMapping("/statistics/time/type")
    @ApiOperation(value = "短剧收益时间统计分类")
    public Result<List<PlayletRevenueRecord>> statisticsTimeType(@RequestBody PlayletRevenueRecord playletRevenueRecord) {
        return Result.success(service.statisticsTimeType(playletRevenueRecord));
    }
}
