package org.xyzh.message.service;

import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.xyzh.api.message.dto.TbMessageDTO;
import org.xyzh.api.message.service.MessageService;
import org.xyzh.api.message.vo.MessageVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.message.config.DynamicConfigLoader;
import org.xyzh.message.utils.EmailUtils;
import org.xyzh.message.utils.SmsUtils;

@DubboService(
    version = "1.0.0",
    group = "message",
    timeout = 3000,
    retries = 0
)
public class MessageServiceImpl implements MessageService{
    
    private static final Logger logger = LoggerFactory.getLogger(MessageServiceImpl.class);
    
    @Autowired
    private EmailUtils emailUtils;

    @Autowired
    private SmsUtils smsUtils;

    @Override
    public ResultDomain<String> sendSimpleEmail(String to, String subject, String content) {
        boolean flag = emailUtils.sendSimpleEmail(to, subject, content);
        if (flag){
            return ResultDomain.success("发生成功");
        }else{
            return ResultDomain.failure("发送失败");
        }
    }

    @Override
    public ResultDomain<String> sendHtmlEmail(String to, String subject, String content) {
        boolean flag = emailUtils.sendHtmlEmail(to, subject, content);
        if (flag){
            return ResultDomain.success("发生成功");
        }else{
            return ResultDomain.failure("发送失败");
        }
    }

    @Override
    public ResultDomain<String> sendEmailVerificationCode(String to, String code) {
        boolean flag = emailUtils.sendVerificationCode(to, code);
        if (flag){
            return ResultDomain.success("发生成功");
        }else{
            return ResultDomain.failure("发送失败");
        }
    }

    @Override
    public ResultDomain<String> sendPhoneVerificationCode(String phone, String code) {
        boolean flag = smsUtils.sendVerificationCode(phone, code);
        if (flag){
            return ResultDomain.success("发生成功");
        }else{
            return ResultDomain.failure("发送失败");
        }
    }

    

    @Override
    public ResultDomain<TbMessageDTO> createMessage(MessageVO messageVO) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<Boolean> deleteMessage(String messageId) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<MessageVO> getMessageDetail(String messageId) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<TbMessageDTO> getMessageList(TbMessageDTO filter) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<TbMessageDTO> getMessagePage(TbMessageDTO filter, PageParam pageParam) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<TbMessageDTO> getMyMessageDetail(String messageId) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<TbMessageDTO> getMyMessageList(TbMessageDTO filter) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<TbMessageDTO> getMyMessagePage(TbMessageDTO filter, PageParam pageParam) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<TbMessageDTO> handleMessage(String messageId, String status) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<MessageVO> sendMessage(MessageVO messageVO) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<TbMessageDTO> updateMessage(MessageVO messageVO) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDomain<TbMessageDTO> withdrawMessage(String messageId) {
        // TODO Auto-generated method stub
        return null;
    }

    

}
