重构:删除没有被使用的代码
早期规划该项目时,功能多于当前实现。删除的是当前无用的代码,例如根据班级名称查找所有学生等。后期如果完善该项目,可以查看该commit删除的代码
This commit is contained in:
parent
5b51b8a151
commit
a7825643a7
@ -14,13 +14,6 @@ public interface StudentDAO extends BaseDAO<Student> {
|
|||||||
*/
|
*/
|
||||||
Student findByStudentId(String studentId);
|
Student findByStudentId(String studentId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据班级查询学生列表
|
|
||||||
* @param className 班级名称
|
|
||||||
* @return 学生列表
|
|
||||||
*/
|
|
||||||
List<Student> findByClassName(String className);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据姓名模糊查询学生
|
* 根据姓名模糊查询学生
|
||||||
* @param name 学生姓名
|
* @param name 学生姓名
|
||||||
|
@ -13,18 +13,4 @@ public interface TeacherDAO extends BaseDAO<Teacher> {
|
|||||||
* @return 教师对象
|
* @return 教师对象
|
||||||
*/
|
*/
|
||||||
Teacher findByTeacherId(String teacherId);
|
Teacher findByTeacherId(String teacherId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据部门查询教师列表
|
|
||||||
* @param department 部门名称
|
|
||||||
* @return 教师列表
|
|
||||||
*/
|
|
||||||
List<Teacher> findByDepartment(String department);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据姓名模糊查询教师
|
|
||||||
* @param name 教师姓名
|
|
||||||
* @return 教师列表
|
|
||||||
*/
|
|
||||||
List<Teacher> findByNameLike(String name);
|
|
||||||
}
|
}
|
||||||
|
@ -133,25 +133,6 @@ public class StudentDAOImpl implements StudentDAO {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Student> findByClassName(String className) {
|
|
||||||
List<Student> students = new ArrayList<>();
|
|
||||||
String sql = "SELECT * FROM students WHERE class_name = ?";
|
|
||||||
try (Connection conn = DatabaseUtil.getConnection();
|
|
||||||
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
||||||
|
|
||||||
stmt.setString(1, className);
|
|
||||||
ResultSet rs = stmt.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
students.add(mapResultSetToStudent(rs));
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return students;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Student> findByNameLike(String name) {
|
public List<Student> findByNameLike(String name) {
|
||||||
List<Student> students = new ArrayList<>();
|
List<Student> students = new ArrayList<>();
|
||||||
|
@ -129,44 +129,6 @@ public class TeacherDAOImpl implements TeacherDAO {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Teacher> findByDepartment(String department) {
|
|
||||||
List<Teacher> teachers = new ArrayList<>();
|
|
||||||
String sql = "SELECT * FROM teachers WHERE department = ?";
|
|
||||||
try (Connection conn = DatabaseUtil.getConnection();
|
|
||||||
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
||||||
|
|
||||||
stmt.setString(1, department);
|
|
||||||
ResultSet rs = stmt.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
teachers.add(mapResultSetToTeacher(rs));
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return teachers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Teacher> findByNameLike(String name) {
|
|
||||||
List<Teacher> teachers = new ArrayList<>();
|
|
||||||
String sql = "SELECT * FROM teachers WHERE name LIKE ?";
|
|
||||||
try (Connection conn = DatabaseUtil.getConnection();
|
|
||||||
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
||||||
|
|
||||||
stmt.setString(1, "%" + name + "%");
|
|
||||||
ResultSet rs = stmt.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
teachers.add(mapResultSetToTeacher(rs));
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return teachers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将ResultSet映射为Teacher对象
|
* 将ResultSet映射为Teacher对象
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user