Commit bb366d4d by yao.xiao

增加-经纪人申请专家支持,发送邮件

parent b5d62d86
...@@ -160,6 +160,29 @@ ...@@ -160,6 +160,29 @@
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-test</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<!-- <version>1.5.3</version> -->
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dm</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -472,4 +472,18 @@ public class PractitionerController { ...@@ -472,4 +472,18 @@ public class PractitionerController {
result.addResult(responseVO); result.addResult(responseVO);
return result; return result;
} }
/**
* 申请专家支持
* @param requestVO 请求信息
* @return 返回信息
*/
@PostMapping(value = "/applyForExpertSupport")
public Object applyForExpertSupport(@RequestBody ApplyForExpertSupportRequestVO requestVO){
JsonResult result = new JsonResult();
ApplyForExpertSupportResponseVO responseVO = practitionerService.applyForExpertSupport(requestVO);
result.setData(responseVO);
result.addResult(responseVO);
return result;
}
} }
package com.yd.api.practitioner.service; package com.yd.api.practitioner.service;
import com.yd.api.practitioner.vo.opportunity.ApplyForExpertSupportRequestVO;
import com.yd.api.practitioner.vo.opportunity.ApplyForExpertSupportResponseVO;
import com.yd.api.practitioner.vo.payscale.PayScalePdfRequestVO; import com.yd.api.practitioner.vo.payscale.PayScalePdfRequestVO;
import com.yd.api.practitioner.vo.payscale.PayScalePdfResponseVO; import com.yd.api.practitioner.vo.payscale.PayScalePdfResponseVO;
import com.yd.api.practitioner.vo.payscale.PayScaleQueryRequestVO; import com.yd.api.practitioner.vo.payscale.PayScaleQueryRequestVO;
...@@ -39,4 +41,5 @@ public interface PractitionerBasicInfoService { ...@@ -39,4 +41,5 @@ public interface PractitionerBasicInfoService {
* @return 响应信息 * @return 响应信息
*/ */
PayScalePdfResponseVO payScalePdf(PayScalePdfRequestVO requestVO); PayScalePdfResponseVO payScalePdf(PayScalePdfRequestVO requestVO);
} }
...@@ -209,4 +209,11 @@ public interface PractitionerService { ...@@ -209,4 +209,11 @@ public interface PractitionerService {
* @return 响应数据 * @return 响应数据
*/ */
SalesScoreDetailQueryResponseVO salesScoreDetailQuery(SalesScoreDetailQueryRequestVO requestVO); SalesScoreDetailQueryResponseVO salesScoreDetailQuery(SalesScoreDetailQueryRequestVO requestVO);
/**
* 申请专家支持
* @param requestVO 请求信息
* @return 响应信息
*/
ApplyForExpertSupportResponseVO applyForExpertSupport(ApplyForExpertSupportRequestVO requestVO);
} }
package com.yd.api.practitioner.service.impl; package com.yd.api.practitioner.service.impl;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.yd.api.practitioner.vo.opportunity.ApplyForExpertSupportRequestVO;
import com.yd.api.practitioner.vo.opportunity.ApplyForExpertSupportResponseVO;
import com.yd.api.practitioner.vo.payscale.PayScalePdfRequestVO; import com.yd.api.practitioner.vo.payscale.PayScalePdfRequestVO;
import com.yd.api.practitioner.service.PractitionerBasicInfoService; import com.yd.api.practitioner.service.PractitionerBasicInfoService;
import com.yd.api.practitioner.vo.payscale.PayScaleInfo; import com.yd.api.practitioner.vo.payscale.PayScaleInfo;
......
...@@ -48,6 +48,7 @@ import com.yd.dal.service.user.AclUserDALService; ...@@ -48,6 +48,7 @@ import com.yd.dal.service.user.AclUserDALService;
import com.yd.dal.entity.customer.practitioner.*; import com.yd.dal.entity.customer.practitioner.*;
import com.yd.dal.service.meta.MdCodeDALService; import com.yd.dal.service.meta.MdCodeDALService;
import com.yd.dal.service.meta.MdDropOptionsDALService; import com.yd.dal.service.meta.MdDropOptionsDALService;
import com.yd.rmi.ali.mail.service.MailService;
import com.yd.rmi.ali.oss.service.OssService; import com.yd.rmi.ali.oss.service.OssService;
import com.yd.rmi.cache.SystemConfigService; import com.yd.rmi.cache.SystemConfigService;
import com.yd.rmi.tencent.wechat.service.WechatService; import com.yd.rmi.tencent.wechat.service.WechatService;
...@@ -151,6 +152,10 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -151,6 +152,10 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
private MdGoalsCalculateExpressionDALService mdGoalsCalculateExpressionDALService; private MdGoalsCalculateExpressionDALService mdGoalsCalculateExpressionDALService;
@Autowired @Autowired
private AclPractitionerPotentialGoalsActionsDALService aclPractitionerPotentialGoalsActionsDALService; private AclPractitionerPotentialGoalsActionsDALService aclPractitionerPotentialGoalsActionsDALService;
@Autowired
private MktLeadsExpertRequestDALService mktLeadsExpertRequestDALService;
@Autowired
private MailService mailService;
@Override @Override
public PractitionerLoginResponseVO practitionerLogin(PractitionerLoginRequestVO requestVO) { public PractitionerLoginResponseVO practitionerLogin(PractitionerLoginRequestVO requestVO) {
...@@ -2978,4 +2983,35 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -2978,4 +2983,35 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
List<AclFileUpload> aclFileUploadList = aclFileUploadDALService.findByAclFileUpload(aclFileUpload); List<AclFileUpload> aclFileUploadList = aclFileUploadDALService.findByAclFileUpload(aclFileUpload);
return aclFileUploadList.size()+1; return aclFileUploadList.size()+1;
} }
@Override
public ApplyForExpertSupportResponseVO applyForExpertSupport(ApplyForExpertSupportRequestVO requestVO) {
ApplyForExpertSupportResponseVO resp = new ApplyForExpertSupportResponseVO();
//申请专家支持
//保存ag_mkt_leads_expert_request
MktLeadsExpertRequest mktLeadsExpertRequest = new MktLeadsExpertRequest();
mktLeadsExpertRequest.setLeadsAssignedId(requestVO.getLeadsAssignedId());
mktLeadsExpertRequest.setIsActive(1);
mktLeadsExpertRequest.setCreatedAt(new Date());
mktLeadsExpertRequest.setUpdatedAt(new Date());
mktLeadsExpertRequest.setCreatedBy(requestVO.getPractitionerId());
mktLeadsExpertRequest.setUpdatedBy(requestVO.getPractitionerId());
mktLeadsExpertRequestDALService.save(mktLeadsExpertRequest);
//发邮件
//发送邮件给客服,同步跟进
String toAddress = systemConfigService.getSingleConfigValue("CommentNotifyToAddress");
List<String> ccList = systemConfigService.getListConfigValue("CommentNotifyCCAddresses");
String[] ccAddresses = new String[ccList.size()];
ccList.toArray(ccAddresses);
String subject = "申请专家支持";
String messageText = "尊敬的管理员,您好!";
messageText += "申请专家支持";
mailService.sysNotify(toAddress,ccAddresses,subject,messageText);
resp.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000")));
return resp;
}
} }
package com.yd.api.practitioner.vo.opportunity;
import lombok.Data;
@Data
public class ApplyForExpertSupportRequestVO {
/**
* 商机指派id
*/
private Long leadsAssignedId;
/**
* 申请经纪人id
*/
private Long practitionerId;
}
package com.yd.api.practitioner.vo.opportunity;
import com.yd.api.result.CommonResult;
import lombok.Data;
@Data
public class ApplyForExpertSupportResponseVO {
private CommonResult commonResult;
}
package com.yd.dal.entity.marketing;
import java.util.Date;
import lombok.Data;
/**
* 指派专家给经纪人辅助开发商机
*/
@Data
public class MktLeadsExpertAssign {
/**
* serial id
*/
private Long id;
/**
* FK ag_mkt_leads_expert_request.id 专家申请表id
*/
private Long leadsExpertRequestId;
/**
* 经纪人id(专家)
*/
private Long expertPractitionerId;
/**
* 0=No, 1=Yes
*/
private Integer isActive;
/**
* 分析建置时间
*/
private Date createdAt;
/**
* 建置者 FK ag_acl_user.id
*/
private Long createdBy;
/**
* 更新时间
*/
private Date updatedAt;
/**
* 更新者 FK ag_acl_user.id
*/
private Long updatedBy;
}
\ No newline at end of file
package com.yd.dal.entity.marketing;
import java.util.Date;
import lombok.Data;
/**
* 经纪人申请专家辅助开发商机
*/
@Data
public class MktLeadsExpertRequest {
/**
* serial id
*/
private Long id;
/**
* FK ag_mkt_leads_assigneds.id 商机指派表id
*/
private Long leadsAssignedId;
/**
* 0=No, 1=Yes
*/
private Integer isActive;
/**
* 分析建置时间
*/
private Date createdAt;
/**
* 建置者 FK ag_acl_user.id
*/
private Long createdBy;
/**
* 更新时间
*/
private Date updatedAt;
/**
* 更新者 FK ag_acl_user.id
*/
private Long updatedBy;
}
\ No newline at end of file
package com.yd.dal.mapper.marketing;
import com.yd.dal.entity.marketing.MktLeadsExpertAssign;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface MktLeadsExpertAssignMapper {
int deleteByPrimaryKey(Long id);
int insert(MktLeadsExpertAssign record);
int insertSelective(MktLeadsExpertAssign record);
MktLeadsExpertAssign selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(MktLeadsExpertAssign record);
int updateByPrimaryKey(MktLeadsExpertAssign record);
int updateBatch(List<MktLeadsExpertAssign> list);
int updateBatchSelective(List<MktLeadsExpertAssign> list);
int batchInsert(@Param("list") List<MktLeadsExpertAssign> list);
}
\ No newline at end of file
package com.yd.dal.mapper.marketing;
import com.yd.dal.entity.marketing.MktLeadsExpertRequest;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface MktLeadsExpertRequestMapper {
int deleteByPrimaryKey(Long id);
int insert(MktLeadsExpertRequest record);
int insertSelective(MktLeadsExpertRequest record);
MktLeadsExpertRequest selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(MktLeadsExpertRequest record);
int updateByPrimaryKey(MktLeadsExpertRequest record);
int updateBatch(List<MktLeadsExpertRequest> list);
int updateBatchSelective(List<MktLeadsExpertRequest> list);
int batchInsert(@Param("list") List<MktLeadsExpertRequest> list);
}
\ No newline at end of file
package com.yd.dal.service.marketing.Impl;
import com.yd.dal.entity.marketing.MktLeadsExpertRequest;
import com.yd.dal.mapper.marketing.MktLeadsExpertRequestMapper;
import com.yd.dal.service.marketing.MktLeadsExpertRequestDALService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service("mktLeadsExpertRequestDALService")
public class MktLeadsExpertRequestDALServiceImpl implements MktLeadsExpertRequestDALService {
@Resource
private MktLeadsExpertRequestMapper mktLeadsExpertRequestMapper;
@Override
public int save(MktLeadsExpertRequest mktLeadsExpertRequest) {
return mktLeadsExpertRequestMapper.insert(mktLeadsExpertRequest);
}
}
package com.yd.dal.service.marketing;
import com.yd.dal.entity.marketing.MktLeadsExpertRequest;
public interface MktLeadsExpertRequestDALService {
int save(MktLeadsExpertRequest mktLeadsExpertRequest);
}
package com.yd.rmi.ali.mail.service;
import com.yd.rmi.ali.mail.vo.SendMailRequestVO;
public interface MailService {
public void sendMail(SendMailRequestVO sendMailRequestVO);
public void sysWarning(String warningSubject,String warningMessage);
public void sysNotify(String toAddress,String[] ccAddress,String notifySubject,String notifyMessage);
public void sysException(String warningSubject,String warningMessage);
}
package com.yd.rmi.ali.mail.service.impl;
import com.yd.rmi.ali.mail.service.MailService;
import com.yd.rmi.ali.mail.vo.SendMailRequestVO;
import com.yd.rmi.ali.mailinterf.service.AliMailInterfService;
import com.yd.rmi.cache.SystemConfigService;
import com.yd.util.CommonUtil;
import com.yd.util.SpringContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("mailService")
public class MailServiceImpl implements MailService {
@Autowired
private AliMailInterfService aliMailInterfService;
@Autowired
private SystemConfigService systemConfigService;
@Override
public void sendMail(SendMailRequestVO sendMailRequestVO) {
String sendType = sendMailRequestVO.getSendType();
String toAddress = sendMailRequestVO.getToAddress();
String[] ccAddresses = sendMailRequestVO.getCcAddresses();
String subject = sendMailRequestVO.getSubject();
String messageHtml = sendMailRequestVO.getMessageHtml();
String messageText = sendMailRequestVO.getMessageText();
String templateName = sendMailRequestVO.getTemplateName();
String receiversName = sendMailRequestVO.getReceiversName();
List<String> attachmentFiles = sendMailRequestVO.getAttachmentFiles();
String imageFile = sendMailRequestVO.getImageFile();
try {
if("1".equals(sendType)){
aliMailInterfService.singleSend(toAddress, subject, messageHtml, messageText);
}else if("2".equals(sendType)){
aliMailInterfService.batchSend(templateName, receiversName);
}else if("3".equals(sendType)){
aliMailInterfService.smtpSend(toAddress,ccAddresses, subject, messageText, attachmentFiles, imageFile);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void sysWarning(String warningSubject,String warningMessage) {
String toAddress = "simon.cheng@ydinsurance.cn";
List<String> ccList = systemConfigService.getListConfigValue("SysWarningCCAddress");
String[] ccAddresses = new String[ccList.size()];
ccList.toArray(ccAddresses);
// String[] ccAddress = new String[]{"water.wang@autogeneral.cn","sweet.zhang@autogeneral.cn","jerold.chen@autogeneral.cn"};
String subject = "【"+ SpringContextUtil.getEnvironmentName()+"环境】"+warningSubject;
String messageText = CommonUtil.currentIP()+" "+warningMessage;
String imageFile = null;
try {
aliMailInterfService.smtpSend(toAddress, ccAddresses,subject, messageText, null, imageFile);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void sysNotify(String toAddress, String[] ccAddress, String notifySubject, String notifyMessage) {
try {
aliMailInterfService.smtpSend(toAddress, ccAddress, notifySubject, notifyMessage, null, null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void sysException(String warningSubject, String warningMessage) {
// if("prod".equals(SpringContextUtil.getActiveProfile())){
String toAddress = "water.wang@ydinsurance.cn";//"simon.cheng@autogeneral.cn";
List<String> ccList = systemConfigService.getListConfigValue("SysWarningCCAddress");
String[] ccAddresses = new String[ccList.size()];
ccList.toArray(ccAddresses);
// String[] ccAddress = new String[]{"water.wang@autogeneral.cn","sweet.zhang@autogeneral.cn","jerold.chen@autogeneral.cn"};
String subject = "【"+SpringContextUtil.getEnvironmentName()+"环境】"+warningSubject;
String messageText = CommonUtil.currentIP()+" "+warningMessage;
String imageFile = null;
try {
aliMailInterfService.smtpSend(toAddress, ccAddresses,subject, messageText, null, imageFile);
} catch (Exception e) {
e.printStackTrace();
}
// }
}
}
package com.yd.rmi.ali.mail.vo;
import java.util.List;
public class SendMailRequestVO {
private String toAddress;//收件人邮箱
private String[] ccAddresses;//抄送人邮箱
private String subject;//邮件标题
private String messageText;//邮件TEXT正文
private String messageHtml;//邮件HTML正文
private List<String> attachmentFiles;//邮件附件
private String imageFile;//邮件图片
private String templateName;//模板名称,阿里云配置
private String receiversName;//收件人列表,阿里云配置
private String sendType;//发送类型: 1 single ; 2 batch ; 3 smpt
public String getToAddress() {
return toAddress;
}
public void setToAddress(String toAddress) {
this.toAddress = toAddress;
}
public String[] getCcAddresses() {
return ccAddresses;
}
public void setCcAddresses(String[] ccAddresses) {
this.ccAddresses = ccAddresses;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getMessageText() {
return messageText;
}
public void setMessageText(String messageText) {
this.messageText = messageText;
}
public String getMessageHtml() {
return messageHtml;
}
public void setMessageHtml(String messageHtml) {
this.messageHtml = messageHtml;
}
public String getImageFile() {
return imageFile;
}
public void setImageFile(String imageFile) {
this.imageFile = imageFile;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public String getReceiversName() {
return receiversName;
}
public void setReceiversName(String receiversName) {
this.receiversName = receiversName;
}
public String getSendType() {
return sendType;
}
public void setSendType(String sendType) {
this.sendType = sendType;
}
public List<String> getAttachmentFiles() {
return attachmentFiles;
}
public void setAttachmentFiles(List<String> attachmentFiles) {
this.attachmentFiles = attachmentFiles;
}
}
\ No newline at end of file
package com.yd.rmi.ali.mailinterf.service;
import java.io.UnsupportedEncodingException;
import java.util.List;
public interface AliMailInterfService {
/**
* 单封邮件发送
* @param toAddress
* @param subject
* @param messageHtml
* @param messageText
*/
public void singleSend(String toAddress,
String subject,
String messageHtml,
String messageText);
/**
* 批量邮件发送
* @param templateName 邮件模板:"成功投保模板"
* @param receiversName 收件人列表:"测试控制台发邮件"
*/
public void batchSend(String templateName,String receiversName);
/**
* SMTP邮件发送
* @param toAddress 收件人地址
* @param ccAddresses 抄送人地址数组
* @param subject 邮件标题
* @param messageText 邮件正文文本
* @param attachmentFiles 附件路径
* @param imageFile 图片路径
*/
public void smtpSend(String toAddress,
String[] ccAddresses,
String subject,
String messageText,
List<String> attachmentFiles,
String imageFile) throws UnsupportedEncodingException, Exception;
}
package com.yd.rmi.ali.mailinterf.service.impl;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dm.model.v20151123.BatchSendMailRequest;
import com.aliyuncs.dm.model.v20151123.BatchSendMailResponse;
import com.aliyuncs.dm.model.v20151123.SingleSendMailRequest;
import com.aliyuncs.dm.model.v20151123.SingleSendMailResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.yd.rmi.ali.mailinterf.service.AliMailInterfService;
import com.yd.rmi.cache.SystemConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.*;
import javax.mail.Message.RecipientType;
import javax.mail.internet.*;
import java.util.Calendar;
import java.util.List;
import java.util.Properties;
@Service("aliMailInterfService")
public class AliMailInterfServiceImpl implements AliMailInterfService {
@Autowired
private SystemConfigService systemConfigService;
// private String REGION_ID = systemConfigService.getSingleConfigValue("ALI_MAIL_REGION_ID");//"cn-hangzhou";
// private String ACCESS_KEY_ID = systemConfigService.getSingleConfigValue("ALI_MAIL_ACCESS_KEY_ID");//"LTAI74cjt1JCZnYd";
// private String ACCESS_KEY_SECRET = systemConfigService.getSingleConfigValue("ALI_MAIL_ACCESS_KEY_SECRET");// "4PhQIwcVkqN0JhN3GGPo4EhBncLCLw";
// private String TAG_NAME = systemConfigService.getSingleConfigValue("ALI_MAIL_TAG_NAME");//"CompareTheMarket";//邮件标签
// private String CLICK_TRACE = systemConfigService.getSingleConfigValue("ALI_MAIL_CLICK_TRACE");//"1";
// private String ALIDM_SMTP_HOST = systemConfigService.getSingleConfigValue("ALI_MAIL_ALIDM_SMTP_HOST");//"smtpdm.aliyun.com";//"smtpdm.aliyun.com" "smtp.163.com"
// private int ALIDM_SMTP_PORT = Integer.parseInt(systemConfigService.getSingleConfigValue("ALI_MAIL_ALIDM_SMTP_PORT"));//25;
// private String ACCOUNT_NAME = systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NAME");//"service@mail.zuihuibijia.com";
// private String ACCOUNT_NICK_NAME = systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NICK_NAME");//"安吉保(上海)企业管理咨询有限公司";
// private String ACCOUNT_PASSWORD = systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_PASSWORD");//"12345abcBE";
// private String TO_NICK_NAME = systemConfigService.getSingleConfigValue("ALI_MAIL_TO_NICK_NAME");//"尊敬的客户";//收件人昵称
// private String REPLY_ADDRESS = systemConfigService.getSingleConfigValue("ALI_MAIL_REPLY_ADDRESS");//"tiger.zheng@autogeneral.cn";//回复地址
// private String REPLY_NICK_NAME = systemConfigService.getSingleConfigValue("ALI_MAIL_REPLY_NICK_NAME");//"安吉保客服中心";//
/**
* 单封邮件发送
* @param toAddress
* @param subject
* @param messageHtml
* @param messageText
*/
@Override
public void singleSend(String toAddress,String subject,String messageHtml,String messageText) {
IClientProfile profile = DefaultProfile.getProfile(systemConfigService.getSingleConfigValue("ALI_MAIL_REGION_ID"), systemConfigService.getSingleConfigValue("ALI_MAIL_ACCESS_KEY_ID"), systemConfigService.getSingleConfigValue("ALI_MAIL_ACCESS_KEY_SECRET"));
IAcsClient client = new DefaultAcsClient(profile);
SingleSendMailRequest request = new SingleSendMailRequest();
try {
/** 去除Action外还有9个入参 **/
request.setAccountName(systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NAME"));
request.setReplyToAddress(true);//是否使用管理控制台中配置的回信地址(状态必须是验证通过)
request.setAddressType(1);//取值范围0~1: 0为随机账号;1为发信地址
request.setToAddress(toAddress);//目标地址,多个Email地址可以逗号分隔,最多100个地址。
request.setFromAlias(systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NICK_NAME"));//发信人昵称,长度小于15个字符 例如:发信人昵称设置为”小红”,发信地址为”test@example.com”,收信人看到的发信地址为"小红"<test@example.com>
request.setSubject(subject);//邮件主题,建议填写
request.setHtmlBody(messageHtml);//邮件html正文
request.setTextBody(messageText);//邮件text正文
request.setClickTrace(systemConfigService.getSingleConfigValue("ALI_MAIL_CLICK_TRACE"));//取值范围0~1: 1为打开数据跟踪功能; 0为关闭数据跟踪功能;该参数默认值为0。
/** 下面这个不属于入参,也不属于公共参数 **/
request.setTagName(systemConfigService.getSingleConfigValue("ALI_MAIL_TAG_NAME"));
SingleSendMailResponse httpResponse = client.getAcsResponse(request);
System.out.println("httpResponse.getEnvId() = "+httpResponse.getEnvId());
}catch (ServerException e) {
e.printStackTrace();
}catch (ClientException e) {
e.printStackTrace();
}
}
/**
* 批量邮件发送
* @param templateName 邮件模板:"成功投保模板"
* @param receiversName 收件人列表:"测试控制台发邮件"
*/
@Override
public void batchSend(String templateName,String receiversName) {
IClientProfile profile = DefaultProfile.getProfile(systemConfigService.getSingleConfigValue("ALI_MAIL_REGION_ID"), systemConfigService.getSingleConfigValue("ALI_MAIL_ACCESS_KEY_ID"), systemConfigService.getSingleConfigValue("ALI_MAIL_ACCESS_KEY_SECRET"));
IAcsClient client = new DefaultAcsClient(profile);
BatchSendMailRequest request = new BatchSendMailRequest();
try {
/** 除Action外,共有6个入参,如下 **/
request.setAccountName(systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NAME"));
request.setAddressType(1);//取值范围0~1: 0为随机账号;1为发信地址
request.setTemplateName(templateName);//预先创建且通过审核的模板名称
request.setReceiversName(receiversName);//预先创建且上传了收件人的收件人列表名称
request.setTagName(systemConfigService.getSingleConfigValue("ALI_MAIL_TAG_NAME"));//邮件标签名称
request.setClickTrace(systemConfigService.getSingleConfigValue("ALI_MAIL_CLICK_TRACE"));//取值范围0~1: 1为打开数据跟踪功能; 0为关闭数据跟踪功能;该参数默认值为0。
BatchSendMailResponse httpResponse = client.getAcsResponse(request);
System.out.println("httpResponse.getEnvId() = "+httpResponse.getEnvId());
httpResponse.getRequestId();
}catch (ServerException e) {
e.printStackTrace();
}catch(ClientException e) {
e.printStackTrace();
}
}
/**
* SMTP邮件发送
* @param toAddress 收件人地址
* @param ccAddresses 抄送人地址数组
* @param subject 邮件标题
* @param messageText 邮件正文文本
* @param attachmentFiles 附件路径
* @param imageFile 图片路径
*/
@Override
public void smtpSend(String toAddress,
String[] ccAddresses,
String subject,
String messageText,
List<String> attachmentFiles,
String imageFile) throws Exception {
String messageStyle = "1";//邮件类型 1、纯文本邮件;2、带附件邮件;3、正文带图片,带附件邮件
if((attachmentFiles != null) && (imageFile == null || "".equals(imageFile))){
messageStyle = "2";
}
if((attachmentFiles != null) && (imageFile != null && !"".equals(imageFile))){
messageStyle = "3";
}
/********** 第一步:配置javax.mail.Session对象 **********/
System.out.println("为" + systemConfigService.getSingleConfigValue("ALI_MAIL_ALIDM_SMTP_HOST") + "配置mail session对象");
Properties props = new Properties();
props.put("mail.smtp.auth", "true"); //使用验证
props.put("mail.smtp.host", systemConfigService.getSingleConfigValue("ALI_MAIL_ALIDM_SMTP_HOST"));
props.put("mail.smtp.port", Integer.parseInt(systemConfigService.getSingleConfigValue("ALI_MAIL_ALIDM_SMTP_PORT"))); //google使用465或587端口
props.put("mail.transport.protocol","smtp");
props.put("mail.smtp.starttls.enable", "true");//使用 STARTTLS安全连接
props.put("mail.debug", "true");
Session mailSession = Session.getInstance(props, new AJBAuthenticator(systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NAME"), systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_PASSWORD")));//Default
/********** 第二步:编写消息 **********/
System.out.println("编写消息from—>to: " + systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NAME") + " —> " + toAddress);
MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress(systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NAME"),systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NICK_NAME"), "UTF-8"));//发件人
message.addRecipient(RecipientType.TO, new InternetAddress(toAddress, systemConfigService.getSingleConfigValue("ALI_MAIL_TO_NICK_NAME"), "UTF-8"));//收件人
if(ccAddresses != null && ccAddresses.length >0){
for(int i=0;i<ccAddresses.length;i++){
message.addRecipient(RecipientType.CC, new InternetAddress(ccAddresses[i], systemConfigService.getSingleConfigValue("ALI_MAIL_TO_NICK_NAME"), "UTF-8"));//收件人
}
}
message.setSentDate(Calendar.getInstance().getTime());//发送时间
message.setSubject(subject,"UTF-8");//标题
message.setReplyTo(InternetAddress.parse("\"" + MimeUtility.encodeText(systemConfigService.getSingleConfigValue("ALI_MAIL_REPLY_NICK_NAME")) + "\" <"+systemConfigService.getSingleConfigValue("ALI_MAIL_REPLY_ADDRESS")+">"));//设置回复人(收件人回复此邮件时,默认收件人)
/** 2.1纯文本邮件 **/
if("1".equals(messageStyle)){
message.setContent(messageText, "text/html;charset=UTF-8");
}
/** 2.2带附件的邮件 **/
if("2".equals(messageStyle)){
Multipart content = new MimeMultipart();
BodyPart textBody = new MimeBodyPart();
textBody.setText(messageText);
content.addBodyPart(textBody);
for (String attachmentFile : attachmentFiles){
BodyPart attachmentBody = new MimeBodyPart();
DataHandler dh = new DataHandler(new FileDataSource(attachmentFile));//读取本地文件
attachmentBody.setDataHandler(dh);//将附件数据添加到“节点”
attachmentBody.setFileName(MimeUtility.encodeText(dh.getName()));//设置附件的文件名(需要编码)
content.addBodyPart(attachmentBody);
}
message.setContent(content);
}
/**2.3正文带图片,带附件的邮件 **/
if("3".equals(messageStyle)){
MimeBodyPart imageBody = new MimeBodyPart();//1.创建图片“节点”
DataHandler dh = new DataHandler(new FileDataSource(imageFile));//读取本地文件
imageBody.setDataHandler(dh);//将图片数据添加到“节点”
imageBody.setContentID("image_fairy_tail");//为“节点”设置一个唯一编号(在文本“节点”将引用该ID)
BodyPart textBody = new MimeBodyPart();//2.创建文本“节点”
textBody.setContent(messageText+"<br/><img src='cid:image_fairy_tail'/>", "text/html;charset=UTF-8");// 这里添加图片的方式是将整个图片包含到邮件内容中, 实际上也可以以 http 链接的形式添加网络图片
MimeMultipart subContent = new MimeMultipart();//3.(文本+图片)设置 文本 和 图片 “节点”的关系(将 文本 和 图片 “节点”合成一个混合“节点”)
subContent.addBodyPart(textBody);
subContent.addBodyPart(imageBody);
subContent.setSubType("related");// 关联关系
BodyPart textImageBody = new MimeBodyPart();//4.将 文本+图片 的混合“节点”封装成一个普通“节点”,最终添加到邮件的 Content 是由多个 BodyPart 组成的 Multipart, 所以我们需要的是 BodyPart,上面的 mm_text_image 并非 BodyPart, 所有要把 mm_text_image 封装成一个 BodyPart
textImageBody.setContent(subContent);
MimeMultipart content = new MimeMultipart();//6.设置(文本+图片)和 附件 的关系(合成一个大的混合“节点” / Multipart )
for (String attachmentFile : attachmentFiles){
BodyPart attachmentBody = new MimeBodyPart();
DataHandler dh2 = new DataHandler(new FileDataSource(attachmentFile));//读取本地文件
attachmentBody.setDataHandler(dh2);//将附件数据添加到“节点”
attachmentBody.setFileName(MimeUtility.encodeText(dh2.getName()));//设置附件的文件名(需要编码)
content.addBodyPart(attachmentBody);
}
content.addBodyPart(textImageBody);
content.setSubType("mixed");//混合关系
message.setContent(content);//7.设置整个邮件的关系(将最终的混合“节点”作为邮件的内容添加到邮件对象)
}
/********** 第三步:发送消息 **********/
message.saveChanges();//保存邮件
Transport transport = mailSession.getTransport("smtp");
transport.connect(systemConfigService.getSingleConfigValue("ALI_MAIL_ALIDM_SMTP_HOST"), systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_NAME"), systemConfigService.getSingleConfigValue("ALI_MAIL_ACCOUNT_PASSWORD"));
Transport.send(message, message.getAllRecipients());
transport.close();
System.out.println("message yes");
}
public static void main(String[] args){
AliMailInterfServiceImpl service = new AliMailInterfServiceImpl();
String toAddress = "water.wang@autogeneral.cn";
String[] ccAddresses = new String[]{"water.wang@autogeneral.cn","1034346366@qq.com"};
String subject = "您已成功通过安吉保购买保险产品";
String messageText = ""
+"尊敬的XX,您好!"
+"<br>恭喜您,您已成功通过安吉保购买了史带财产保险股份有限公司的 爱自由-境内旅行保障计划 - 计划A ,保单号 AABA000000W2017E00000029 ,保险期限:2017-06-22 00:00:00 至 2017-07-02 23:59:59 。"
+"<br>您可以访问http://policy.starrchina.cn/进行保单验真、查询详细保单条款。"
+"<br>您也可以关注 \"最会比价\"官方微信获取其他优质增值服务!"
+"<br>全国客服热线电话:40099 95507。"
+"<br>祝您万事如意!";
List<String> attachmentFiles = null;
String imageFile = null;
try {
service.smtpSend(toAddress, ccAddresses,subject, messageText, attachmentFiles, imageFile);
} catch (Exception e) {
e.printStackTrace();
}
}
}
class AJBAuthenticator extends Authenticator {
String userName = "";
String password = "";
public AJBAuthenticator() {}
public AJBAuthenticator(String userName, String password) {
this.userName = userName;
this.password = password;
}
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yd.dal.mapper.marketing.MktLeadsExpertAssignMapper">
<resultMap id="BaseResultMap" type="com.yd.dal.entity.marketing.MktLeadsExpertAssign">
<!--@mbg.generated-->
<!--@Table ag_mkt_leads_expert_assign-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="leads_expert_request_id" jdbcType="BIGINT" property="leadsExpertRequestId" />
<result column="expert_practitioner_id" jdbcType="BIGINT" property="expertPractitionerId" />
<result column="is_active" jdbcType="INTEGER" property="isActive" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="BIGINT" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, leads_expert_request_id, expert_practitioner_id, is_active, created_at, created_by,
updated_at, updated_by
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from ag_mkt_leads_expert_assign
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--@mbg.generated-->
delete from ag_mkt_leads_expert_assign
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsExpertAssign" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into ag_mkt_leads_expert_assign (leads_expert_request_id, expert_practitioner_id,
is_active, created_at, created_by,
updated_at, updated_by)
values (#{leadsExpertRequestId,jdbcType=BIGINT}, #{expertPractitionerId,jdbcType=BIGINT},
#{isActive,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT},
#{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsExpertAssign" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into ag_mkt_leads_expert_assign
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="leadsExpertRequestId != null">
leads_expert_request_id,
</if>
<if test="expertPractitionerId != null">
expert_practitioner_id,
</if>
<if test="isActive != null">
is_active,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="leadsExpertRequestId != null">
#{leadsExpertRequestId,jdbcType=BIGINT},
</if>
<if test="expertPractitionerId != null">
#{expertPractitionerId,jdbcType=BIGINT},
</if>
<if test="isActive != null">
#{isActive,jdbcType=INTEGER},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=BIGINT},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=BIGINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.marketing.MktLeadsExpertAssign">
<!--@mbg.generated-->
update ag_mkt_leads_expert_assign
<set>
<if test="leadsExpertRequestId != null">
leads_expert_request_id = #{leadsExpertRequestId,jdbcType=BIGINT},
</if>
<if test="expertPractitionerId != null">
expert_practitioner_id = #{expertPractitionerId,jdbcType=BIGINT},
</if>
<if test="isActive != null">
is_active = #{isActive,jdbcType=INTEGER},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=BIGINT},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.marketing.MktLeadsExpertAssign">
<!--@mbg.generated-->
update ag_mkt_leads_expert_assign
set leads_expert_request_id = #{leadsExpertRequestId,jdbcType=BIGINT},
expert_practitioner_id = #{expertPractitionerId,jdbcType=BIGINT},
is_active = #{isActive,jdbcType=INTEGER},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update ag_mkt_leads_expert_assign
<trim prefix="set" suffixOverrides=",">
<trim prefix="leads_expert_request_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.leadsExpertRequestId,jdbcType=BIGINT}
</foreach>
</trim>
<trim prefix="expert_practitioner_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.expertPractitionerId,jdbcType=BIGINT}
</foreach>
</trim>
<trim prefix="is_active = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.isActive,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="created_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix="created_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
</foreach>
</trim>
<trim prefix="updated_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix="updated_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<update id="updateBatchSelective" parameterType="java.util.List">
<!--@mbg.generated-->
update ag_mkt_leads_expert_assign
<trim prefix="set" suffixOverrides=",">
<trim prefix="leads_expert_request_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.leadsExpertRequestId != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.leadsExpertRequestId,jdbcType=BIGINT}
</if>
</foreach>
</trim>
<trim prefix="expert_practitioner_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.expertPractitionerId != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.expertPractitionerId,jdbcType=BIGINT}
</if>
</foreach>
</trim>
<trim prefix="is_active = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.isActive != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.isActive,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="created_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.createdAt != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
<trim prefix="created_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.createdBy != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
</if>
</foreach>
</trim>
<trim prefix="updated_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.updatedAt != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
<trim prefix="updated_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.updatedBy != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into ag_mkt_leads_expert_assign
(leads_expert_request_id, expert_practitioner_id, is_active, created_at, created_by,
updated_at, updated_by)
values
<foreach collection="list" item="item" separator=",">
(#{item.leadsExpertRequestId,jdbcType=BIGINT}, #{item.expertPractitionerId,jdbcType=BIGINT},
#{item.isActive,jdbcType=INTEGER}, #{item.createdAt,jdbcType=TIMESTAMP}, #{item.createdBy,jdbcType=BIGINT},
#{item.updatedAt,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=BIGINT})
</foreach>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yd.dal.mapper.marketing.MktLeadsExpertRequestMapper">
<resultMap id="BaseResultMap" type="com.yd.dal.entity.marketing.MktLeadsExpertRequest">
<!--@mbg.generated-->
<!--@Table ag_mkt_leads_expert_request-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="leads_assigned_id" jdbcType="BIGINT" property="leadsAssignedId" />
<result column="is_active" jdbcType="INTEGER" property="isActive" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="BIGINT" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, leads_assigned_id, is_active, created_at, created_by, updated_at, updated_by
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from ag_mkt_leads_expert_request
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--@mbg.generated-->
delete from ag_mkt_leads_expert_request
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsExpertRequest" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into ag_mkt_leads_expert_request (leads_assigned_id, is_active, created_at,
created_by, updated_at, updated_by
)
values (#{leadsAssignedId,jdbcType=BIGINT}, #{isActive,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP},
#{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsExpertRequest" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into ag_mkt_leads_expert_request
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="leadsAssignedId != null">
leads_assigned_id,
</if>
<if test="isActive != null">
is_active,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="leadsAssignedId != null">
#{leadsAssignedId,jdbcType=BIGINT},
</if>
<if test="isActive != null">
#{isActive,jdbcType=INTEGER},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=BIGINT},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=BIGINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.marketing.MktLeadsExpertRequest">
<!--@mbg.generated-->
update ag_mkt_leads_expert_request
<set>
<if test="leadsAssignedId != null">
leads_assigned_id = #{leadsAssignedId,jdbcType=BIGINT},
</if>
<if test="isActive != null">
is_active = #{isActive,jdbcType=INTEGER},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=BIGINT},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.marketing.MktLeadsExpertRequest">
<!--@mbg.generated-->
update ag_mkt_leads_expert_request
set leads_assigned_id = #{leadsAssignedId,jdbcType=BIGINT},
is_active = #{isActive,jdbcType=INTEGER},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update ag_mkt_leads_expert_request
<trim prefix="set" suffixOverrides=",">
<trim prefix="leads_assigned_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.leadsAssignedId,jdbcType=BIGINT}
</foreach>
</trim>
<trim prefix="is_active = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.isActive,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="created_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix="created_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
</foreach>
</trim>
<trim prefix="updated_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix="updated_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<update id="updateBatchSelective" parameterType="java.util.List">
<!--@mbg.generated-->
update ag_mkt_leads_expert_request
<trim prefix="set" suffixOverrides=",">
<trim prefix="leads_assigned_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.leadsAssignedId != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.leadsAssignedId,jdbcType=BIGINT}
</if>
</foreach>
</trim>
<trim prefix="is_active = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.isActive != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.isActive,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="created_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.createdAt != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
<trim prefix="created_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.createdBy != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
</if>
</foreach>
</trim>
<trim prefix="updated_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.updatedAt != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
<trim prefix="updated_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.updatedBy != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into ag_mkt_leads_expert_request
(leads_assigned_id, is_active, created_at, created_by, updated_at, updated_by)
values
<foreach collection="list" item="item" separator=",">
(#{item.leadsAssignedId,jdbcType=BIGINT}, #{item.isActive,jdbcType=INTEGER}, #{item.createdAt,jdbcType=TIMESTAMP},
#{item.createdBy,jdbcType=BIGINT}, #{item.updatedAt,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=BIGINT}
)
</foreach>
</insert>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment