From f5a216cb2706e5da248734e19d5c33a6aebd35d0 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 15 May 2024 15:34:00 +0800 Subject: [PATCH] admin stu manage --- .../admin/AdminStuManageController.java | 61 ++++++++++++++ .../worker/WorkerFixListController.java | 33 ++++---- .../worker/WorkerHistoryListController.java | 31 +++---- .../worker/WorkerHistoryLoginController.java | 30 +++---- .../worker/WorkerLoginController.java | 2 +- .../worker/WorkerOrderStatusController.java | 2 +- .../java/cn/edu/cqwu/repair/dao/StuDao.java | 4 +- .../edu/cqwu/repair/dao/impl/StuDaoImpl.java | 8 ++ src/main/webapp/admin/stu_manage.jsp | 80 +++++++++++++++++++ src/main/webapp/includes/menu.jsp | 10 +-- src/main/webapp/worker_login.jsp | 2 +- 11 files changed, 207 insertions(+), 56 deletions(-) create mode 100644 src/main/java/cn/edu/cqwu/repair/controller/admin/AdminStuManageController.java create mode 100644 src/main/webapp/admin/stu_manage.jsp diff --git a/src/main/java/cn/edu/cqwu/repair/controller/admin/AdminStuManageController.java b/src/main/java/cn/edu/cqwu/repair/controller/admin/AdminStuManageController.java new file mode 100644 index 0000000..64e2971 --- /dev/null +++ b/src/main/java/cn/edu/cqwu/repair/controller/admin/AdminStuManageController.java @@ -0,0 +1,61 @@ +package cn.edu.cqwu.repair.controller.admin; + + +import cn.edu.cqwu.repair.dao.StuDao; +import cn.edu.cqwu.repair.entity.Stu; +import cn.edu.cqwu.repair.util.Encrypt; +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 java.util.ArrayList; + +/** + * @author xtaod + */ +@Controller +public class AdminStuManageController { + private final StuDao stuDao; + + @Autowired + public AdminStuManageController(StuDao stuDao) { + this.stuDao = stuDao; + } + + @RequestMapping("/admin/stu_manage/manage.do") + public String manage(String username, String userNo, Model model) { + if (!username.isEmpty()) { + findStusLikeUsername(username, model); + } else if (!userNo.isEmpty()) { + findStusLikeUserNo(userNo, model); + } else { + model.addAttribute("stuManageMess", "* 请输入查询条件!"); + } + return "/admin/stu_manage"; + } + + @RequestMapping("/admin/stu_manage/passReset.do") + public String passReset(String username, Model model) { + stuPassReset(username, model); + return "/admin/stu_manage"; + } + + private void findStusLikeUsername(String username, Model model) { + ArrayList stus = stuDao.findStusLikeUsername(username); + model.addAttribute("stus", stus); + } + + private void findStusLikeUserNo(String userNo, Model model) { + ArrayList stus = stuDao.findStusLikeUserNo(userNo); + model.addAttribute("stus", stus); + } + + private void stuPassReset(String username, Model model) { + if (stuDao.passModify(username, Encrypt.SHA("000000")) != 0) { + model.addAttribute("stuPassResetMess", "* 用户 " + username + " 的密码已重置为‘000000’!"); + } else { + model.addAttribute("stuPassResetMess", "* 用户 " + username + " 的密码清零操作失败!"); + } + } +} diff --git a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerFixListController.java b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerFixListController.java index 6236187..556cb21 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerFixListController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerFixListController.java @@ -1,35 +1,34 @@ package cn.edu.cqwu.repair.controller.worker; -import cn.edu.cqwu.repair.dao.WorkerDao; -import org.springframework.stereotype.Controller; - - import cn.edu.cqwu.repair.dao.OrderDao; - -import javax.servlet.http.*; -import cn.edu.cqwu.repair.entity.*; +import cn.edu.cqwu.repair.entity.Order; +import cn.edu.cqwu.repair.entity.Worker; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import java.util.List; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import java.util.List; - +/** + * @author sobear + */ @Controller -public class WorkerFixListController extends HttpServlet{ - private OrderDao orderDao; - private WorkerDao workerDao; +public class WorkerFixListController extends HttpServlet { + private final OrderDao orderDao; + @Autowired - public WorkerFixListController(WorkerDao workerDao, OrderDao orderDao) { - this.workerDao = workerDao; + public WorkerFixListController(OrderDao orderDao) { this.orderDao = orderDao; } - @GetMapping("/workerFixList.do") + @RequestMapping("/worker/FixList.do") public String getOrders(Model model, HttpSession session, - HttpServletRequest request){ + HttpServletRequest request) { // 获取Session对象 session = request.getSession(); diff --git a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryListController.java b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryListController.java index d7eeeff..867703a 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryListController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryListController.java @@ -1,32 +1,33 @@ package cn.edu.cqwu.repair.controller.worker; -import cn.edu.cqwu.repair.dao.WorkerDao; -import org.springframework.stereotype.Controller; - - import cn.edu.cqwu.repair.dao.OrderDao; - -import javax.servlet.http.*; -import cn.edu.cqwu.repair.entity.*; +import cn.edu.cqwu.repair.entity.Order; +import cn.edu.cqwu.repair.entity.Worker; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; -import java.util.List; + +import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import java.util.List; +/** + * @author sobear + */ @Controller -public class WorkerHistoryListController extends HttpServlet{ - private OrderDao orderDao; - private WorkerDao workerDao; +public class WorkerHistoryListController extends HttpServlet { + private final OrderDao orderDao; + @Autowired - public WorkerHistoryListController(WorkerDao workerDao, OrderDao orderDao) { - this.workerDao = workerDao; + public WorkerHistoryListController(OrderDao orderDao) { this.orderDao = orderDao; } - @GetMapping("/workerHistoryList.do") + + @GetMapping("/worker/HistoryList.do") public String getOrders(Model model, HttpSession session, - HttpServletRequest request){ + HttpServletRequest request) { // 获取Session对象 session = request.getSession(); diff --git a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryLoginController.java b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryLoginController.java index e8a9928..c92d0e1 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryLoginController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryLoginController.java @@ -1,33 +1,33 @@ package cn.edu.cqwu.repair.controller.worker; import cn.edu.cqwu.repair.dao.RecordDao; -import cn.edu.cqwu.repair.dao.WorkerDao; -import org.springframework.stereotype.Controller; - - -import cn.edu.cqwu.repair.dao.OrderDao; - -import javax.servlet.http.*; -import cn.edu.cqwu.repair.entity.*; +import cn.edu.cqwu.repair.entity.Record; +import cn.edu.cqwu.repair.entity.Worker; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; -import java.util.List; + +import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import java.util.List; +/** + * @author sobear + */ @Controller -public class WorkerHistoryLoginController extends HttpServlet{ +public class WorkerHistoryLoginController extends HttpServlet { private final RecordDao recordDao; - private final WorkerDao workerDao; + @Autowired - public WorkerHistoryLoginController(WorkerDao workerDao, RecordDao recordDao) { - this.workerDao = workerDao; + public WorkerHistoryLoginController(RecordDao recordDao) { this.recordDao = recordDao; } - @GetMapping("/workerHistoryLogin.do") + + @GetMapping("/worker/HistoryLogin.do") public String getOrders(Model model, HttpSession session, - HttpServletRequest request){ + HttpServletRequest request) { // 获取Session对象 session = request.getSession(); diff --git a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerLoginController.java b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerLoginController.java index da63b64..0e41cd0 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerLoginController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerLoginController.java @@ -28,7 +28,7 @@ public class WorkerLoginController { this.recordService = recordService; } - @RequestMapping("/workerLogin.do") + @RequestMapping("/worker/Login.do") public String workerLogin( String username, String password, String code, Model model, HttpSession session, HttpServletRequest request diff --git a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerOrderStatusController.java b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerOrderStatusController.java index d95eba5..00ced50 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerOrderStatusController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerOrderStatusController.java @@ -31,7 +31,7 @@ public class WorkerOrderStatusController { }else { model.addAttribute("workerListStatusMes", "* 状态更新失败!"); } - return "forward:/workerFixList.do"; + return "forward:/worker/FixList.do"; } diff --git a/src/main/java/cn/edu/cqwu/repair/dao/StuDao.java b/src/main/java/cn/edu/cqwu/repair/dao/StuDao.java index ac5b9f8..c85c4e0 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/StuDao.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/StuDao.java @@ -13,5 +13,7 @@ public interface StuDao { public int passModify(String username, String newpass); - public ArrayList findStusLikeUsername(String username); + ArrayList findStusLikeUsername(String username); + + ArrayList findStusLikeUserNo(String userNo); } diff --git a/src/main/java/cn/edu/cqwu/repair/dao/impl/StuDaoImpl.java b/src/main/java/cn/edu/cqwu/repair/dao/impl/StuDaoImpl.java index 20562d8..bc577a8 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/impl/StuDaoImpl.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/impl/StuDaoImpl.java @@ -60,4 +60,12 @@ public class StuDaoImpl implements StuDao { .where(STU.USERNAME.like(username)); return (ArrayList) MAPPER.selectListByQuery(qw); } + + @Override + public ArrayList findStusLikeUserNo(String userNo) { + QueryWrapper qw = new QueryWrapper(); + qw.select(STU.ALL_COLUMNS) + .where(STU.USER_NO.like(userNo)); + return (ArrayList) MAPPER.selectListByQuery(qw); + } } diff --git a/src/main/webapp/admin/stu_manage.jsp b/src/main/webapp/admin/stu_manage.jsp new file mode 100644 index 0000000..d9cf572 --- /dev/null +++ b/src/main/webapp/admin/stu_manage.jsp @@ -0,0 +1,80 @@ +<%-- + Created by IntelliJ IDEA. + User: xtaod + Date: 2024/5/14 + Time: 下午8:21 + 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" %> + + + + + + + ${title} + + + + + + +
+ <%@ include file="../includes/header.jsp" %> + +
+ +

${title}

+ + + + +
+
+ 用户名 + +
+
+ 学号 + +
+ +

+
+ + +
查询到的用户列表
+ + + + + + + + + + + + + + + + + + + + + +
序号用户名注册时间注册IP密码清零
${rows.count}${stu.username}${stu.regtime}${stu.regip}清零 +
+
+
+
+ + diff --git a/src/main/webapp/includes/menu.jsp b/src/main/webapp/includes/menu.jsp index decd922..9620696 100644 --- a/src/main/webapp/includes/menu.jsp +++ b/src/main/webapp/includes/menu.jsp @@ -32,8 +32,8 @@