parent
21e28f0c80
commit
aaa718bcf1
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="dataSourceStorageLocal" created-in="IU-243.22562.218">
|
||||
<data-source name="@localhost" uuid="b17b4acc-8ddf-4336-a9b5-af14c1e96c6f">
|
||||
<database-info product="MySQL" version="9.1.0" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="9.1.0" exact-driver-version="8.2">
|
||||
<extra-name-characters>#@</extra-name-characters>
|
||||
<identifier-quote-string>`</identifier-quote-string>
|
||||
</database-info>
|
||||
<case-sensitivity plain-identifiers="lower" quoted-identifiers="lower" />
|
||||
<secret-storage>master_key</secret-storage>
|
||||
<user-name>zbl</user-name>
|
||||
<schema-mapping>
|
||||
<introspection-scope>
|
||||
<node kind="schema" negative="1" />
|
||||
</introspection-scope>
|
||||
</schema-mapping>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="@localhost" uuid="b17b4acc-8ddf-4336-a9b5-af14c1e96c6f">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@
|
||||
#n:dormitory
|
||||
!<md> [0, 0, null, null, -2147483648, -2147483648]
|
||||
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#n:information_schema
|
||||
!<md> [0, 0, null, null, -2147483648, -2147483648]
|
||||
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#n:mysql
|
||||
!<md> [0, 0, null, null, -2147483648, -2147483648]
|
||||
@ -0,0 +1,2 @@
|
||||
#n:performance_schema
|
||||
!<md> [0, 0, null, null, -2147483648, -2147483648]
|
||||
@ -0,0 +1,2 @@
|
||||
#n:sakila
|
||||
!<md> [0, 0, null, null, -2147483648, -2147483648]
|
||||
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#n:sys
|
||||
!<md> [0, 0, null, null, -2147483648, -2147483648]
|
||||
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#n:world
|
||||
!<md> [0, 0, null, null, -2147483648, -2147483648]
|
||||
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JpaBuddyIdeaProjectConfig" newRepositoryParent="org.springframework.data.jpa.repository.JpaRepository">
|
||||
<option name="defaultUnitInitialized" value="true" />
|
||||
<option name="reLastEntityCreationPackage" value="src/main/java/dataschema" />
|
||||
<option name="renamerInitialized" value="true" />
|
||||
<option name="reverseEngineeringLastDbConnectionId" value="b17b4acc-8ddf-4336-a9b5-af14c1e96c6f__dormitory" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
</project>
|
||||
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.studentmanagement</groupId>
|
||||
<artifactId>student-management</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>student-management</name>
|
||||
<description>Student Management Application</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.5</version> <!-- 请根据实际情况使用最新版本 -->
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring Boot Starter Web (包含 RESTful Web API 相关依赖) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot Starter Data JPA (提供数据访问和 JPA 功能) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MySQL Driver (用于连接 MySQL 数据库) -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.28</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot Starter Test (用于单元测试和集成测试) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot Starter Logging (用于日志管理) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 适用于 Spring Boot 的 Lombok (简化 Java 代码) -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Spring Boot Maven Plugin (用于构建 Spring Boot 应用) -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- 设置 Java 版本 -->
|
||||
<java.version>1.8</java.version> <!-- 根据你使用的 JDK 版本调整 -->
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,24 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.accommodationRecords;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface AccommodationRecordsRepository extends JpaRepository<accommodationRecords, Integer> {
|
||||
|
||||
// 根据学生ID查询住宿记录
|
||||
List<accommodationRecords> findByStudentID(int studentID);
|
||||
|
||||
// 根据宿舍ID查询住宿记录
|
||||
List<accommodationRecords> findByDormitoryID(int dormitoryID);
|
||||
|
||||
// 根据状态查询住宿记录
|
||||
List<accommodationRecords> findByStatus(boolean status);
|
||||
|
||||
// 根据学生ID和宿舍ID查询住宿记录
|
||||
List<accommodationRecords> findByStudentIDAndDormitoryID(int studentID, int dormitoryID);
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.buildings;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface BuildingsRepository extends JpaRepository<buildings, Integer> {
|
||||
|
||||
// 根据建筑物ID查询
|
||||
Optional<buildings> findById(Integer id);
|
||||
|
||||
// 查询所有建筑物
|
||||
List<buildings> findAll();
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.classes;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ClassesRepository extends JpaRepository<classes, Integer> {
|
||||
|
||||
// 根据班级名称查询
|
||||
Optional<classes> findByName(String name);
|
||||
|
||||
// 根据班级ID查询
|
||||
Optional<classes> findById(Integer id);
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.dormitory;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface DormitoryRepository extends JpaRepository<dormitory, Integer> {
|
||||
|
||||
// 根据宿舍ID查询
|
||||
Optional<dormitory> findById(Integer id);
|
||||
|
||||
// 根据建筑ID查询宿舍
|
||||
List<dormitory> findByBuildingID(int buildingID);
|
||||
|
||||
// 根据班级ID查询宿舍
|
||||
List<dormitory> findByClassID(int classID);
|
||||
|
||||
// 根据人数查询宿舍
|
||||
List<dormitory> findByOccupantsGreaterThan(int occupants);
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.EnergyConsumptions;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface EnergyConsumptionsRepository extends JpaRepository<EnergyConsumptions, Integer> {
|
||||
|
||||
// 根据宿舍ID查询能源消耗记录
|
||||
List<EnergyConsumptions> findByDormitoryID(int dormitoryID);
|
||||
|
||||
// 查询水电费大于某个值的记录
|
||||
List<EnergyConsumptions> findByWaterBillGreaterThan(double waterBill);
|
||||
|
||||
// 查询电费大于某个值的记录
|
||||
List<EnergyConsumptions> findByElectricityBillGreaterThan(double electricityBill);
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.HealthInspections;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface HealthInspectionsRepository extends JpaRepository<HealthInspections, Integer> {
|
||||
|
||||
// 根据宿舍ID查询健康检查记录
|
||||
List<HealthInspections> findByDormitoryID(int dormitoryID);
|
||||
|
||||
// 根据健康评分查询
|
||||
List<HealthInspections> findByRating(int rating);
|
||||
|
||||
// 根据检查时间范围查询
|
||||
List<HealthInspections> findByInspectionTimeBetween(String startTime, String endTime);
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.MaintenanceRecords;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface MaintenanceRecordsRepository extends JpaRepository<MaintenanceRecords, Integer> {
|
||||
|
||||
// 根据宿舍ID查询维修记录
|
||||
List<MaintenanceRecords> findByDormitoryID(int dormitoryID);
|
||||
|
||||
// 根据维修人员查询
|
||||
List<MaintenanceRecords> findByRepairPerson(String repairPerson);
|
||||
|
||||
// 根据维修时间范围查询
|
||||
List<MaintenanceRecords> findByRepairTimeBetween(String startTime, String endTime);
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.SafetyInspections;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface SafetyInspectionsRepository extends JpaRepository<SafetyInspections, Integer> {
|
||||
|
||||
// 根据宿舍ID查询安全检查记录
|
||||
List<SafetyInspections> findByDormitoryID(int dormitoryID);
|
||||
|
||||
// 根据检查人查询
|
||||
List<SafetyInspections> findByInspector(String inspector);
|
||||
|
||||
// 根据检查时间范围查询
|
||||
List<SafetyInspections> findByInspectionTimeBetween(String startTime, String endTime);
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.student;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@org.springframework.stereotype.Repository
|
||||
public interface StudentRepository extends JpaRepository<student, Integer> {
|
||||
|
||||
|
||||
// 根据学生姓名查询学生
|
||||
List<student> findByName(String name);
|
||||
|
||||
// 根据班级ID查询学生
|
||||
List<student> findByClassID(int classID);
|
||||
|
||||
// 根据性别查询学生
|
||||
List<student> findByGender(char gender);
|
||||
|
||||
// 根据学生ID查询学生
|
||||
Optional<student> findById(Integer id);
|
||||
|
||||
// 删除学生记录(可以通过继承 JpaRepository 默认方法)
|
||||
void deleteById(Integer id);
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.studentmanagement;
|
||||
|
||||
import com.studentmanagement.model.Takeouts;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface TakeoutsRepository extends JpaRepository<Takeouts, Integer> {
|
||||
|
||||
// 根据宿舍ID查询外卖记录
|
||||
List<Takeouts> findByDormitoryID(int dormitoryID);
|
||||
|
||||
// 根据外卖状态查询外卖记录
|
||||
List<Takeouts> findByStatus(boolean status);
|
||||
|
||||
// 根据外卖送达时间查询
|
||||
List<Takeouts> findByDeliveryTimeBetween(String startTime, String endTime);
|
||||
|
||||
// 根据外卖取餐时间查询
|
||||
List<Takeouts> findByPickupTimeBetween(String startTime, String endTime);
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "energy_consumptions")
|
||||
public class EnergyConsumptions {
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "dormitory_id")
|
||||
private int dormitory_id;
|
||||
|
||||
@Column(name = "water_bill")
|
||||
private double waterBill;
|
||||
|
||||
@Column(name = "electricity_bill")
|
||||
private double electricityBill;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public EnergyConsumptions() {}
|
||||
|
||||
public EnergyConsumptions(int dormitory_id, double waterBill, double electricityBill) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
this.waterBill = waterBill;
|
||||
this.electricityBill = electricityBill;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public int getDormitory() {
|
||||
return dormitory_id;
|
||||
}
|
||||
|
||||
public void setDormitory(int dormitory_id) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
}
|
||||
|
||||
public double getWaterBill() {
|
||||
return waterBill;
|
||||
}
|
||||
|
||||
public void setWaterBill(double waterBill) {
|
||||
this.waterBill = waterBill;
|
||||
}
|
||||
|
||||
public double getElectricityBill() {
|
||||
return electricityBill;
|
||||
}
|
||||
|
||||
public void setElectricityBill(double electricityBill) {
|
||||
this.electricityBill = electricityBill;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "health_inspections")
|
||||
public class HealthInspections {
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "dormitory_id")
|
||||
private int dormitory_id;
|
||||
|
||||
@Id
|
||||
@Column(name = "inspection_time")
|
||||
private Timestamp inspectionTime;
|
||||
|
||||
@Column(name = "rating")
|
||||
private int rating;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public HealthInspections() {}
|
||||
|
||||
public HealthInspections(int dormitory_id, Timestamp inspectionTime, int rating) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
this.inspectionTime = inspectionTime;
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public int getDormitory() {
|
||||
return dormitory_id;
|
||||
}
|
||||
|
||||
public void setDormitory(int dormitory_id) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
}
|
||||
|
||||
public Timestamp getInspectionTime() {
|
||||
return inspectionTime;
|
||||
}
|
||||
|
||||
public void setInspectionTime(Timestamp inspectionTime) {
|
||||
this.inspectionTime = inspectionTime;
|
||||
}
|
||||
|
||||
public int getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public void setRating(int rating) {
|
||||
this.rating = rating;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "maintenance_records")
|
||||
public class MaintenanceRecords {
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "dormitory_id")
|
||||
private int dormitory_id;
|
||||
|
||||
@Column(name = "repair_time")
|
||||
private Timestamp repairTime;
|
||||
|
||||
@Column(name = "repair_person")
|
||||
private String repairPerson;
|
||||
|
||||
@Column(name = "repair_details")
|
||||
private String repairDetails;
|
||||
|
||||
@Column(name = "status")
|
||||
private boolean status;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public MaintenanceRecords() {}
|
||||
|
||||
public MaintenanceRecords(int dormitory_id, Timestamp repairTime, String repairPerson, String repairDetails, boolean status) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
this.repairTime = repairTime;
|
||||
this.repairPerson = repairPerson;
|
||||
this.repairDetails = repairDetails;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public int getDormitory() {
|
||||
return dormitory_id;
|
||||
}
|
||||
|
||||
public void setDormitory(int dormitory_id) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
}
|
||||
|
||||
public Timestamp getRepairTime() {
|
||||
return repairTime;
|
||||
}
|
||||
|
||||
public void setRepairTime(Timestamp repairTime) {
|
||||
this.repairTime = repairTime;
|
||||
}
|
||||
|
||||
public String getRepairPerson() {
|
||||
return repairPerson;
|
||||
}
|
||||
|
||||
public void setRepairPerson(String repairPerson) {
|
||||
this.repairPerson = repairPerson;
|
||||
}
|
||||
|
||||
public String getRepairDetails() {
|
||||
return repairDetails;
|
||||
}
|
||||
|
||||
public void setRepairDetails(String repairDetails) {
|
||||
this.repairDetails = repairDetails;
|
||||
}
|
||||
|
||||
public boolean isStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "safety_inspections")
|
||||
public class SafetyInspections {
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "dormitory_id")
|
||||
private int dormitory_id;
|
||||
|
||||
@Id
|
||||
@Column(name = "inspection_time")
|
||||
private Timestamp inspectionTime;
|
||||
|
||||
@Column(name = "inspector")
|
||||
private String inspector;
|
||||
|
||||
@Column(name = "issues")
|
||||
private String issues;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public SafetyInspections() {}
|
||||
|
||||
public SafetyInspections(int dormitory_id, Timestamp inspectionTime, String inspector, String issues) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
this.inspectionTime = inspectionTime;
|
||||
this.inspector = inspector;
|
||||
this.issues = issues;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public int getDormitory() {
|
||||
return dormitory_id;
|
||||
}
|
||||
|
||||
public void setDormitory(int dormitory_id) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
}
|
||||
|
||||
public Timestamp getInspectionTime() {
|
||||
return inspectionTime;
|
||||
}
|
||||
|
||||
public void setInspectionTime(Timestamp inspectionTime) {
|
||||
this.inspectionTime = inspectionTime;
|
||||
}
|
||||
|
||||
public String getInspector() {
|
||||
return inspector;
|
||||
}
|
||||
|
||||
public void setInspector(String inspector) {
|
||||
this.inspector = inspector;
|
||||
}
|
||||
|
||||
public String getIssues() {
|
||||
return issues;
|
||||
}
|
||||
|
||||
public void setIssues(String issues) {
|
||||
this.issues = issues;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "takeouts")
|
||||
public class Takeouts {
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "dormitory_id")
|
||||
private int dormitory_id;
|
||||
|
||||
@Id
|
||||
@Column(name = "delivery_time")
|
||||
private Timestamp deliveryTime;
|
||||
|
||||
@Column(name = "pickup_time")
|
||||
private Timestamp pickupTime;
|
||||
|
||||
@Column(name = "status")
|
||||
private boolean status;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public Takeouts() {}
|
||||
|
||||
public Takeouts(int dormitory_id, Timestamp deliveryTime, Timestamp pickupTime, boolean status) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
this.deliveryTime = deliveryTime;
|
||||
this.pickupTime = pickupTime;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public int getDormitory() {
|
||||
return dormitory_id;
|
||||
}
|
||||
|
||||
public void setDormitory(int dormitory_id) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
}
|
||||
|
||||
public Timestamp getDeliveryTime() {
|
||||
return deliveryTime;
|
||||
}
|
||||
|
||||
public void setDeliveryTime(Timestamp deliveryTime) {
|
||||
this.deliveryTime = deliveryTime;
|
||||
}
|
||||
|
||||
public Timestamp getPickupTime() {
|
||||
return pickupTime;
|
||||
}
|
||||
|
||||
public void setPickupTime(Timestamp pickupTime) {
|
||||
this.pickupTime = pickupTime;
|
||||
}
|
||||
|
||||
public boolean isStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "accommodation_records")
|
||||
public class accommodationRecords {
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "student_id")
|
||||
private int student_id;
|
||||
|
||||
@Id
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "dormitory_id")
|
||||
private int dormitory_id;
|
||||
|
||||
@Column(name = "status")
|
||||
private boolean status;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public accommodationRecords() {}
|
||||
|
||||
public accommodationRecords(int student_id, int dormitory_id, boolean status) {
|
||||
this.student_id = student_id;
|
||||
this.dormitory_id = dormitory_id;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public int getStudent() {
|
||||
return this.student_id;
|
||||
}
|
||||
|
||||
public void setStudent(int student_id) {
|
||||
this.student_id = student_id;
|
||||
}
|
||||
|
||||
public int getDormitory() {
|
||||
return this.dormitory_id;
|
||||
}
|
||||
|
||||
public void setDormitory(int dormitory_id) {
|
||||
this.dormitory_id = dormitory_id;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "buildings")
|
||||
public class buildings {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "building_id")
|
||||
private int buildingID;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public buildings() {}
|
||||
|
||||
public buildings(int buildingID) {
|
||||
this.buildingID = buildingID;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public int getBuildingID() {
|
||||
return buildingID;
|
||||
}
|
||||
|
||||
public void setBuildingID(int buildingID) {
|
||||
this.buildingID = buildingID;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "classes")
|
||||
public class classes {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "class_id")
|
||||
private int classID;
|
||||
|
||||
@Column(name = "teacher_name")
|
||||
private String teacherName;
|
||||
|
||||
@Column(name = "teacher_phone")
|
||||
private String teacherPhone;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public classes() {}
|
||||
|
||||
public classes(String teacherName, String teacherPhone) {
|
||||
this.teacherName = teacherName;
|
||||
this.teacherPhone = teacherPhone;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public int getClassID() {
|
||||
return classID;
|
||||
}
|
||||
|
||||
public void setClassID(int classID) {
|
||||
this.classID = classID;
|
||||
}
|
||||
|
||||
public String getTeacherName() {
|
||||
return teacherName;
|
||||
}
|
||||
|
||||
public void setTeacherName(String teacherName) {
|
||||
this.teacherName = teacherName;
|
||||
}
|
||||
|
||||
public String getTeacherPhone() {
|
||||
return teacherPhone;
|
||||
}
|
||||
|
||||
public void setTeacherPhone(String teacherPhone) {
|
||||
this.teacherPhone = teacherPhone;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "dormitories")
|
||||
public class dormitory {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "dormitory_id")
|
||||
private int dormitoryID;
|
||||
|
||||
@Column(name = "building_id")
|
||||
private int buildingID;
|
||||
|
||||
@Column(name = "class_id")
|
||||
private int classID;
|
||||
|
||||
@Column(name = "occupants")
|
||||
private int occupants;
|
||||
|
||||
@Column(name = "room_count")
|
||||
private int roomCount;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public dormitory() {}
|
||||
|
||||
public dormitory(int buildingID, int classID, int occupants, int roomCount) {
|
||||
this.buildingID = buildingID;
|
||||
this.classID = classID;
|
||||
this.occupants = occupants;
|
||||
this.roomCount = roomCount;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public int getDormitoryID() {
|
||||
return dormitoryID;
|
||||
}
|
||||
|
||||
public void setDormitoryID(int dormitoryID) {
|
||||
this.dormitoryID = dormitoryID;
|
||||
}
|
||||
|
||||
public int getBuildingID() {
|
||||
return buildingID;
|
||||
}
|
||||
|
||||
public void setBuildingID(int buildingID) {
|
||||
this.buildingID = buildingID;
|
||||
}
|
||||
|
||||
public int getClassID() {
|
||||
return classID;
|
||||
}
|
||||
|
||||
public void setClassID(int classID) {
|
||||
this.classID = classID;
|
||||
}
|
||||
|
||||
public int getOccupants() {
|
||||
return occupants;
|
||||
}
|
||||
|
||||
public void setOccupants(int occupants) {
|
||||
this.occupants = occupants;
|
||||
}
|
||||
|
||||
public int getRoomCount() {
|
||||
return roomCount;
|
||||
}
|
||||
|
||||
public void setRoomCount(int roomCount) {
|
||||
this.roomCount = roomCount;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package com.studentmanagement.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "students")
|
||||
public class student {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "student_id")
|
||||
private int studentID;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "gender")
|
||||
private char gender;
|
||||
|
||||
@Column(name = "class_id")
|
||||
private int classID;
|
||||
|
||||
@Column(name = "dormitory_id")
|
||||
private int dormitoryID;
|
||||
|
||||
// Constructors, Getters and Setters
|
||||
public student() {}
|
||||
|
||||
public student(String name, char gender, int classID, int dormitoryID) {
|
||||
this.name = name;
|
||||
this.gender = gender;
|
||||
this.classID = classID;
|
||||
this.dormitoryID = dormitoryID;
|
||||
}
|
||||
|
||||
public Object getStudentID() {
|
||||
return studentID;
|
||||
}
|
||||
|
||||
public Object getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Object getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public Object getDormitoryID() {
|
||||
return dormitoryID;
|
||||
}
|
||||
|
||||
public Object getClassID() {
|
||||
return classID;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.accommodationRecords;
|
||||
import com.studentmanagement.service.AccommodationRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/accommodation-records")
|
||||
public class AccommodationRecordController {
|
||||
|
||||
@Autowired
|
||||
private AccommodationRecordService accommodationRecordService;
|
||||
|
||||
// 获取所有住宿记录
|
||||
@GetMapping
|
||||
public List<accommodationRecords> getAllAccommodationRecords() {
|
||||
return accommodationRecordService.getAllAccommodationRecords();
|
||||
}
|
||||
|
||||
// 根据学生ID和宿舍ID获取住宿记录
|
||||
@GetMapping("/student/{studentID}/dormitory/{dormitoryID}")
|
||||
public List<accommodationRecords> getAccommodationRecordByStudentAndDormitory(
|
||||
@PathVariable int studentID, @PathVariable int dormitoryID) {
|
||||
return accommodationRecordService.getAccommodationRecordByStudentAndDormitory(dormitoryID);
|
||||
}
|
||||
|
||||
// 创建或更新住宿记录
|
||||
@PostMapping
|
||||
public accommodationRecords saveAccommodationRecord(@RequestBody accommodationRecords accommodationRecord) {
|
||||
return accommodationRecordService.saveAccommodationRecord(accommodationRecord);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.buildings;
|
||||
import com.studentmanagement.service.BuildingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/buildings")
|
||||
public class BuildingController {
|
||||
|
||||
@Autowired
|
||||
private BuildingService buildingService;
|
||||
|
||||
// 获取所有宿舍楼
|
||||
@GetMapping
|
||||
public List<buildings> getAllBuildings() {
|
||||
return buildingService.getAllBuildings();
|
||||
}
|
||||
|
||||
// 根据宿舍楼ID获取宿舍楼
|
||||
@GetMapping("/{buildingID}")
|
||||
public Optional<buildings> getBuildingById(@PathVariable int buildingID) {
|
||||
return buildingService.getBuildingById(buildingID);
|
||||
}
|
||||
|
||||
// 创建或更新宿舍楼
|
||||
@PostMapping
|
||||
public buildings saveBuilding(@RequestBody buildings building) {
|
||||
return buildingService.saveBuilding(building);
|
||||
}
|
||||
|
||||
// 删除宿舍楼
|
||||
@DeleteMapping("/{buildingID}")
|
||||
public void deleteBuilding(@PathVariable int buildingID) {
|
||||
buildingService.deleteBuildingById(buildingID);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.classes;
|
||||
import com.studentmanagement.service.ClassService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/classes")
|
||||
public class ClassController {
|
||||
|
||||
@Autowired
|
||||
private ClassService classService;
|
||||
|
||||
// 获取所有班级
|
||||
@GetMapping
|
||||
public List<classes> getAllClasses() {
|
||||
return classService.getAllClasses();
|
||||
}
|
||||
|
||||
// 根据班级ID获取班级
|
||||
@GetMapping("/{classID}")
|
||||
public Optional<classes> getClassById(@PathVariable int classID) {
|
||||
return classService.getClassById(classID);
|
||||
}
|
||||
|
||||
// 创建或更新班级
|
||||
@PostMapping
|
||||
public classes saveClass(@RequestBody classes classObj) {
|
||||
return classService.saveClass(classObj);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.dormitory;
|
||||
import com.studentmanagement.service.DormitoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/dormitories")
|
||||
public class DormitoryController {
|
||||
|
||||
@Autowired
|
||||
private DormitoryService dormitoryService;
|
||||
|
||||
// 获取所有宿舍
|
||||
@GetMapping
|
||||
public List<dormitory> getAllDormitories() {
|
||||
return dormitoryService.getAllDormitories();
|
||||
}
|
||||
|
||||
// 根据宿舍ID获取宿舍
|
||||
@GetMapping("/{dormitoryID}")
|
||||
public Optional<dormitory> getDormitoryById(@PathVariable int dormitoryID) {
|
||||
return dormitoryService.getDormitoryById(dormitoryID);
|
||||
}
|
||||
|
||||
// 创建或更新宿舍
|
||||
@PostMapping
|
||||
public dormitory saveDormitory(@RequestBody dormitory dormitory) {
|
||||
return dormitoryService.saveDormitory(dormitory);
|
||||
}
|
||||
|
||||
// 删除宿舍
|
||||
@DeleteMapping("/{dormitoryID}")
|
||||
public void deleteDormitory(@PathVariable int dormitoryID) {
|
||||
dormitoryService.deleteDormitoryById(dormitoryID);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.EnergyConsumptions;
|
||||
import com.studentmanagement.service.EnergyConsumptionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/energy-consumptions")
|
||||
public class EnergyConsumptionController {
|
||||
|
||||
@Autowired
|
||||
private EnergyConsumptionService energyConsumptionService;
|
||||
|
||||
// 根据宿舍ID获取能源消耗记录
|
||||
@GetMapping("/dormitory/{dormitoryID}")
|
||||
public List<EnergyConsumptions> getEnergyConsumptionByDormitoryID(@PathVariable int dormitoryID) {
|
||||
return energyConsumptionService.getAllEnergyConsumptions(dormitoryID);
|
||||
}
|
||||
|
||||
// 创建或更新能源消耗记录
|
||||
@PostMapping
|
||||
public EnergyConsumptions saveEnergyConsumption(@RequestBody EnergyConsumptions energyConsumption) {
|
||||
return energyConsumptionService.saveEnergyConsumption(energyConsumption);
|
||||
}
|
||||
|
||||
// 删除能源消耗记录
|
||||
@DeleteMapping("/{dormitoryID}")
|
||||
public void deleteEnergyConsumption(@PathVariable int dormitoryID) {
|
||||
energyConsumptionService.deleteEnergyConsumptionByDormitoryID(dormitoryID);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.HealthInspections;
|
||||
import com.studentmanagement.service.HealthInspectionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/health-inspections")
|
||||
public class HealthInspectionController {
|
||||
|
||||
@Autowired
|
||||
private HealthInspectionService healthInspectionService;
|
||||
|
||||
// 获取所有卫生检查记录
|
||||
@GetMapping
|
||||
public List<HealthInspections> getAllHealthInspections() {
|
||||
return healthInspectionService.getAllHealthInspections();
|
||||
}
|
||||
|
||||
// 根据宿舍ID获取卫生检查记录
|
||||
@GetMapping("/dormitory/{dormitoryID}")
|
||||
public List<HealthInspections> getHealthInspectionsByDormitoryID(@PathVariable int dormitoryID) {
|
||||
return healthInspectionService.getHealthInspectionsByDormitoryID(dormitoryID);
|
||||
}
|
||||
|
||||
// 创建或更新卫生检查记录
|
||||
@PostMapping
|
||||
public HealthInspections saveHealthInspection(@RequestBody HealthInspections healthInspection) {
|
||||
return healthInspectionService.saveHealthInspection(healthInspection);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.MaintenanceRecords;
|
||||
import com.studentmanagement.service.MaintenanceRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/maintenance-records")
|
||||
public class MaintenanceRecordController {
|
||||
|
||||
@Autowired
|
||||
private MaintenanceRecordService maintenanceRecordService;
|
||||
|
||||
// 获取所有维修记录
|
||||
@GetMapping
|
||||
public List<MaintenanceRecords> getAllMaintenanceRecords() {
|
||||
return maintenanceRecordService.getAllMaintenanceRecords();
|
||||
}
|
||||
|
||||
// 根据维修记录ID获取维修记录
|
||||
@GetMapping("/{dormitoryID}/{repairTime}")
|
||||
public Optional<MaintenanceRecords> getMaintenanceRecordById(
|
||||
@PathVariable int dormitoryID) {
|
||||
return maintenanceRecordService.getMaintenanceRecordById(dormitoryID);
|
||||
}
|
||||
|
||||
// 创建或更新维修记录
|
||||
@PostMapping
|
||||
public MaintenanceRecords saveMaintenanceRecord(@RequestBody MaintenanceRecords maintenanceRecord) {
|
||||
return maintenanceRecordService.saveMaintenanceRecord(maintenanceRecord);
|
||||
}
|
||||
|
||||
// 删除维修记录
|
||||
@DeleteMapping("/{dormitoryID}/{repairTime}")
|
||||
public void deleteMaintenanceRecord(
|
||||
@PathVariable int dormitoryID) {
|
||||
maintenanceRecordService.deleteMaintenanceRecordById(dormitoryID);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.SafetyInspections;
|
||||
import com.studentmanagement.service.SafetyInspectionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/safety-inspections")
|
||||
public class SafetyInspectionController {
|
||||
|
||||
@Autowired
|
||||
private SafetyInspectionService safetyInspectionService;
|
||||
|
||||
// 获取所有安全检查记录
|
||||
@GetMapping
|
||||
public List<SafetyInspections> getAllSafetyInspections() {
|
||||
return safetyInspectionService.getAllSafetyInspections();
|
||||
}
|
||||
|
||||
// 根据宿舍ID获取安全检查记录
|
||||
@GetMapping("/dormitory/{dormitoryID}")
|
||||
public List<SafetyInspections> getSafetyInspectionsByDormitoryID(@PathVariable int dormitoryID) {
|
||||
return safetyInspectionService.getSafetyInspectionsByDormitoryID(dormitoryID);
|
||||
}
|
||||
|
||||
// 创建或更新安全检查记录
|
||||
@PostMapping
|
||||
public SafetyInspections saveSafetyInspection(@RequestBody SafetyInspections safetyInspection) {
|
||||
return safetyInspectionService.saveSafetyInspection(safetyInspection);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,225 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.*;
|
||||
import java.util.Vector;
|
||||
|
||||
public class SimpleDormitoryManagement {
|
||||
private static Connection connection;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 连接数据库
|
||||
connectToDatabase();
|
||||
|
||||
// 创建主窗口
|
||||
JFrame frame = new JFrame("宿舍管理系统");
|
||||
frame.setSize(800, 600);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
// 表格展示区域
|
||||
JTable table = new JTable();
|
||||
JScrollPane scrollPane = new JScrollPane(table);
|
||||
frame.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
// 按钮操作区域
|
||||
JPanel buttonPanel = new JPanel();
|
||||
JButton addButton = new JButton("添加");
|
||||
JButton updateButton = new JButton("修改");
|
||||
JButton deleteButton = new JButton("删除");
|
||||
JButton refreshButton = new JButton("刷新");
|
||||
|
||||
buttonPanel.add(addButton);
|
||||
buttonPanel.add(updateButton);
|
||||
buttonPanel.add(deleteButton);
|
||||
buttonPanel.add(refreshButton);
|
||||
frame.add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
// 刷新表格数据
|
||||
refreshTableData(table);
|
||||
|
||||
// 添加按钮功能
|
||||
addButton.addActionListener(e -> showAddDialog(frame, table));
|
||||
|
||||
// 修改按钮功能
|
||||
updateButton.addActionListener(e -> showUpdateDialog(frame, table));
|
||||
|
||||
// 删除按钮功能
|
||||
deleteButton.addActionListener(e -> deleteSelectedRow(frame, table));
|
||||
|
||||
// 刷新按钮功能
|
||||
refreshButton.addActionListener(e -> refreshTableData(table));
|
||||
|
||||
// 显示窗口
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void connectToDatabase() {
|
||||
try {
|
||||
// 使用你的数据库配置
|
||||
String url = "jdbc:mysql://localhost:3306/dormitory"; // 数据库 URL
|
||||
String user = "zbl"; // 数据库用户名
|
||||
String password = "123456"; // 数据库密码
|
||||
connection = DriverManager.getConnection(url, user, password);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "无法连接到数据库!", "错误", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void refreshTableData(JTable table) {
|
||||
try {
|
||||
String query = "SELECT * FROM students"; // 假设要显示的表是 students
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery(query);
|
||||
|
||||
// 获取元数据
|
||||
ResultSetMetaData metaData = resultSet.getMetaData();
|
||||
int columnCount = metaData.getColumnCount();
|
||||
|
||||
// 构建表头
|
||||
Vector<String> columnNames = new Vector<>();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
columnNames.add(metaData.getColumnName(i));
|
||||
}
|
||||
|
||||
// 构建数据
|
||||
Vector<Vector<Object>> data = new Vector<>();
|
||||
while (resultSet.next()) {
|
||||
Vector<Object> row = new Vector<>();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
row.add(resultSet.getObject(i));
|
||||
}
|
||||
data.add(row);
|
||||
}
|
||||
|
||||
// 设置表模型
|
||||
DefaultTableModel model = new DefaultTableModel(data, columnNames);
|
||||
table.setModel(model);
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "无法加载数据!", "错误", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
private static void showAddDialog(JFrame parent, JTable table) {
|
||||
JTextField nameField = new JTextField(40);
|
||||
JTextField genderField = new JTextField(40);
|
||||
JTextField classIDField = new JTextField(40);
|
||||
JTextField dormitoryIDField = new JTextField(40);
|
||||
JTextField StudentIDField = new JTextField(40);
|
||||
JPanel panel = new JPanel(new GridLayout(5, 2));
|
||||
panel.add(new JLabel("学号:"));
|
||||
panel.add(StudentIDField);
|
||||
panel.add(new JLabel("姓名:"));
|
||||
panel.add(nameField);
|
||||
panel.add(new JLabel("性别:"));
|
||||
panel.add(genderField);
|
||||
panel.add(new JLabel("班级ID:"));
|
||||
panel.add(classIDField);
|
||||
panel.add(new JLabel("宿舍ID:"));
|
||||
panel.add(dormitoryIDField);
|
||||
|
||||
|
||||
int result = JOptionPane.showConfirmDialog(parent, panel, "添加学生", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
if (result == JOptionPane.OK_OPTION) {
|
||||
try {
|
||||
String query = "INSERT INTO students (StudentID,Name, Gender, ClassID, DormitoryID) VALUES (?, ?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(query);
|
||||
statement.setString(1, StudentIDField.getText());
|
||||
statement.setString(2, nameField.getText());
|
||||
statement.setString(3, genderField.getText());
|
||||
statement.setInt(4, Integer.parseInt(classIDField.getText()));
|
||||
statement.setInt(5, Integer.parseInt(dormitoryIDField.getText()));
|
||||
statement.executeUpdate();
|
||||
|
||||
refreshTableData(table);
|
||||
JOptionPane.showMessageDialog(parent, "添加成功!");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(parent, "添加失败!", "错误", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void showUpdateDialog(JFrame parent, JTable table) {
|
||||
int selectedRow = table.getSelectedRow();
|
||||
if (selectedRow == -1) {
|
||||
JOptionPane.showMessageDialog(parent, "请先选择一行!", "错误", JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
int studentID = (int) table.getValueAt(selectedRow, 0);
|
||||
String name = (String) table.getValueAt(selectedRow, 1);
|
||||
String gender = (String) table.getValueAt(selectedRow, 2);
|
||||
int classID = (int) table.getValueAt(selectedRow, 3);
|
||||
int dormitoryID = (int) table.getValueAt(selectedRow, 4);
|
||||
|
||||
JTextField StudentIDField = new JTextField(studentID);
|
||||
JTextField nameField = new JTextField(name, 20);
|
||||
JTextField genderField = new JTextField(gender, 5);
|
||||
JTextField classIDField = new JTextField(String.valueOf(classID), 5);
|
||||
JTextField dormitoryIDField = new JTextField(String.valueOf(dormitoryID), 5);
|
||||
|
||||
JPanel panel = new JPanel(new GridLayout(5, 2));
|
||||
panel.add(new JLabel("姓名:"));
|
||||
panel.add(nameField);
|
||||
panel.add(new JLabel("性别:"));
|
||||
panel.add(genderField);
|
||||
panel.add(new JLabel("班级ID:"));
|
||||
panel.add(classIDField);
|
||||
panel.add(new JLabel("宿舍ID:"));
|
||||
panel.add(dormitoryIDField);
|
||||
|
||||
int result = JOptionPane.showConfirmDialog(parent, panel, "修改学生", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
if (result == JOptionPane.OK_OPTION) {
|
||||
try {
|
||||
String query = "UPDATE students SET Name = ?, Gender = ?, ClassID = ?, DormitoryID = ? WHERE StudentID = ?";
|
||||
PreparedStatement statement = connection.prepareStatement(query);
|
||||
statement.setString(1, nameField.getText());
|
||||
statement.setString(2, genderField.getText());
|
||||
statement.setInt(3, Integer.parseInt(classIDField.getText()));
|
||||
statement.setInt(4, Integer.parseInt(dormitoryIDField.getText()));
|
||||
statement.setInt(5, studentID);
|
||||
statement.executeUpdate();
|
||||
|
||||
refreshTableData(table);
|
||||
JOptionPane.showMessageDialog(parent, "修改成功!");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(parent, "修改失败!", "错误", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteSelectedRow(JFrame parent, JTable table) {
|
||||
int selectedRow = table.getSelectedRow();
|
||||
if (selectedRow == -1) {
|
||||
JOptionPane.showMessageDialog(parent, "请先选择一行!", "错误", JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
int studentID = (int) table.getValueAt(selectedRow, 0);
|
||||
|
||||
int result = JOptionPane.showConfirmDialog(parent, "确定要删除选中的学生吗?", "删除学生", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
try {
|
||||
String query = "DELETE FROM students WHERE StudentID = ?";
|
||||
PreparedStatement statement = connection.prepareStatement(query);
|
||||
statement.setInt(1, studentID);
|
||||
statement.executeUpdate();
|
||||
|
||||
refreshTableData(table);
|
||||
JOptionPane.showMessageDialog(parent, "删除成功!");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(parent, "删除失败!", "错误", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.student;
|
||||
import com.studentmanagement.service.StudentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/students")
|
||||
public class StudentController {
|
||||
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
|
||||
// 获取所有学生
|
||||
@GetMapping
|
||||
public List<student> getAllStudents() {
|
||||
return studentService.getAllStudents();
|
||||
}
|
||||
|
||||
// 根据班级ID获取学生
|
||||
@GetMapping("/class/{classID}")
|
||||
public List<student> getStudentsByClassID(@PathVariable int classID) {
|
||||
return studentService.getStudentsByClassID(classID);
|
||||
}
|
||||
|
||||
// 根据性别获取学生
|
||||
@GetMapping("/gender/{gender}")
|
||||
public List<student> getStudentsByGender(@PathVariable char gender) {
|
||||
return studentService.getStudentsByGender(gender);
|
||||
}
|
||||
|
||||
// 根据学生ID获取学生
|
||||
@GetMapping("/{studentID}")
|
||||
public Optional<student> getStudentById(@PathVariable int studentID) {
|
||||
return studentService.getStudentById(studentID);
|
||||
}
|
||||
|
||||
// 创建或更新学生
|
||||
@PostMapping
|
||||
public student saveStudent(@RequestBody student student) {
|
||||
return studentService.saveStudent(student);
|
||||
}
|
||||
|
||||
// 删除学生
|
||||
@DeleteMapping("/{studentID}")
|
||||
public void deleteStudent(@PathVariable int studentID) {
|
||||
studentService.deleteStudentById(studentID);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.studentmanagement.operation;
|
||||
|
||||
import com.studentmanagement.model.Takeouts;
|
||||
import com.studentmanagement.service.TakeoutsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/takeouts")
|
||||
public class TakeoutController {
|
||||
|
||||
@Autowired
|
||||
private TakeoutsService takeoutService;
|
||||
|
||||
// 获取所有外卖记录
|
||||
@GetMapping
|
||||
public List<Takeouts> getAllTakeouts() {
|
||||
return takeoutService.getAllTakeouts();
|
||||
}
|
||||
|
||||
// 根据宿舍ID获取外卖记录
|
||||
@GetMapping("/dormitory/{dormitoryID}")
|
||||
public List<Takeouts> getTakeoutsByDormitoryID(@PathVariable int dormitoryID) {
|
||||
return takeoutService.getTakeoutsByDormitoryID(dormitoryID);
|
||||
}
|
||||
|
||||
// 创建或更新外卖记录
|
||||
@PostMapping
|
||||
public Takeouts saveTakeout(@RequestBody Takeouts takeout) {
|
||||
return takeoutService.saveTakeout(takeout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.accommodationRecords;
|
||||
import com.studentmanagement.AccommodationRecordsRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AccommodationRecordService {
|
||||
|
||||
@Autowired
|
||||
private AccommodationRecordsRepository accommodationRecordRepository;
|
||||
|
||||
// 保存或更新住宿记录
|
||||
public accommodationRecords saveAccommodationRecord(accommodationRecords accommodationRecord) {
|
||||
return accommodationRecordRepository.save(accommodationRecord);
|
||||
}
|
||||
|
||||
// 获取所有住宿记录
|
||||
public List<accommodationRecords> getAllAccommodationRecords() {
|
||||
return accommodationRecordRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据学生ID查询住宿记录
|
||||
public List<accommodationRecords> getAccommodationRecordsByStudentID(int studentID) {
|
||||
return accommodationRecordRepository.findByStudentID(studentID);
|
||||
}
|
||||
|
||||
// 根据宿舍ID查询住宿记录
|
||||
public List<accommodationRecords> getAccommodationRecordsByDormitoryID(int dormitoryID) {
|
||||
return accommodationRecordRepository.findByDormitoryID(dormitoryID);
|
||||
}
|
||||
|
||||
// 根据状态查询住宿记录
|
||||
public List<accommodationRecords> getAccommodationRecordsByStatus(boolean status) {
|
||||
return accommodationRecordRepository.findByStatus(status);
|
||||
}
|
||||
|
||||
public List<accommodationRecords> getAccommodationRecordByStudentAndDormitory(int dormitoryID) {
|
||||
return accommodationRecordRepository.findByDormitoryID(dormitoryID);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.buildings;
|
||||
import com.studentmanagement.BuildingsRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class BuildingService {
|
||||
|
||||
@Autowired
|
||||
private BuildingsRepository buildingRepository;
|
||||
|
||||
// 保存或更新建筑物
|
||||
public buildings saveBuilding(buildings building) {
|
||||
return buildingRepository.save(building);
|
||||
}
|
||||
|
||||
// 获取所有建筑物
|
||||
public List<buildings> getAllBuildings() {
|
||||
return buildingRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据建筑物ID查询
|
||||
public Optional<buildings> getBuildingById(int buildingID) {
|
||||
return buildingRepository.findById(buildingID);
|
||||
}
|
||||
|
||||
// 删除建筑物
|
||||
public void deleteBuildingById(int buildingID) {
|
||||
buildingRepository.deleteById(buildingID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.classes;
|
||||
import com.studentmanagement.ClassesRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class ClassService {
|
||||
|
||||
@Autowired
|
||||
private ClassesRepository classesRepository;
|
||||
|
||||
// 保存或更新班级
|
||||
public classes saveClass(classes aClass) {
|
||||
return classesRepository.save(aClass);
|
||||
}
|
||||
|
||||
// 获取所有班级
|
||||
public List<classes> getAllClasses() {
|
||||
return classesRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据班级ID查询班级
|
||||
public Optional<classes> getClassById(int classID) {
|
||||
return classesRepository.findById(classID);
|
||||
}
|
||||
|
||||
// 根据班级名称查询
|
||||
public Optional<classes> getClassByName(String name) {
|
||||
return classesRepository.findByName(name);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.dormitory;
|
||||
import com.studentmanagement.DormitoryRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class DormitoryService {
|
||||
|
||||
@Autowired
|
||||
private DormitoryRepository dormitoryRepository;
|
||||
|
||||
// 保存或更新宿舍
|
||||
public dormitory saveDormitory(dormitory dormitory) {
|
||||
return dormitoryRepository.save(dormitory);
|
||||
}
|
||||
|
||||
// 获取所有宿舍
|
||||
public List<dormitory> getAllDormitories() {
|
||||
return dormitoryRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据宿舍ID查询宿舍
|
||||
public Optional<dormitory> getDormitoryById(int dormitoryID) {
|
||||
return dormitoryRepository.findById(dormitoryID);
|
||||
}
|
||||
|
||||
// 根据建筑ID查询宿舍
|
||||
public List<dormitory> getDormitoriesByBuildingID(int buildingID) {
|
||||
return dormitoryRepository.findByBuildingID(buildingID);
|
||||
}
|
||||
|
||||
// 根据班级ID查询宿舍
|
||||
public List<dormitory> getDormitoriesByClassID(int classID) {
|
||||
return dormitoryRepository.findByClassID(classID);
|
||||
}
|
||||
|
||||
// 根据宿舍人数查询
|
||||
public List<dormitory> getDormitoriesByOccupants(int occupants) {
|
||||
return dormitoryRepository.findByOccupantsGreaterThan(occupants);
|
||||
}
|
||||
|
||||
// 删除宿舍
|
||||
public void deleteDormitoryById(int dormitoryID) {
|
||||
dormitoryRepository.deleteById(dormitoryID);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.EnergyConsumptions;
|
||||
import com.studentmanagement.EnergyConsumptionsRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class EnergyConsumptionService {
|
||||
|
||||
@Autowired
|
||||
private EnergyConsumptionsRepository energyConsumptionRepository;
|
||||
|
||||
// 保存或更新能源消耗记录
|
||||
public EnergyConsumptions saveEnergyConsumption(EnergyConsumptions energyConsumption) {
|
||||
return energyConsumptionRepository.save(energyConsumption);
|
||||
}
|
||||
|
||||
// 获取所有能源消耗记录
|
||||
public List<EnergyConsumptions> getAllEnergyConsumptions(int dormitoryID) {
|
||||
return energyConsumptionRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据宿舍ID查询能源消耗记录
|
||||
public List<EnergyConsumptions> getEnergyConsumptionsByDormitoryID(int dormitoryID) {
|
||||
return energyConsumptionRepository.findByDormitoryID(dormitoryID);
|
||||
}
|
||||
|
||||
// 删除能源消耗记录
|
||||
public void deleteEnergyConsumptionByDormitoryID(int dormitoryID) {
|
||||
energyConsumptionRepository.deleteById(dormitoryID);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.HealthInspections;
|
||||
import com.studentmanagement.HealthInspectionsRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class HealthInspectionService {
|
||||
|
||||
@Autowired
|
||||
private HealthInspectionsRepository healthInspectionRepository;
|
||||
|
||||
// 保存或更新健康检查记录
|
||||
public HealthInspections saveHealthInspection(HealthInspections healthInspection) {
|
||||
return healthInspectionRepository.save(healthInspection);
|
||||
}
|
||||
|
||||
// 获取所有健康检查记录
|
||||
public List<HealthInspections> getAllHealthInspections() {
|
||||
return healthInspectionRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据宿舍ID查询健康检查记录
|
||||
public List<HealthInspections> getHealthInspectionsByDormitoryID(int dormitoryID) {
|
||||
return healthInspectionRepository.findByDormitoryID(dormitoryID);
|
||||
}
|
||||
|
||||
// 根据评分查询健康检查记录
|
||||
public List<HealthInspections> getHealthInspectionsByRating(int rating) {
|
||||
return healthInspectionRepository.findByRating(rating);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.MaintenanceRecords;
|
||||
import com.studentmanagement.MaintenanceRecordsRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class MaintenanceRecordService {
|
||||
|
||||
@Autowired
|
||||
private MaintenanceRecordsRepository maintenanceRecordRepository;
|
||||
|
||||
// 保存或更新维修记录
|
||||
public MaintenanceRecords saveMaintenanceRecord(MaintenanceRecords maintenanceRecord) {
|
||||
return maintenanceRecordRepository.save(maintenanceRecord);
|
||||
}
|
||||
|
||||
// 获取所有维修记录
|
||||
public List<MaintenanceRecords> getAllMaintenanceRecords() {
|
||||
return maintenanceRecordRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据维修记录ID查询维修记录
|
||||
public Optional<MaintenanceRecords> getMaintenanceRecordById(int dormitoryID) {
|
||||
return maintenanceRecordRepository.findById(dormitoryID);
|
||||
}
|
||||
|
||||
// 根据宿舍ID删除维修记录
|
||||
public void deleteMaintenanceRecordById(int dormitoryID) {
|
||||
maintenanceRecordRepository.deleteById(dormitoryID);
|
||||
}
|
||||
|
||||
// 删除维修记录
|
||||
public void deleteMaintenanceRecord(MaintenanceRecords maintenanceRecord) {
|
||||
maintenanceRecordRepository.delete(maintenanceRecord);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.SafetyInspections;
|
||||
import com.studentmanagement.SafetyInspectionsRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SafetyInspectionService {
|
||||
|
||||
@Autowired
|
||||
private SafetyInspectionsRepository safetyInspectionRepository;
|
||||
|
||||
// 保存或更新安全检查记录
|
||||
public SafetyInspections saveSafetyInspection(SafetyInspections safetyInspection) {
|
||||
return safetyInspectionRepository.save(safetyInspection);
|
||||
}
|
||||
|
||||
// 获取所有安全检查记录
|
||||
public List<SafetyInspections> getAllSafetyInspections() {
|
||||
return safetyInspectionRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据宿舍ID查询安全检查记录
|
||||
public List<SafetyInspections> getSafetyInspectionsByDormitoryID(int dormitoryID) {
|
||||
return safetyInspectionRepository.findByDormitoryID(dormitoryID);
|
||||
}
|
||||
|
||||
// 根据检查员查询安全检查记录
|
||||
public List<SafetyInspections> getSafetyInspectionsByInspector(String inspector) {
|
||||
return safetyInspectionRepository.findByInspector(inspector);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.student;
|
||||
import com.studentmanagement.StudentRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class StudentService {
|
||||
|
||||
@Autowired
|
||||
private StudentRepository studentRepository;
|
||||
|
||||
// 保存或更新学生
|
||||
public student saveStudent(student student) {
|
||||
return (com.studentmanagement.model.student) studentRepository.save(student);
|
||||
}
|
||||
|
||||
// 获取所有学生
|
||||
public List<student> getAllStudents() {
|
||||
return studentRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据班级ID查询学生
|
||||
public List<student> getStudentsByClassID(int classID) {
|
||||
return studentRepository.findByClassID(classID);
|
||||
}
|
||||
|
||||
// 根据性别查询学生
|
||||
public List<student> getStudentsByGender(char gender) {
|
||||
return studentRepository.findByGender(gender);
|
||||
}
|
||||
|
||||
// 根据学生ID查询学生
|
||||
public Optional<student> getStudentById(int studentID) {
|
||||
return studentRepository.findById(studentID);
|
||||
}
|
||||
|
||||
// 删除学生
|
||||
public void deleteStudentById(int studentID) {
|
||||
studentRepository.deleteById(studentID);
|
||||
}
|
||||
|
||||
public List<student> getAllStudentAsObject() {
|
||||
return studentRepository.findAll();
|
||||
}
|
||||
|
||||
public void addStudent(student student) {
|
||||
studentRepository.save(student);
|
||||
}
|
||||
|
||||
public List<student> getstudentByname(String nameText) {
|
||||
return studentRepository.findByName(nameText);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.studentmanagement.service;
|
||||
|
||||
import com.studentmanagement.model.Takeouts;
|
||||
import com.studentmanagement.TakeoutsRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TakeoutsService {
|
||||
|
||||
@Autowired
|
||||
private TakeoutsRepository takeoutRepository;
|
||||
|
||||
// 保存或更新外卖记录
|
||||
public Takeouts saveTakeout(Takeouts takeout) {
|
||||
return takeoutRepository.save(takeout);
|
||||
}
|
||||
|
||||
// 获取所有外卖记录
|
||||
public List<Takeouts> getAllTakeouts() {
|
||||
return takeoutRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据宿舍ID查询外卖记录
|
||||
public List<Takeouts> getTakeoutsByDormitoryID(int dormitoryID) {
|
||||
return takeoutRepository.findByDormitoryID(dormitoryID);
|
||||
}
|
||||
|
||||
// 根据外卖状态查询外卖记录
|
||||
public List<Takeouts> getTakeoutsByStatus(boolean status) {
|
||||
return takeoutRepository.findByStatus(status);
|
||||
}
|
||||
|
||||
// 根据送达时间查询外卖记录
|
||||
public List<Takeouts> getTakeoutsByDeliveryTimeBetween(String startTime, String endTime) {
|
||||
return takeoutRepository.findByDeliveryTimeBetween(startTime, endTime);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.studentmanagement.util;
|
||||
|
||||
import com.studentmanagement.model.*;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
public class HibernateUtil {
|
||||
|
||||
private static final SessionFactory sessionFactory;
|
||||
|
||||
static {
|
||||
try {
|
||||
sessionFactory = new Configuration()
|
||||
.configure("hibernate.cfg.xml") // 配置文件路径
|
||||
.addAnnotatedClass(student.class) // 添加实体类
|
||||
.addAnnotatedClass(classes.class)
|
||||
.addAnnotatedClass(dormitory.class)
|
||||
.addAnnotatedClass(Takeouts.class)
|
||||
.addAnnotatedClass(SafetyInspections.class)
|
||||
.addAnnotatedClass(MaintenanceRecords.class)
|
||||
.addAnnotatedClass(HealthInspections.class)
|
||||
.addAnnotatedClass(EnergyConsumptions.class)
|
||||
// 添加所有的实体类
|
||||
.buildSessionFactory();
|
||||
} catch (Throwable ex) {
|
||||
throw new ExceptionInInitializerError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static SessionFactory getSessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
public static void shutdown() {
|
||||
getSessionFactory().close();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
# ???????
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/dormitory?useSSL=false&serverTimezone=UTC
|
||||
spring.datasource.username=zbl
|
||||
spring.datasource.password=123456
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
# JPA ??
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
|
||||
# Spring Boot ??
|
||||
server.port=8080
|
||||
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<hibernate-configuration>
|
||||
<!-- JDBC Database connection settings -->
|
||||
<session-factory>
|
||||
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/zbl?useSSL=false&serverTimezone=UTC</property>
|
||||
<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
|
||||
<property name="hibernate.connection.username">root</property>
|
||||
<property name="hibernate.connection.password">your_password</property>
|
||||
|
||||
<!-- Hibernate Dialect -->
|
||||
<property name="hibernate.dialect">org.hibernate.dialect.MySQL8Dialect</property>
|
||||
|
||||
<!-- Enable Hibernate's automatic session context management -->
|
||||
<property name="hibernate.current_session_context_class">thread</property>
|
||||
|
||||
<!-- Echo all executed SQL to stdout -->
|
||||
<property name="hibernate.show_sql">true</property>
|
||||
|
||||
<!-- Drop and re-create the database schema on startup -->
|
||||
<property name="hibernate.hbm2ddl.auto">update</property>
|
||||
|
||||
<!-- Disable the second-level cache -->
|
||||
<property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
|
||||
</session-factory>
|
||||
</hibernate-configuration>
|
||||
Loading…
Reference in new issue