Commit c95f5402012e05d5ed00bfb68f4a2078c1333535
1 parent
083dac77
迁移登陆日志的代码
Showing
12 changed files
with
336 additions
and
318 deletions
ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java deleted
| 1 | -package com.ruoyi.web.controller.monitor; | ||
| 2 | - | ||
| 3 | -import java.util.List; | ||
| 4 | - | ||
| 5 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 7 | -import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 8 | -import org.springframework.web.bind.annotation.GetMapping; | ||
| 9 | -import org.springframework.web.bind.annotation.PathVariable; | ||
| 10 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
| 11 | -import org.springframework.web.bind.annotation.RestController; | ||
| 12 | -import com.ruoyi.common.annotation.Log; | ||
| 13 | -import com.ruoyi.common.core.controller.BaseController; | ||
| 14 | -import com.ruoyi.common.core.domain.AjaxResult; | ||
| 15 | -import com.ruoyi.common.core.page.TableDataInfo; | ||
| 16 | -import com.ruoyi.common.enums.BusinessType; | ||
| 17 | -import com.ruoyi.common.utils.poi.ExcelUtil; | ||
| 18 | -import com.ruoyi.system.domain.SysLogininfor; | ||
| 19 | -import com.ruoyi.system.service.ISysLogininforService; | ||
| 20 | - | ||
| 21 | -/** | ||
| 22 | - * 系统访问记录 | ||
| 23 | - * | ||
| 24 | - * @author ruoyi | ||
| 25 | - */ | ||
| 26 | -@RestController | ||
| 27 | -@RequestMapping("/monitor/logininfor") | ||
| 28 | -public class SysLogininforController extends BaseController { | ||
| 29 | - | ||
| 30 | - @Autowired | ||
| 31 | - private ISysLogininforService logininforService; | ||
| 32 | - | ||
| 33 | - @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')") | ||
| 34 | - @GetMapping("/list") | ||
| 35 | - public TableDataInfo list(SysLogininfor logininfor) { | ||
| 36 | - startPage(); | ||
| 37 | - List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); | ||
| 38 | - return getDataTable(list); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - @Log(title = "登录日志", businessType = BusinessType.EXPORT) | ||
| 42 | - @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')") | ||
| 43 | - @GetMapping("/export") | ||
| 44 | - public AjaxResult export(SysLogininfor logininfor) { | ||
| 45 | - List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); | ||
| 46 | - ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class); | ||
| 47 | - return util.exportExcel(list, "登录日志"); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | -} |
ruoyi-ui/src/api/monitor/logininfor.js renamed to ruoyi-ui/src/api/system/loginlog.js
| 1 | -import request from '@/utils/request' | ||
| 2 | - | ||
| 3 | -// 查询登录日志列表 | ||
| 4 | -export function list(query) { | ||
| 5 | - return request({ | ||
| 6 | - url: '/monitor/logininfor/list', | ||
| 7 | - method: 'get', | ||
| 8 | - params: query | ||
| 9 | - }) | ||
| 10 | -} | ||
| 11 | - | ||
| 12 | -// 删除登录日志 | ||
| 13 | -export function delLogininfor(infoId) { | ||
| 14 | - return request({ | ||
| 15 | - url: '/monitor/logininfor/' + infoId, | ||
| 16 | - method: 'delete' | ||
| 17 | - }) | ||
| 18 | -} | ||
| 19 | - | ||
| 20 | -// 清空登录日志 | ||
| 21 | -export function cleanLogininfor() { | ||
| 22 | - return request({ | ||
| 23 | - url: '/monitor/logininfor/clean', | ||
| 24 | - method: 'delete' | ||
| 25 | - }) | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | -// 导出登录日志 | ||
| 29 | -export function exportLogininfor(query) { | ||
| 30 | - return request({ | ||
| 31 | - url: '/monitor/logininfor/export', | ||
| 32 | - method: 'get', | ||
| 33 | - params: query | ||
| 34 | - }) | ||
| 35 | -} | ||
| 36 | \ No newline at end of file | 1 | \ No newline at end of file |
| 2 | +import request from '@/utils/request' | ||
| 3 | + | ||
| 4 | +// 查询登录日志列表 | ||
| 5 | +export function list(query) { | ||
| 6 | + return request({ | ||
| 7 | + url: '/system/login-log/page', | ||
| 8 | + method: 'get', | ||
| 9 | + params: query | ||
| 10 | + }) | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +// 导出登录日志 | ||
| 14 | +export function exportLoginLog(query) { | ||
| 15 | + return request({ | ||
| 16 | + url: '/system/login-log/export', | ||
| 17 | + method: 'get', | ||
| 18 | + params: query, | ||
| 19 | + responseType: 'blob' | ||
| 20 | + }) | ||
| 21 | +} |
ruoyi-ui/src/utils/dict.js
| @@ -12,7 +12,8 @@ export const DICT_TYPE = { | @@ -12,7 +12,8 @@ export const DICT_TYPE = { | ||
| 12 | SYS_DATA_SCOPE: 'sys_data_scope', | 12 | SYS_DATA_SCOPE: 'sys_data_scope', |
| 13 | SYS_USER_SEX: 'sys_user_sex', | 13 | SYS_USER_SEX: 'sys_user_sex', |
| 14 | SYS_NOTICE_TYPE: 'sys_notice_type', | 14 | SYS_NOTICE_TYPE: 'sys_notice_type', |
| 15 | - SYS_OPERATE_TYPE: 'sys_operate_type' | 15 | + SYS_OPERATE_TYPE: 'sys_operate_type', |
| 16 | + SYS_LOGIN_RESULT: 'sys_login_result' | ||
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | /** | 19 | /** |
ruoyi-ui/src/views/monitor/logininfor/index.vue renamed to ruoyi-ui/src/views/system/loginlog/index.vue
| 1 | -<template> | ||
| 2 | - <div class="app-container"> | ||
| 3 | - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | - <el-form-item label="登录地址" prop="ipaddr"> | ||
| 5 | - <el-input | ||
| 6 | - v-model="queryParams.ipaddr" | ||
| 7 | - placeholder="请输入登录地址" | ||
| 8 | - clearable | ||
| 9 | - style="width: 240px;" | ||
| 10 | - size="small" | ||
| 11 | - @keyup.enter.native="handleQuery" | ||
| 12 | - /> | ||
| 13 | - </el-form-item> | ||
| 14 | - <el-form-item label="用户名称" prop="userName"> | ||
| 15 | - <el-input | ||
| 16 | - v-model="queryParams.userName" | ||
| 17 | - placeholder="请输入用户名称" | ||
| 18 | - clearable | ||
| 19 | - style="width: 240px;" | ||
| 20 | - size="small" | ||
| 21 | - @keyup.enter.native="handleQuery" | ||
| 22 | - /> | ||
| 23 | - </el-form-item> | ||
| 24 | - <el-form-item label="状态" prop="status"> | ||
| 25 | - <el-select | ||
| 26 | - v-model="queryParams.status" | ||
| 27 | - placeholder="登录状态" | ||
| 28 | - clearable | ||
| 29 | - size="small" | ||
| 30 | - style="width: 240px" | ||
| 31 | - > | ||
| 32 | - <el-option | ||
| 33 | - v-for="dict in statusOptions" | ||
| 34 | - :key="dict.dictValue" | ||
| 35 | - :label="dict.dictLabel" | ||
| 36 | - :value="dict.dictValue" | ||
| 37 | - /> | ||
| 38 | - </el-select> | ||
| 39 | - </el-form-item> | ||
| 40 | - <el-form-item label="登录时间"> | ||
| 41 | - <el-date-picker | ||
| 42 | - v-model="dateRange" | ||
| 43 | - size="small" | ||
| 44 | - style="width: 240px" | ||
| 45 | - value-format="yyyy-MM-dd" | ||
| 46 | - type="daterange" | ||
| 47 | - range-separator="-" | ||
| 48 | - start-placeholder="开始日期" | ||
| 49 | - end-placeholder="结束日期" | ||
| 50 | - ></el-date-picker> | ||
| 51 | - </el-form-item> | ||
| 52 | - <el-form-item> | ||
| 53 | - <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 54 | - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 55 | - </el-form-item> | ||
| 56 | - </el-form> | ||
| 57 | - | ||
| 58 | - <el-row :gutter="10" class="mb8"> | ||
| 59 | - <el-col :span="1.5"> | ||
| 60 | - <el-button | ||
| 61 | - type="danger" | ||
| 62 | - icon="el-icon-delete" | ||
| 63 | - size="mini" | ||
| 64 | - :disabled="multiple" | ||
| 65 | - @click="handleDelete" | ||
| 66 | - v-hasPermi="['monitor:logininfor:remove']" | ||
| 67 | - >删除</el-button> | ||
| 68 | - </el-col> | ||
| 69 | - <el-col :span="1.5"> | ||
| 70 | - <el-button | ||
| 71 | - type="danger" | ||
| 72 | - icon="el-icon-delete" | ||
| 73 | - size="mini" | ||
| 74 | - @click="handleClean" | ||
| 75 | - v-hasPermi="['monitor:logininfor:remove']" | ||
| 76 | - >清空</el-button> | ||
| 77 | - </el-col> | ||
| 78 | - <el-col :span="1.5"> | ||
| 79 | - <el-button | ||
| 80 | - type="warning" | ||
| 81 | - icon="el-icon-download" | ||
| 82 | - size="mini" | ||
| 83 | - @click="handleExport" | ||
| 84 | - v-hasPermi="['system:logininfor:export']" | ||
| 85 | - >导出</el-button> | ||
| 86 | - </el-col> | ||
| 87 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 88 | - </el-row> | ||
| 89 | - | ||
| 90 | - <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange"> | ||
| 91 | - <el-table-column type="selection" width="55" align="center" /> | ||
| 92 | - <el-table-column label="访问编号" align="center" prop="infoId" /> | ||
| 93 | - <el-table-column label="用户名称" align="center" prop="userName" /> | ||
| 94 | - <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" /> | ||
| 95 | - <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" /> | ||
| 96 | - <el-table-column label="浏览器" align="center" prop="browser" /> | ||
| 97 | - <el-table-column label="操作系统" align="center" prop="os" /> | ||
| 98 | - <el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat" /> | ||
| 99 | - <el-table-column label="操作信息" align="center" prop="msg" /> | ||
| 100 | - <el-table-column label="登录日期" align="center" prop="loginTime" width="180"> | ||
| 101 | - <template slot-scope="scope"> | ||
| 102 | - <span>{{ parseTime(scope.row.loginTime) }}</span> | ||
| 103 | - </template> | ||
| 104 | - </el-table-column> | ||
| 105 | - </el-table> | ||
| 106 | - | ||
| 107 | - <pagination | ||
| 108 | - v-show="total>0" | ||
| 109 | - :total="total" | ||
| 110 | - :page.sync="queryParams.pageNum" | ||
| 111 | - :limit.sync="queryParams.pageSize" | ||
| 112 | - @pagination="getList" | ||
| 113 | - /> | ||
| 114 | - </div> | ||
| 115 | -</template> | ||
| 116 | - | ||
| 117 | -<script> | ||
| 118 | -import { list, delLogininfor, cleanLogininfor, exportLogininfor } from "@/api/monitor/logininfor"; | ||
| 119 | - | ||
| 120 | -export default { | ||
| 121 | - name: "Logininfor", | ||
| 122 | - data() { | ||
| 123 | - return { | ||
| 124 | - // 遮罩层 | ||
| 125 | - loading: true, | ||
| 126 | - // 选中数组 | ||
| 127 | - ids: [], | ||
| 128 | - // 非多个禁用 | ||
| 129 | - multiple: true, | ||
| 130 | - // 显示搜索条件 | ||
| 131 | - showSearch: true, | ||
| 132 | - // 总条数 | ||
| 133 | - total: 0, | ||
| 134 | - // 表格数据 | ||
| 135 | - list: [], | ||
| 136 | - // 状态数据字典 | ||
| 137 | - statusOptions: [], | ||
| 138 | - // 日期范围 | ||
| 139 | - dateRange: [], | ||
| 140 | - // 查询参数 | ||
| 141 | - queryParams: { | ||
| 142 | - pageNum: 1, | ||
| 143 | - pageSize: 10, | ||
| 144 | - ipaddr: undefined, | ||
| 145 | - userName: undefined, | ||
| 146 | - status: undefined | ||
| 147 | - } | ||
| 148 | - }; | ||
| 149 | - }, | ||
| 150 | - created() { | ||
| 151 | - this.getList(); | ||
| 152 | - this.getDicts("sys_common_status").then(response => { | ||
| 153 | - this.statusOptions = response.data; | ||
| 154 | - }); | ||
| 155 | - }, | ||
| 156 | - methods: { | ||
| 157 | - /** 查询登录日志列表 */ | ||
| 158 | - getList() { | ||
| 159 | - this.loading = true; | ||
| 160 | - list(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||
| 161 | - this.list = response.rows; | ||
| 162 | - this.total = response.total; | ||
| 163 | - this.loading = false; | ||
| 164 | - } | ||
| 165 | - ); | ||
| 166 | - }, | ||
| 167 | - // 登录状态字典翻译 | ||
| 168 | - statusFormat(row, column) { | ||
| 169 | - return this.selectDictLabel(this.statusOptions, row.status); | ||
| 170 | - }, | ||
| 171 | - /** 搜索按钮操作 */ | ||
| 172 | - handleQuery() { | ||
| 173 | - this.queryParams.pageNum = 1; | ||
| 174 | - this.getList(); | ||
| 175 | - }, | ||
| 176 | - /** 重置按钮操作 */ | ||
| 177 | - resetQuery() { | ||
| 178 | - this.dateRange = []; | ||
| 179 | - this.resetForm("queryForm"); | ||
| 180 | - this.handleQuery(); | ||
| 181 | - }, | ||
| 182 | - // 多选框选中数据 | ||
| 183 | - handleSelectionChange(selection) { | ||
| 184 | - this.ids = selection.map(item => item.infoId) | ||
| 185 | - this.multiple = !selection.length | ||
| 186 | - }, | ||
| 187 | - /** 删除按钮操作 */ | ||
| 188 | - handleDelete(row) { | ||
| 189 | - const infoIds = row.infoId || this.ids; | ||
| 190 | - this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", { | ||
| 191 | - confirmButtonText: "确定", | ||
| 192 | - cancelButtonText: "取消", | ||
| 193 | - type: "warning" | ||
| 194 | - }).then(function() { | ||
| 195 | - return delLogininfor(infoIds); | ||
| 196 | - }).then(() => { | ||
| 197 | - this.getList(); | ||
| 198 | - this.msgSuccess("删除成功"); | ||
| 199 | - }) | ||
| 200 | - }, | ||
| 201 | - /** 清空按钮操作 */ | ||
| 202 | - handleClean() { | ||
| 203 | - this.$confirm('是否确认清空所有登录日志数据项?', "警告", { | ||
| 204 | - confirmButtonText: "确定", | ||
| 205 | - cancelButtonText: "取消", | ||
| 206 | - type: "warning" | ||
| 207 | - }).then(function() { | ||
| 208 | - return cleanLogininfor(); | ||
| 209 | - }).then(() => { | ||
| 210 | - this.getList(); | ||
| 211 | - this.msgSuccess("清空成功"); | ||
| 212 | - }) | ||
| 213 | - }, | ||
| 214 | - /** 导出按钮操作 */ | ||
| 215 | - handleExport() { | ||
| 216 | - const queryParams = this.queryParams; | ||
| 217 | - this.$confirm('是否确认导出所有操作日志数据项?', "警告", { | ||
| 218 | - confirmButtonText: "确定", | ||
| 219 | - cancelButtonText: "取消", | ||
| 220 | - type: "warning" | ||
| 221 | - }).then(function() { | ||
| 222 | - return exportLogininfor(queryParams); | ||
| 223 | - }).then(response => { | ||
| 224 | - this.download(response.msg); | ||
| 225 | - }) | ||
| 226 | - } | ||
| 227 | - } | ||
| 228 | -}; | ||
| 229 | -</script> | ||
| 230 | - | 1 | +<template> |
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | + <el-form-item label="登录地址" prop="userIp"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.userIp" | ||
| 7 | + placeholder="请输入登录地址" | ||
| 8 | + clearable | ||
| 9 | + style="width: 240px;" | ||
| 10 | + size="small" | ||
| 11 | + @keyup.enter.native="handleQuery" | ||
| 12 | + /> | ||
| 13 | + </el-form-item> | ||
| 14 | + <el-form-item label="用户名称" prop="username"> | ||
| 15 | + <el-input | ||
| 16 | + v-model="queryParams.username" | ||
| 17 | + placeholder="请输入用户名称" | ||
| 18 | + clearable | ||
| 19 | + style="width: 240px;" | ||
| 20 | + size="small" | ||
| 21 | + @keyup.enter.native="handleQuery" | ||
| 22 | + /> | ||
| 23 | + </el-form-item> | ||
| 24 | + <el-form-item label="状态" prop="status"> | ||
| 25 | + <el-select | ||
| 26 | + v-model="queryParams.status" | ||
| 27 | + placeholder="结果" | ||
| 28 | + clearable | ||
| 29 | + size="small" | ||
| 30 | + style="width: 240px" | ||
| 31 | + > | ||
| 32 | + <el-option | ||
| 33 | + :key="true" | ||
| 34 | + label="成功" | ||
| 35 | + :value="true" | ||
| 36 | + /> | ||
| 37 | + <el-option | ||
| 38 | + :key="false" | ||
| 39 | + label="失败" | ||
| 40 | + :value="false" | ||
| 41 | + /> | ||
| 42 | + </el-select> | ||
| 43 | + </el-form-item> | ||
| 44 | + <el-form-item label="登录时间"> | ||
| 45 | + <el-date-picker | ||
| 46 | + v-model="dateRange" | ||
| 47 | + size="small" | ||
| 48 | + style="width: 240px" | ||
| 49 | + value-format="yyyy-MM-dd" | ||
| 50 | + type="daterange" | ||
| 51 | + range-separator="-" | ||
| 52 | + start-placeholder="开始日期" | ||
| 53 | + end-placeholder="结束日期" | ||
| 54 | + ></el-date-picker> | ||
| 55 | + </el-form-item> | ||
| 56 | + <el-form-item> | ||
| 57 | + <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 58 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 59 | + </el-form-item> | ||
| 60 | + </el-form> | ||
| 61 | + | ||
| 62 | + <el-row :gutter="10" class="mb8"> | ||
| 63 | + <el-col :span="1.5"> | ||
| 64 | + <el-button | ||
| 65 | + type="warning" | ||
| 66 | + icon="el-icon-download" | ||
| 67 | + size="mini" | ||
| 68 | + @click="handleExport" | ||
| 69 | + v-hasPermi="['system:login-log:export']" | ||
| 70 | + >导出</el-button> | ||
| 71 | + </el-col> | ||
| 72 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 73 | + </el-row> | ||
| 74 | + | ||
| 75 | + <el-table v-loading="loading" :data="list"> | ||
| 76 | + <el-table-column label="访问编号" align="center" prop="id" /> | ||
| 77 | + <el-table-column label="日志类型" align="center" prop="logType"> | ||
| 78 | + <template slot-scope="scope"> | ||
| 79 | + <span>{{ scope.row.logType === 1 ? '登录' : '退出' }}</span> | ||
| 80 | + </template> | ||
| 81 | + </el-table-column> | ||
| 82 | + <el-table-column label="用户名称" align="center" prop="username" /> | ||
| 83 | + <el-table-column label="登录地址" align="center" prop="userIp" width="130" :show-overflow-tooltip="true" /> | ||
| 84 | + <el-table-column label="userAgent" align="center" prop="userAgent" width="400" :show-overflow-tooltip="true" /> | ||
| 85 | + <el-table-column label="结果" align="center" prop="status"> | ||
| 86 | + <template slot-scope="scope"> | ||
| 87 | + <span v-if="scope.row.result === 0">成功</span> | ||
| 88 | + <span v-if="scope.row.result > 0">失败:{{ getDictDataLabel(DICT_TYPE.SYS_LOGIN_RESULT, scope.row.result) }} </span> | ||
| 89 | + </template> | ||
| 90 | + </el-table-column> | ||
| 91 | + <el-table-column label="登录日期" align="center" prop="loginTime" width="180"> | ||
| 92 | + <template slot-scope="scope"> | ||
| 93 | + <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 94 | + </template> | ||
| 95 | + </el-table-column> | ||
| 96 | + </el-table> | ||
| 97 | + | ||
| 98 | + <pagination | ||
| 99 | + v-show="total>0" | ||
| 100 | + :total="total" | ||
| 101 | + :page.sync="queryParams.pageNo" | ||
| 102 | + :limit.sync="queryParams.pageSize" | ||
| 103 | + @pagination="getList" | ||
| 104 | + /> | ||
| 105 | + </div> | ||
| 106 | +</template> | ||
| 107 | + | ||
| 108 | +<script> | ||
| 109 | +import { list, exportLoginLog } from "@/api/system/loginlog"; | ||
| 110 | + | ||
| 111 | +export default { | ||
| 112 | + name: "Logininfor", | ||
| 113 | + data() { | ||
| 114 | + return { | ||
| 115 | + // 遮罩层 | ||
| 116 | + loading: true, | ||
| 117 | + // 显示搜索条件 | ||
| 118 | + showSearch: true, | ||
| 119 | + // 总条数 | ||
| 120 | + total: 0, | ||
| 121 | + // 表格数据 | ||
| 122 | + list: [], | ||
| 123 | + // 状态数据字典 | ||
| 124 | + statusOptions: [], | ||
| 125 | + // 日期范围 | ||
| 126 | + dateRange: [], | ||
| 127 | + // 查询参数 | ||
| 128 | + queryParams: { | ||
| 129 | + pageNo: 1, | ||
| 130 | + pageSize: 10, | ||
| 131 | + userIp: undefined, | ||
| 132 | + username: undefined, | ||
| 133 | + status: undefined | ||
| 134 | + } | ||
| 135 | + }; | ||
| 136 | + }, | ||
| 137 | + created() { | ||
| 138 | + this.getList(); | ||
| 139 | + }, | ||
| 140 | + methods: { | ||
| 141 | + /** 查询登录日志列表 */ | ||
| 142 | + getList() { | ||
| 143 | + this.loading = true; | ||
| 144 | + list(this.addDateRange(this.queryParams, [ | ||
| 145 | + this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined, | ||
| 146 | + this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined, | ||
| 147 | + ])).then(response => { | ||
| 148 | + this.list = response.data.list; | ||
| 149 | + this.total = response.data.total; | ||
| 150 | + this.loading = false; | ||
| 151 | + } | ||
| 152 | + ); | ||
| 153 | + }, | ||
| 154 | + // 登录状态字典翻译 | ||
| 155 | + statusFormat(row, column) { | ||
| 156 | + return this.selectDictLabel(this.statusOptions, row.status); | ||
| 157 | + }, | ||
| 158 | + /** 搜索按钮操作 */ | ||
| 159 | + handleQuery() { | ||
| 160 | + this.queryParams.pageNo = 1; | ||
| 161 | + this.getList(); | ||
| 162 | + }, | ||
| 163 | + /** 重置按钮操作 */ | ||
| 164 | + resetQuery() { | ||
| 165 | + this.dateRange = []; | ||
| 166 | + this.resetForm("queryForm"); | ||
| 167 | + this.handleQuery(); | ||
| 168 | + }, | ||
| 169 | + /** 导出按钮操作 */ | ||
| 170 | + handleExport() { | ||
| 171 | + const queryParams = this.queryParams; | ||
| 172 | + this.$confirm('是否确认导出所有操作日志数据项?', "警告", { | ||
| 173 | + confirmButtonText: "确定", | ||
| 174 | + cancelButtonText: "取消", | ||
| 175 | + type: "warning" | ||
| 176 | + }).then(function() { | ||
| 177 | + return exportLoginLog(queryParams); | ||
| 178 | + }).then(response => { | ||
| 179 | + this.downloadExcel(response, '登陆日志.xls'); | ||
| 180 | + }) | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | +}; | ||
| 184 | +</script> | ||
| 185 | + |
src/main/java/cn/iocoder/dashboard/modules/system/controller/logger/SysLoginLogController.java
| 1 | package cn.iocoder.dashboard.modules.system.controller.logger; | 1 | package cn.iocoder.dashboard.modules.system.controller.logger; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogPageReqVO; | ||
| 6 | +import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogRespVO; | ||
| 7 | +import cn.iocoder.dashboard.modules.system.convert.logger.SysLoginLogConvert; | ||
| 8 | +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.logger.SysLoginLogDO; | ||
| 9 | +import cn.iocoder.dashboard.modules.system.service.logger.SysLoginLogService; | ||
| 10 | +import io.swagger.annotations.Api; | ||
| 11 | +import io.swagger.annotations.ApiOperation; | ||
| 12 | +import org.springframework.validation.annotation.Validated; | ||
| 13 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 14 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 15 | +import org.springframework.web.bind.annotation.RestController; | ||
| 16 | + | ||
| 17 | +import javax.annotation.Resource; | ||
| 18 | + | ||
| 19 | +@Api(tags = "登陆日志 API") | ||
| 20 | +@RestController | ||
| 21 | +@RequestMapping("/system/login-log") | ||
| 3 | public class SysLoginLogController { | 22 | public class SysLoginLogController { |
| 23 | + | ||
| 24 | + @Resource | ||
| 25 | + private SysLoginLogService loginLogService; | ||
| 26 | + | ||
| 27 | + @ApiOperation("获得登陆日志分页列表") | ||
| 28 | + @GetMapping("/page") | ||
| 29 | +// @PreAuthorize("@ss.hasPermi('system:login-log:query')") | ||
| 30 | + public CommonResult<PageResult<SysLoginLogRespVO>> getLoginLogPage(@Validated SysLoginLogPageReqVO reqVO) { | ||
| 31 | + PageResult<SysLoginLogDO> page = loginLogService.getLoginLogPage(reqVO); | ||
| 32 | + return CommonResult.success(SysLoginLogConvert.INSTANCE.convertPage(page)); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | +// @GetMapping("/export") | ||
| 36 | +//// @Log(title = "登录日志", businessType = BusinessType.EXPORT) | ||
| 37 | +//// @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')") | ||
| 38 | +// public void exportLoginLog(SysLogininfor logininfor) { | ||
| 39 | +// List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); | ||
| 40 | +// ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class); | ||
| 41 | +// return util.exportExcel(list, "登录日志"); | ||
| 42 | +// } | ||
| 43 | + | ||
| 4 | } | 44 | } |
src/main/java/cn/iocoder/dashboard/modules/system/controller/logger/vo/loginlog/SysLoginLogPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.PageParam; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Data; | ||
| 7 | +import lombok.EqualsAndHashCode; | ||
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | + | ||
| 10 | +import java.util.Date; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + | ||
| 14 | +@ApiModel("登陆日志分页列表 Request VO") | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +public class SysLoginLogPageReqVO extends PageParam { | ||
| 18 | + | ||
| 19 | + @ApiModelProperty(value = "用户 IP", example = "127.0.0.1", notes = "模拟匹配") | ||
| 20 | + private String userIp; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "用户账号", example = "芋道", notes = "模拟匹配") | ||
| 23 | + private String username; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty(value = "操作状态", example = "true") | ||
| 26 | + private Boolean status; | ||
| 27 | + | ||
| 28 | + @ApiModelProperty(value = "开始时间", example = "2020-10-24") | ||
| 29 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 30 | + private Date beginTime; | ||
| 31 | + | ||
| 32 | + @ApiModelProperty(value = "结束时间", example = "2020-10-24") | ||
| 33 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 34 | + private Date endTime; | ||
| 35 | + | ||
| 36 | +} |
src/main/java/cn/iocoder/dashboard/modules/system/controller/logger/vo/loginlog/SysLoginLogRespVO.java
| @@ -8,7 +8,7 @@ import lombok.ToString; | @@ -8,7 +8,7 @@ import lombok.ToString; | ||
| 8 | 8 | ||
| 9 | import java.util.Date; | 9 | import java.util.Date; |
| 10 | 10 | ||
| 11 | -@ApiModel("操作日志 Response VO") | 11 | +@ApiModel("登陆日志 Response VO") |
| 12 | @Data | 12 | @Data |
| 13 | @EqualsAndHashCode(callSuper = true) | 13 | @EqualsAndHashCode(callSuper = true) |
| 14 | @ToString(callSuper = true) | 14 | @ToString(callSuper = true) |
src/main/java/cn/iocoder/dashboard/modules/system/convert/logger/SysLoginLogConvert.java
| 1 | package cn.iocoder.dashboard.modules.system.convert.logger; | 1 | package cn.iocoder.dashboard.modules.system.convert.logger; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 3 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogCreateReqVO; | 4 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogCreateReqVO; |
| 5 | +import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogRespVO; | ||
| 4 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.logger.SysLoginLogDO; | 6 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.logger.SysLoginLogDO; |
| 5 | import org.mapstruct.Mapper; | 7 | import org.mapstruct.Mapper; |
| 6 | import org.mapstruct.factory.Mappers; | 8 | import org.mapstruct.factory.Mappers; |
| @@ -12,4 +14,6 @@ public interface SysLoginLogConvert { | @@ -12,4 +14,6 @@ public interface SysLoginLogConvert { | ||
| 12 | 14 | ||
| 13 | SysLoginLogDO convert(SysLoginLogCreateReqVO bean); | 15 | SysLoginLogDO convert(SysLoginLogCreateReqVO bean); |
| 14 | 16 | ||
| 17 | + PageResult<SysLoginLogRespVO> convertPage(PageResult<SysLoginLogDO> page); | ||
| 18 | + | ||
| 15 | } | 19 | } |
src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/logger/SysLoginLogMapper.java
| 1 | package cn.iocoder.dashboard.modules.system.dal.mysql.dao.logger; | 1 | package cn.iocoder.dashboard.modules.system.dal.mysql.dao.logger; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 3 | import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; | ||
| 6 | +import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogPageReqVO; | ||
| 4 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.logger.SysLoginLogDO; | 7 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.logger.SysLoginLogDO; |
| 8 | +import cn.iocoder.dashboard.modules.system.enums.logger.SysLoginResultEnum; | ||
| 5 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 10 | ||
| 7 | @Mapper | 11 | @Mapper |
| 8 | public interface SysLoginLogMapper extends BaseMapperX<SysLoginLogDO> { | 12 | public interface SysLoginLogMapper extends BaseMapperX<SysLoginLogDO> { |
| 13 | + | ||
| 14 | + default PageResult<SysLoginLogDO> selectPage(SysLoginLogPageReqVO reqVO) { | ||
| 15 | + QueryWrapperX<SysLoginLogDO> query = new QueryWrapperX<SysLoginLogDO>() | ||
| 16 | + .likeIfPresent("user_ip", reqVO.getUserIp()) | ||
| 17 | + .likeIfPresent("username", reqVO.getUsername()) | ||
| 18 | + .betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()); | ||
| 19 | + if (Boolean.TRUE.equals(reqVO.getStatus())) { | ||
| 20 | + query.eq("result", SysLoginResultEnum.SUCCESS.getResult()); | ||
| 21 | + } else if (Boolean.FALSE.equals(reqVO.getStatus())) { | ||
| 22 | + query.gt("result", SysLoginResultEnum.SUCCESS.getResult()); | ||
| 23 | + } | ||
| 24 | + query.orderByDesc("id"); // 降序 | ||
| 25 | + return selectPage(reqVO, query); | ||
| 26 | + } | ||
| 27 | + | ||
| 9 | } | 28 | } |
src/main/java/cn/iocoder/dashboard/modules/system/enums/logger/SysLoginResultEnum.java
| @@ -12,7 +12,7 @@ public enum SysLoginResultEnum { | @@ -12,7 +12,7 @@ public enum SysLoginResultEnum { | ||
| 12 | 12 | ||
| 13 | SUCCESS(0), // 成功 | 13 | SUCCESS(0), // 成功 |
| 14 | BAD_CREDENTIALS(10), // 账号或密码不正确 | 14 | BAD_CREDENTIALS(10), // 账号或密码不正确 |
| 15 | - USER_DISABLED(20), // 账号或密码不正确 | 15 | + USER_DISABLED(20), // 用户被禁用 |
| 16 | CAPTCHA_NOT_FOUND(30), // 验证码不存在 | 16 | CAPTCHA_NOT_FOUND(30), // 验证码不存在 |
| 17 | CAPTCHA_CODE_ERROR(31), // 验证码不正确 | 17 | CAPTCHA_CODE_ERROR(31), // 验证码不正确 |
| 18 | 18 |
src/main/java/cn/iocoder/dashboard/modules/system/service/logger/SysLoginLogService.java
| 1 | package cn.iocoder.dashboard.modules.system.service.logger; | 1 | package cn.iocoder.dashboard.modules.system.service.logger; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 3 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogCreateReqVO; | 4 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogCreateReqVO; |
| 5 | +import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogPageReqVO; | ||
| 6 | +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.logger.SysLoginLogDO; | ||
| 4 | 7 | ||
| 5 | /** | 8 | /** |
| 6 | * 登陆日志 Service 接口 | 9 | * 登陆日志 Service 接口 |
| @@ -14,4 +17,12 @@ public interface SysLoginLogService { | @@ -14,4 +17,12 @@ public interface SysLoginLogService { | ||
| 14 | */ | 17 | */ |
| 15 | void createLoginLog(SysLoginLogCreateReqVO reqVO); | 18 | void createLoginLog(SysLoginLogCreateReqVO reqVO); |
| 16 | 19 | ||
| 20 | + /** | ||
| 21 | + * 获得登陆日志分页 | ||
| 22 | + * | ||
| 23 | + * @param reqVO 分页条件 | ||
| 24 | + * @return 登陆日志分页 | ||
| 25 | + */ | ||
| 26 | + PageResult<SysLoginLogDO> getLoginLogPage(SysLoginLogPageReqVO reqVO); | ||
| 27 | + | ||
| 17 | } | 28 | } |
src/main/java/cn/iocoder/dashboard/modules/system/service/logger/impl/SysLoginLogServiceImpl.java
| 1 | package cn.iocoder.dashboard.modules.system.service.logger.impl; | 1 | package cn.iocoder.dashboard.modules.system.service.logger.impl; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.util.StrUtil; | ||
| 5 | +import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 3 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogCreateReqVO; | 6 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogCreateReqVO; |
| 7 | +import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogPageReqVO; | ||
| 4 | import cn.iocoder.dashboard.modules.system.convert.logger.SysLoginLogConvert; | 8 | import cn.iocoder.dashboard.modules.system.convert.logger.SysLoginLogConvert; |
| 5 | import cn.iocoder.dashboard.modules.system.dal.mysql.dao.logger.SysLoginLogMapper; | 9 | import cn.iocoder.dashboard.modules.system.dal.mysql.dao.logger.SysLoginLogMapper; |
| 6 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.logger.SysLoginLogDO; | 10 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.logger.SysLoginLogDO; |
| 11 | +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.user.SysUserDO; | ||
| 7 | import cn.iocoder.dashboard.modules.system.service.logger.SysLoginLogService; | 12 | import cn.iocoder.dashboard.modules.system.service.logger.SysLoginLogService; |
| 13 | +import cn.iocoder.dashboard.modules.system.service.user.SysUserService; | ||
| 8 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
| 9 | 15 | ||
| 10 | import javax.annotation.Resource; | 16 | import javax.annotation.Resource; |
| 17 | +import java.util.Collection; | ||
| 18 | + | ||
| 19 | +import static cn.iocoder.dashboard.util.collection.CollectionUtils.convertSet; | ||
| 11 | 20 | ||
| 12 | /** | 21 | /** |
| 13 | * 登陆日志 Service 实现 | 22 | * 登陆日志 Service 实现 |
| @@ -18,10 +27,18 @@ public class SysLoginLogServiceImpl implements SysLoginLogService { | @@ -18,10 +27,18 @@ public class SysLoginLogServiceImpl implements SysLoginLogService { | ||
| 18 | @Resource | 27 | @Resource |
| 19 | private SysLoginLogMapper loginLogMapper; | 28 | private SysLoginLogMapper loginLogMapper; |
| 20 | 29 | ||
| 30 | + @Resource | ||
| 31 | + private SysUserService userService; | ||
| 32 | + | ||
| 21 | @Override | 33 | @Override |
| 22 | public void createLoginLog(SysLoginLogCreateReqVO reqVO) { | 34 | public void createLoginLog(SysLoginLogCreateReqVO reqVO) { |
| 23 | SysLoginLogDO loginLog = SysLoginLogConvert.INSTANCE.convert(reqVO); | 35 | SysLoginLogDO loginLog = SysLoginLogConvert.INSTANCE.convert(reqVO); |
| 24 | loginLogMapper.insert(loginLog); | 36 | loginLogMapper.insert(loginLog); |
| 25 | } | 37 | } |
| 26 | 38 | ||
| 39 | + @Override | ||
| 40 | + public PageResult<SysLoginLogDO> getLoginLogPage(SysLoginLogPageReqVO reqVO) { | ||
| 41 | + return loginLogMapper.selectPage(reqVO); | ||
| 42 | + } | ||
| 43 | + | ||
| 27 | } | 44 | } |