diff --git a/ticketing-master/src/com/cn/dao/TrainDao.java b/ticketing-master/src/com/cn/dao/TrainDao.java index 5faa6c4..15a084f 100644 --- a/ticketing-master/src/com/cn/dao/TrainDao.java +++ b/ticketing-master/src/com/cn/dao/TrainDao.java @@ -1,82 +1,96 @@ -package com.cn.dao; +package com.cn.dao; // 定义接口所在的包名 -import java.sql.SQLException; -import java.util.List; +import java.sql.SQLException; // 导入SQLException类 +import java.util.List; // 导入List接口 -import com.cn.domain.Train; +import com.cn.domain.Train; // 导入Train实体类 /** - * - * @ClassName: TrainDao + * TrainDao接口,定义车次数据访问对象(DAO)的操作。 + *

该接口声明了与车次相关的数据库操作,包括添加、删除、修改、查询等。

+ * @ClassName: TrainDao * @Description: Train表的数据持久层接口 * @author: ljy * @date: 2019年9月1日 下午1:33:46 */ public interface TrainDao { - - /** - * 添加车次 - * @return 返回1为添加成功 - * @throws SQLException - */ - int add(Train train) throws SQLException; - - /** - * 删除车次 - * @return 返回1为删除成功 - * @throws SQLException - */ - int delete(Integer trainId) throws SQLException; - - /** - * 修改车次 - * @return 返回1为修改成功 - * @throws SQLException - */ - int update(Train train) throws SQLException; - - /** - * 获取所有车次信息 - * @return 返回元素为Train对象的list - * @throws SQLException - */ - List getAll() throws SQLException; - - /** - * 根据id查询车次信息 - * @return Train的对象 - * @throws SQLException - */ - Train getById(Integer trainId) throws SQLException; - - /** - * 根据车次查询车次信息 - * @return 元素为Train的对象的list - * @throws SQLException - */ - List getByTrainNumber(String trainNumber) throws SQLException; - - /** - * 根据起始站、终点站、开车时间、查询车次信息 - * @param startStation 起始站 - * @param endStation 终点站 - * @param startTime 传进去的时候没有时分秒 - * @return Train的对象 - * @throws SQLException - */ - List getByStartEndStation(String startStation, String endStation, String startTime) throws SQLException; - - /** - * 获取所有非重复的起始站 - * @return - * @throws SQLException - */ - List getAllStartStation() throws SQLException; - - /** - * 获取所有非重复的终点站 - * @return - * @throws SQLException - */ - List getAllEndStation() throws SQLException; + /** + * 添加新的车次到数据库。 + *

该方法接受一个Train对象作为参数,将车次信息插入到数据库中。

+ * @param train 要添加的车次对象 + * @return 返回1表示添加成功,返回0表示添加失败 + * @throws SQLException 如果数据库操作出现异常 + */ + int add(Train train) throws SQLException; + + /** + * 根据车次ID从数据库中删除车次。 + *

该方法接受一个车次ID作为参数,根据该ID从数据库中删除对应的车次记录。

+ * @param trainId 要删除的车次ID + * @return 返回1表示删除成功,返回0表示删除失败 + * @throws SQLException 如果数据库操作出现异常 + */ + int delete(Integer trainId) throws SQLException; + + /** + * 更新数据库中的车次信息。 + *

该方法接受一个Train对象作为参数,根据对象中的ID更新数据库中的车次记录。

+ * @param train 包含更新信息的车次对象 + * @return 返回1表示修改成功,返回0表示修改失败 + * @throws SQLException 如果数据库操作出现异常 + */ + int update(Train train) throws SQLException; + + /** + * 查询数据库中的所有车次信息。 + *

该方法返回一个包含所有车次信息的列表。

+ * @return 返回包含所有车次信息的列表 + * @throws SQLException 如果数据库操作出现异常 + */ + List getAll() throws SQLException; + + /** + * 根据车次ID查询车次信息。 + *

该方法接受一个车次ID作为参数,返回包含该ID的车次信息。

+ * @param trainId 要查询的车次ID + * @return 返回包含指定ID的车次信息 + * @throws SQLException 如果数据库操作出现异常 + */ + Train getById(Integer trainId) throws SQLException; + + /** + * 根据车次编号查询车次信息。 + *

该方法接受一个车次编号作为参数,返回包含该编号的所有车次信息。

+ * @param trainNumber 车次编号 + * @return 返回包含指定车次编号的所有车次信息的列表 + * @throws SQLException 如果数据库操作出现异常 + */ + List getByTrainNumber(String trainNumber) throws SQLException; + + /** + * 根据起始站、终点站、开车时间查询车次信息。 + *

该方法接受起始站、终点站和开车时间作为参数,返回匹配的车次信息。

+ * @param startStation 起始站 + * @param endStation 终点站 + * @param startTime 开车时间(不含时分秒) + * @return 返回匹配的车次信息列表 + * @throws SQLException 如果数据库操作出现异常 + */ + List getByStartEndStation(String startStation, String endStation, String startTime) throws SQLException; + + /** + * 查询所有非重复的起始站。 + *

该方法返回一个包含所有非重复起始站的列表。

+ * @return 返回所有非重复起始站的列表 + * @throws SQLException 如果数据库操作出现异常 + */ + List getAllStartStation() throws SQLException; + + /** + * 查询所有非重复的终点站。 + *

该方法返回一个包含所有非重复终点站的列表。

+ * @return 返回所有非重复终点站的列表 + * @throws SQLException 如果数据库操作出现异常 + */ + List getAllEndStation() throws SQLException; }