package cn.lihongjie.coal.noticeStatus.controller;

import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.noticeStatus.dto.CreateNoticeStatusDto;
import cn.lihongjie.coal.noticeStatus.dto.NoticeStatusDto;
import cn.lihongjie.coal.noticeStatus.dto.UpdateNoticeStatusDto;
import cn.lihongjie.coal.noticeStatus.service.NoticeStatusService;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/noticeStatus")
@SysLog(module = "消息通知状态")
@Slf4j
public class NoticeStatusController {
    @Autowired private NoticeStatusService service;

    @PostMapping("/create")
    public NoticeStatusDto create(@RequestBody CreateNoticeStatusDto request) {
        return this.service.create(request);
    }

    @PostMapping("/update")
    public NoticeStatusDto update(@RequestBody UpdateNoticeStatusDto request) {
        return this.service.update(request);
    }

    @PostMapping("/delete")
    public Object delete(@RequestBody IdRequest request) {
        this.service.delete(request);
        return true;
    }

    @PostMapping("/read")
    public Object read(@RequestBody IdRequest request) {
        this.service.read(request);
        return true;
    }

    /**
     * 获取我的消息数量
     *
     * @return
     */
    @PostMapping("/getMyNoticeCount")
    public Object getMyNoticeCount() {
        return this.service.getMyNoticeCount();
    }

    @PostMapping("/getById")
    public NoticeStatusDto getById(@RequestBody IdRequest request) {
        return this.service.getById(request.getId());
    }

    @PostMapping("/list")
    public Page<NoticeStatusDto> list(@RequestBody CommonQuery request) {
        return this.service.list(request);
    }
}
