6 files modified
9 files added
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.email.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import lombok.AllArgsConstructor; |
| | | import javax.validation.Valid; |
| | | |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.modules.email.entity.EmailTemplateEntity; |
| | | import org.springblade.modules.email.vo.EmailTemplateVO; |
| | | import org.springblade.modules.email.wrapper.EmailTemplateWrapper; |
| | | import org.springblade.modules.email.service.IEmailTemplateService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | |
| | | /** |
| | | * 邮件模版表 控制器 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-03-04 |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("blade-email/emailTemplate") |
| | | @Api(value = "邮件模版表", tags = "邮件模版表接口") |
| | | public class EmailTemplateController extends BladeController { |
| | | |
| | | private final IEmailTemplateService emailTemplateService; |
| | | |
| | | /** |
| | | * 邮件模版表 详情 |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入emailTemplate") |
| | | public R<EmailTemplateVO> detail(EmailTemplateEntity emailTemplate) { |
| | | EmailTemplateEntity detail = emailTemplateService.getOne(Condition.getQueryWrapper(emailTemplate)); |
| | | return R.data(EmailTemplateWrapper.build().entityVO(detail)); |
| | | } |
| | | /** |
| | | * 邮件模版表 分页 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "分页", notes = "传入emailTemplate") |
| | | public R<IPage<EmailTemplateVO>> list(EmailTemplateEntity emailTemplate, Query query) { |
| | | IPage<EmailTemplateEntity> pages = emailTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper(emailTemplate)); |
| | | return R.data(EmailTemplateWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | | /** |
| | | * 邮件模版表 自定义分页 |
| | | */ |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入emailTemplate") |
| | | public R<IPage<EmailTemplateVO>> page(EmailTemplateVO emailTemplate, Query query) { |
| | | IPage<EmailTemplateVO> pages = emailTemplateService.selectEmailTemplatePage(Condition.getPage(query), emailTemplate); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 邮件模版表 新增 |
| | | */ |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入emailTemplate") |
| | | public R save(@Valid @RequestBody EmailTemplateEntity emailTemplate) { |
| | | return R.status(emailTemplateService.save(emailTemplate)); |
| | | } |
| | | |
| | | /** |
| | | * 邮件模版表 修改 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入emailTemplate") |
| | | public R update(@Valid @RequestBody EmailTemplateEntity emailTemplate) { |
| | | return R.status(emailTemplateService.updateById(emailTemplate)); |
| | | } |
| | | |
| | | /** |
| | | * 邮件模版表 新增或修改 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入emailTemplate") |
| | | public R submit(@Valid @RequestBody EmailTemplateEntity emailTemplate) { |
| | | return R.status(emailTemplateService.saveOrUpdate(emailTemplate)); |
| | | } |
| | | |
| | | /** |
| | | * 邮件模版表 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "逻辑删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | return R.status(emailTemplateService.removeBatchByIds(Func.toLongList(ids))); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.email.dto; |
| | | |
| | | import org.springblade.modules.email.entity.EmailTemplateEntity; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 邮件模版表 数据传输对象实体类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-03-04 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class EmailTemplateDTO extends EmailTemplateEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.email.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 邮件模版表 实体类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-03-04 |
| | | */ |
| | | @Data |
| | | @TableName("blade_email_template") |
| | | @ApiModel(value = "EmailTemplate对象", description = "邮件模版表") |
| | | public class EmailTemplateEntity{ |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | |
| | | /** id */ |
| | | @ApiModelProperty(value = "主键ID", example = "") |
| | | private Integer id; |
| | | |
| | | /** 标题 */ |
| | | @ApiModelProperty(value = "标题", example = "") |
| | | @TableField("title") |
| | | private String title; |
| | | |
| | | /** 邮件内容 */ |
| | | @ApiModelProperty(value = "邮件内容", example = "") |
| | | @TableField("content") |
| | | private String content; |
| | | |
| | | /** 创建时间 */ |
| | | @ApiModelProperty(value = "创建时间", example = "") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | |
| | | /** 更新时间 */ |
| | | @ApiModelProperty(value = "更新时间", example = "") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField("update_time") |
| | | private Date updateTime; |
| | | |
| | | /** 是否已删除 */ |
| | | @ApiModelProperty(value = "是否已删除", example = "") |
| | | @TableField("is_delete") |
| | | private Integer isDelete; |
| | | |
| | | /** 创建人 */ |
| | | @ApiModelProperty(value = "创建人", example = "") |
| | | @TableField("create_by") |
| | | private Long createBy; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.email.mapper; |
| | | |
| | | import org.springblade.modules.email.dto.EmailTemplateDTO; |
| | | import org.springblade.modules.email.entity.EmailTemplateEntity; |
| | | import org.springblade.modules.email.vo.EmailTemplateVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 邮件模版表 Mapper 接口 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-03-04 |
| | | */ |
| | | public interface EmailTemplateMapper extends BaseMapper<EmailTemplateEntity> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param emailTemplate |
| | | * @return |
| | | */ |
| | | List<EmailTemplateVO> selectEmailTemplatePage(IPage page, EmailTemplateVO emailTemplate); |
| | | |
| | | |
| | | /** |
| | | * 查询 |
| | | * |
| | | * @param id ID |
| | | * @return |
| | | */ |
| | | public EmailTemplateDTO selectBladeEmailTemplateById(Integer id); |
| | | |
| | | /** |
| | | * 查询列表 |
| | | * |
| | | * @param bladeEmailTemplateDTO |
| | | * @return 集合 |
| | | */ |
| | | public List<EmailTemplateDTO> selectBladeEmailTemplateList(EmailTemplateDTO bladeEmailTemplateDTO); |
| | | } |
| New 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="org.springblade.modules.email.mapper.EmailTemplateMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="emailTemplateResultMap" type="org.springblade.modules.email.entity.EmailTemplateEntity"> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="selectEmailTemplatePage" resultMap="emailTemplateResultMap"> |
| | | select * from blade_email_template where is_deleted = 0 |
| | | </select> |
| | | |
| | | <resultMap type="org.springblade.modules.email.dto.EmailTemplateDTO" id="BladeEmailTemplateDTOResult"> |
| | | <result property="id" column="id" /> |
| | | <result property="title" column="title" /> |
| | | <result property="content" column="content" /> |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="isDelete" column="is_delete" /> |
| | | <result property="createBy" column="create_by" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectBladeEmailTemplate"> |
| | | select |
| | | id, |
| | | title, |
| | | content, |
| | | create_time, |
| | | update_time, |
| | | is_delete, |
| | | create_by |
| | | from |
| | | blade_email_template |
| | | </sql> |
| | | |
| | | <select id="selectBladeEmailTemplateById" parameterType="int" resultMap="BladeEmailTemplateDTOResult"> |
| | | <include refid="selectBladeEmailTemplate"/> |
| | | where |
| | | id = #{id} |
| | | </select> |
| | | |
| | | <select id="selectBladeEmailTemplateList" parameterType="org.springblade.modules.email.dto.EmailTemplateDTO" resultMap="BladeEmailTemplateDTOResult"> |
| | | <include refid="selectBladeEmailTemplate"/> |
| | | <where> |
| | | <if test="id != null "> and id = #{id}</if> |
| | | <if test="title != null and title != ''"> and title = #{title}</if> |
| | | <if test="content != null and content != ''"> and content = #{content}</if> |
| | | <if test="createTime != null "> and create_time = #{createTime}</if> |
| | | <if test="updateTime != null "> and update_time = #{updateTime}</if> |
| | | <if test="isDelete != null "> and is_delete = #{isDelete}</if> |
| | | <if test="createBy != null "> and create_by = #{createBy}</if> |
| | | </where> |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | public interface IEmailAccountService { |
| | | |
| | | /**用于注册成功后发送邮件 @param account 账号信息*/ |
| | | void senderEmail(EmailAccount account); |
| | | Boolean senderEmail(EmailAccount account); |
| | | |
| | | void sendMessageUserEmail(String title, String content, List<MessageUser> messageUserList); |
| | | Boolean sendMessageUserEmail(String title, String content, List<MessageUser> messageUserList); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.email.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.modules.email.dto.EmailTemplateDTO; |
| | | import org.springblade.modules.email.entity.EmailTemplateEntity; |
| | | import org.springblade.modules.email.vo.EmailTemplateVO; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 邮件模版表 服务类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-03-04 |
| | | */ |
| | | public interface IEmailTemplateService extends IService<EmailTemplateEntity> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param emailTemplate |
| | | * @return |
| | | */ |
| | | IPage<EmailTemplateVO> selectEmailTemplatePage(IPage<EmailTemplateVO> page, EmailTemplateVO emailTemplate); |
| | | /** |
| | | * 查询 |
| | | * |
| | | * @param id ID |
| | | * @return |
| | | */ |
| | | public EmailTemplateDTO selectBladeEmailTemplateById(Integer id); |
| | | |
| | | /** |
| | | * 查询列表 |
| | | * |
| | | * @param bladeEmailTemplateDTO |
| | | * @return 集合 |
| | | */ |
| | | public List<EmailTemplateDTO> selectBladeEmailTemplateList(EmailTemplateDTO bladeEmailTemplateDTO); |
| | | |
| | | } |
| | |
| | | package org.springblade.modules.email.service.impl; |
| | | |
| | | import com.xxl.job.core.util.DateUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.modules.email.config.MailProperties; |
| | | import org.springblade.modules.email.config.MailSenderConfig; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.mail.MessagingException; |
| | | import javax.mail.internet.MimeMessage; |
| | | import java.io.File; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @Slf4j |
| | | public class EmailAccountServiceImpl implements IEmailAccountService { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(EmailAccountServiceImpl.class); |
| | | |
| | | @Autowired |
| | | MailSenderConfig senderConfig; |
| | |
| | | MailProperties mailProperties; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void senderEmail(EmailAccount account) { |
| | | public Boolean senderEmail(EmailAccount account) { |
| | | |
| | | if (account.getEmails().size()>0){ |
| | | if (account.getEmails().size() > 0) { |
| | | log.info(Thread.currentThread().getName()); |
| | | JavaMailSenderImpl javaMailSender = senderConfig.getSender(); |
| | | //一个复杂的邮件 |
| | |
| | | //主题(标题) |
| | | helper.setSubject(account.getSubject()); |
| | | |
| | | helper.setText(account.getContent(),true); |
| | | helper.setText(account.getContent(), true); |
| | | |
| | | helper.setTo(account.getEmails().toArray(new String[account.getEmails().size()])); |
| | | |
| | | helper.setFrom(javaMailSender.getUsername()); |
| | | |
| | | javaMailSender.send(message); |
| | | return true; |
| | | |
| | | } catch (MessagingException e) { |
| | | e.printStackTrace(); |
| | | logger.error("邮件发送失败!", e); |
| | | return false; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public void sendMessageUserEmail(String title, String content, List<MessageUser> messageUserList) { |
| | | public Boolean sendMessageUserEmail(String title, String content, List<MessageUser> messageUserList) { |
| | | |
| | | List<String> emails = messageUserList.stream().filter(e -> StringUtil.isNotBlank(e.getEmail())).map(MessageUser::getEmail).collect(Collectors.toList()); |
| | | |
| | |
| | | emailAccount.setSubject(title); |
| | | emailAccount.setContent(content); |
| | | |
| | | senderEmail(emailAccount); |
| | | return senderEmail(emailAccount); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.email.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.modules.email.dto.EmailTemplateDTO; |
| | | import org.springblade.modules.email.entity.EmailTemplateEntity; |
| | | import org.springblade.modules.email.vo.EmailTemplateVO; |
| | | import org.springblade.modules.email.mapper.EmailTemplateMapper; |
| | | import org.springblade.modules.email.service.IEmailTemplateService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 邮件模版表 服务实现类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-03-04 |
| | | */ |
| | | @Service |
| | | public class EmailTemplateServiceImpl extends ServiceImpl<EmailTemplateMapper, EmailTemplateEntity> implements IEmailTemplateService { |
| | | |
| | | @Override |
| | | public IPage<EmailTemplateVO> selectEmailTemplatePage(IPage<EmailTemplateVO> page, EmailTemplateVO emailTemplate) { |
| | | return page.setRecords(baseMapper.selectEmailTemplatePage(page, emailTemplate)); |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | * |
| | | * @param id ID |
| | | * @return |
| | | */ |
| | | @Override |
| | | public EmailTemplateDTO selectBladeEmailTemplateById(Integer id) |
| | | { |
| | | return this.baseMapper.selectBladeEmailTemplateById(id); |
| | | } |
| | | |
| | | /** |
| | | * 查询列表 |
| | | * |
| | | * @param bladeEmailTemplateDTO |
| | | * @return 集合 |
| | | */ |
| | | @Override |
| | | public List<EmailTemplateDTO> selectBladeEmailTemplateList(EmailTemplateDTO bladeEmailTemplateDTO) |
| | | { |
| | | return this.baseMapper.selectBladeEmailTemplateList(bladeEmailTemplateDTO); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.email.vo; |
| | | |
| | | import org.springblade.modules.email.entity.EmailTemplateEntity; |
| | | import org.springblade.core.tool.node.INode; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 邮件模版表 视图实体类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-03-04 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class EmailTemplateVO extends EmailTemplateEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 邮件配置 视图实体类 |
| | | * 邮件模版表 视图实体类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-01-18 |
| | | * @since 2024-03-04 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class EmailVO extends EmailEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String statusName; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.email.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.email.entity.EmailTemplateEntity; |
| | | import org.springblade.modules.email.vo.EmailTemplateVO; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 邮件模版表 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-03-04 |
| | | */ |
| | | public class EmailTemplateWrapper extends BaseEntityWrapper<EmailTemplateEntity, EmailTemplateVO> { |
| | | |
| | | public static EmailTemplateWrapper build() { |
| | | return new EmailTemplateWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public EmailTemplateVO entityVO(EmailTemplateEntity emailTemplate) { |
| | | EmailTemplateVO emailTemplateVO = Objects.requireNonNull(BeanUtil.copy(emailTemplate, EmailTemplateVO.class)); |
| | | |
| | | //User createUser = UserCache.getUser(emailTemplate.getCreateUser()); |
| | | //User updateUser = UserCache.getUser(emailTemplate.getUpdateUser()); |
| | | //emailTemplateVO.setCreateUserName(createUser.getName()); |
| | | //emailTemplateVO.setUpdateUserName(updateUser.getName()); |
| | | |
| | | return emailTemplateVO; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.springblade.modules.email.wrapper; |
| | | |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.common.enums.DictEnum; |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.email.entity.EmailEntity; |
| | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 邮件配置 包装类,返回视图层所需的字段 |
| | | * 邮件模版表 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-01-18 |
| | | * @since 2024-03-04 |
| | | */ |
| | | public class EmailWrapper extends BaseEntityWrapper<EmailEntity, EmailVO> { |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public EmailVO entityVO(EmailEntity email) { |
| | | EmailVO emailVO = Objects.requireNonNull(BeanUtil.copy(email, EmailVO.class)); |
| | | public EmailVO entityVO(EmailEntity emailTemplate) { |
| | | EmailVO emailTemplateVO = Objects.requireNonNull(BeanUtil.copy(emailTemplate, EmailVO.class)); |
| | | |
| | | //User createUser = UserCache.getUser(email.getCreateUser()); |
| | | //User updateUser = UserCache.getUser(email.getUpdateUser()); |
| | | //emailVO.setCreateUserName(createUser.getName()); |
| | | //emailVO.setUpdateUserName(updateUser.getName()); |
| | | String statusName = DictCache.getValue(DictEnum.YES_NO, email.getStatus()); |
| | | emailVO.setStatusName(statusName); |
| | | return emailVO; |
| | | //User createUser = UserCache.getUser(emailTemplate.getCreateUser()); |
| | | //User updateUser = UserCache.getUser(emailTemplate.getUpdateUser()); |
| | | //emailTemplateVO.setCreateUserName(createUser.getName()); |
| | | //emailTemplateVO.setUpdateUserName(updateUser.getName()); |
| | | |
| | | return emailTemplateVO; |
| | | } |
| | | |
| | | |
| | |
| | | //是否已读(1、已读;2、未读) |
| | | private String isRead; |
| | | |
| | | // 1:待发送,2.:发送成功 3:发送失败 |
| | | private String sendStatus; |
| | | |
| | | // 重试次数 |
| | | private String retryNumber; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("创建时间") |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.modules.email.service.IEmailAccountService; |
| | | import org.springblade.modules.email.service.IEmailService; |
| | | import org.springblade.modules.messageRecord.entity.MessageRecord; |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 消息记录表 服务实现类 |
| | |
| | | messageUser.setType(messageRecord.getType()); |
| | | messageUser.setCreateTime(DateUtil.now()); |
| | | messageUser.setUpdateTime(DateUtil.now()); |
| | | |
| | | if (messageRecord.getType().indexOf("2") > -1) { |
| | | messageUser.setSendStatus("1"); |
| | | if (messageRecord.getType().indexOf("1") > -1) { |
| | | messageUser.setSendStatus("2"); |
| | | } else if (messageRecord.getType().indexOf("2") > -1) { |
| | | messageUser.setEmail(user.getEmail()); |
| | | } |
| | | |
| | | if (messageRecord.getType().indexOf("3") > -1) { |
| | | } else if (messageRecord.getType().indexOf("3") > -1) { |
| | | messageUser.setSendStatus("2"); |
| | | messageUser.setPhone(user.getPhone()); |
| | | } |
| | | |
| | |
| | | //在message_user表里存数据 |
| | | boolean saveBatch = messageUserService.saveBatch(messageUserList); |
| | | |
| | | if (saveBatch&&saveRecord){ |
| | | if (saveBatch && saveRecord) { |
| | | if (messageRecord.getType().indexOf("2") > -1) { |
| | | emailAccountService.sendMessageUserEmail(messageRecord.getTitle(), messageRecord.getContent(), messageUserList); |
| | | return true; |
| | | Boolean aBoolean = emailAccountService.sendMessageUserEmail(messageRecord.getTitle(), messageRecord.getContent(), messageUserList); |
| | | // 邮件发送成功,更新邮件状态 |
| | | if (aBoolean) { |
| | | List<MessageUser> collect = messageUserList.stream().filter(e -> StringUtil.isNotBlank(e.getEmail())).collect(Collectors.toList()); |
| | | messageUserService.updateBatchById(collect); |
| | | } |
| | | } |
| | | |
| | | if (messageRecord.getType().indexOf("3") > -1) { |
| | |
| | | List<MessageUser> messageUserList = messageUserService.list(new QueryWrapper<MessageUser>().eq("message_record_id", id)); |
| | | |
| | | if (messageRecord.getType().indexOf("2") > -1) { |
| | | emailAccountService.sendMessageUserEmail(messageRecord.getTitle(), messageRecord.getContent(), messageUserList); |
| | | return true; |
| | | return emailAccountService.sendMessageUserEmail(messageRecord.getTitle(), messageRecord.getContent(), messageUserList); |
| | | } |
| | | |
| | | if (messageRecord.getType().indexOf("3") > -1) { |