diff --git a/ticketing-master/src/com/cn/service/TrainService.java b/ticketing-master/src/com/cn/service/TrainService.java index e2d16d6..246ec02 100644 --- a/ticketing-master/src/com/cn/service/TrainService.java +++ b/ticketing-master/src/com/cn/service/TrainService.java @@ -1,74 +1,83 @@ package com.cn.service; -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类,该类代表车次的实体 +/** + * 定义车次服务接口,提供车次相关的业务操作。 + */ public interface TrainService { - /** - * 添加车次 - * @return 返回1为添加成功 - * @throws SQLException - */ - int add(Train train); - - /** - * 删除车次 - * @return 返回1为删除成功 - * @throws SQLException - */ - int delete(Integer trainId); - - /** - * 修改车次 - * @return 返回1为修改成功 - * @throws SQLException - */ - int update(Train train); - - /** - * 获取所有车次信息 - * @return 返回元素为Train对象的list - * @throws SQLException - */ - List getAll(); - - /** - * 根据id查询车次信息 - * @return Train的对象 - * @throws SQLException - */ - Train getById(Integer trainId); - - /** - * 根据车次查询车次信息 - * @return 元素为Train的对象的list - * @throws SQLException - */ - List getByTrainNumber(String trainNumber); - - /** - * 根据起始站、终点站、开车时间、查询车次信息 - * @param startStation 起始站 - * @param endStation 终点站 - * @param startTime 传进去的时候没有时分秒 - * @return 元素为Train对象的list - * @throws SQLException - */ - List getByStartEndStation(String startStation, String endStation, String startTime); - - /** - * 获取所有非重复的起始站 - * @return - * @throws SQLException - */ - List getAllStartStation(); - - /** - * 获取所有非重复的终点站 - * @return - * @throws SQLException - */ - List getAllEndStation(); -} + + /** + * 添加一个新的车次。 + * @param train 车次对象,包含车次的详细信息。 + * @return 返回1表示添加成功。 + * @throws SQLException 如果数据库操作失败,则抛出SQLException异常。 + */ + int add(Train train); + + /** + * 根据车次ID删除一个车次。 + * @param trainId 要删除的车次的ID。 + * @return 返回1表示删除成功。 + * @throws SQLException 如果数据库操作失败,则抛出SQLException异常。 + */ + int delete(Integer trainId); + + /** + * 更新一个车次的信息。 + * @param train 包含更新信息的车次对象。 + * @return 返回1表示更新成功。 + * @throws SQLException 如果数据库操作失败,则抛出SQLException异常。 + */ + int update(Train train); + + /** + * 获取所有车次的信息。 + * @return 返回一个包含所有车次信息的List,其中每个元素都是Train对象。 + * @throws SQLException 如果数据库操作失败,则抛出SQLException异常。 + */ + List getAll(); + + /** + * 根据车次ID查询一个车次的详细信息。 + * @param trainId 要查询的车次的ID。 + * @return 返回一个Train对象,包含车次的详细信息。 + * @throws SQLException 如果数据库操作失败,则抛出SQLException异常。 + */ + Train getById(Integer trainId); + + /** + * 根据车次号查询车次信息。 + * @param trainNumber 车次号。 + * @return 返回一个包含匹配车次号的所有车次信息的List,其中每个元素都是Train对象。 + * @throws SQLException 如果数据库操作失败,则抛出SQLException异常。 + */ + List getByTrainNumber(String trainNumber); + + /** + * 根据起始站、终点站、开车时间查询车次信息。 + * @param startStation 起始站名称。 + * @param endStation 终点站名称。 + * @param startTime 开车时间,传入时不包含时分秒。 + * @return 返回一个包含匹配起始站、终点站和开车时间的所有车次信息的List,其中每个元素都是Train对象。 + * @throws SQLException 如果数据库操作失败,则抛出SQLException异常。 + */ + List getByStartEndStation(String startStation, String endStation, String startTime); + + /** + * 获取所有非重复的起始站。 + * @return 返回一个包含所有非重复起始站的List,其中每个元素都是Train对象。 + * @throws SQLException 如果数据库操作失败,则抛出SQLException异常。 + */ + List getAllStartStation(); + + /** + * 获取所有非重复的终点站。 + * @return 返回一个包含所有非重复终点站的List,其中每个元素都是Train对象。 + * @throws SQLException 如果数据库操作失败,则抛出SQLException异常。 + */ + List getAllEndStation(); +} \ No newline at end of file