新增邮件发送
This commit is contained in:
parent
a61b9d0405
commit
0c844f2892
@ -0,0 +1,96 @@
|
||||
package com.cm.manager.sms.config.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: EmailProperties
|
||||
* @Description: 邮箱
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/7/31 4:17 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "email")
|
||||
public class EmailProperties {
|
||||
|
||||
private Boolean active = false;
|
||||
private String smtp = "smtp.163.com";
|
||||
private Integer port = 25;
|
||||
private String senderEmail;
|
||||
private String senderPassword;
|
||||
private List<String> ccPersons = new ArrayList<>();
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public String getSmtp() {
|
||||
return smtp == null ? "" : smtp.trim();
|
||||
}
|
||||
|
||||
public void setSmtp(String smtp) {
|
||||
this.smtp = smtp;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getSenderEmail() {
|
||||
return senderEmail == null ? "" : senderEmail.trim();
|
||||
}
|
||||
|
||||
public void setSenderEmail(String senderEmail) {
|
||||
this.senderEmail = senderEmail;
|
||||
}
|
||||
|
||||
public String getSenderPassword() {
|
||||
return senderPassword == null ? "" : senderPassword.trim();
|
||||
}
|
||||
|
||||
public void setSenderPassword(String senderPassword) {
|
||||
this.senderPassword = senderPassword;
|
||||
}
|
||||
|
||||
public List<String> getCcPersons() {
|
||||
return ccPersons;
|
||||
}
|
||||
|
||||
public void setCcPersons(List<String> ccPersons) {
|
||||
this.ccPersons = ccPersons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"active\":")
|
||||
.append(active);
|
||||
sb.append(",\"smtp\":")
|
||||
.append("\"").append(smtp).append("\"");
|
||||
sb.append(",\"port\":")
|
||||
.append(port);
|
||||
sb.append(",\"senderEmail\":")
|
||||
.append("\"").append(senderEmail).append("\"");
|
||||
sb.append(",\"senderPassword\":")
|
||||
.append("\"").append(senderPassword).append("\"");
|
||||
sb.append(",\"ccPersons\":")
|
||||
.append(ccPersons);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.cm.manager.sms.dao.email;
|
||||
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SaveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.exception.UpdateException;
|
||||
import com.cm.manager.sms.pojo.dtos.email.EmailDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IEmailDao
|
||||
* @Description: 邮件
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/7/31 4:20 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Repository
|
||||
public interface IEmailDao {
|
||||
/**
|
||||
* 保存Email
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void saveEmail(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除Email
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void removeEmail(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 更新邮件发送状态
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateEmailSendingStatus(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* Email详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
EmailDTO getEmail(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* Email列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<EmailDTO> listEmail(Map<String, Object> params) throws SearchException;
|
||||
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package com.cm.manager.sms.pojo.dtos.email;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: EmailDTO
|
||||
* @Description: 邮箱
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/7/31 4:37 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class EmailDTO {
|
||||
|
||||
@ApiModelProperty(name = "emailId", value = "ID")
|
||||
private String emailId;
|
||||
@ApiModelProperty(name = "emailSender", value = "发送人")
|
||||
private String emailSender;
|
||||
@ApiModelProperty(name = "emailReceiver", value = "接收人")
|
||||
private String emailReceiver;
|
||||
@ApiModelProperty(name = "emailCc", value = "抄送人")
|
||||
private String emailCc;
|
||||
@ApiModelProperty(name = "emailType", value = "邮件类型")
|
||||
private String emailType;
|
||||
@ApiModelProperty(name = "emailSubject", value = "主题")
|
||||
private String emailSubject;
|
||||
@ApiModelProperty(name = "emailContent", value = "内容")
|
||||
private String emailContent;
|
||||
@ApiModelProperty(name = "sendingStatus", value = "发送状态")
|
||||
private Integer sendingStatus;
|
||||
@ApiModelProperty(name = "gmtCreate", value = "发送时间")
|
||||
private String gmtCreate;
|
||||
|
||||
public String getEmailId() {
|
||||
return emailId == null ? "" : emailId.trim();
|
||||
}
|
||||
|
||||
public void setEmailId(String emailId) {
|
||||
this.emailId = emailId;
|
||||
}
|
||||
|
||||
public String getEmailSender() {
|
||||
return emailSender == null ? "" : emailSender.trim();
|
||||
}
|
||||
|
||||
public void setEmailSender(String emailSender) {
|
||||
this.emailSender = emailSender;
|
||||
}
|
||||
|
||||
public String getEmailReceiver() {
|
||||
return emailReceiver == null ? "" : emailReceiver.trim();
|
||||
}
|
||||
|
||||
public void setEmailReceiver(String emailReceiver) {
|
||||
this.emailReceiver = emailReceiver;
|
||||
}
|
||||
|
||||
public String getEmailCc() {
|
||||
return emailCc == null ? "" : emailCc.trim();
|
||||
}
|
||||
|
||||
public void setEmailCc(String emailCc) {
|
||||
this.emailCc = emailCc;
|
||||
}
|
||||
|
||||
public String getEmailType() {
|
||||
return emailType == null ? "" : emailType.trim();
|
||||
}
|
||||
|
||||
public void setEmailType(String emailType) {
|
||||
this.emailType = emailType;
|
||||
}
|
||||
|
||||
public String getEmailSubject() {
|
||||
return emailSubject == null ? "" : emailSubject.trim();
|
||||
}
|
||||
|
||||
public void setEmailSubject(String emailSubject) {
|
||||
this.emailSubject = emailSubject;
|
||||
}
|
||||
|
||||
public String getEmailContent() {
|
||||
return emailContent == null ? "" : emailContent.trim();
|
||||
}
|
||||
|
||||
public void setEmailContent(String emailContent) {
|
||||
this.emailContent = emailContent;
|
||||
}
|
||||
|
||||
public Integer getSendingStatus() {
|
||||
return sendingStatus;
|
||||
}
|
||||
|
||||
public void setSendingStatus(Integer sendingStatus) {
|
||||
this.sendingStatus = sendingStatus;
|
||||
}
|
||||
|
||||
public String getGmtCreate() {
|
||||
return gmtCreate == null ? "" : gmtCreate.trim();
|
||||
}
|
||||
|
||||
public void setGmtCreate(String gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"emailId\":")
|
||||
.append("\"").append(emailId).append("\"");
|
||||
sb.append(",\"emailSender\":")
|
||||
.append("\"").append(emailSender).append("\"");
|
||||
sb.append(",\"emailReceiver\":")
|
||||
.append("\"").append(emailReceiver).append("\"");
|
||||
sb.append(",\"emailCc\":")
|
||||
.append("\"").append(emailCc).append("\"");
|
||||
sb.append(",\"emailType\":")
|
||||
.append("\"").append(emailType).append("\"");
|
||||
sb.append(",\"emailSubject\":")
|
||||
.append("\"").append(emailSubject).append("\"");
|
||||
sb.append(",\"emailContent\":")
|
||||
.append("\"").append(emailContent).append("\"");
|
||||
sb.append(",\"sendingStatus\":")
|
||||
.append(sendingStatus);
|
||||
sb.append(",\"gmtCreate\":")
|
||||
.append("\"").append(gmtCreate).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.cm.manager.sms.pojo.vos.email;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: EmailVO
|
||||
* @Description: 邮件
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/7/31 4:31 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class EmailVO {
|
||||
|
||||
@ApiModelProperty(name = "emailSender", value = "发送人")
|
||||
private String emailSender;
|
||||
@ApiModelProperty(name = "emailReceiver", value = "接收人")
|
||||
private String emailReceiver;
|
||||
@ApiModelProperty(name = "emailCc", value = "抄送人")
|
||||
private String emailCc;
|
||||
@ApiModelProperty(name = "emailType", value = "邮件类型")
|
||||
private String emailType;
|
||||
@ApiModelProperty(name = "emailSubject", value = "主题")
|
||||
private String emailSubject;
|
||||
@ApiModelProperty(name = "emailContent", value = "内容")
|
||||
private String emailContent;
|
||||
@ApiModelProperty(name = "sendingStatus", value = "发送状态")
|
||||
private Integer sendingStatus;
|
||||
|
||||
public String getEmailSender() {
|
||||
return emailSender == null ? "" : emailSender.trim();
|
||||
}
|
||||
|
||||
public void setEmailSender(String emailSender) {
|
||||
this.emailSender = emailSender;
|
||||
}
|
||||
|
||||
public String getEmailReceiver() {
|
||||
return emailReceiver == null ? "" : emailReceiver.trim();
|
||||
}
|
||||
|
||||
public void setEmailReceiver(String emailReceiver) {
|
||||
this.emailReceiver = emailReceiver;
|
||||
}
|
||||
|
||||
public String getEmailCc() {
|
||||
return emailCc == null ? "" : emailCc.trim();
|
||||
}
|
||||
|
||||
public void setEmailCc(String emailCc) {
|
||||
this.emailCc = emailCc;
|
||||
}
|
||||
|
||||
public String getEmailType() {
|
||||
return emailType == null ? "" : emailType.trim();
|
||||
}
|
||||
|
||||
public void setEmailType(String emailType) {
|
||||
this.emailType = emailType;
|
||||
}
|
||||
|
||||
public String getEmailSubject() {
|
||||
return emailSubject == null ? "" : emailSubject.trim();
|
||||
}
|
||||
|
||||
public void setEmailSubject(String emailSubject) {
|
||||
this.emailSubject = emailSubject;
|
||||
}
|
||||
|
||||
public String getEmailContent() {
|
||||
return emailContent == null ? "" : emailContent.trim();
|
||||
}
|
||||
|
||||
public void setEmailContent(String emailContent) {
|
||||
this.emailContent = emailContent;
|
||||
}
|
||||
|
||||
public Integer getSendingStatus() {
|
||||
return sendingStatus;
|
||||
}
|
||||
|
||||
public void setSendingStatus(Integer sendingStatus) {
|
||||
this.sendingStatus = sendingStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"emailSender\":")
|
||||
.append("\"").append(emailSender).append("\"");
|
||||
sb.append(",\"emailReceiver\":")
|
||||
.append("\"").append(emailReceiver).append("\"");
|
||||
sb.append(",\"emailCc\":")
|
||||
.append("\"").append(emailCc).append("\"");
|
||||
sb.append(",\"emailType\":")
|
||||
.append("\"").append(emailType).append("\"");
|
||||
sb.append(",\"emailSubject\":")
|
||||
.append("\"").append(emailSubject).append("\"");
|
||||
sb.append(",\"emailContent\":")
|
||||
.append("\"").append(emailContent).append("\"");
|
||||
sb.append(",\"sendingStatus\":")
|
||||
.append(sendingStatus);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.cm.manager.sms.service;
|
||||
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import com.cm.manager.sms.pojo.dtos.email.EmailDTO;
|
||||
import com.cm.manager.sms.pojo.dtos.sms.SmsDTO;
|
||||
import com.cm.manager.sms.pojo.vos.email.EmailVO;
|
||||
import com.cm.manager.sms.pojo.vos.sms.SmsVO;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IEmailService
|
||||
* @Description: 邮件服务
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/7/31 4:19 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IEmailService {
|
||||
|
||||
/**
|
||||
* 保存并发送系统邮件
|
||||
*
|
||||
* @param emailVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
SuccessResult saveAndSendSystemEmail(EmailVO emailVO) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除邮件
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
* @throws RemoveException
|
||||
*/
|
||||
SuccessResult removeEmail(String ids) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 更新重新发送系统邮件
|
||||
*
|
||||
* @param emailId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
SuccessResult updateReSendSystemEmailByEmailId(String emailId) throws Exception;
|
||||
|
||||
/**
|
||||
* 邮件详情(通过ID)
|
||||
*
|
||||
* @param emailId
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
EmailDTO getEmailById(String emailId) throws SearchException;
|
||||
|
||||
/**
|
||||
* 邮件列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<EmailDTO> listEmail(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 邮件分页列表
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
SuccessResultList<List<EmailDTO>> listPageEmail(ListPage page) throws SearchException;
|
||||
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package com.cm.manager.sms.service.impl;
|
||||
|
||||
import com.cm.common.base.AbstractService;
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SaveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.exception.UpdateException;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import com.cm.common.utils.HashMapUtil;
|
||||
import com.cm.common.utils.email.SimpleMailSenderUtil;
|
||||
import com.cm.manager.sms.config.properties.EmailProperties;
|
||||
import com.cm.manager.sms.dao.email.IEmailDao;
|
||||
import com.cm.manager.sms.pojo.dtos.email.EmailDTO;
|
||||
import com.cm.manager.sms.pojo.vos.email.EmailVO;
|
||||
import com.cm.manager.sms.service.IEmailService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: EmailServiceImpl
|
||||
* @Description: 邮件业务
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/7/31 4:19 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Service
|
||||
public class EmailServiceImpl extends AbstractService implements IEmailService {
|
||||
|
||||
@Autowired
|
||||
private EmailProperties emailProperties;
|
||||
@Autowired
|
||||
private IEmailDao emailDao;
|
||||
|
||||
@Override
|
||||
public SuccessResult saveAndSendSystemEmail(EmailVO emailVO) throws Exception {
|
||||
if (!emailProperties.getActive()) {
|
||||
throw new SaveException("邮件未激活");
|
||||
}
|
||||
List<String> ccPersons = emailProperties.getCcPersons();
|
||||
StringBuilder ccSB = new StringBuilder();
|
||||
for (String ccPerson : ccPersons) {
|
||||
if (ccSB.length() > 0) {
|
||||
ccSB.append(",");
|
||||
}
|
||||
ccSB.append(ccPerson);
|
||||
}
|
||||
emailVO.setEmailCc(ccSB.toString());
|
||||
LOG.debug("发送邮件");
|
||||
boolean sendSuccess = SimpleMailSenderUtil.sendEmail(emailProperties.getSmtp(), emailProperties.getPort(),
|
||||
emailProperties.getSenderEmail(), emailProperties.getSenderPassword(),
|
||||
emailVO.getEmailReceiver(), emailVO.getEmailCc(), emailVO.getEmailSubject(),
|
||||
emailVO.getEmailContent(), emailVO.getEmailType());
|
||||
if (!sendSuccess) {
|
||||
LOG.error("邮件发送失败");
|
||||
}
|
||||
emailVO.setSendingStatus(sendSuccess ? 1 : 0);
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(emailVO);
|
||||
setSaveInfoByUserId(params, "1");
|
||||
emailDao.saveEmail(params);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResult removeEmail(String ids) throws RemoveException {
|
||||
Map<String, Object> params = getHashMap(3);
|
||||
params.put("emailIds", Arrays.asList(ids.split("_")));
|
||||
setUpdateInfo(params);
|
||||
emailDao.removeEmail(params);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResult updateReSendSystemEmailByEmailId(String emailId) throws Exception {
|
||||
EmailDTO emailDTO = getEmailById(emailId);
|
||||
if (emailDTO == null) {
|
||||
throw new SearchException("邮件信息不存在");
|
||||
}
|
||||
if (emailDTO.getSendingStatus() == 1) {
|
||||
throw new UpdateException("邮件已发送成功,无需重新发送");
|
||||
}
|
||||
LOG.debug("发送邮件");
|
||||
boolean sendSuccess = SimpleMailSenderUtil.sendEmail(emailProperties.getSmtp(), emailProperties.getPort(),
|
||||
emailProperties.getSenderEmail(), emailProperties.getSenderPassword(),
|
||||
emailDTO.getEmailReceiver(), emailDTO.getEmailCc(), emailDTO.getEmailSubject(),
|
||||
emailDTO.getEmailContent(), emailDTO.getEmailType());
|
||||
Map<String, Object> params = getHashMap(6);
|
||||
params.put("emailId", emailId);
|
||||
params.put("sendingStatus", sendSuccess ? 1 : 0);
|
||||
setUpdateInfo(params);
|
||||
emailDao.updateEmailSendingStatus(params);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmailDTO getEmailById(String emailId) throws SearchException {
|
||||
Map<String, Object> params = super.getHashMap(1);
|
||||
params.put("emailId", emailId);
|
||||
return emailDao.getEmail(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmailDTO> listEmail(Map<String, Object> params) throws SearchException {
|
||||
return emailDao.listEmail(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<EmailDTO>> listPageEmail(ListPage page) throws SearchException {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<EmailDTO> emailDTOs = emailDao.listEmail(page.getParams());
|
||||
PageInfo<EmailDTO> pageInfo = new PageInfo<>(emailDTOs);
|
||||
return new SuccessResultList<>(emailDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
<?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.cm.manager.sms.dao.email.IEmailDao">
|
||||
|
||||
<resultMap id="emailDTO" type="com.cm.manager.sms.pojo.dtos.email.EmailDTO">
|
||||
<id column="email_id" property="emailId"/>
|
||||
<result column="email_sender" property="emailSender"/>
|
||||
<result column="email_receiver" property="emailReceiver"/>
|
||||
<result column="email_cc" property="emailCc"/>
|
||||
<result column="email_type" property="emailType"/>
|
||||
<result column="email_subject" property="emailSubject"/>
|
||||
<result column="email_content" property="emailContent"/>
|
||||
<result column="sending_status" property="sendingStatus"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 新增短信 -->
|
||||
<insert id="saveEmail" parameterType="map">
|
||||
INSERT INTO sms_email(
|
||||
email_id,
|
||||
email_sender,
|
||||
email_receiver,
|
||||
email_cc,
|
||||
email_type,
|
||||
email_subject,
|
||||
email_content,
|
||||
sending_status,
|
||||
creator,
|
||||
gmt_create,
|
||||
modifier,
|
||||
gmt_modified,
|
||||
is_delete
|
||||
) VALUES(
|
||||
#{emailId},
|
||||
#{emailSender},
|
||||
#{emailReceiver},
|
||||
#{emailCc},
|
||||
#{emailType},
|
||||
#{emailSubject},
|
||||
#{emailContent},
|
||||
#{sendingStatus},
|
||||
#{creator},
|
||||
#{gmtCreate},
|
||||
#{modifier},
|
||||
#{gmtModified},
|
||||
#{isDelete}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 删除短信 -->
|
||||
<update id="removeEmail" parameterType="map">
|
||||
UPDATE
|
||||
sms_email
|
||||
SET
|
||||
is_delete = 1,
|
||||
modifier = #{modifier},
|
||||
gmt_modified = #{gmtModified}
|
||||
WHERE
|
||||
email_id IN
|
||||
<foreach collection="smsIds" index="index" open="(" separator="," close=")">
|
||||
#{smsIds[${index}]}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 更新邮件发送状态 -->
|
||||
<update id="updateEmailSendingStatus" parameterType="map">
|
||||
UPDATE
|
||||
sms_email
|
||||
SET
|
||||
sending_status = #{sendingStatus}
|
||||
WHERE
|
||||
is_delete = 0
|
||||
AND
|
||||
email_id = #{emailId}
|
||||
</update>
|
||||
|
||||
<!-- 短信详情 -->
|
||||
<select id="getEmail" parameterType="map" resultMap="emailDTO">
|
||||
SELECT
|
||||
t1.email_id,
|
||||
t1.email_sender,
|
||||
t1.email_receiver,
|
||||
t1.email_cc,
|
||||
t1.email_type,
|
||||
t1.email_subject,
|
||||
t1.email_content,
|
||||
t1.sending_status,
|
||||
t1.gmt_create
|
||||
FROM
|
||||
sms_email t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
<if test="emailId != null and emailId != ''">
|
||||
AND
|
||||
t1.email_id = #{emailId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 短信列表 -->
|
||||
<select id="listEmail" parameterType="map" resultMap="emailDTO">
|
||||
SELECT
|
||||
t1.email_id,
|
||||
t1.email_sender,
|
||||
t1.email_receiver,
|
||||
t1.email_cc,
|
||||
t1.email_type,
|
||||
t1.email_subject,
|
||||
t1.email_content,
|
||||
t1.sending_status,
|
||||
t1.gmt_create
|
||||
FROM
|
||||
sms_email t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND (
|
||||
t1.email_sender LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
t1.email_receiver LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
t1.email_cc LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
t1.email_subject LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND
|
||||
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND
|
||||
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
||||
</if>
|
||||
<if test="smsIds != null and smsIds.size > 0">
|
||||
AND
|
||||
t1.email_id IN
|
||||
<foreach collection="smsIds" index="index" open="(" separator="," close=")">
|
||||
#{emailIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -106,7 +106,11 @@
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
<if test="keywords != null and keywords != ''">
|
||||
<!-- 这里添加检索关键字 -->
|
||||
AND (
|
||||
t1.phone LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
t1.content LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND
|
||||
|
Loading…
Reference in New Issue
Block a user