mirror of https://gitee.com/xiaonuobase/snowy
【更新】日志增加导出,去掉前端大量调用字典翻译接口
parent
3241cee232
commit
1cea64a89a
|
@ -55,3 +55,33 @@ export function sysOpLogDelete (parameter) {
|
|||
data: parameter
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出登录日志
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2021/5/30 18:03
|
||||
*/
|
||||
export function sysVisLogExport (parameter) {
|
||||
return axios({
|
||||
url: '/sysVisLog/export',
|
||||
method: 'get',
|
||||
params: parameter,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出操作日志
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2021/5/30 18:03
|
||||
*/
|
||||
export function sysOpLogExport (parameter) {
|
||||
return axios({
|
||||
url: '/sysOpLog/export',
|
||||
method: 'get',
|
||||
params: parameter,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<a-col :md="8" :sm="24">
|
||||
<a-form-item label="操作类型">
|
||||
<a-select v-model="queryParam.opType" allow-clear placeholder="请选择操作类型" >
|
||||
<a-select-option v-for="(item,index) in opTypeDict" :key="index" :value="item.code" >{{ item.value }}</a-select-option>
|
||||
<a-select-option v-for="(item,index) in opTypeDict" :key="index" :value="item.code" >{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
@ -20,7 +20,7 @@
|
|||
<a-col :md="8" :sm="24">
|
||||
<a-form-item label="是否成功">
|
||||
<a-select v-model="queryParam.success" placeholder="请选择是否成功" >
|
||||
<a-select-option v-for="(item,index) in successDict" :key="index" :value="item.code" >{{ item.value }}</a-select-option>
|
||||
<a-select-option v-for="(item,index) in successDict" :key="index" :value="item.code" >{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
@ -56,20 +56,24 @@
|
|||
ref="table"
|
||||
:columns="columns"
|
||||
:data="loadData"
|
||||
:alert="true"
|
||||
:alert="false"
|
||||
:rowKey="(record) => record.id"
|
||||
:rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
||||
>
|
||||
<template slot="operator" v-if="hasPerm('sysOpLog:delete')">
|
||||
<a-popconfirm @confirm="() => sysOpLogDelete()" placement="top" title="确认清空日志?">
|
||||
<a-button >清空日志</a-button>
|
||||
<template slot="operator">
|
||||
<a-popconfirm v-if="hasPerm('sysOpLog:delete')" @confirm="() => sysOpLogDelete()" placement="top" title="确认清空日志?">
|
||||
<a-button type="danger" ghost>清空日志</a-button>
|
||||
</a-popconfirm>
|
||||
<x-down
|
||||
v-if="hasPerm('sysOpLog:export')"
|
||||
ref="batchExport"
|
||||
@batchExport="batchExport"
|
||||
/>
|
||||
</template>
|
||||
<span slot="opType" slot-scope="text">
|
||||
{{ opTypeFilter(text) }}
|
||||
{{ 'op_type' | dictType(text) }}
|
||||
</span>
|
||||
<span slot="success" slot-scope="text">
|
||||
{{ successFilter(text) }}
|
||||
{{ 'yes_or_no' | dictType(text) }}
|
||||
</span>
|
||||
<span slot="name" slot-scope="text">
|
||||
<ellipsis :length="10" tooltip>{{ text }}</ellipsis>
|
||||
|
@ -91,13 +95,14 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { STable, Ellipsis, XCard } from '@/components'
|
||||
import { sysOpLogPage, sysOpLogDelete } from '@/api/modular/system/logManage'
|
||||
import { STable, Ellipsis, XCard, XDown } from '@/components'
|
||||
import { sysOpLogPage, sysOpLogDelete, sysOpLogExport } from '@/api/modular/system/logManage'
|
||||
import detailsOplog from './details'
|
||||
import { sysDictTypeDropDown } from '@/api/modular/system/dictManage'
|
||||
import moment from 'moment'
|
||||
export default {
|
||||
components: {
|
||||
XDown,
|
||||
XCard,
|
||||
STable,
|
||||
Ellipsis,
|
||||
|
@ -156,9 +161,6 @@
|
|||
return res.data
|
||||
})
|
||||
},
|
||||
selectedRowKeys: [],
|
||||
selectedRows: [],
|
||||
defaultExpandedKeys: [],
|
||||
opTypeDict: [],
|
||||
successDict: []
|
||||
}
|
||||
|
@ -168,20 +170,6 @@
|
|||
},
|
||||
methods: {
|
||||
moment,
|
||||
opTypeFilter (opType) {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
const values = this.opTypeDict.filter(item => item.code == opType)
|
||||
if (values.length > 0) {
|
||||
return values[0].value
|
||||
}
|
||||
},
|
||||
successFilter (success) {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
const values = this.successDict.filter(item => item.code == success)
|
||||
if (values.length > 0) {
|
||||
return values[0].value
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 查询参数组装
|
||||
*/
|
||||
|
@ -203,12 +191,8 @@
|
|||
* 获取字典数据
|
||||
*/
|
||||
sysDictTypeDropDown () {
|
||||
sysDictTypeDropDown({ code: 'op_type' }).then((res) => {
|
||||
this.opTypeDict = res.data
|
||||
})
|
||||
sysDictTypeDropDown({ code: 'yes_or_no' }).then((res) => {
|
||||
this.successDict = res.data
|
||||
})
|
||||
this.opTypeDict = this.$options.filters['dictData']('op_type')
|
||||
this.successDict = this.$options.filters['dictData']('yes_or_no')
|
||||
},
|
||||
/**
|
||||
* 清空日志
|
||||
|
@ -223,12 +207,16 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 批量导出
|
||||
*/
|
||||
batchExport () {
|
||||
sysOpLogExport().then((res) => {
|
||||
this.$refs.batchExport.downloadfile(res)
|
||||
})
|
||||
},
|
||||
toggleAdvanced () {
|
||||
this.advanced = !this.advanced
|
||||
},
|
||||
onSelectChange (selectedRowKeys, selectedRows) {
|
||||
this.selectedRowKeys = selectedRowKeys
|
||||
this.selectedRows = selectedRows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<a-col :md="8" :sm="24">
|
||||
<a-form-item label="访问类型">
|
||||
<a-select v-model="queryParam.visType" allow-clear placeholder="请选择访问类型" >
|
||||
<a-select-option v-for="(item,index) in visTypeDict" :key="index" :value="item.code" >{{ item.value }}</a-select-option>
|
||||
<a-select-option v-for="(item,index) in visTypeDict" :key="index" :value="item.code" >{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
@ -20,7 +20,7 @@
|
|||
<a-col :md="8" :sm="24">
|
||||
<a-form-item label="是否成功">
|
||||
<a-select v-model="queryParam.success" placeholder="请选择是否成功" >
|
||||
<a-select-option v-for="(item,index) in successDict" :key="index" :value="item.code" >{{ item.value }}</a-select-option>
|
||||
<a-select-option v-for="(item,index) in successDict" :key="index" :value="item.code" >{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
@ -53,17 +53,21 @@
|
|||
</x-card>
|
||||
<a-card :bordered="false">
|
||||
<s-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:data="loadData"
|
||||
:alert="true"
|
||||
:rowKey="(record) => record.id"
|
||||
:rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
||||
:alert="false"
|
||||
ref="table"
|
||||
>
|
||||
<template slot="operator" v-if="hasPerm('sysVisLog:sysVisLog')">
|
||||
<template slot="operator">
|
||||
<a-popconfirm @confirm="() => sysVisLogDelete()" placement="top" title="确认清空日志?" v-if="hasPerm('sysVisLog:delete')">
|
||||
<a-button >清空日志</a-button>
|
||||
<a-button type="danger" ghost>清空日志</a-button>
|
||||
</a-popconfirm>
|
||||
<x-down
|
||||
v-if="hasPerm('sysVisLog:export')"
|
||||
ref="batchExport"
|
||||
@batchExport="batchExport"
|
||||
/>
|
||||
</template>
|
||||
<span slot="name" slot-scope="text">
|
||||
<ellipsis :length="10" tooltip>{{ text }}</ellipsis>
|
||||
|
@ -72,10 +76,10 @@
|
|||
<ellipsis :length="10" tooltip>{{ text }}</ellipsis>
|
||||
</span>
|
||||
<span slot="visType" slot-scope="text">
|
||||
{{ visTypeFilter(text) }}
|
||||
{{ 'vis_type' | dictType(text) }}
|
||||
</span>
|
||||
<span slot="success" slot-scope="text">
|
||||
{{ successFilter(text) }}
|
||||
{{ 'yes_or_no' | dictType(text) }}
|
||||
</span>
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<span slot="action" >
|
||||
|
@ -88,13 +92,13 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { STable, Ellipsis, XCard } from '@/components'
|
||||
import { sysVisLogPage, sysVisLogDelete } from '@/api/modular/system/logManage'
|
||||
import { STable, Ellipsis, XCard, XDown } from '@/components'
|
||||
import { sysVisLogPage, sysVisLogDelete, sysVisLogExport } from '@/api/modular/system/logManage'
|
||||
import detailsVislog from './details'
|
||||
import { sysDictTypeDropDown } from '@/api/modular/system/dictManage'
|
||||
import moment from 'moment'
|
||||
export default {
|
||||
components: {
|
||||
XDown,
|
||||
XCard,
|
||||
STable,
|
||||
Ellipsis,
|
||||
|
@ -152,8 +156,6 @@
|
|||
return res.data
|
||||
})
|
||||
},
|
||||
selectedRowKeys: [],
|
||||
selectedRows: [],
|
||||
defaultExpandedKeys: [],
|
||||
visTypeDict: [],
|
||||
successDict: []
|
||||
|
@ -167,30 +169,12 @@
|
|||
},
|
||||
methods: {
|
||||
moment,
|
||||
visTypeFilter (visType) {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
const values = this.visTypeDict.filter(item => item.code == visType)
|
||||
if (values.length > 0) {
|
||||
return values[0].value
|
||||
}
|
||||
},
|
||||
successFilter (success) {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
const values = this.successDict.filter(item => item.code == success)
|
||||
if (values.length > 0) {
|
||||
return values[0].value
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取字典数据
|
||||
*/
|
||||
sysDictTypeDropDown () {
|
||||
sysDictTypeDropDown({ code: 'vis_type' }).then((res) => {
|
||||
this.visTypeDict = res.data
|
||||
})
|
||||
sysDictTypeDropDown({ code: 'yes_or_no' }).then((res) => {
|
||||
this.successDict = res.data
|
||||
})
|
||||
this.visTypeDict = this.$options.filters['dictData']('vis_type')
|
||||
this.successDict = this.$options.filters['dictData']('yes_or_no')
|
||||
},
|
||||
/**
|
||||
* 查询参数组装
|
||||
|
@ -209,6 +193,14 @@
|
|||
delete obj.dates
|
||||
return obj
|
||||
},
|
||||
/**
|
||||
* 批量导出
|
||||
*/
|
||||
batchExport () {
|
||||
sysVisLogExport().then((res) => {
|
||||
this.$refs.batchExport.downloadfile(res)
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 清空日志
|
||||
*/
|
||||
|
@ -224,10 +216,6 @@
|
|||
},
|
||||
toggleAdvanced () {
|
||||
this.advanced = !this.advanced
|
||||
},
|
||||
onSelectChange (selectedRowKeys, selectedRows) {
|
||||
this.selectedRowKeys = selectedRowKeys
|
||||
this.selectedRows = selectedRows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import vip.xiaonuo.sys.modular.log.service.SysVisLogService;
|
|||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
|
@ -105,4 +104,31 @@ public class SysLogController {
|
|||
sysOpLogService.delete();
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出系统操作日志
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2020/5/30 17:55
|
||||
*/
|
||||
@Permission
|
||||
@GetMapping("/sysOpLog/export")
|
||||
@BusinessLog(title = "操作日志_导出", opType = LogAnnotionOpTypeEnum.EXPORT)
|
||||
public void export(SysOpLogParam sysOpLogParam) {
|
||||
sysOpLogService.export(sysOpLogParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出系统访问日志
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2020/5/30 17:55
|
||||
*/
|
||||
@Permission
|
||||
@GetMapping("/sysVisLog/export")
|
||||
@BusinessLog(title = "访问日志_导出", opType = LogAnnotionOpTypeEnum.EXPORT)
|
||||
public void export(SysVisLogParam sysVisLogParam) {
|
||||
sysVisLogService.export(sysVisLogParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
|
|||
*/
|
||||
package vip.xiaonuo.sys.modular.log.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
@ -51,76 +52,91 @@ public class SysOpLog {
|
|||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Excel(name = "名称", width = 20)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 操作类型(见LogAnnotionOpTypeEnum)
|
||||
*/
|
||||
@Excel(name = "操作类型", width = 20)
|
||||
private Integer opType;
|
||||
|
||||
/**
|
||||
* 是否执行成功(Y-是,N-否)
|
||||
*/
|
||||
@Excel(name = "是否执行成功", replace = {"是_Y", "否_N"}, width = 20)
|
||||
private String success;
|
||||
|
||||
/**
|
||||
* 具体消息
|
||||
*/
|
||||
@Excel(name = "具体消息", width = 20)
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* ip
|
||||
*/
|
||||
@Excel(name = "ip", width = 20)
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@Excel(name = "地址", width = 20)
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 浏览器
|
||||
*/
|
||||
@Excel(name = "浏览器", width = 40)
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
@Excel(name = "操作系统", width = 20)
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* 请求地址
|
||||
*/
|
||||
@Excel(name = "请求地址", width = 40)
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 类名称
|
||||
*/
|
||||
@Excel(name = "类名称", width = 20)
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 方法名称
|
||||
*/
|
||||
@Excel(name = "方法名称", width = 20)
|
||||
private String methodName;
|
||||
|
||||
/**
|
||||
* 请求方式(GET POST PUT DELETE)
|
||||
*/
|
||||
@Excel(name = "请求方式", width = 20)
|
||||
private String reqMethod;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
@Excel(name = "请求参数", width = 40)
|
||||
private String param;
|
||||
|
||||
/**
|
||||
* 返回结果
|
||||
*/
|
||||
@Excel(name = "返回结果", width = 20)
|
||||
private String result;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@Excel(name = "操作时间", databaseFormat = "yyyy-MM-dd HH:mm:ss", format = "yyyy-MM-dd HH:mm:ss", width = 20)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date opTime;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
|
|||
*/
|
||||
package vip.xiaonuo.sys.modular.log.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
@ -51,46 +52,55 @@ public class SysVisLog {
|
|||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Excel(name = "名称", width = 20)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 是否执行成功(Y-是,N-否)
|
||||
*/
|
||||
@Excel(name = "是否执行成功", replace = {"是_Y", "否_N"}, width = 20)
|
||||
private String success;
|
||||
|
||||
/**
|
||||
* 具体消息
|
||||
*/
|
||||
@Excel(name = "具体消息", width = 20)
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* ip
|
||||
*/
|
||||
@Excel(name = "ip", width = 20)
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@Excel(name = "地址", width = 20)
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 浏览器
|
||||
*/
|
||||
@Excel(name = "浏览器", width = 20)
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
@Excel(name = "操作系统", width = 20)
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* 访问类型(字典 1登入 2登出)
|
||||
*/
|
||||
@Excel(name = "访问类型", replace = {"登入_1", "登出_2"}, width = 20)
|
||||
private Integer visType;
|
||||
|
||||
/**
|
||||
* 访问时间
|
||||
*/
|
||||
@Excel(name = "操作时间", databaseFormat = "yyyy-MM-dd HH:mm:ss", format = "yyyy-MM-dd HH:mm:ss", width = 20)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date visTime;
|
||||
|
||||
|
|
|
@ -54,4 +54,12 @@ public interface SysOpLogService extends IService<SysOpLog> {
|
|||
* @date 2020/6/1 11:05
|
||||
*/
|
||||
void delete();
|
||||
|
||||
/**
|
||||
* 导出系统操作日志
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2021/5/30 17:58
|
||||
*/
|
||||
void export(SysOpLogParam sysOpLogParam);
|
||||
}
|
||||
|
|
|
@ -54,4 +54,12 @@ public interface SysVisLogService extends IService<SysVisLog> {
|
|||
* @date 2020/6/1 11:04
|
||||
*/
|
||||
void delete();
|
||||
|
||||
/**
|
||||
* 导出系统访问日志
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2021/5/30 17:58
|
||||
*/
|
||||
void export(SysVisLogParam sysVisLogParam);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import vip.xiaonuo.core.factory.PageFactory;
|
||||
import vip.xiaonuo.core.pojo.page.PageResult;
|
||||
import vip.xiaonuo.core.util.PoiUtil;
|
||||
import vip.xiaonuo.sys.modular.log.entity.SysOpLog;
|
||||
import vip.xiaonuo.sys.modular.log.mapper.SysOpLogMapper;
|
||||
import vip.xiaonuo.sys.modular.log.param.SysOpLogParam;
|
||||
|
@ -78,4 +79,10 @@ public class SysOpLogServiceImpl extends ServiceImpl<SysOpLogMapper, SysOpLog> i
|
|||
public void delete() {
|
||||
this.remove(new QueryWrapper<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export(SysOpLogParam sysOpLogParam) {
|
||||
List<SysOpLog> list = this.list();
|
||||
PoiUtil.exportExcelWithStream("SysOpLog.xls", SysOpLog.class, list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import vip.xiaonuo.core.factory.PageFactory;
|
||||
import vip.xiaonuo.core.pojo.page.PageResult;
|
||||
import vip.xiaonuo.sys.modular.log.entity.SysOpLog;
|
||||
import vip.xiaonuo.core.util.PoiUtil;
|
||||
import vip.xiaonuo.sys.modular.log.entity.SysVisLog;
|
||||
import vip.xiaonuo.sys.modular.log.mapper.SysVisLogMapper;
|
||||
import vip.xiaonuo.sys.modular.log.param.SysVisLogParam;
|
||||
|
@ -77,4 +77,10 @@ public class SysVisLogServiceImpl extends ServiceImpl<SysVisLogMapper, SysVisLog
|
|||
public void delete() {
|
||||
this.remove(new QueryWrapper<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export(SysVisLogParam sysVisLogParam) {
|
||||
List<SysVisLog> list = this.list();
|
||||
PoiUtil.exportExcelWithStream("SysVisLog.xls", SysVisLog.class, list);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue