package com.njcn.rdms.module.system.api.notify;

import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.system.api.notify.dto.NotifySingleSendReqDTO;
import com.njcn.rdms.module.system.service.notify.NotifySendService;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import static com.njcn.rdms.framework.common.pojo.CommonResult.success;

/**
 * {@link NotifyMessageSendApi} 的实现：委托现有 {@link NotifySendService}，不重写发送逻辑。
 *
 * @author hongawen
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
@Hidden
public class NotifyMessageSendApiImpl implements NotifyMessageSendApi {

    @Resource
    private NotifySendService notifySendService;

    @Override
    public CommonResult<Long> sendSingleNotify(NotifySingleSendReqDTO reqDTO) {
        Long logId = notifySendService.sendSingleNotifyToAdmin(
                reqDTO.getUserId(), reqDTO.getTemplateCode(), reqDTO.getTemplateParams());
        return success(logId);
    }

}
