添加独立的邮件发送页面,调整邮件表
This commit is contained in:
parent
1624b00522
commit
5761e42a37
@ -10,12 +10,21 @@ import java.util.Date;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("db_error_verify_mail")
|
@TableName("db_verify_email")
|
||||||
public class VerifyMailError {
|
public class VerifyEmail {
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
Integer id;
|
Integer id;
|
||||||
String email;
|
String email;
|
||||||
String type;
|
String type;
|
||||||
String code;
|
String code;
|
||||||
Date time;
|
Date time;
|
||||||
|
boolean success;
|
||||||
|
|
||||||
|
public static VerifyEmail success() {
|
||||||
|
return new VerifyEmail().setSuccess(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VerifyEmail failure() {
|
||||||
|
return new VerifyEmail().setSuccess(false);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package com.example.listener;
|
package com.example.listener;
|
||||||
|
|
||||||
import com.example.entity.QueueMessage;
|
import com.example.entity.QueueMessage;
|
||||||
import com.example.entity.dto.VerifyMailError;
|
import com.example.entity.dto.VerifyEmail;
|
||||||
import com.example.mapper.VerifyMailErrorMapper;
|
import com.example.mapper.VerifyEmailMapper;
|
||||||
import com.example.utils.Const;
|
import com.example.utils.Const;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -18,14 +18,14 @@ import java.util.Date;
|
|||||||
public class ErrorQueueListener {
|
public class ErrorQueueListener {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
VerifyMailErrorMapper mapper;
|
VerifyEmailMapper mapper;
|
||||||
|
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void saveErrorToDatabase(QueueMessage message) {
|
public void saveErrorToDatabase(QueueMessage message) {
|
||||||
log.error("出现一条错误的队列消息: {}", message);
|
log.error("出现一条错误的队列消息: {}", message);
|
||||||
switch (message.getMessageType()) {
|
switch (message.getMessageType()) {
|
||||||
case "email" -> {
|
case "email" -> {
|
||||||
VerifyMailError error = new VerifyMailError()
|
VerifyEmail error = VerifyEmail.failure()
|
||||||
.setCode(message.get("code").toString())
|
.setCode(message.get("code").toString())
|
||||||
.setType(message.get("type"))
|
.setType(message.get("type"))
|
||||||
.setEmail(message.get("email"))
|
.setEmail(message.get("email"))
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.example.listener;
|
package com.example.listener;
|
||||||
|
|
||||||
import com.example.entity.QueueMessage;
|
import com.example.entity.QueueMessage;
|
||||||
|
import com.example.entity.dto.VerifyEmail;
|
||||||
|
import com.example.mapper.VerifyEmailMapper;
|
||||||
import com.example.utils.Const;
|
import com.example.utils.Const;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -11,6 +13,8 @@ import org.springframework.mail.SimpleMailMessage;
|
|||||||
import org.springframework.mail.javamail.JavaMailSender;
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于处理邮件发送的消息队列监听器
|
* 用于处理邮件发送的消息队列监听器
|
||||||
*/
|
*/
|
||||||
@ -22,6 +26,9 @@ public class MailQueueListener {
|
|||||||
@Resource
|
@Resource
|
||||||
JavaMailSender sender;
|
JavaMailSender sender;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
VerifyEmailMapper emailMapper;
|
||||||
|
|
||||||
@Value("${spring.mail.username}")
|
@Value("${spring.mail.username}")
|
||||||
String username;
|
String username;
|
||||||
|
|
||||||
@ -51,6 +58,12 @@ public class MailQueueListener {
|
|||||||
if(mailMessage == null) return;
|
if(mailMessage == null) return;
|
||||||
log.info("正在向 {} 发送 {} 类型的电子邮件...", email, type);
|
log.info("正在向 {} 发送 {} 类型的电子邮件...", email, type);
|
||||||
sender.send(mailMessage);
|
sender.send(mailMessage);
|
||||||
|
VerifyEmail record = VerifyEmail.success()
|
||||||
|
.setCode(message.get("code").toString())
|
||||||
|
.setType(message.get("type"))
|
||||||
|
.setEmail(message.get("email"))
|
||||||
|
.setTime(new Date());
|
||||||
|
emailMapper.insert(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.example.mapper;
|
package com.example.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.example.entity.dto.VerifyMailError;
|
import com.example.entity.dto.VerifyEmail;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface VerifyMailErrorMapper extends BaseMapper<VerifyMailError> {
|
public interface VerifyEmailMapper extends BaseMapper<VerifyEmail> {
|
||||||
}
|
}
|
@ -69,8 +69,12 @@ const router = createRouter({
|
|||||||
component: () => import('@/views/admin/UserAdmin.vue')
|
component: () => import('@/views/admin/UserAdmin.vue')
|
||||||
}, {
|
}, {
|
||||||
path: 'forum',
|
path: 'forum',
|
||||||
name: 'forum-setting',
|
name: 'admin-forum',
|
||||||
component: () => import('@/views/admin/ForumAdmin.vue')
|
component: () => import('@/views/admin/ForumAdmin.vue')
|
||||||
|
}, {
|
||||||
|
path: 'email',
|
||||||
|
name: 'admin-email',
|
||||||
|
component: () => import('@/views/admin/EmailAdmin.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
DataLine,
|
DataLine,
|
||||||
Document,
|
Document,
|
||||||
Files,
|
Files,
|
||||||
Location,
|
Location, Message,
|
||||||
Monitor, Notification, Position, School,
|
Monitor, Notification, Position, School,
|
||||||
Umbrella,
|
Umbrella,
|
||||||
User
|
User
|
||||||
@ -19,6 +19,7 @@ const adminMenu = [
|
|||||||
{
|
{
|
||||||
title: '校园论坛管理', icon: Location, sub: [
|
title: '校园论坛管理', icon: Location, sub: [
|
||||||
{title: '用户管理', icon: User, index: '/admin/user' },
|
{title: '用户管理', icon: User, index: '/admin/user' },
|
||||||
|
{title: '邮件发信管理', icon: Message, index: '/admin/email' },
|
||||||
{title: '帖子广场管理', icon: ChatDotSquare, index: '/admin/forum' },
|
{title: '帖子广场管理', icon: ChatDotSquare, index: '/admin/forum' },
|
||||||
{title: '失物招领管理', icon: Bell},
|
{title: '失物招领管理', icon: Bell},
|
||||||
{title: '校园活动管理', icon: Notification},
|
{title: '校园活动管理', icon: Notification},
|
||||||
|
32
my-project-frontend/src/views/admin/EmailAdmin.vue
Normal file
32
my-project-frontend/src/views/admin/EmailAdmin.vue
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<script setup>
|
||||||
|
import {Message} from "@element-plus/icons-vue";
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="email-admin">
|
||||||
|
<div class="title">
|
||||||
|
<el-icon><Message/></el-icon>
|
||||||
|
邮件发信列表
|
||||||
|
</div>
|
||||||
|
<div class="desc">在这里查看所有发送的电子邮件列表,失败邮件可以选择重新发送</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.email-admin {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desc {
|
||||||
|
color: #bababa;
|
||||||
|
font-size: 13px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -40,7 +40,7 @@ watchEffect(() => apiUserList(userTable.page, userTable.size, data => {
|
|||||||
论坛用户列表
|
论坛用户列表
|
||||||
</div>
|
</div>
|
||||||
<div class="desc">在这里管理论坛的所有用户,包括账号信息、封禁和禁言</div>
|
<div class="desc">在这里管理论坛的所有用户,包括账号信息、封禁和禁言</div>
|
||||||
<el-table :data="userTable.data" style="width: 100%" height="320">
|
<el-table :data="userTable.data" style="width: 100%;flex: 1">
|
||||||
<el-table-column prop="id" label="编号" width="80" />
|
<el-table-column prop="id" label="编号" width="80" />
|
||||||
<el-table-column label="用户名" width="180">
|
<el-table-column label="用户名" width="180">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
@ -88,6 +88,9 @@ watchEffect(() => apiUserList(userTable.page, userTable.size, data => {
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.user-admin {
|
.user-admin {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user