package com.tzld.piaoquan.api.controller.contentplatform;

import com.tzld.piaoquan.api.annotation.JwtIgnore;
import com.tzld.piaoquan.api.job.contentplatform.ContentPlatformIllegalVideoJob;
import com.tzld.piaoquan.api.model.param.contentplatform.NoticeListParam;
import com.tzld.piaoquan.api.model.param.contentplatform.NoticeReadParam;
import com.tzld.piaoquan.api.model.vo.contentplatform.NoticeItemVO;
import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformNoticeService;
import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
import com.tzld.piaoquan.growth.common.utils.page.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/contentPlatform/notice")
@CrossOrigin(origins = "*")
public class ContentPlatformNoticeController {

    @Autowired
    ContentPlatformNoticeService noticeService;

    @Autowired
    private ContentPlatformIllegalVideoJob job;

    @ApiOperation(value = "通知列表")
    @PostMapping("/list")
    public CommonResponse<Page<NoticeItemVO>> noticeList(@RequestBody NoticeListParam param) {
        return CommonResponse.success(noticeService.noticeList(param));
    }

    @ApiOperation(value = "获取未读通知数量")
    @PostMapping("/getNotReadCount")
    public CommonResponse<Long> getNotReadCount() {
        return CommonResponse.success(noticeService.getNotReadCount());
    }

    @ApiOperation(value = "通知已读")
    @PostMapping("/read")
    public CommonResponse<Void> noticeRead(@RequestBody NoticeReadParam param) {
        noticeService.noticeRead(param);
        return CommonResponse.success();
    }

    @ApiOperation(value = "一键全部已读")
    @PostMapping("/readAll")
    public CommonResponse<Void> noticeReadAll() {
        noticeService.noticeReadAll();
        return CommonResponse.success();
    }

    @ApiOperation(value = "检查违规视频发送通知", hidden = true)
    @JwtIgnore
    @GetMapping("/job/checkContentPlatformIllegalVideoJob")
    public CommonResponse<Void> checkContentPlatformIllegalVideoJob(String dateStr) {
        job.checkContentPlatformIllegalVideoJob(dateStr);
        return CommonResponse.success();
    }
}
