package cn.ey.biz.module.weaver.api.msg;


import cn.ey.biz.module.weaver.autoconfigure.FeignConfiguration;
import cn.ey.biz.module.weaver.common.Constants;
import lombok.Data;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;

/**
 * 邮件发送
 *
 */
@FeignClient(name= Constants.WEAVER_NAME, url="${weaver.service.url}", configuration = FeignConfiguration.class)
public interface SendEmailService {

    @RequestMapping(method= RequestMethod.POST, value="/api/ey/msgcenter/sendEmail",
            consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = MediaType.APPLICATION_JSON_VALUE)
    SendEmailResponse sendEmail(@RequestBody  SendEmailRequest request);

    @Data
    class SendEmailRequest {
        String  title;        //邮件主题
        String  content;      //邮件内容
        String  sendTo;       //接收人邮件（多个用，分割）
        String  sendCc;       //抄送人邮箱（多个用，分割）
        String  code;         //code
        TemplateRequest  template;     //模板编码
        List<FilesRequest> files;        //邮件附件（见补充说明）
    }

    @Data
    class TemplateRequest {
        String  code;
        Map<String,String> params;
    }

    @Data
    class FilesRequest{
        String  name;   //附件名称2.jpg",
        String  data;   //"base64:xxxx"
    }

    @Data
    class SendEmailResponse{
        Boolean api_status;
        String api_msg;
    }

}
