diff --git a/src/main/java/cn/ppdxzz/dao/StudentDao.java b/src/main/java/cn/ppdxzz/dao/StudentDao.java index 507c9b1..9b0baa4 100644 --- a/src/main/java/cn/ppdxzz/dao/StudentDao.java +++ b/src/main/java/cn/ppdxzz/dao/StudentDao.java @@ -7,88 +7,87 @@ import org.springframework.stereotype.Repository; import java.util.List; /** - * Description:学生类的持久层 - * - * @Date: 2020/2/17 14:19 - * @Author: PeiChen + * Description:学生类的持久层接口,用于定义对学生信息进行数据库操作的方法 */ @Repository public interface StudentDao { /** * 查询所有学生信息 - * @return - * @throws Exception + * @return 返回包含所有学生信息的列表 + * @throws Exception 如果查询过程中发生错误则抛出异常 */ @Select("select * from students") List findAll() throws Exception; /** * 通过学号sno查询学生信息 - * @return - * @throws Exception + * @param sno 学生的学号 + * @return 返回对应学号的学生信息 + * @throws Exception 如果查询过程中发生错误则抛出异常 */ @Select("select * from students where sno = #{sno}") Student findBySno(String sno) throws Exception; /** * 模糊查询学生信息 - * @return - * @throws Exception + * @param keyword 搜索关键字 + * @return 返回匹配关键字的学生信息列表 + * @throws Exception 如果查询过程中发生错误则抛出异常 */ @Select("select * from students where name like '%${keyword}%' or sex like '%${keyword}%' or sno like '%${keyword}%' or stu_class like '%${keyword}%' or phone like '%${keyword}%' or place like '%${keyword}%' or dorm_id like '%${keyword}%' or teacher like '%${keyword}%' ") List search(@Param(value = "keyword") String keyword) throws Exception; /** * 添加学生信息 - * @param student - * @throws Exception + * @param student 要添加的学生对象 + * @throws Exception 如果添加过程中发生错误则抛出异常 */ @Insert("insert into students(name, sex, sno, stu_class, phone, place, dorm_id, teacher, status) values(#{name},#{sex},#{sno},#{stu_class},#{phone},#{place},#{dorm_id},#{teacher},#{status})") void add(Student student) throws Exception; /** - * 根据id删除学生 - * @param sno - * @throws Exception + * 根据学号删除学生信息 + * @param sno 学生的学号 + * @throws Exception 如果删除过程中发生错误则抛出异常 */ @Delete("delete from students where sno = #{sno}") void delete(String sno) throws Exception; /** - * 根据id修改学生信息 - * @param student - * @throws Exception + * 根据学号修改学生信息 + * @param student 更新后的学生对象 + * @throws Exception 如果更新过程中发生错误则抛出异常 */ @Update("update students set name = #{name},sex = #{sex},sno = #{sno},stu_class = #{stu_class},phone = #{phone},place = #{place},dorm_id = #{dorm_id},teacher = #{teacher},status = #{status} where id = #{id}") void update(Student student) throws Exception; /** - * 根据宿舍号查询状态为status的宿舍学生 - * @param dorm_id - * @return - * @throws Exception + * 根据宿舍号和状态查询学生信息 + * @param dorm_id 宿舍号 + * @param status 学生状态 + * @return 返回符合条件的学生信息列表 + * @throws Exception 如果查询过程中发生错误则抛出异常 */ @Select("select * from students where dorm_id = #{dorm_id} and status = #{status}") List findByDormId(@Param(value = "dorm_id") String dorm_id,@Param(value = "status") Integer status) throws Exception; /** - * 查询育人导师为teacher的学生集合 - * @param teacher - * @return - * @throws Exception + * 查询指定育人导师所带的所有学生信息 + * @param teacher 育人导师的名字 + * @return 返回该育人导师所带的学生信息列表 + * @throws Exception 如果查询过程中发生错误则抛出异常 */ @Select("select * from students where teacher = #{teacher}") List findByTeacher(String teacher) throws Exception; /** - * 模糊查询固定育人导师所带学生信息 - * @param teacher - * @param keyword - * @return - * @throws Exception + * 模糊查询固定育人导师所带的学生信息 + * @param teacher 育人导师的名字 + * @param keyword 搜索关键字 + * @return 返回匹配关键字的该育人导师所带的学生信息列表 + * @throws Exception 如果查询过程中发生错误则抛出异常 */ @Select("select * from students where teacher = #{teacher} and sno = #{keyword} ") List searchStudent(@Param(value = "teacher") String teacher,@Param(value = "keyword") String keyword) throws Exception; - } diff --git a/src/main/java/cn/ppdxzz/domain/Student.java b/src/main/java/cn/ppdxzz/domain/Student.java index aa7464f..7c95104 100644 --- a/src/main/java/cn/ppdxzz/domain/Student.java +++ b/src/main/java/cn/ppdxzz/domain/Student.java @@ -3,26 +3,26 @@ package cn.ppdxzz.domain; import java.io.Serializable; /** - * Description: - * - * @Date: 2020/2/17 14:08 - * @Author: PeiChen + * Student类表示一个学生对象,包含学生的基本信息和状态。 + * 该类实现了Serializable接口,允许其对象被序列化。 */ public class Student implements Serializable { - private Integer id; - private String name;//姓名 - private String sex;//性别 - private String sno;//学号 - private String stu_class;//班级 - private String phone;//联系方式 - private String place;//家庭住址 - private String dorm_id;//宿舍号 - private String teacher;//育人导师 - private Integer status;//学生状态是否激活:1 激活 0 禁用 - + private Integer id; // 学生的唯一标识符 + private String name; // 学生的姓名 + private String sex; // 学生的性别 + private String sno; // 学生的学号 + private String stu_class; // 学生所在的班级 + private String phone; // 学生的联系电话 + private String place; // 学生的家庭住址 + private String dorm_id; // 学生宿舍的编号 + private String teacher; // 负责学生育人导师的名字 + private Integer status; // 学生的状态:1表示激活,0表示禁用 + + // 无参构造函数 public Student() { } + // 全参构造函数,用于创建具有所有属性的学生对象 public Student(Integer id, String name, String sex, String sno, String stu_class, String phone, String place, String dorm_id, String teacher, Integer status) { this.id = id; this.name = name; @@ -36,6 +36,7 @@ public class Student implements Serializable { this.status = status; } + // Getter和Setter方法用于访问和修改私有属性 public Integer getId() { return id; } @@ -116,6 +117,7 @@ public class Student implements Serializable { this.status = status; } + // toString方法用于返回对象的字符串表示形式,便于调试和日志记录 @Override public String toString() { return "Student{" + diff --git a/src/main/java/cn/ppdxzz/service/StudentService.java b/src/main/java/cn/ppdxzz/service/StudentService.java index a3a1ab6..f24ae2a 100644 --- a/src/main/java/cn/ppdxzz/service/StudentService.java +++ b/src/main/java/cn/ppdxzz/service/StudentService.java @@ -6,31 +6,93 @@ import java.io.InputStream; import java.util.List; /** - * Description:学生业务层 - * - * @Date: 2020/2/17 14:21 - * @Author: PeiChen + * Description:学生业务层接口,定义了对学生信息进行操作的方法 */ public interface StudentService { - List findAll(int page,int size) throws Exception; + /** + * 分页查询所有学生信息 + * @param page 当前页码 + * @param size 每页显示的记录数 + * @return 返回学生列表 + * @throws Exception 如果查询过程中发生错误 + */ + List findAll(int page, int size) throws Exception; + /** + * 根据学号查询学生信息 + * @param sno 学生的学号 + * @return 返回对应的学生对象 + * @throws Exception 如果查询过程中发生错误 + */ Student findBySno(String sno) throws Exception; + /** + * 分页搜索学生信息 + * @param page 当前页码 + * @param size 每页显示的记录数 + * @param keyword 搜索关键字 + * @return 返回符合条件的学生列表 + * @throws Exception 如果搜索过程中发生错误 + */ List search(int page, int size, String keyword) throws Exception; + /** + * 添加新的学生信息 + * @param student 要添加的学生对象 + * @return 成功添加返回true,否则返回false + * @throws Exception 如果添加过程中发生错误 + */ boolean add(Student student) throws Exception; + /** + * 根据学号删除学生信息 + * @param sno 学生的学号 + * @throws Exception 如果删除过程中发生错误 + */ void delete(String sno) throws Exception; + /** + * 更新学生信息 + * @param student 要更新的学生对象 + * @throws Exception 如果更新过程中发生错误 + */ void update(Student student) throws Exception; - //返回一个携带所有学生信息数据的InputStream输入流 + /** + * 获取包含所有学生信息的输入流 + * @return 返回一个携带所有学生信息数据的InputStream输入流 + * @throws Exception 如果获取过程中发生错误 + */ InputStream getInputStream() throws Exception; - List findByDormId(String dorm_id,Integer status) throws Exception; + /** + * 根据宿舍ID和状态查询学生信息 + * @param dorm_id 宿舍ID + * @param status 学生状态(激活或禁用) + * @return 返回符合条件的学生列表 + * @throws Exception 如果查询过程中发生错误 + */ + List findByDormId(String dorm_id, Integer status) throws Exception; - List findByTeacher(int page,int size,String teacher) throws Exception; + /** + * 根据教师姓名分页查询学生信息 + * @param page 当前页码 + * @param size 每页显示的记录数 + * @param teacher 教师姓名 + * @return 返回符合条件的学生列表 + * @throws Exception 如果查询过程中发生错误 + */ + List findByTeacher(int page, int size, String teacher) throws Exception; - List searchStudent(int page,int size,String teacher,String keyword) throws Exception; + /** + * 根据教师姓名和搜索关键字分页查询学生信息 + * @param page 当前页码 + * @param size 每页显示的记录数 + * @param teacher 教师姓名 + * @param keyword 搜索关键字 + * @return 返回符合条件的学生列表 + * @throws Exception 如果查询过程中发生错误 + */ + List searchStudent(int page, int size, String teacher, String keyword) throws Exception; } diff --git a/src/main/webapp/WEB-INF/jsp/student-add.jsp b/src/main/webapp/WEB-INF/jsp/student-add.jsp index b5efdb2..3ebaf56 100644 --- a/src/main/webapp/WEB-INF/jsp/student-add.jsp +++ b/src/main/webapp/WEB-INF/jsp/student-add.jsp @@ -1,33 +1,19 @@ -<%-- - Created by IntelliJ IDEA. - User: user - Date: 2020/2/17 - Time: 12:33 - To change this template use File | Settings | File Templates. ---%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> Title + - - -
+ - - - + + + - - - - + + + + - + - + @@ -73,49 +47,45 @@ - + - + - +
- - - - - -
- - - - - - - -
- - - -
- -
- - - -
+ - 返回列表 + + 返回列表
+ + + - - - - - - +<%-- 导航栏部分被注释掉了 --%> <%--
首页 @@ -50,7 +44,7 @@ 导航元素 - +
--%>
@@ -58,24 +52,29 @@
+
- +
+ 添加 - 导出 + + 导出 + 共有数据:${pageInfo.total} 条
+ @@ -94,38 +93,44 @@ <% - int j = 1; + int j = 1; // 初始化行号计数器 %> + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + +
<%=j++%>${student.name}${student.sex}${student.sno}${student.stu_class}${student.phone}${student.dorm_id}${student.teacher} - - - - - - -
<%=j++%> ${student.name} ${student.sex} ${student.sno} ${student.stu_class} ${student.phone} ${student.dorm_id} ${student.teacher} + + + + + + + + +
+
@@ -139,32 +144,28 @@ 条
+ + // 根据总页数和当前页码,动态设置分页导航的起始和结束页码 - - - - + + - - - - + + - - - - + + - - - - + + + + // 分页导航按钮部分
@@ -183,8 +184,7 @@ - -
+
diff --git a/src/main/webapp/WEB-INF/jsp/studentsTeacher.jsp b/src/main/webapp/WEB-INF/jsp/studentsTeacher.jsp index ac57c43..3d17369 100644 --- a/src/main/webapp/WEB-INF/jsp/studentsTeacher.jsp +++ b/src/main/webapp/WEB-INF/jsp/studentsTeacher.jsp @@ -1,10 +1,3 @@ -<%-- - Created by IntelliJ IDEA. - User: user - Date: 2020/2/10 - Time: 21:45 - 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" %> @@ -13,21 +6,16 @@ + - - - - - + - +<%-- 注释掉的导航栏代码 --%> <%--
首页 @@ -35,14 +23,16 @@ 导航元素 - +
--%> +
+ <%--
@@ -56,10 +46,13 @@ --%>
+ 添加 + 共有数据:${pageInfo.total} 条
+ @@ -73,40 +66,47 @@ + <% - int j = 1; + int j = 1; // 初始化行号计数器 %> + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + +
育人导师 状态 操作
<%=j++%>${student.name}${student.sex}${student.sno}${student.stu_class}${student.phone}${student.dorm_id}${student.teacher}
<%=j++%> ${student.name} ${student.sex} ${student.sno} ${student.stu_class} ${student.phone} ${student.dorm_id} ${student.teacher}
+
共 ${pageInfo.pages} 页 当前页:${pageInfo.pageNum} / ${pageInfo.pages}  每页 +
+ + - - - - + + + - - - - + + + - - - - + + + - - - - + + + +
+
+ + + + ${i} + ${i} + +
@@ -168,24 +175,28 @@
- + + +