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

import cn.axzo.foundation.result.ApiResult;
import cn.axzo.msg.center.api.request.v3.MessageSendReqV3;
import cn.axzo.msg.center.api.response.v3.MessageSendRespV3;
import cn.axzo.msg.center.api.v2.message.feign.MessageApiV2;
import cn.axzo.msg.center.api.v2.message.req.MessageSendV2Req;
import cn.axzo.msg.center.api.v2.message.resp.MessageSendV2Resp;
import cn.axzo.msg.center.inside.notices.service.MessageServiceV3;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : zhanghonghao@axzo.cn
 * @since : 2024/12/13
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class MessageApiV2Controller implements MessageApiV2 {

    private final MessageServiceV3 messageServiceV3;

    @Override
    public ApiResult<MessageSendV2Resp> send(MessageSendV2Req req) {
        log.info("MessageAPIV3Controller.send req={}", req);
        MessageSendReqV3 sendReqV3 = new MessageSendReqV3();
        BeanUtils.copyProperties(req, sendReqV3);
        MessageSendRespV3 sendRespV3 = messageServiceV3.send(sendReqV3);
        MessageSendV2Resp sendV2Resp = new MessageSendV2Resp();
        BeanUtils.copyProperties(sendRespV3, sendV2Resp);
        return ApiResult.success(sendV2Resp);
    }
}