邮件模板由后端保存,基础增删改查
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
package com.ruoyi.oa.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.oa.domain.vo.OaEmailTemplateVo;
|
||||
import com.ruoyi.oa.domain.bo.OaEmailTemplateBo;
|
||||
import com.ruoyi.oa.service.IOaEmailTemplateService;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 邮件模板
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/oa/emailTemplate")
|
||||
public class OaEmailTemplateController extends BaseController {
|
||||
|
||||
private final IOaEmailTemplateService iOaEmailTemplateService;
|
||||
|
||||
/**
|
||||
* 查询邮件模板列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<OaEmailTemplateVo> list(OaEmailTemplateBo bo, PageQuery pageQuery) {
|
||||
return iOaEmailTemplateService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出邮件模板列表
|
||||
*/
|
||||
@Log(title = "邮件模板", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(OaEmailTemplateBo bo, HttpServletResponse response) {
|
||||
List<OaEmailTemplateVo> list = iOaEmailTemplateService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "邮件模板", OaEmailTemplateVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取邮件模板详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<OaEmailTemplateVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(iOaEmailTemplateService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增邮件模板
|
||||
*/
|
||||
@Log(title = "邮件模板", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody OaEmailTemplateBo bo) {
|
||||
return toAjax(iOaEmailTemplateService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改邮件模板
|
||||
*/
|
||||
@Log(title = "邮件模板", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OaEmailTemplateBo bo) {
|
||||
return toAjax(iOaEmailTemplateService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除邮件模板
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@Log(title = "邮件模板", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iOaEmailTemplateService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.ruoyi.oa.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 邮件模板对象 oa_email_template
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("oa_email_template")
|
||||
public class OaEmailTemplate extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
private String templateName;
|
||||
/**
|
||||
* 模板分类
|
||||
*/
|
||||
private String category;
|
||||
/**
|
||||
* 模板内容(富文本HTML)
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 附件信息(逗号分隔或JSON)
|
||||
*/
|
||||
private String attachments;
|
||||
/**
|
||||
* 删除标志:0正常;1已删除
|
||||
*/
|
||||
@TableLogic
|
||||
private Long delFlag;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.oa.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 邮件模板业务对象 oa_email_template
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class OaEmailTemplateBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
private String templateName;
|
||||
|
||||
/**
|
||||
* 模板分类
|
||||
*/
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 模板内容(富文本HTML)
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 附件信息(逗号分隔或JSON)
|
||||
*/
|
||||
private String attachments;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -20,4 +20,6 @@ public class EmailSendRequest {
|
||||
private List<String> attachmentPaths;
|
||||
/** 内嵌图片路径列表 */
|
||||
private List<String> inlineImagePaths;
|
||||
/** 家具ID列表(发送邮件时关联的多个家具) */
|
||||
private List<Long> furnitureIds;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.oa.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 邮件模板视图对象 oa_email_template
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class OaEmailTemplateVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ExcelProperty(value = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
@ExcelProperty(value = "模板名称")
|
||||
private String templateName;
|
||||
|
||||
/**
|
||||
* 模板分类
|
||||
*/
|
||||
@ExcelProperty(value = "模板分类")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 模板内容(富文本HTML)
|
||||
*/
|
||||
@ExcelProperty(value = "模板内容", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "富=文本HTML")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 附件信息(逗号分隔或JSON)
|
||||
*/
|
||||
@ExcelProperty(value = "附件信息", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "逗=号分隔或JSON")
|
||||
private String attachments;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.oa.mapper;
|
||||
|
||||
import com.ruoyi.oa.domain.OaEmailTemplate;
|
||||
import com.ruoyi.oa.domain.vo.OaEmailTemplateVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 邮件模板Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
public interface OaEmailTemplateMapper extends BaseMapperPlus<OaEmailTemplateMapper, OaEmailTemplate, OaEmailTemplateVo> {
|
||||
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import com.ruoyi.oa.domain.OaFurnitureTable;
|
||||
import com.ruoyi.oa.domain.vo.OaFurnitureTableVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 家具Mapper接口
|
||||
*
|
||||
@@ -12,4 +14,13 @@ import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
*/
|
||||
public interface OaFurnitureTableMapper extends BaseMapperPlus<OaFurnitureTableMapper, OaFurnitureTable, OaFurnitureTableVo> {
|
||||
|
||||
/**
|
||||
* 邮件发送成功后,更新发送次数和上次发送时间
|
||||
*/
|
||||
int updateEmailSendInfo(Long furnitureId);
|
||||
|
||||
/**
|
||||
* 根据家具ID列表批量查询邮箱地址
|
||||
*/
|
||||
List<String> selectEmailsByFurnitureIds(List<Long> furnitureIds);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.ruoyi.oa.service;
|
||||
|
||||
import com.ruoyi.oa.domain.OaEmailTemplate;
|
||||
import com.ruoyi.oa.domain.vo.OaEmailTemplateVo;
|
||||
import com.ruoyi.oa.domain.bo.OaEmailTemplateBo;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 邮件模板Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
public interface IOaEmailTemplateService {
|
||||
|
||||
/**
|
||||
* 查询邮件模板
|
||||
*/
|
||||
OaEmailTemplateVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询邮件模板列表
|
||||
*/
|
||||
TableDataInfo<OaEmailTemplateVo> queryPageList(OaEmailTemplateBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询邮件模板列表
|
||||
*/
|
||||
List<OaEmailTemplateVo> queryList(OaEmailTemplateBo bo);
|
||||
|
||||
/**
|
||||
* 新增邮件模板
|
||||
*/
|
||||
Boolean insertByBo(OaEmailTemplateBo bo);
|
||||
|
||||
/**
|
||||
* 修改邮件模板
|
||||
*/
|
||||
Boolean updateByBo(OaEmailTemplateBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除邮件模板信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import com.ruoyi.oa.domain.request.EmailSendRequest;
|
||||
import com.ruoyi.oa.utils.EmailUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import com.ruoyi.oa.mapper.OaFurnitureTableMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -49,6 +50,9 @@ public class OaEmailAccountServiceImpl implements IOaEmailAccountService {
|
||||
@Autowired
|
||||
private EmailUtil emailUtil;
|
||||
|
||||
@Autowired
|
||||
private OaFurnitureTableMapper oaFurnitureTableMapper;
|
||||
|
||||
/**
|
||||
* 查询发件人邮箱账号管理
|
||||
*/
|
||||
@@ -137,51 +141,41 @@ public class OaEmailAccountServiceImpl implements IOaEmailAccountService {
|
||||
if (account == null) {
|
||||
return "发件人邮箱账号不存在";
|
||||
}
|
||||
// 通过furnitureIds查找所有邮箱
|
||||
List<String> emailList = oaFurnitureTableMapper.selectEmailsByFurnitureIds(request.getFurnitureIds());
|
||||
int type = account.getType() == null ? -1 : account.getType().intValue();
|
||||
int success = 0, fail = 0;
|
||||
StringBuilder failList = new StringBuilder();
|
||||
|
||||
if (type == 0 || type == 1) {
|
||||
if (type == 0 || type == 1) {
|
||||
// 网易/QQ邮箱 SMTP方式
|
||||
for (String to : request.getToList()) {
|
||||
for (String to : emailList) {
|
||||
try {
|
||||
// 判断是否为HTML内容
|
||||
boolean isHtml = request.getContent() != null &&
|
||||
(request.getContent().contains("<html") ||
|
||||
request.getContent().contains("<div") ||
|
||||
request.getContent().contains("<p>"));
|
||||
|
||||
// 检查是否有附件
|
||||
boolean hasAttachments = request.getAttachmentPaths() != null && !request.getAttachmentPaths().isEmpty();
|
||||
// 检查是否有内嵌图片
|
||||
boolean hasInlineImages = request.getInlineImagePaths() != null && !request.getInlineImagePaths().isEmpty();
|
||||
|
||||
if (hasAttachments && hasInlineImages) {
|
||||
// 既有附件又有内嵌图片
|
||||
if (isHtml) {
|
||||
String processedContent = emailUtil.processHtmlWithInlineImages(request.getContent(), request.getInlineImagePaths());
|
||||
emailUtil.sendHtmlMailWithAttachmentsAndDynamicConfig(account, to, request.getSubject(), processedContent, request.getAttachmentPaths());
|
||||
} else {
|
||||
// 纯文本不支持内嵌图片,只发送附件
|
||||
emailUtil.sendMailWithAttachmentAndDynamicConfig(account, to, request.getSubject(), request.getContent(), request.getAttachmentPaths().get(0));
|
||||
}
|
||||
} else if (hasAttachments) {
|
||||
// 只有附件
|
||||
if (isHtml) {
|
||||
emailUtil.sendHtmlMailWithAttachmentsAndDynamicConfig(account, to, request.getSubject(), request.getContent(), request.getAttachmentPaths());
|
||||
} else {
|
||||
emailUtil.sendMailWithAttachmentAndDynamicConfig(account, to, request.getSubject(), request.getContent(), request.getAttachmentPaths().get(0));
|
||||
}
|
||||
} else if (hasInlineImages) {
|
||||
// 只有内嵌图片
|
||||
if (isHtml) {
|
||||
emailUtil.sendHtmlMailWithInlineImagesAndDynamicConfig(account, to, request.getSubject(), request.getContent(), request.getInlineImagePaths());
|
||||
} else {
|
||||
// 纯文本不支持内嵌图片
|
||||
emailUtil.sendMailWithDynamicConfig(account, to, request.getSubject(), request.getContent());
|
||||
}
|
||||
} else {
|
||||
// 无附件无内嵌图片
|
||||
if (isHtml) {
|
||||
emailUtil.sendHtmlMailWithDynamicConfig(account, to, request.getSubject(), request.getContent());
|
||||
} else {
|
||||
@@ -194,10 +188,8 @@ public class OaEmailAccountServiceImpl implements IOaEmailAccountService {
|
||||
failList.append(to).append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == 2) {
|
||||
// 阿里云邮件推送API
|
||||
for (String to : request.getToList()) {
|
||||
} else if (type == 2) {
|
||||
for (String to : emailList) {
|
||||
try {
|
||||
boolean result = sendAliyunMail(account, to, request.getSubject(), request.getContent());
|
||||
if (result) {
|
||||
@@ -212,8 +204,7 @@ public class OaEmailAccountServiceImpl implements IOaEmailAccountService {
|
||||
}
|
||||
}
|
||||
} else if (type == 3) {
|
||||
// 飞书邮件API
|
||||
for (String to : request.getToList()) {
|
||||
for (String to : emailList) {
|
||||
try {
|
||||
boolean result = sendFeishuMail(account, to, request.getSubject(), request.getContent());
|
||||
if (result) {
|
||||
@@ -227,10 +218,15 @@ public class OaEmailAccountServiceImpl implements IOaEmailAccountService {
|
||||
failList.append(to).append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return "不支持的邮箱类型";
|
||||
}
|
||||
// 邮件发送逻辑结束后,统计success>0时批量更新所有furnitureId
|
||||
if (success > 0 && request.getFurnitureIds() != null) {
|
||||
for (Long furnitureId : request.getFurnitureIds()) {
|
||||
oaFurnitureTableMapper.updateEmailSendInfo(furnitureId);
|
||||
}
|
||||
}
|
||||
return "发送成功" + success + "封,失败" + fail + "封" + (fail > 0 ? (",失败邮箱:" + failList) : "");
|
||||
}
|
||||
private boolean sendAliyunMail(OaEmailAccount account, String to, String subject, String content) {
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.ruoyi.oa.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.oa.domain.bo.OaEmailTemplateBo;
|
||||
import com.ruoyi.oa.domain.vo.OaEmailTemplateVo;
|
||||
import com.ruoyi.oa.domain.OaEmailTemplate;
|
||||
import com.ruoyi.oa.mapper.OaEmailTemplateMapper;
|
||||
import com.ruoyi.oa.service.IOaEmailTemplateService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 邮件模板Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class OaEmailTemplateServiceImpl implements IOaEmailTemplateService {
|
||||
|
||||
private final OaEmailTemplateMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询邮件模板
|
||||
*/
|
||||
@Override
|
||||
public OaEmailTemplateVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询邮件模板列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<OaEmailTemplateVo> queryPageList(OaEmailTemplateBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<OaEmailTemplate> lqw = buildQueryWrapper(bo);
|
||||
Page<OaEmailTemplateVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询邮件模板列表
|
||||
*/
|
||||
@Override
|
||||
public List<OaEmailTemplateVo> queryList(OaEmailTemplateBo bo) {
|
||||
LambdaQueryWrapper<OaEmailTemplate> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<OaEmailTemplate> buildQueryWrapper(OaEmailTemplateBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<OaEmailTemplate> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getTemplateName()), OaEmailTemplate::getTemplateName, bo.getTemplateName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCategory()), OaEmailTemplate::getCategory, bo.getCategory());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getContent()), OaEmailTemplate::getContent, bo.getContent());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAttachments()), OaEmailTemplate::getAttachments, bo.getAttachments());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增邮件模板
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(OaEmailTemplateBo bo) {
|
||||
OaEmailTemplate add = BeanUtil.toBean(bo, OaEmailTemplate.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改邮件模板
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(OaEmailTemplateBo bo) {
|
||||
OaEmailTemplate update = BeanUtil.toBean(bo, OaEmailTemplate.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(OaEmailTemplate entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除邮件模板
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.ruoyi.oa.mapper.OaEmailTemplateMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.oa.domain.OaEmailTemplate" id="OaEmailTemplateResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="templateName" column="template_name"/>
|
||||
<result property="category" column="category"/>
|
||||
<result property="content" column="content"/>
|
||||
<result property="attachments" column="attachments"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -28,5 +28,21 @@
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<update id="updateEmailSendInfo">
|
||||
UPDATE oa_furniture_table
|
||||
SET email_send_count = IFNULL(email_send_count,0) + 1,
|
||||
last_email_send_time = NOW()
|
||||
WHERE furniture_id = #{furnitureId}
|
||||
</update>
|
||||
|
||||
<select id="selectEmailsByFurnitureIds" resultType="java.lang.String">
|
||||
SELECT email FROM oa_furniture_table
|
||||
WHERE furniture_id IN
|
||||
<foreach collection="list" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND del_flag = 0
|
||||
AND email IS NOT NULL AND email != ''
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user