package com.red.circle.external.inner.endpoint.message;

import com.red.circle.external.infra.common.OfficialNoticeCommonService;
import com.red.circle.external.inner.endpoint.message.api.OfficialNoticeClientApi;
import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateCustomizeCmd;
import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd;
import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum;
import com.red.circle.framework.dto.ResultResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 官方通知， 服务.
 *
 * @author pengliang on 2023/7/24
 */
@Validated
@RestController
@RequestMapping(value = OfficialNoticeClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class OfficialNoticeClientEndpoint implements OfficialNoticeClientApi {

  private final OfficialNoticeCommonService officialNoticeCommonService;

  @Override
  public ResultResponse<Void> send(NoticeExtTemplateCustomizeCmd cmd) {
    officialNoticeCommonService.send(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> send(NoticeExtTemplateTypeCmd cmd) {
    officialNoticeCommonService.send(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> send(Long toAccount, String langCode,
      OfficialNoticeTypeEnum officialNoticeTypeEnum) {
    officialNoticeCommonService.send(toAccount, langCode, officialNoticeTypeEnum);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> send(Long toAccount, OfficialNoticeTypeEnum officialNoticeTypeEnum) {
    officialNoticeCommonService.send(toAccount, null, officialNoticeTypeEnum);
    return ResultResponse.success();
  }

}
