Compare commits

...

2 Commits

Author SHA1 Message Date
bunny 4c3a2e87d0 fix: 邮件模板配置用户 2024-10-14 16:00:51 +08:00
bunny a3dfe63e92 fix: 删除邮件用户关联模板 2024-10-14 14:31:35 +08:00
17 changed files with 64 additions and 54 deletions

View File

@ -20,6 +20,10 @@ public class EmailTemplateAddDto {
@NotNull(message = "模板名称不能为空")
private String templateName;
@Schema(name = "emailUser", title = "配置邮件用户")
@NotNull(message = "配置邮件用户不能为空")
private Long emailUser;
@Schema(name = "subject", title = "主题")
@NotBlank(message = "主题不能为空")
@NotNull(message = "主题不能为空")

View File

@ -18,12 +18,16 @@ public class EmailTemplateUpdateDto {
@Schema(name = "id", title = "主键")
@NotNull(message = "id不能为空")
private Long id;
@Schema(name = "templateName", title = "模板名称")
@NotBlank(message = "模板名称不能为空")
@NotNull(message = "模板名称不能为空")
private String templateName;
@Schema(name = "emailUser", title = "配置邮件用户")
@NotNull(message = "配置邮件用户不能为空")
private Long emailUser;
@Schema(name = "subject", title = "主题")
@NotBlank(message = "主题不能为空")
@NotNull(message = "主题不能为空")

View File

@ -20,9 +20,6 @@ public class EmailUsersAddDto {
@NotNull(message = "邮箱不能为空")
private String email;
@Schema(name = "emailTemplate", title = "邮件模板")
private Long emailTemplate;
@Schema(name = "password", title = "密码")
@NotBlank(message = "密码不能为空")
@NotNull(message = "密码不能为空")

View File

@ -24,9 +24,6 @@ public class EmailUsersUpdateDto {
@NotNull(message = "邮箱不能为空")
private String email;
@Schema(name = "emailTemplate", title = "邮件模板")
private Long emailTemplate;
@Schema(name = "password", title = "密码")
@NotBlank(message = "密码不能为空")
@NotNull(message = "密码不能为空")

View File

@ -25,6 +25,9 @@ public class EmailTemplate extends BaseEntity {
@Schema(name = "templateName", title = "模板名称")
private String templateName;
@Schema(name = "emailUser", title = "模板名称")
private Long emailUser;
@Schema(name = "subject", title = "主题")
private String subject;

View File

@ -25,9 +25,6 @@ public class EmailUsers extends BaseEntity {
@Schema(name = "email", title = "邮箱")
private String email;
@Schema(name = "emailTemplate", title = "使用邮件模板")
private Long emailTemplate;
@Schema(name = "password", title = "密码")
private String password;

View File

@ -1,6 +1,9 @@
package cn.bunny.dao.vo.system.email;
import cn.bunny.dao.vo.BaseVo;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@ -15,6 +18,14 @@ public class EmailTemplateVo extends BaseVo {
@Schema(name = "templateName", title = "模板名称")
private String templateName;
@Schema(name = "emailUser", title = "配置邮件用户")
@JsonFormat(shape = JsonFormat.Shape.STRING)
@JSONField(serializeUsing = ToStringSerializer.class)
private Long emailUser;
@Schema(name = "emailUsername", title = "邮箱账户")
private String emailUsername;
@Schema(name = "subject", title = "主题")
private String subject;

View File

@ -1,9 +1,6 @@
package cn.bunny.dao.vo.system.email;
import cn.bunny.dao.vo.BaseVo;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@ -18,11 +15,6 @@ public class EmailUsersVo extends BaseVo {
@Schema(name = "email", title = "邮箱")
private String email;
@Schema(name = "emailTemplate", title = "使用邮件模板")
@JsonFormat(shape = JsonFormat.Shape.STRING)
@JSONField(serializeUsing = ToStringSerializer.class)
private Long emailTemplate;
@Schema(name = "password", title = "密码")
private String password;

View File

@ -49,13 +49,6 @@ public class EmailTemplateController {
return Mono.just(Result.success(pageResult));
}
@Operation(summary = "查询所有邮件模板", description = "查询所有邮件模板")
@GetMapping("getAllEmailTemplates")
public Mono<Result<List<EmailTemplateVo>>> getAllEmailTemplates() {
List<EmailTemplateVo> voList = emailTemplateService.getAllEmailTemplates();
return Mono.just(Result.success(voList));
}
@Operation(summary = "添加邮件模板表", description = "添加邮件模板表")
@PostMapping("addEmailTemplate")
public Mono<Result<String>> addEmailTemplate(@Valid @RequestBody EmailTemplateAddDto dto) {

View File

@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -50,6 +51,13 @@ public class EmailUsersController {
return Mono.just(Result.success(pageResult));
}
@Operation(summary = "获取所有邮箱配置用户", description = "获取所有邮箱配置用户")
@GetMapping("getAllMailboxConfigurationUsers")
public Mono<Result<List<Map<String, String>>>> getAllMailboxConfigurationUsers() {
List<Map<String, String>> list = emailUsersService.getAllMailboxConfigurationUsers();
return Mono.just(Result.success(list));
}
@Operation(summary = "添加邮箱用户发送配置", description = "添加邮箱用户发送配置")
@PostMapping("addEmailUsers")
public Mono<Result<String>> addEmailUsers(@Valid @RequestBody EmailUsersAddDto dto) {

View File

@ -49,11 +49,4 @@ public interface EmailTemplateService extends IService<EmailTemplate> {
* @param ids 删除id列表
*/
void deleteEmailTemplate(List<Long> ids);
/**
* * 查询所有邮件模板
*
* @return 邮箱模板返回内容列表
*/
List<EmailTemplateVo> getAllEmailTemplates();
}

View File

@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.validation.Valid;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -57,4 +58,12 @@ public interface EmailUsersService extends IService<EmailUsers> {
* @param dto 邮箱用户更新状态表单
*/
void updateEmailUserStatus(EmailUserUpdateStatusDto dto);
/**
* * 获取所有邮箱配置用户
*
* @return 邮件用户列表
*/
List<Map<String, String>> getAllMailboxConfigurationUsers();
}

View File

@ -100,21 +100,7 @@ public class EmailTemplateServiceImpl extends ServiceImpl<EmailTemplateMapper, E
public void deleteEmailTemplate(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
baseMapper.deleteBatchIdsWithPhysics(ids);
}
/**
* * 查询所有邮件模板
*
* @return 邮箱模板返回内容列表
*/
@Override
public List<EmailTemplateVo> getAllEmailTemplates() {
return list().stream().map(emailTemplate -> {
EmailTemplateVo emailTemplateVo = new EmailTemplateVo();
BeanUtils.copyProperties(emailTemplate, emailTemplateVo);
return emailTemplateVo;
}).toList();
}
}

View File

@ -22,7 +22,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -71,9 +73,8 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
* @param dto 邮箱用户发送配置添加
*/
@Override
public void addEmailUsers(@Valid EmailUsersAddDto dto) {
public void addEmailUsers(EmailUsersAddDto dto) {
// 判断邮箱是否添加
String email = dto.getEmail();
List<EmailUsers> emailUsersList = list(Wrappers.<EmailUsers>lambdaQuery().eq(EmailUsers::getEmail, dto.getEmail()));
if (!emailUsersList.isEmpty()) throw new BunnyException(ResultCodeEnum.EMAIL_EXIST);
@ -112,7 +113,7 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
public void deleteEmailUsers(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
baseMapper.deleteBatchIdsWithPhysics(ids);
}
@ -130,4 +131,19 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
BeanUtils.copyProperties(dto, emailUsers);
updateById(emailUsers);
}
/**
* * 获取所有邮箱配置用户
*
* @return 邮件用户列表
*/
@Override
public List<Map<String, String>> getAllMailboxConfigurationUsers() {
return list().stream().map(emailUsers -> {
Map<String, String> map = new HashMap<>();
map.put("key", emailUsers.getEmail());
map.put("value", emailUsers.getId().toString());
return map;
}).toList();
}
}

View File

@ -67,7 +67,7 @@ spring:
quartz:
job-store-type: jdbc
jdbc:
initialize-schema: always
initialize-schema: embedded
auto-startup: true
wait-for-jobs-to-complete-on-shutdown: true
overwrite-existing-jobs: false

View File

@ -11,6 +11,7 @@
<id column="update_user" property="updateUser"/>
<id column="is_deleted" property="isDeleted"/>
<id column="template_name" property="templateName"/>
<id column="email_user" property="emailUser"/>
<id column="subject" property="subject"/>
<id column="body" property="body"/>
<id column="type" property="type"/>
@ -19,7 +20,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, create_time, update_time, create_user, update_user, is_deleted, template_name, subject, body, type, is_default
id, create_time, update_time, create_user, update_user, is_deleted, template_name, email_user, subject, body, type, is_default
</sql>
<!-- 分页查询邮件模板表内容 -->

View File

@ -11,7 +11,6 @@
<id column="update_user" property="updateUser"/>
<id column="is_deleted" property="isDeleted"/>
<id column="email" property="email"/>
<id column="email_template" property="emailTemplate"/>
<id column="password" property="password"/>
<id column="host" property="host"/>
<id column="port" property="port"/>
@ -21,7 +20,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, create_time, update_time, create_user, update_user, is_deleted, email, email_template, password, host, port, smtp_agreement, is_default
id, create_time, update_time, create_user, update_user, is_deleted, email, password, host, port, smtp_agreement, is_default
</sql>
<!-- 分页查询邮箱用户发送配置内容 -->