mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
邮箱模块:vue3 邮件日志的管理
This commit is contained in:
parent
86a884e3d2
commit
28ba9a7456
@ -5,14 +5,19 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateRespVO;
|
||||
import cn.iocoder.yudao.module.system.convert.mail.MailLogConvert;
|
||||
import cn.iocoder.yudao.module.system.convert.mail.MailTemplateConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.service.mail.MailLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -37,4 +42,13 @@ public class MailLogController {
|
||||
return success(MailLogConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得邮箱日志")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('system:mail-log:query')")
|
||||
public CommonResult<MailLogRespVO> getMailTemplate(@RequestParam("id") Long id) {
|
||||
MailLogDO mailLogDO = mailLogService.getMailLog(id);
|
||||
return success(MailLogConvert.INSTANCE.convert(mailLogDO));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,6 @@ public interface MailLogConvert {
|
||||
|
||||
PageResult<MailLogRespVO> convertPage(PageResult<MailLogDO> pageResult);
|
||||
|
||||
MailLogRespVO convert(MailLogDO bean);
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,14 @@ public interface MailLogService {
|
||||
*/
|
||||
PageResult<MailLogDO> getMailLogPage(MailLogPageReqVO pageVO);
|
||||
|
||||
/**
|
||||
* 获得指定编号的邮件日志
|
||||
*
|
||||
* @param id 日志编号
|
||||
* @return 邮件日志
|
||||
*/
|
||||
MailLogDO getMailLog(Long id);
|
||||
|
||||
/**
|
||||
* 创建邮件日志
|
||||
*
|
||||
|
@ -35,6 +35,11 @@ public class MailLogServiceImpl implements MailLogService {
|
||||
return mailLogMapper.selectPage(pageVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MailLogDO getMailLog(Long id) {
|
||||
return mailLogMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createMailLog(Long userId, Integer userType, String toMail,
|
||||
MailAccountDO account, MailTemplateDO template,
|
||||
|
40
yudao-ui-admin-vue3/src/api/system/mail/log/index.ts
Normal file
40
yudao-ui-admin-vue3/src/api/system/mail/log/index.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
export interface MailLogVO {
|
||||
id: number
|
||||
userId: number
|
||||
userType: number
|
||||
toMail: string
|
||||
accountId: number
|
||||
fromMail: string
|
||||
templateId: number
|
||||
templateCode: string
|
||||
templateNickname: string
|
||||
templateTitle: string
|
||||
templateContent: string
|
||||
templateParams: string
|
||||
sendStatus: number
|
||||
sendTime: Date
|
||||
sendMessageId: string
|
||||
sendException: string
|
||||
}
|
||||
|
||||
export interface MailLogPageReqVO extends PageParam {
|
||||
userId?: number
|
||||
userType?: number
|
||||
toMail?: string
|
||||
accountId?: number
|
||||
templateId?: number
|
||||
sendStatus?: number
|
||||
sendTime?: Date[]
|
||||
}
|
||||
|
||||
// 查询邮件日志列表
|
||||
export const getMailLogPageApi = async (params: MailLogPageReqVO) => {
|
||||
return await request.get({ url: '/system/mail-log/page', params })
|
||||
}
|
||||
|
||||
// 查询邮件日志详情
|
||||
export const getMailLogApi = async (id: number) => {
|
||||
return await request.get({ url: '/system/mail-log/get?id=' + id })
|
||||
}
|
@ -90,6 +90,7 @@ export enum DICT_TYPE {
|
||||
SYSTEM_SMS_RECEIVE_STATUS = 'system_sms_receive_status',
|
||||
SYSTEM_ERROR_CODE_TYPE = 'system_error_code_type',
|
||||
SYSTEM_OAUTH2_GRANT_TYPE = 'system_oauth2_grant_type',
|
||||
SYSTEM_MAIL_SEND_STATUS = 'system_mail_send_status',
|
||||
|
||||
// ========== INFRA 模块 ==========
|
||||
INFRA_BOOLEAN_STRING = 'infra_boolean_string',
|
||||
|
96
yudao-ui-admin-vue3/src/views/system/mail/log/index.vue
Normal file
96
yudao-ui-admin-vue3/src/views/system/mail/log/index.vue
Normal file
@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 列表 -->
|
||||
<XTable @register="registerTable">
|
||||
<template #accountId_search>
|
||||
<el-select v-model="queryParams.accountId">
|
||||
<el-option :key="undefined" label="全部" :value="undefined" />
|
||||
<el-option
|
||||
v-for="item in accountOptions"
|
||||
:key="item.id"
|
||||
:label="item.mail"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
<template #toMail_default="{ row }">
|
||||
<div>{{ row.toMail }}</div>
|
||||
<div v-if="row.userType && row.userId">
|
||||
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="row.userType" />{{ '(' + row.userId + ')' }}
|
||||
</div>
|
||||
</template>
|
||||
<template #actionbtns_default="{ row }">
|
||||
<!-- 操作:详情 -->
|
||||
<XTextButton
|
||||
preIcon="ep:view"
|
||||
:title="t('action.detail')"
|
||||
v-hasPermi="['system:mail-log:query']"
|
||||
@click="handleDetail(row.id)"
|
||||
/>
|
||||
</template>
|
||||
</XTable>
|
||||
</ContentWrap>
|
||||
<!-- 弹窗 -->
|
||||
<XModal id="mailLogModel" :loading="modelLoading" v-model="modelVisible" :title="modelTitle">
|
||||
<!-- 表单:详情 -->
|
||||
<Descriptions
|
||||
v-if="actionType === 'detail'"
|
||||
:schema="allSchemas.detailSchema"
|
||||
:data="detailData"
|
||||
/>
|
||||
<template #footer>
|
||||
<!-- 按钮:关闭 -->
|
||||
<XButton :loading="actionLoading" :title="t('dialog.close')" @click="modelVisible = false" />
|
||||
</template>
|
||||
</XModal>
|
||||
</template>
|
||||
<script setup lang="ts" name="MailLog">
|
||||
// 业务相关的 import
|
||||
import { allSchemas } from './log.data'
|
||||
import * as MailLogApi from '@/api/system/mail/log'
|
||||
import * as MailAccountApi from '@/api/system/mail/account'
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
// 列表相关的变量
|
||||
const queryParams = reactive({
|
||||
accountId: null
|
||||
})
|
||||
const [registerTable] = useXTable({
|
||||
allSchemas: allSchemas,
|
||||
params: queryParams,
|
||||
getListApi: MailLogApi.getMailLogPageApi
|
||||
})
|
||||
const accountOptions = ref([]) // 账号下拉选项
|
||||
|
||||
// 弹窗相关的变量
|
||||
const modelVisible = ref(false) // 是否显示弹出层
|
||||
const modelTitle = ref('edit') // 弹出层标题
|
||||
const modelLoading = ref(false) // 弹出层loading
|
||||
const actionType = ref('') // 操作按钮的类型
|
||||
const actionLoading = ref(false) // 按钮 Loading
|
||||
const detailData = ref() // 详情 Ref
|
||||
|
||||
// 设置标题
|
||||
const setDialogTile = (type: string) => {
|
||||
modelLoading.value = true
|
||||
modelTitle.value = t('action.' + type)
|
||||
actionType.value = type
|
||||
modelVisible.value = true
|
||||
}
|
||||
|
||||
// 详情操作
|
||||
const handleDetail = async (rowId: number) => {
|
||||
setDialogTile('detail')
|
||||
const res = await MailLogApi.getMailLogApi(rowId)
|
||||
detailData.value = res
|
||||
modelLoading.value = false
|
||||
}
|
||||
|
||||
// ========== 初始化 ==========
|
||||
onMounted(() => {
|
||||
MailAccountApi.getSimpleMailAccounts().then((data) => {
|
||||
accountOptions.value = data
|
||||
})
|
||||
})
|
||||
</script>
|
121
yudao-ui-admin-vue3/src/views/system/mail/log/log.data.ts
Normal file
121
yudao-ui-admin-vue3/src/views/system/mail/log/log.data.ts
Normal file
@ -0,0 +1,121 @@
|
||||
import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
|
||||
|
||||
// CrudSchema
|
||||
const crudSchemas = reactive<VxeCrudSchema>({
|
||||
primaryKey: 'id',
|
||||
primaryTitle: '编号',
|
||||
primaryType: 'id',
|
||||
action: true,
|
||||
actionWidth: '70',
|
||||
columns: [
|
||||
{
|
||||
title: '发送时间',
|
||||
field: 'sendTime',
|
||||
table: {
|
||||
width: 180
|
||||
},
|
||||
formatter: 'formatDate',
|
||||
search: {
|
||||
show: true,
|
||||
itemRender: {
|
||||
name: 'XDataTimePicker'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '接收邮箱',
|
||||
field: 'toMail',
|
||||
isSearch: true,
|
||||
table: {
|
||||
width: 180,
|
||||
slots: {
|
||||
default: 'toMail_default'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '用户编号',
|
||||
field: 'userId',
|
||||
isSearch: true,
|
||||
isTable: false
|
||||
},
|
||||
{
|
||||
title: '用户类型',
|
||||
field: 'userType',
|
||||
dictType: DICT_TYPE.USER_TYPE,
|
||||
dictClass: 'number',
|
||||
isSearch: true,
|
||||
isTable: false
|
||||
},
|
||||
{
|
||||
title: '邮件标题',
|
||||
field: 'templateTitle'
|
||||
},
|
||||
{
|
||||
title: '邮件内容',
|
||||
field: 'templateContent',
|
||||
isTable: false
|
||||
},
|
||||
{
|
||||
title: '邮箱参数',
|
||||
field: 'templateParams',
|
||||
isTable: false
|
||||
},
|
||||
{
|
||||
title: '发送状态',
|
||||
field: 'sendStatus',
|
||||
dictType: DICT_TYPE.SYSTEM_MAIL_SEND_STATUS,
|
||||
dictClass: 'string',
|
||||
isSearch: true
|
||||
},
|
||||
{
|
||||
title: '邮箱账号',
|
||||
field: 'accountId',
|
||||
isSearch: true,
|
||||
isTable: false,
|
||||
search: {
|
||||
slots: {
|
||||
default: 'accountId_search'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '发送邮箱地址',
|
||||
field: 'fromMail',
|
||||
table: {
|
||||
title: '邮箱账号'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '模板编号',
|
||||
field: 'templateId',
|
||||
isSearch: true
|
||||
},
|
||||
{
|
||||
title: '模板编码',
|
||||
field: 'templateCode',
|
||||
isTable: false
|
||||
},
|
||||
{
|
||||
title: '模版发送人名称',
|
||||
field: 'templateNickname',
|
||||
isTable: false
|
||||
},
|
||||
{
|
||||
title: '发送返回的消息编号',
|
||||
field: 'sendMessageId',
|
||||
isTable: false
|
||||
},
|
||||
{
|
||||
title: '发送异常',
|
||||
field: 'sendException',
|
||||
isTable: false
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
field: 'createTime',
|
||||
isTable: false
|
||||
}
|
||||
]
|
||||
})
|
||||
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
|
Loading…
Reference in New Issue
Block a user