package cn.axzo.msg.center.inside.notices.service.impl;

import cn.axzo.msg.center.api.MessageApi;
import cn.axzo.msg.center.api.request.MessageModuleStatisticReq;
import cn.axzo.msg.center.api.request.MessagePageQueryReq;
import cn.axzo.msg.center.api.request.MessageReadAllReq;
import cn.axzo.msg.center.api.request.MessageStatisticReq;
import cn.axzo.msg.center.api.response.MessageDetailRes;
import cn.axzo.msg.center.api.response.MessageModuleStatisticRes;
import cn.axzo.msg.center.api.response.MessageStatisticRes;
import cn.axzo.msg.center.inside.notices.service.MessageCoreService;
import cn.azxo.framework.common.model.CommonResponse;
import cn.azxo.framework.common.model.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author cold_blade
 * @date 2023/9/13
 * @version 1.0
 */
@RestController
@RequiredArgsConstructor
public class MessageApiImpl implements MessageApi {

    private final MessageCoreService messageCoreService;

    @Override
    public CommonResponse<MessageStatisticRes> countPersonMessage(@RequestBody @Valid MessageStatisticReq request) {
        return CommonResponse.success(messageCoreService.countPersonMessage(request));
    }

    @Override
    public CommonResponse<List<MessageModuleStatisticRes>> statisticPersonModuleMessage(@RequestBody @Valid
                                                                                        MessageModuleStatisticReq request) {
        return CommonResponse.success(messageCoreService.statisticPersonModuleMessage(request));
    }

    @Override
    public CommonResponse<Void> readAllMessages(@RequestBody @Valid MessageReadAllReq request) {
        messageCoreService.readAllMessages(request);
        return CommonResponse.success();
    }

    @Override
    public CommonResponse<Page<MessageDetailRes>> pageQueryMessageRecords(@RequestBody @Valid
                                                                          MessagePageQueryReq request) {
        return CommonResponse.success(messageCoreService.pageQueryMessageRecords(request));
    }
}
