From 1cbd412735c954ca2cbb4695a605bf1c7a9338f6 Mon Sep 17 00:00:00 2001 From: Lmx <1960868911@qq.com> Date: Sun, 16 Mar 2025 11:37:08 +0800 Subject: [PATCH] 1 --- src/com/ssm/ioc/Announcement.java | 85 ++++++++++++++++++++++++++++ src/com/ssm/ioc/Movie.java | 88 +++++++++++++++++++++++++++++ src/com/ssm/ioc/ScreeningRoom.java | 87 +++++++++++++++++++++++++++++ src/com/ssm/ioc/ShowSchedule.java | 89 ++++++++++++++++++++++++++++++ src/com/ssm/ioc/Tag.java | 85 ++++++++++++++++++++++++++++ src/com/ssm/ioc/TestIoc.java | 29 ++++++++++ 6 files changed, 463 insertions(+) create mode 100644 src/com/ssm/ioc/Announcement.java create mode 100644 src/com/ssm/ioc/Movie.java create mode 100644 src/com/ssm/ioc/ScreeningRoom.java create mode 100644 src/com/ssm/ioc/ShowSchedule.java create mode 100644 src/com/ssm/ioc/Tag.java create mode 100644 src/com/ssm/ioc/TestIoc.java diff --git a/src/com/ssm/ioc/Announcement.java b/src/com/ssm/ioc/Announcement.java new file mode 100644 index 0000000..1b1c216 --- /dev/null +++ b/src/com/ssm/ioc/Announcement.java @@ -0,0 +1,85 @@ +package com.ssm.ioc; +/** + * 该类表示公告实体,用于公告管理模块。 + * 包含公告的基本信息,如编号、标题、内容、发布日期和发布人等。 + */ +public class Announcement { + private int id; // 公告的唯一编号,用于标识不同的公告 + private String title; // 公告的标题,用于概括公告的主要内容 + private String content; // 公告的具体内容,包含详细信息 + private String publishDate; // 公告的发布日期,记录公告发布的时间 + private String publisher; // 公告的发布人,记录发布公告的人员 + + // 构造方法、getter 和 setter 方法 + /** + * 无参构造函数,用于创建一个空的 Announcement 对象。 + */ + public Announcement() {} + /** + * 有参构造函数,用于创建一个具有完整信息的 Announcement 对象。 + * + * @param id 公告的编号 + * @param title 公告的标题 + * @param content 公告的内容 + * @param publishDate 公告的发布日期 + * @param publisher 公告的发布人 + */ + public Announcement(int id, String title, String content, String publishDate, String publisher) { + this.id = id; + this.title = title; + this.content = content; + this.publishDate = publishDate; + this.publisher = publisher; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getPublishDate() { + return publishDate; + } + + public void setPublishDate(String publishDate) { + this.publishDate = publishDate; + } + + public String getPublisher() { + return publisher; + } + + public void setPublisher(String publisher) { + this.publisher = publisher; + } + + @Override + public String toString() { + return "Announcement{" + + "id=" + id + + ", title='" + title + '\'' + + ", content='" + content + '\'' + + ", publishDate='" + publishDate + '\'' + + ", publisher='" + publisher + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/com/ssm/ioc/Movie.java b/src/com/ssm/ioc/Movie.java new file mode 100644 index 0000000..9b7af4a --- /dev/null +++ b/src/com/ssm/ioc/Movie.java @@ -0,0 +1,88 @@ +package com.ssm.ioc; +/** + * 该类表示电影实体,用于电影管理模块。 + * 包含电影的基本信息,如编号、名称、导演、类型和时长等。 + */ +public class Movie { + private int id; // 电影的唯一编号,用于标识不同的电影 + private String name; // 电影的名称,用于展示和识别电影 + private String director; // 电影的导演,记录电影的创作者之一 + private String genre; // 电影的类型,如动作、冒险、科幻等 + private int duration; // 电影的时长,以分钟为单位 + + // 构造方法、getter 和 setter 方法 + //无参构造函数,用于创建一个空的 Movie 对象。 + public Movie() {} + + /** + * 有参构造函数,用于创建一个具有完整信息的 Movie 对象。 + * + * @param id 电影的编号 + * @param name 电影的名称 + * @param director 电影的导演 + * @param genre 电影的类型 + * @param duration 电影的时长 + */ + public Movie(int id, String name, String director, String genre, int duration) { + this.id = id; + this.name = name; + this.director = director; + this.genre = genre; + this.duration = duration; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getGenre() { + return genre; + } + + public void setGenre(String genre) { + this.genre = genre; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + /** + * 重写 toString 方法,用于方便打印电影对象的信息。 + * + * @return 包含电影信息的字符串 + */ + @Override + public String toString() { + return "Movie{" + + "id=" + id + + ", name='" + name + '\'' + + ", director='" + director + '\'' + + ", genre='" + genre + '\'' + + ", duration=" + duration + + '}'; + } +} \ No newline at end of file diff --git a/src/com/ssm/ioc/ScreeningRoom.java b/src/com/ssm/ioc/ScreeningRoom.java new file mode 100644 index 0000000..1a236a5 --- /dev/null +++ b/src/com/ssm/ioc/ScreeningRoom.java @@ -0,0 +1,87 @@ +package com.ssm.ioc; +/** + * 该类表示放映厅实体,用于放映厅管理模块。 + * 包含放映厅的基本信息,如编号、名称、容量、类型和状态等。 + */ +public class ScreeningRoom { + // 放映厅的唯一编号,用于标识不同的放映厅 + private int id; + // 放映厅的名称,用于识别放映厅 + private String name; + // 放映厅的容量,即可以容纳的人数 + private int capacity; + // 放映厅的类型,如 2D、3D 等 + private String type; + // 放映厅的状态,如可用、不可用等 + private String status; + + // 构造方法、getter 和 setter 方法 + public ScreeningRoom() {} + /** + * 有参构造函数,用于创建一个具有完整信息的 ScreeningRoom 对象。 + * + * @param id 放映厅的编号 + * @param name 放映厅的名称 + * @param capacity 放映厅的容量 + * @param type 放映厅的类型 + * @param status 放映厅的状态 + */ + public ScreeningRoom(int id, String name, int capacity, String type, String status) { + this.id = id; + this.name = name; + this.capacity = capacity; + this.type = type; + this.status = status; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getCapacity() { + return capacity; + } + + public void setCapacity(int capacity) { + this.capacity = capacity; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public String toString() { + return "ScreeningRoom{" + + "id=" + id + + ", name='" + name + '\'' + + ", capacity=" + capacity + + ", type='" + type + '\'' + + ", status='" + status + '\'' + + '}'; + } + } diff --git a/src/com/ssm/ioc/ShowSchedule.java b/src/com/ssm/ioc/ShowSchedule.java new file mode 100644 index 0000000..e729f56 --- /dev/null +++ b/src/com/ssm/ioc/ShowSchedule.java @@ -0,0 +1,89 @@ +package com.ssm.ioc; + +/** + * 该类表示场次安排实体,用于场次安排管理模块。 + * 包含场次的基本信息,如编号、关联的电影编号、放映厅编号、开始时间和结束时间等。 + */ +public class ShowSchedule { + // 场次的唯一编号,用于标识不同的场次 + private int id; + // 外键,关联的电影编号,用于确定该场次放映的电影 + private int movieId; + // 关联的放映厅编号,用于确定该场次在哪个放映厅放映 + private int screeningRoomId; + // 场次的开始时间,使用 java.util.Date 类型记录 + private String startTime; + // 场次的结束时间,使用 java.util.Date 类型记录 + private String endTime; + + // 构造方法、getter 和 setter 方法 + public ShowSchedule() {} + /** + * 有参构造函数,用于创建一个具有完整信息的 ShowSchedule 对象。 + * + * @param id 场次的编号 + * @param movieId 关联的电影编号 + * @param screeningRoomId 关联的放映厅编号 + * @param startTime 场次的开始时间 + * @param endTime 场次的结束时间 + */ + public ShowSchedule(int id, int movieId, int screeningRoomId, String startTime, String endTime) { + this.id = id; + this.movieId = movieId; + this.screeningRoomId = screeningRoomId; + this.startTime = String.valueOf(startTime); + this.endTime = String.valueOf(endTime); + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getMovieId() { + return movieId; + } + + public void setMovieId(int movieId) { + this.movieId = movieId; + } + + public int getScreeningRoomId() { + return screeningRoomId; + } + + public void setScreeningRoomId(int screeningRoomId) { + this.screeningRoomId = screeningRoomId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime =startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + @Override + public String toString() { + return "ShowSchedule{" + + "id=" + id + + ", movieId=" + movieId + + ", screeningRoomId=" + screeningRoomId + + ", startTime=" + startTime + + ", endTime=" + endTime + + '}'; + } + +} \ No newline at end of file diff --git a/src/com/ssm/ioc/Tag.java b/src/com/ssm/ioc/Tag.java new file mode 100644 index 0000000..f07248d --- /dev/null +++ b/src/com/ssm/ioc/Tag.java @@ -0,0 +1,85 @@ +package com.ssm.ioc; +/** + * 该类表示标签实体,用于标签管理模块。 + * 包含标签的基本信息,如编号、名称、描述、创建日期和状态等。 + */ +public class Tag { + private int id; // 标签的唯一编号,用于标识不同的标签 + private String name; // 标签的名称,用于识别标签的用途 + private String description; // 标签的描述,对标签的详细说明 + private String createDate; // 标签的创建日期,记录标签创建的时间 + private int status; // 标签的状态,如启用、禁用等 + + // 构造方法、getter 和 setter 方法 + /** + * 无参构造函数,用于创建一个空的 Tag 对象。 + */ + public Tag() {} + /** + * 有参构造函数,用于创建一个具有完整信息的 Tag 对象。 + * + * @param id 标签的编号 + * @param name 标签的名称 + * @param description 标签的描述 + * @param createDate 标签的创建日期 + * @param status 标签的状态 + */ + public Tag(int id, String name, String description, String createDate, int status) { + this.id = id; + this.name = name; + this.description = description; + this.createDate = createDate; + this.status = status; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateDate() { + return createDate; + } + + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + @Override + public String toString() { + return "Tag{" + + "id=" + id + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", createDate='" + createDate + '\'' + + ", status=" + status + + '}'; + } +} \ No newline at end of file diff --git a/src/com/ssm/ioc/TestIoc.java b/src/com/ssm/ioc/TestIoc.java new file mode 100644 index 0000000..656261b --- /dev/null +++ b/src/com/ssm/ioc/TestIoc.java @@ -0,0 +1,29 @@ +package com.ssm.ioc; + +import com.ssm.di.xml.Announcement; +import com.ssm.di.xml.Movie; +import com.ssm.di.xml.ScreeningRoom; +import com.ssm.di.xml.ShowSchedule; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class TestIoc { + public static void main(String[] args) { + ApplicationContext context = new ClassPathXmlApplicationContext("bean-ioc.xml"); + + Movie movie = (Movie) context.getBean("movie"); + System.out.println(movie.toString()); + + Announcement announcement = (Announcement) context.getBean("announcement"); + System.out.println(announcement); + + Tag tag = (Tag) context.getBean("tag"); + System.out.println(tag); + + ShowSchedule showSchedule = (ShowSchedule) context.getBean("showSchedule"); + System.out.println(showSchedule); + + ScreeningRoom screeningRoom = (ScreeningRoom) context.getBean("screeningRoom"); + System.out.println(screeningRoom); + } +}