Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2c28d19806
@ -47,7 +47,7 @@ public class AdminLoginController {
|
||||
return "manage";
|
||||
}
|
||||
if (recordService.add(user, request.getRemoteAddr()) != 0) {
|
||||
session.setAttribute("adminuser", user);
|
||||
session.setAttribute("adminUser", user);
|
||||
return "redirect:/admin/state.jsp";
|
||||
} else {
|
||||
model.addAttribute("adminLoginMess", "* 登录异常!");
|
||||
|
@ -0,0 +1,42 @@
|
||||
package cn.edu.cqwu.repair.controller.admin;
|
||||
|
||||
import cn.edu.cqwu.repair.entity.AdminUser;
|
||||
import cn.edu.cqwu.repair.service.RecordService;
|
||||
import cn.edu.cqwu.repair.util.PageModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttribute;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
@Controller
|
||||
public class AdminRecordController {
|
||||
private final RecordService recordService;
|
||||
|
||||
@Autowired
|
||||
public AdminRecordController(RecordService recordService) {
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/record.do")
|
||||
public String adminRecord(
|
||||
@SessionAttribute AdminUser adminUser, Model model, HttpServletRequest request) {
|
||||
String pageNoS = request.getParameter("pageNo");
|
||||
int pageNo = 1;
|
||||
try {
|
||||
pageNo = Integer.parseInt(pageNoS);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
PageModel pm = recordService.pageByLogname(
|
||||
adminUser.getAdminName(), adminUser.getAdminGroup(), 10, pageNo
|
||||
);
|
||||
pm.setPageNav("record.do");
|
||||
model.addAttribute("pm", pm);
|
||||
return "/admin/record";
|
||||
}
|
||||
}
|
32
src/main/java/cn/edu/cqwu/repair/listener/CountListener.java
Normal file
32
src/main/java/cn/edu/cqwu/repair/listener/CountListener.java
Normal file
@ -0,0 +1,32 @@
|
||||
package cn.edu.cqwu.repair.listener;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.annotation.WebListener;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
@WebListener
|
||||
public class CountListener implements HttpSessionListener {
|
||||
@Override
|
||||
public void sessionCreated(javax.servlet.http.HttpSessionEvent se) {
|
||||
ServletContext context = se.getSession().getServletContext();
|
||||
if (context.getAttribute("count") == null) {
|
||||
Integer count = 1;
|
||||
context.setAttribute("count", count);
|
||||
} else {
|
||||
Integer count = (Integer) context.getAttribute("count");
|
||||
context.setAttribute("count", count + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sessionDestroyed(javax.servlet.http.HttpSessionEvent se) {
|
||||
ServletContext context = se.getSession().getServletContext();
|
||||
Integer count = (Integer) context.getAttribute("count");
|
||||
if (count != null) {
|
||||
context.setAttribute("count", count - 1);
|
||||
}
|
||||
}
|
||||
}
|
60
src/main/webapp/admin/record.jsp
Normal file
60
src/main/webapp/admin/record.jsp
Normal file
@ -0,0 +1,60 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: xtaod
|
||||
Date: 2023/12/25
|
||||
Time: 19:57
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ page isELIgnored="false" %>
|
||||
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
|
||||
<c:set var="title" value="登录历史"/>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title>${title}</title>
|
||||
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css" crossorigin="anonymous">
|
||||
<script src="${webroot}/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="${webroot}/js/record.js"></script>
|
||||
<link rel="stylesheet" href="${webroot}/styles/sidebar.css" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<main class="d-flex flex-nowrap">
|
||||
<%@ include file="../includes/header.jsp" %>
|
||||
|
||||
<main class="form-signin w-100 m-auto" style="max-width: 600px;">
|
||||
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
|
||||
<h1 class="h3 mb-3 fw-normal">${title}</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">序号</th>
|
||||
<th scope="col">登录名</th>
|
||||
<th scope="col">用户组</th>
|
||||
<th scope="col">登录时间</th>
|
||||
<th scope="col">登录IP</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${pm.data}" var="recode" varStatus="row">
|
||||
<tr>
|
||||
<td>${pm.fromIndex + row.index + 1}</td>
|
||||
<td>${recode.logname}</td>
|
||||
<td>${recode.usergroup}</td>
|
||||
<td>${recode.logtime}</td>
|
||||
<td>${recode.logip}</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
${pm.pageNav}
|
||||
</main>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
@ -36,7 +36,7 @@
|
||||
</c:if>
|
||||
|
||||
<div class="alert alert-primary" role="alert">
|
||||
系统当前处于 ${applicationScope.currstage.stagename} 阶段
|
||||
系统当前有 0 个维修单未处理
|
||||
</div>
|
||||
<div class="alert alert-info" role="alert">
|
||||
系统当前在线人数 ${applicationScope.count} 人
|
||||
|
@ -31,13 +31,13 @@
|
||||
</ul>
|
||||
</div>
|
||||
</c:when>
|
||||
<c:when test="${not empty sessionScope.adminuser}">
|
||||
<c:when test="${not empty sessionScope.adminUser}">
|
||||
<hr>
|
||||
<div class="dropdown">
|
||||
<a href="#" class="d-flex align-items-center link-body-emphasis text-decoration-none dropdown-toggle"
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<img src="${webroot}/images/logo.jpg" alt="" width="32" height="32" class="rounded-circle me-2">
|
||||
<strong>${sessionScope.adminuser.adminName}</strong>
|
||||
<strong>${sessionScope.adminUser.adminName}</strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu text-small shadow">
|
||||
<li><a class="dropdown-item" href="${webroot}/admin/message.do">消息中心</a></li>
|
||||
|
@ -20,7 +20,7 @@
|
||||
</a>
|
||||
</li>
|
||||
</c:when>
|
||||
<c:when test="${not empty sessionScope.adminuser}">
|
||||
<c:when test="${not empty sessionScope.adminUser}">
|
||||
<li class="nav-item">
|
||||
<a href="${webroot}/admin/state.jsp" class="nav-link link-body-emphasis" aria-current="page">
|
||||
>> 系统状态
|
||||
|
Loading…
Reference in New Issue
Block a user