feat: 获取所有邮件模板内容,修复路由添加和更新问题
This commit is contained in:
parent
31b9bd8cb3
commit
3fa7ed2043
|
@ -16,9 +16,6 @@ public class EmailUsersDto {
|
|||
@Schema(name = "email", title = "邮箱")
|
||||
private String email;
|
||||
|
||||
@Schema(name = "emailTemplate", title = "使用邮件模板")
|
||||
private Long emailTemplate;
|
||||
|
||||
@Schema(name = "host", title = "Host地址")
|
||||
private String host;
|
||||
|
||||
|
|
|
@ -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.*;
|
||||
|
||||
|
@ -16,6 +19,8 @@ public class EmailUsersVo extends BaseVo {
|
|||
private String email;
|
||||
|
||||
@Schema(name = "emailTemplate", title = "使用邮件模板")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||
private Long emailTemplate;
|
||||
|
||||
@Schema(name = "password", title = "密码")
|
||||
|
|
|
@ -49,6 +49,13 @@ 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) {
|
||||
|
|
|
@ -82,7 +82,7 @@ public class WebSecurityConfig {
|
|||
String[] annotations = {
|
||||
"/", "/ws/**",
|
||||
"/*/*/noAuth/**", "/*/noAuth/**", "/noAuth/**",
|
||||
"/media.ico", "/favicon.ico", "*.html", "/webjars/**", "/v3/api-docs/**",
|
||||
"/media.ico", "/favicon.ico", "*.html", "/webjars/**", "/v3/api-docs/**", "swagger-ui/**",
|
||||
"/error", "/*/i18n/getI18n",
|
||||
};
|
||||
return web -> web.ignoring().requestMatchers(annotations)
|
||||
|
|
|
@ -49,4 +49,11 @@ public interface EmailTemplateService extends IService<EmailTemplate> {
|
|||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteEmailTemplate(List<Long> ids);
|
||||
|
||||
/**
|
||||
* * 查询所有邮件模板
|
||||
*
|
||||
* @return 邮箱模板返回内容列表
|
||||
*/
|
||||
List<EmailTemplateVo> getAllEmailTemplates();
|
||||
}
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
package cn.bunny.services.service.impl;
|
||||
|
||||
import cn.bunny.common.service.exception.BunnyException;
|
||||
import cn.bunny.dao.dto.system.email.EmailTemplateAddDto;
|
||||
import cn.bunny.dao.dto.system.email.EmailTemplateDto;
|
||||
import cn.bunny.dao.dto.system.email.EmailTemplateUpdateDto;
|
||||
import cn.bunny.dao.entity.system.EmailTemplate;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.system.email.EmailTemplateVo;
|
||||
import cn.bunny.services.mapper.EmailTemplateMapper;
|
||||
import cn.bunny.services.service.EmailTemplateService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.validation.Valid;
|
||||
|
@ -61,6 +64,10 @@ public class EmailTemplateServiceImpl extends ServiceImpl<EmailTemplateMapper, E
|
|||
*/
|
||||
@Override
|
||||
public void addEmailTemplate(@Valid EmailTemplateAddDto dto) {
|
||||
// 查询是否添加过这个模板
|
||||
List<EmailTemplate> emailTemplateList = list(Wrappers.<EmailTemplate>lambdaQuery().eq(EmailTemplate::getTemplateName, dto.getTemplateName()));
|
||||
if (!emailTemplateList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_EXIST);
|
||||
|
||||
// 保存数据
|
||||
EmailTemplate emailTemplate = new EmailTemplate();
|
||||
BeanUtils.copyProperties(dto, emailTemplate);
|
||||
|
@ -74,6 +81,10 @@ public class EmailTemplateServiceImpl extends ServiceImpl<EmailTemplateMapper, E
|
|||
*/
|
||||
@Override
|
||||
public void updateEmailTemplate(@Valid EmailTemplateUpdateDto dto) {
|
||||
// 查询是否有这个模板
|
||||
List<EmailTemplate> emailTemplateList = list(Wrappers.<EmailTemplate>lambdaQuery().eq(EmailTemplate::getId, dto.getId()));
|
||||
if (emailTemplateList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
|
||||
|
||||
// 更新内容
|
||||
EmailTemplate emailTemplate = new EmailTemplate();
|
||||
BeanUtils.copyProperties(dto, emailTemplate);
|
||||
|
@ -89,4 +100,18 @@ public class EmailTemplateServiceImpl extends ServiceImpl<EmailTemplateMapper, E
|
|||
public void deleteEmailTemplate(List<Long> ids) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,11 +129,14 @@ public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> impleme
|
|||
IPage<Router> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
// 构建返回对象
|
||||
List<RouterManageVo> voList = page.getRecords().stream().map(router -> {
|
||||
List<RouterManageVo> voList = page.getRecords().stream()
|
||||
.map(router -> {
|
||||
RouterManageVo routerManageVo = new RouterManageVo();
|
||||
BeanUtils.copyProperties(router, routerManageVo);
|
||||
return routerManageVo;
|
||||
}).toList();
|
||||
})
|
||||
.sorted(Comparator.comparing(RouterManageVo::getRouterRank))
|
||||
.toList();
|
||||
|
||||
return PageResult.<RouterManageVo>builder()
|
||||
.list(voList)
|
||||
|
@ -154,11 +157,14 @@ public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> impleme
|
|||
lambdaQueryWrapper.like(StringUtils.hasText(dto.getTitle()), Router::getTitle, dto.getTitle());
|
||||
lambdaQueryWrapper.eq(dto.getVisible() != null, Router::getVisible, dto.getVisible());
|
||||
|
||||
return list(lambdaQueryWrapper).stream().map(router -> {
|
||||
return list(lambdaQueryWrapper).stream()
|
||||
.map(router -> {
|
||||
RouterManageVo routerManageVo = new RouterManageVo();
|
||||
BeanUtils.copyProperties(router, routerManageVo);
|
||||
return routerManageVo;
|
||||
}).toList();
|
||||
})
|
||||
.sorted(Comparator.comparing(RouterManageVo::getRouterRank))
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,8 +175,7 @@ public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> impleme
|
|||
@Override
|
||||
public void addMenu(RouterAddDto dto) {
|
||||
// 查找是否添加过路由名称
|
||||
String routeName = dto.getRouteName();
|
||||
Router router = getOne(Wrappers.<Router>lambdaQuery().eq(Router::getRouteName, routeName));
|
||||
Router router = getOne(Wrappers.<Router>lambdaQuery().eq(Router::getPath, dto.getPath()));
|
||||
if (router != null) throw new BunnyException(ResultCodeEnum.DATA_EXIST);
|
||||
|
||||
// 添加路由
|
||||
|
@ -187,9 +192,12 @@ public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> impleme
|
|||
*/
|
||||
@Override
|
||||
public void updateMenu(RouterUpdateDto dto) {
|
||||
Long id = dto.getId();
|
||||
Router router = getOne(Wrappers.<Router>lambdaQuery().eq(Router::getId, id));
|
||||
Router router = getOne(Wrappers.<Router>lambdaQuery().eq(Router::getId, dto.getId()));
|
||||
|
||||
// 判断更新数据是否存在
|
||||
if (router == null) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
|
||||
|
||||
// 判断更新数据id和父级id是否重复
|
||||
if (dto.getId().equals(dto.getParentId())) throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
|
||||
|
||||
router = new Router();
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
<if test="dto.email != null and dto.email != ''">
|
||||
and email like CONCAT('%',#{dto.email},'%')
|
||||
</if>
|
||||
<if test="dto.emailTemplate != null and dto.emailTemplate != ''">
|
||||
and email_template like CONCAT('%',#{dto.emailTemplate},'%')
|
||||
</if>
|
||||
<if test="dto.host != null and dto.host != ''">
|
||||
and host like CONCAT('%',#{dto.host},'%')
|
||||
</if>
|
||||
|
|
|
@ -76,6 +76,5 @@
|
|||
and visible = #{dto.visible}
|
||||
</if>
|
||||
</where>
|
||||
order by router_rank
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue