parent
51c7fe7358
commit
dfc3db10e9
@ -0,0 +1,41 @@
|
|||||||
|
package com.xjs.business.log.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件日志实体类
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MailLog implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键id */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 邮件标题 */
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/** 邮件内容 */
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/** 收件人 */
|
||||||
|
private String recipient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件类型
|
||||||
|
*/
|
||||||
|
private String mailType;
|
||||||
|
|
||||||
|
/** 请求时间 */
|
||||||
|
private Long requestTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
|
||||||
|
// 查询邮件日志列表
|
||||||
|
export function listMaillog(query) {
|
||||||
|
return request({
|
||||||
|
url: '/log/maillog/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询邮件日志详细
|
||||||
|
export function getMaillog(id) {
|
||||||
|
return request({
|
||||||
|
url: '/log/maillog/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除邮件日志
|
||||||
|
export function delMaillog(id) {
|
||||||
|
return request({
|
||||||
|
url: '/log/maillog/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,253 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="邮件主题" prop="title">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.title"
|
||||||
|
placeholder="请输入邮件主题"
|
||||||
|
clearable
|
||||||
|
maxlength="20"
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="邮件内容" prop="content">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.content"
|
||||||
|
placeholder="请输入邮件内容"
|
||||||
|
clearable
|
||||||
|
maxlength="20"
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="收件人" prop="recipient">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.recipient"
|
||||||
|
placeholder="请输入收件人"
|
||||||
|
clearable
|
||||||
|
maxlength="20"
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="daterangeCreateTime"
|
||||||
|
size="small"
|
||||||
|
:picker-options="pickerOptions"
|
||||||
|
style="width: 240px"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
type="daterange"
|
||||||
|
@change="dateQuery('queryForm')"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['log:maillog:remove']"
|
||||||
|
>删除
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['log:maillog:export']"
|
||||||
|
>导出
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="maillogList" @selection-change="handleSelectionChange" border>
|
||||||
|
<el-table-column type="selection" width="55" align="center"/>
|
||||||
|
<el-table-column label="邮件主题" align="center" prop="title" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="邮件内容" align="center" prop="content" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="收件人" align="center" prop="recipient" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="邮件类型" align="center" prop="mailType" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="请求时间" align="center" prop="requestTime">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{
|
||||||
|
scope.row.requestTime < 1000
|
||||||
|
?
|
||||||
|
scope.row.requestTime + '毫秒'
|
||||||
|
:
|
||||||
|
Math.round(scope.row.requestTime / 1000) + '秒'
|
||||||
|
}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" :show-overflow-tooltip="true"/>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['log:maillog:remove']"
|
||||||
|
>删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {listMaillog, delMaillog,} from "@/api/business/log/maillog";
|
||||||
|
import {pickerOptions} from "@/layout/mixin/PickerOptions";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [pickerOptions],
|
||||||
|
name: "Maillog",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 邮件日志表格数据
|
||||||
|
maillogList: [],
|
||||||
|
// 创建时间时间范围
|
||||||
|
daterangeCreateTime: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
title: null,
|
||||||
|
content: null,
|
||||||
|
recipient: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询邮件日志列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
if (null != this.daterangeCreateTime && '' !== this.daterangeCreateTime) {
|
||||||
|
this.queryParams.createTime = this.daterangeCreateTime[0];
|
||||||
|
this.queryParams.endCreateTime = this.daterangeCreateTime[1];
|
||||||
|
}
|
||||||
|
listMaillog(this.queryParams).then(response => {
|
||||||
|
this.maillogList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
|
||||||
|
dateQuery(formName) {
|
||||||
|
//清空时间参数
|
||||||
|
this.queryParams.createTime=null
|
||||||
|
this.queryParams.endCreateTime=null
|
||||||
|
|
||||||
|
this.handleQuery(formName);
|
||||||
|
},
|
||||||
|
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: null,
|
||||||
|
title: null,
|
||||||
|
content: null,
|
||||||
|
recipient: null,
|
||||||
|
mailType: null,
|
||||||
|
requestTime: null,
|
||||||
|
createTime: null
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$modal.confirm('是否确认删除邮件日志编号为"' + ids + '"的数据项?').then(function () {
|
||||||
|
return delMaillog(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
this.download('log/maillog/export', {
|
||||||
|
...this.queryParams
|
||||||
|
}, `maillog_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.xjs.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义邮件日志注解
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-13
|
||||||
|
*/
|
||||||
|
@Target({ ElementType.PARAMETER, ElementType.METHOD })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface MailLog {
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package com.xjs.maillog.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.xjs.maillog.domain.MailLog;
|
||||||
|
import com.xjs.maillog.service.MailLogService;
|
||||||
|
import com.xjs.validation.group.SelectGroup;
|
||||||
|
import com.xjs.web.MyBaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件日志Controller
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-14
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/maillog")
|
||||||
|
@Api(tags = "业务模块-邮件日志")
|
||||||
|
@Transactional
|
||||||
|
public class MailLogController extends MyBaseController<MailLog> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MailLogService mailLogService;
|
||||||
|
|
||||||
|
//---------------------------远程调用-----------------------------------
|
||||||
|
|
||||||
|
@PostMapping("saveForRPC")
|
||||||
|
@ApiOperation("保存邮件日志ForRPC")
|
||||||
|
public R<Object> saveMailLog(@RequestBody MailLog mailLog) {
|
||||||
|
boolean save = mailLogService.save(mailLog);
|
||||||
|
return save ? R.ok() : R.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------代码生成-----------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮件日志列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("log:maillog:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
@ApiOperation("查询邮件日志列表")
|
||||||
|
public TableDataInfo list(@Validated({SelectGroup.class}) MailLog mailLog) {
|
||||||
|
startPage();
|
||||||
|
List<MailLog> list = mailLogService.selectMailLogList(mailLog);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出邮件日志列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("log:maillog:export")
|
||||||
|
@Log(title = "邮件日志", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
@ApiOperation("导出邮件日志列表")
|
||||||
|
public void export(HttpServletResponse response, MailLog mailLog) {
|
||||||
|
List<MailLog> list = mailLogService.selectMailLogList(mailLog);
|
||||||
|
ExcelUtil<MailLog> util = new ExcelUtil<MailLog>(MailLog.class);
|
||||||
|
util.exportExcel(response, list, "邮件日志数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取邮件日志详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("log:maillog:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
@ApiOperation("获取邮件日志详细信息")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
|
return AjaxResult.success(mailLogService.selectMailLogById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除邮件日志
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("log:maillog:remove")
|
||||||
|
@Log(title = "邮件日志", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
@ApiOperation("删除邮件日志")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
|
return toAjax(mailLogService.deleteMailLogByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.xjs.maillog.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xjs.maillog.domain.MailLog;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件日志Mapper接口
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-14
|
||||||
|
*/
|
||||||
|
public interface MailLogMapper extends BaseMapper<MailLog> {
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------代码生成-----------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮件日志
|
||||||
|
*
|
||||||
|
* @param id 邮件日志主键
|
||||||
|
* @return 邮件日志
|
||||||
|
*/
|
||||||
|
public MailLog selectMailLogById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮件日志列表
|
||||||
|
*
|
||||||
|
* @param mailLog 邮件日志
|
||||||
|
* @return 邮件日志集合
|
||||||
|
*/
|
||||||
|
public List<MailLog> selectMailLogList(MailLog mailLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除邮件日志
|
||||||
|
*
|
||||||
|
* @param id 邮件日志主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteMailLogById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除邮件日志
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteMailLogByIds(Long[] ids);
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.xjs.maillog.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.xjs.maillog.domain.MailLog;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件日志Service接口
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-14
|
||||||
|
*/
|
||||||
|
public interface MailLogService extends IService<MailLog> {
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------代码生成-----------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮件日志
|
||||||
|
*
|
||||||
|
* @param id 邮件日志主键
|
||||||
|
* @return 邮件日志
|
||||||
|
*/
|
||||||
|
MailLog selectMailLogById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮件日志列表
|
||||||
|
*
|
||||||
|
* @param mailLog 邮件日志
|
||||||
|
* @return 邮件日志集合
|
||||||
|
*/
|
||||||
|
List<MailLog> selectMailLogList(MailLog mailLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除邮件日志
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的邮件日志主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteMailLogByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除邮件日志信息
|
||||||
|
*
|
||||||
|
* @param id 邮件日志主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteMailLogById(Long id);
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package com.xjs.maillog.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.xjs.maillog.domain.MailLog;
|
||||||
|
import com.xjs.maillog.mapper.MailLogMapper;
|
||||||
|
import com.xjs.maillog.service.MailLogService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件日志Service业务层处理
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-14
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MailLogServiceImpl extends ServiceImpl<MailLogMapper,MailLog> implements MailLogService {
|
||||||
|
@Resource
|
||||||
|
private MailLogMapper mailLogMapper;
|
||||||
|
|
||||||
|
//---------------------------代码生成-----------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮件日志
|
||||||
|
*
|
||||||
|
* @param id 邮件日志主键
|
||||||
|
* @return 邮件日志
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MailLog selectMailLogById(Long id) {
|
||||||
|
return mailLogMapper.selectMailLogById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮件日志列表
|
||||||
|
*
|
||||||
|
* @param mailLog 邮件日志
|
||||||
|
* @return 邮件日志
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MailLog> selectMailLogList(MailLog mailLog) {
|
||||||
|
return mailLogMapper.selectMailLogList(mailLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除邮件日志
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的邮件日志主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteMailLogByIds(Long[] ids) {
|
||||||
|
return mailLogMapper.deleteMailLogByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除邮件日志信息
|
||||||
|
*
|
||||||
|
* @param id 邮件日志主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteMailLogById(Long id) {
|
||||||
|
return mailLogMapper.deleteMailLogById(id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
<?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.xjs.maillog.mapper.MailLogMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.xjs.maillog.domain.MailLog" id="MailLogResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="title" column="title" />
|
||||||
|
<result property="content" column="content" />
|
||||||
|
<result property="recipient" column="recipient" />
|
||||||
|
<result property="mailType" column="mail_type" />
|
||||||
|
<result property="requestTime" column="request_time" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectMailLogVo">
|
||||||
|
select id, title, content, recipient, mail_type, request_time, create_time from mail_log
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectMailLogList" parameterType="com.xjs.maillog.domain.MailLog" resultMap="MailLogResult">
|
||||||
|
<include refid="selectMailLogVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
|
||||||
|
<if test="content != null and content != ''"> and content like concat('%', #{content}, '%')</if>
|
||||||
|
<if test="recipient != null and recipient != ''"> and recipient like concat('%', #{recipient}, '%')</if>
|
||||||
|
<if test="createTime != null and endCreateTime != null"> and create_time between #{createTime} and #{endCreateTime}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectMailLogById" parameterType="Long" resultMap="MailLogResult">
|
||||||
|
<include refid="selectMailLogVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteMailLogById" parameterType="Long">
|
||||||
|
delete from mail_log where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteMailLogByIds" parameterType="String">
|
||||||
|
delete from mail_log where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.xjs.aop;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.xjs.business.log.RemoteLogFeign;
|
||||||
|
import com.xjs.business.log.domain.MailLog;
|
||||||
|
import com.xjs.domain.mall.MailBean;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件日志切面类
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-13
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Aspect
|
||||||
|
@Log4j2
|
||||||
|
public class MailLogAspect {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteLogFeign remoteLogFeign;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 声明AOP签名
|
||||||
|
*/
|
||||||
|
@Pointcut("@annotation(com.xjs.annotation.MailLog)")
|
||||||
|
public void pointcut() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Around("pointcut()")
|
||||||
|
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
|
//记录时间
|
||||||
|
LocalDateTime localDateTime1 = DateUtil.date().toLocalDateTime();
|
||||||
|
Object obj = joinPoint.proceed();
|
||||||
|
LocalDateTime localDateTime2 = DateUtil.date().toLocalDateTime();
|
||||||
|
long between = ChronoUnit.MILLIS.between(localDateTime1, localDateTime2);
|
||||||
|
|
||||||
|
//获取形参
|
||||||
|
Object[] args = joinPoint.getArgs();
|
||||||
|
for (Object arg : args) {
|
||||||
|
if (arg instanceof MailBean) {
|
||||||
|
MailBean mailBean = (MailBean) arg;
|
||||||
|
|
||||||
|
//构建对象
|
||||||
|
MailLog mailLog = new MailLog();
|
||||||
|
mailLog.setMailType(mailBean.getMailType().getMsg());
|
||||||
|
mailLog.setContent(mailBean.getContent());
|
||||||
|
mailLog.setTitle(mailBean.getSubject());
|
||||||
|
mailLog.setRecipient(mailBean.getRecipient());
|
||||||
|
mailLog.setRequestTime(between);
|
||||||
|
|
||||||
|
remoteLogFeign.saveMailLog(mailLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue