删除:未使用代码
This commit is contained in:
parent
7b5dffa6a7
commit
18a584f73e
@ -21,13 +21,6 @@ public interface BaseDAO<T> {
|
|||||||
*/
|
*/
|
||||||
int deleteById(int id);
|
int deleteById(int id);
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新记录
|
|
||||||
* @param entity 实体对象
|
|
||||||
* @return 影响的行数
|
|
||||||
*/
|
|
||||||
int update(T entity);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询记录
|
* 根据ID查询记录
|
||||||
* @param id 主键ID
|
* @param id 主键ID
|
||||||
|
@ -87,46 +87,6 @@ public class LeaveRequestDAOImpl implements LeaveRequestDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新请假申请信息
|
|
||||||
* 根据请假申请对象的ID更新其他字段的值
|
|
||||||
*
|
|
||||||
* @param request 包含更新信息的请假申请对象
|
|
||||||
* @return 影响的行数,更新成功返回1,失败返回0
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int update(LeaveRequest request) {
|
|
||||||
if (request == null || request.getStudent() == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
String sql = "UPDATE leave_requests SET student_id = ?, start_time = ?, " +
|
|
||||||
"end_time = ?, status = ?, duration = ?, location = ?, " +
|
|
||||||
"reason_type = ?, reason_detail = ?, is_leaving_city = ?, " +
|
|
||||||
"request_time = ? WHERE id = ?";
|
|
||||||
try (Connection conn = DatabaseUtil.getConnection();
|
|
||||||
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
||||||
|
|
||||||
// 设置预处理语句的参数
|
|
||||||
stmt.setInt(1, request.getStudent().getId());
|
|
||||||
stmt.setTimestamp(2, new Timestamp(request.getStartTime().getTime()));
|
|
||||||
stmt.setTimestamp(3, new Timestamp(request.getEndTime().getTime()));
|
|
||||||
stmt.setString(4, request.getStatus().name());
|
|
||||||
stmt.setDouble(5, request.getDuration());
|
|
||||||
stmt.setString(6, request.getLocation());
|
|
||||||
stmt.setString(7, request.getReasonType());
|
|
||||||
stmt.setString(8, request.getReasonDetail());
|
|
||||||
stmt.setBoolean(9, request.isLeavingCity());
|
|
||||||
stmt.setTimestamp(10, new Timestamp(request.getRequestTime().getTime()));
|
|
||||||
stmt.setInt(11, request.getId());
|
|
||||||
|
|
||||||
return stmt.executeUpdate();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询请假申请信息
|
* 根据ID查询请假申请信息
|
||||||
* 同时会关联查询学生信息
|
* 同时会关联查询学生信息
|
||||||
|
@ -73,34 +73,6 @@ public class TeacherDAOImpl implements TeacherDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新教师信息
|
|
||||||
* 根据教师对象的ID更新其他字段的值
|
|
||||||
*
|
|
||||||
* @param teacher 包含更新信息的教师对象
|
|
||||||
* @return 影响的行数,更新成功返回1,失败返回0
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int update(Teacher teacher) {
|
|
||||||
String sql = "UPDATE teachers SET teacher_id = ?, name = ?, department = ?, contact = ?, password = ? WHERE id = ?";
|
|
||||||
try (Connection conn = DatabaseUtil.getConnection();
|
|
||||||
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
||||||
|
|
||||||
// 设置预处理语句的参数
|
|
||||||
stmt.setString(1, teacher.getTeacherId());
|
|
||||||
stmt.setString(2, teacher.getName());
|
|
||||||
stmt.setString(3, teacher.getDepartment());
|
|
||||||
stmt.setString(4, teacher.getContact());
|
|
||||||
stmt.setString(5, teacher.getPassword());
|
|
||||||
stmt.setInt(6, teacher.getId());
|
|
||||||
|
|
||||||
return stmt.executeUpdate();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询教师信息
|
* 根据ID查询教师信息
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user