package com.sonic.pigeon.controller.web;

import com.sonic.common.auth.domains.Session;
import com.sonic.common.rpc.Page;
import com.sonic.common.rpc.Result;
import com.sonic.pigeon.domain.input.MessageListInput;
import com.sonic.pigeon.domain.output.MessageListOutput;
import com.sonic.pigeon.domain.output.MessageStatOutput;
import com.sonic.pigeon.service.MessageService;
import com.sonic.pigeon.service.MessageStatService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Web-系统消息
 *
 * @author mzc
 */
@Validated
@RestController
public class MessageWeb {

    @Autowired
    private MessageStatService messageStatService;
    @Autowired
    private MessageService messageService;

    @ApiOperation(value = "系统消息统计", tags = {"Web-系统消息"})
    @PostMapping("/web/message/stat")
    public Result<MessageStatOutput> messageStat(@ApiParam(hidden = true) Session session) {
        return Result.success(messageStatService.messageStat(session.getUserId()));
    }

    @ApiOperation(value = "系统消息列表", tags = {"Web-系统消息"})
    @PostMapping("/web/message/list")
    public Result<Page<MessageListOutput>> messageList(@Validated @RequestBody MessageListInput input, @ApiParam(hidden = true) Session session) {
        return Result.success(messageService.messageList(session.getUserId(), input));
    }

}
