package cn.iocoder.yudao.module.system.api.notify;

import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import cn.iocoder.yudao.module.system.api.wechat.dto.CorpSendMessage;
import cn.iocoder.yudao.module.system.service.notify.NotifySendService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 站内信发送 API 实现类
 *
 * @author xrcoder
 */
@Service
public class NotifyMessageSendApiImpl implements NotifyMessageSendApi {

    @Resource
    private NotifySendService notifySendService;

    @Override
    public Long sendSingleMessageToAdmin(NotifySendSingleToUserReqDTO reqDTO) {
        return notifySendService.sendSingleNotifyToAdmin(reqDTO.getUserId(),
                reqDTO.getTemplateCode(), reqDTO.getTemplateParams());
    }

    @Override
    public Long sendSingleMessageToMember(NotifySendSingleToUserReqDTO reqDTO) {
        return notifySendService.sendSingleNotifyToMember(reqDTO.getUserId(),
                reqDTO.getTemplateCode(), reqDTO.getTemplateParams());
    }

    @Override
    public Long sendSingleMessageToAdminByDTO(NotifySendSingleToUserReqDTO reqDTO) {
        return notifySendService.sendSingleNotifyToAdmin(reqDTO.getUserId(), reqDTO.getPkMessage(),
                reqDTO.getPkMessage2(), reqDTO.getGotoUrl(), reqDTO.getTemplateCode(), reqDTO.getTemplateParams(),
                reqDTO.getBusinessType(), reqDTO.getNotifyType(), reqDTO.getPriority(), reqDTO.getCompletedStatus(), reqDTO.getTenantId());
    }

    @Override
    public void updateMessageStatus(String processInstanceId, String taskId, Long userId, Integer completedStatus) {
        notifySendService.updateMessageStatus(processInstanceId, taskId, userId, completedStatus);
    }

    @Override
    public void updateSelfMessageStatus(String processInstanceId, String taskId, Long userId, Long assigneeUserId,
                                        Integer completedStatus, Integer approveMethod, Boolean startNodeFlag) {
        notifySendService.updateSelfMessageStatus(processInstanceId, taskId, userId, assigneeUserId, completedStatus, approveMethod, startNodeFlag);
    }

    @Override
    public Long sendSingleMessageToAdminByList(List<NotifySendSingleToUserReqDTO> copyNotifyList) {
        return notifySendService.sendNotifyList(copyNotifyList);
    }

    @Override
    public Long sendMessageAndCorpMessage(NotifySendSingleToUserReqDTO reqDTO, CorpSendMessage corpSendMessage) {
        return notifySendService.sendMessageAndCorpMessage(reqDTO, corpSendMessage);
    }

    @Override
    public Long sendCorpMessageList(List<CorpSendMessage> corpList, NotifySendSingleToUserReqDTO notifyDTO) {
        return notifySendService.sendCorpMessageList(corpList, notifyDTO);
    }

    @Override
    public Long sendCorpCancelMessage(CorpSendMessage corpSendMessage) {
        return notifySendService.sendCorpCancelMessage(corpSendMessage);
    }

    @Override
    public Integer updateMessageByCodeAndPkMessage(String templateCode, Long elderlyId) {
        return notifySendService.updateMessageByCodeAndPkMessage(templateCode, elderlyId == null ? null : String.valueOf(elderlyId));
    }
}
