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

import com.tzld.piaoquan.api.annotation.RequireSign;
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;

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

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

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

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