This commit is contained in:
zrh050423 2024-10-28 22:46:33 +08:00
commit d295140b27
76 changed files with 1674 additions and 0 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,13 @@
<component name="ArtifactManager">
<artifact type="exploded-war" name="SimpleStudentManagementSystem:Web exploded">
<output-path>$PROJECT_DIR$/out/artifacts/SimpleStudentManagementSystem_Web_exploded</output-path>
<root id="root">
<element id="javaee-facet-resources" facet="SimpleStudentManagementSystem/web/Web" />
<element id="directory" name="WEB-INF">
<element id="directory" name="classes">
<element id="module-output" name="SimpleStudentManagementSystem" />
</element>
</element>
</root>
</artifact>
</component>

20
.idea/compiler.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="SimpleStudentManagementSystem" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel target="17" />
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="SimpleStudentManagementSystem" options="-parameters" />
</option>
</component>
</project>

19
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="mb202201080137@10.33.66.120" uuid="322d394b-46a0-4a99-b4c1-3ed9044286a7">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>$PROJECT_DIR$/SimpleStudentManagementSystem/src/main/resources/application.properties</remarks>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://10.33.66.120:3306/mb202201080137</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>

6
.idea/encodings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/SimpleStudentManagementSystem/src/main/java" charset="UTF-8" />
</component>
</project>

20
.idea/jarRepositories.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

15
.idea/misc.xml Normal file
View File

@ -0,0 +1,15 @@
<?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$/C05-1-MyBatis-XML-Demo/pom.xml" />
<option value="$PROJECT_DIR$/SimpleStudentManagementSystem/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/JavaEEHW1.iml" filepath="$PROJECT_DIR$/JavaEEHW1.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

8
JavaEEHW1.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="GENERAL_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

38
Readme.md Normal file
View File

@ -0,0 +1,38 @@
# JavaEE第1次作业
## SpringBoot + Thymeleaf 学生管理系统
### 要求
在已有代码基础上,增加课程管理和成绩管理的内容。
请注意:
1. 请重新建立一个名为“学号-HW1”的工程并在你的git下重新建立名为“学号-HW1”的仓库如工程和仓库名为“202208010101-HW1”
2. 一个新工程请先检查Maven设置的仓库是否正确
3. application.properties可能会乱码乱码请查看语雀
4. 数据库请使用统一提供的 "mb" 开头的数据库
5. 主包名必须是你名字的缩写,如张三的包名应为:**edu.zs**
6. service层必须先写接口再写实现类
7. 请写好注释
8. 提交作业时,请提交仓库地址与运行结果截图
#### 学生管理
##### 选做内容
1. 显示性别时,显示具体的“男”或“女”,而不是数字
#### 课程管理
##### 必做内容
1. 查询所有课程名
2. 增加某个课程
3. 更新某个课程
4. 删除某个课程
##### 选做内容
1. 查询这个课程学生选课情况
#### 成绩管理
##### 必做内容
1. 查询某个人所有成绩,注:查询时需要显示姓名和课程名,不能只有编号
2. 增加某个人某条成绩
3. 更新某个人某条成绩
4. 删除某个人某条成绩
##### 选做内容
1. 查询某人成绩同时计算平均分
### 更新内容
1. 2024-10-20: 更新化简项目后残留的cookie

View File

@ -0,0 +1,96 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>edu.zrh</groupId>
<artifactId>SimpleStudentManagementSystem</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SimpleStudentManagementSystem</name>
<description>SimpleStudentManagementSystem</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<!-- 热部署 -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,15 @@
package edu.zrh;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication()
@MapperScan("edu.zrh.mapper")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,30 @@
package edu.zrh.controller;
import edu.zrh.pojo.Student;
import edu.zrh.service.AccountStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@Controller
public class AccountStudentController {
private final AccountStudentService accountStudentService;
@Autowired
public AccountStudentController(AccountStudentService accountStudentService) {
this.accountStudentService = accountStudentService;
}
@PostMapping("/accountstudent")
public String addAccountStudent(Student student,
Model model){
accountStudentService.addStudentAccount(student);
return "redirect:/students";
}
@GetMapping("/deleteaccountstudent/{account}")
public String deleteAccountStudent(@PathVariable String account, Model model){
System.out.println(account);
accountStudentService.deleteStudentAccount(account);
return "redirect:/students";
}
}

View File

@ -0,0 +1,30 @@
package edu.zrh.controller;
import edu.zrh.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class LoginController {
private final AccountService accountService;
@Autowired
public LoginController(AccountService accountService) {
this.accountService = accountService;
}
@GetMapping({"/", "/login"})
public String loginPage(Model model){
model.addAttribute("title","教务系统");
return "login";
}
@PostMapping("/login")
public String login(String username, String password, Model model){
boolean result = accountService.validate(username, password);
if (result){
return "index";
}
return "login";
}
}

View File

@ -0,0 +1,49 @@
package edu.zrh.controller;
import edu.zrh.pojo.Student;
import edu.zrh.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller
public class StudentController {
private final StudentService studentService;
@Autowired
public StudentController(StudentService studentService) {
this.studentService = studentService;
}
// 加载页面
@GetMapping("/studentpage")
public String getStudentPage(){
return "student";
}
@GetMapping("addstudentpage")
public String addStudentPage(){
return "addstudent";
}
// 处理数据
@GetMapping("/students")
public String getAllStudents(Model model){
List<Student> students = studentService.getAllStudents();
model.addAttribute("students",students);
return "student";
}
@GetMapping("updatestudentpage/{id}")
public String updateStudentPage(@PathVariable String id,
Model model){
Student student = studentService.getStudentById(id);
System.out.println(student);
model.addAttribute("student",student);
return "updatestudent";
}
@PostMapping("/updatestudent")
public String updateStudent(@ModelAttribute Student student) {
studentService.updateStudent(student);
return "redirect:/students";
}
}

View File

@ -0,0 +1,18 @@
package edu.zrh.mapper;
import edu.zrh.pojo.Account;
import java.util.List;
public interface AccountMapper {
// 查询账号
Account getAccount(String account);
// 添加账号
void insertAccount(Account account);
// 根据账号获取学生信息
List<Account> getAccountWithDetails();
void deleteByAccount(String account);
}

View File

@ -0,0 +1,24 @@
package edu.zrh.mapper;
import edu.zrh.pojo.Score;
import java.util.List;
public interface ScoreMapper {
// 新增成绩
void insert(Score score);
// 更新成绩
void update(Score score);
// 根据id删除成绩
void deleteById(Integer id);
// 批量删除成绩
void deleteByIds(List<Integer> ids);
// 根据no查询成绩
List<Score> getAll();
}

View File

@ -0,0 +1,32 @@
package edu.zrh.mapper;
import edu.zrh.pojo.Score;
import edu.zrh.pojo.Student;
import java.util.List;
// 在运行时会自动生成该接口的实现类对象 并将该对交给IOC容器管理 成为一个bean
public interface StudentMapper {
// 查询全部学生信息
List<Student> getAll();
List<Score> getAllCourseNames();
// 根据id查询学生
Student getById(String id);
// 添加学生
void insertStudent(Student student);
// 动态条件查询 根据姓名字数和性别查询
List<Student> getByCondition(Integer len, Integer gender);
// 动态更新学生
void update(Student student);
List<Student> getAllWithGender();
Student getStudentScoresById(String id);
void deleteById(String id);
}

View File

@ -0,0 +1,8 @@
package edu.zrh.mapper;
import edu.zrh.pojo.StudentScore;
public interface StudentScoreMapper {
StudentScore getByNo(String id);
}

View File

@ -0,0 +1,13 @@
package edu.zrh.pojo;
import lombok.Data;
@Data
public class Account extends BaseEntity {
private Integer id;
private String account;
private String password;
private Integer role = 1;
// 一对一查询
private Student studentDetails;
}

View File

@ -0,0 +1,13 @@
package edu.zrh.pojo;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class BaseEntity {
private Integer createBy;
private LocalDateTime createTime;
private Integer updateBy;
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,9 @@
package edu.zrh.pojo;
import lombok.Data;
@Data
public class Course extends BaseEntity{
private Integer id;
private String name;
}

View File

@ -0,0 +1,9 @@
package edu.zrh.pojo;
import lombok.Data;
@Data
public class Gender extends BaseEntity {
private Integer id;
private String name;
}

View File

@ -0,0 +1,18 @@
package edu.zrh.pojo;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class Score extends BaseEntity{
private Integer id;
private String studentId;
private String courseId;
private Integer score;
private LocalDateTime createTime;
// 学生和课程是一的一方
private Student student;
private Course course;
}

View File

@ -0,0 +1,18 @@
package edu.zrh.pojo;
import lombok.*;
import java.time.LocalDate;
import java.util.List;
@Data
public class Student extends BaseEntity {
private String id;
private String name;
private Integer gender;
// @DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate birthday;
// 性别是一的一方
private Gender genderDetails;
private List<Score> scores;
}

View File

@ -0,0 +1,11 @@
package edu.zrh.pojo;
import lombok.Data;
import java.util.List;
@Data
public class StudentScore {
private Student student;
private List<Score> scores;
}

View File

@ -0,0 +1,9 @@
package edu.zrh.service;
import edu.zrh.pojo.Account;
public interface AccountService {
// 验证数据集账号密码
boolean validate(String username, String password);
void insertAccount(Account account);
}

View File

@ -0,0 +1,12 @@
package edu.zrh.service;
import edu.zrh.pojo.Student;
import org.springframework.transaction.annotation.Transactional;
public interface AccountStudentService {
@Transactional
void addStudentAccount(Student student);
@Transactional
void deleteStudentAccount(String account);
}

View File

@ -0,0 +1,12 @@
package edu.zrh.service;
import edu.zrh.pojo.Student;
import java.util.List;
public interface StudentService {
List<Student> getAllStudents();
void insertStudent(Student student);
Student getStudentById(String id);
void updateStudent(Student student);
}

View File

@ -0,0 +1,31 @@
package edu.zrh.service.impl;
import edu.zrh.mapper.AccountMapper;
import edu.zrh.pojo.Account;
import edu.zrh.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AccountServiceImpl implements AccountService {
private final AccountMapper accountMapper;
@Autowired
public AccountServiceImpl(AccountMapper accountMapper) {
this.accountMapper = accountMapper;
}
@Override
public boolean validate(String username, String password) {
Account dbAccount = accountMapper.getAccount(username);
if(dbAccount != null && dbAccount.getPassword().equals(password)){
return true;
}
return false;
}
@Override
public void insertAccount(Account account) {
accountMapper.insertAccount(account);
}
}

View File

@ -0,0 +1,50 @@
package edu.zrh.service.impl;
import edu.zrh.mapper.AccountMapper;
import edu.zrh.mapper.StudentMapper;
import edu.zrh.pojo.Account;
import edu.zrh.pojo.Student;
import edu.zrh.service.AccountStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
@Service
public class AccountStudentServiceImpl implements AccountStudentService {
private final AccountMapper accountMapper;
private final StudentMapper studentMapper;
@Autowired
public AccountStudentServiceImpl(AccountMapper accountMapper, StudentMapper studentMapper) {
this.accountMapper = accountMapper;
this.studentMapper = studentMapper;
}
@Override
@Transactional
public void addStudentAccount(Student student) {
LocalDateTime now = LocalDateTime.now();
// 在数据库中创建Account
Account account = new Account();
account.setAccount(student.getId());// 学号
account.setPassword("12346"); // 默认密码
account.setRole(1); // 默认角色
account.setCreateBy(1);
account.setCreateTime(now);
accountMapper.insertAccount(account);
// 在数据库中创建Student
student.setCreateBy(1);
student.setCreateTime(now);
studentMapper.insertStudent(student);
}
@Override
@Transactional
public void deleteStudentAccount(String account) {
// 在数据库中删除student
studentMapper.deleteById(account);
// 在数据库中删除account
accountMapper.deleteByAccount(account);
}
}

View File

@ -0,0 +1,43 @@
package edu.zrh.service.impl;
import edu.zrh.mapper.StudentMapper;
import edu.zrh.pojo.Student;
import edu.zrh.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class StudentServiceImpl implements StudentService {
private final StudentMapper studentMapper;
@Autowired
public StudentServiceImpl(StudentMapper studentMapper) {
this.studentMapper = studentMapper;
}
@Override
public List<Student> getAllStudents() {
return studentMapper.getAll();
}
@Override
public void insertStudent(Student student) {
// 添加学生之前需要先创建账号
studentMapper.insertStudent(student);
}
@Override
public Student getStudentById(String id) {
Student student = studentMapper.getById(id);
return student;
}
@Override
public void updateStudent(Student student) {
student.setUpdateBy(1);
student.setUpdateTime(LocalDateTime.now());
studentMapper.update(student);
}
}

View File

@ -0,0 +1,25 @@
spring.application.name=SimpleStudentManagementSystem
spring.devtools.restart.enabled=true
spring.devtools.restart.additional-paths=src/main/java
spring.jackson.time-zone=Asia/Shanghai
spring.devtools.restart.exclude=static/**
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://10.33.66.120:3306/mb202201080137
spring.datasource.username=mb202201080137
spring.datasource.password=KQGTTX732721
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mybatis.configuration.map-underscore-to-camel-case=true
mybatis.mapper-locations=classpath*:mapper/*.xml
mybatis.type-aliases-package=edu.zrh.pojo
spring.transaction.annotation-proxy-target-class=true
server.port=8080
server.servlet.context-path=/
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.mvc.hiddenmethod.filter.enabled=true

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.zrh.mapper.AccountMapper">
<select id="getAccount" resultType="Account">
select id, account, password, role
from account
where account = #{account}
</select>
<delete id="deleteByAccount">
delete from account where account = #{account}
</delete>
<insert id="insertAccount" keyProperty="id" useGeneratedKeys="true">
insert into account(id, account, password, role, create_by)
values(#{id}, #{account}, #{password}, #{role}, #{createBy})
</insert>
<select id="getAccountWithDetails" resultMap="AccountWithDetails">
select a.id, a.account, s.`name`, s.gender, s.birthday
from account as a, student as s
where a.account = s.id
</select>
<resultMap id="AccountWithDetails" type="Account">
<id column="id" property="id" />
<result column="account" property="account" />
<association property="studentDetails" javaType="Student">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="gender" property="gender" />
<result column="birthday" property="birthday" />
</association>
</resultMap>
</mapper>

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.zrh.mapper.ScoreMapper">
<!-- 插入成绩 -->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into score(id, student_id, course_id, score, create_by, create_time)
values(#{id}, #{studentId}, #{courseId}, #{score}, #{createBy}, #{createTime})
</insert>
<update id="update">
update grade
<set>
<if test="grade != null">grade = #{grade},</if>
<if test="updateTime != null"> update_time = #{updateTime}</if>
</set>
where no = #{no}
</update>
<!-- 删除一条成绩 -->
<delete id="deleteById">
delete from score where id = #{id}
</delete>
<!-- 删除多条成绩 -->
<delete id="deleteByIds">
delete from score where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<!-- 查询成绩带上名称 -->
<select id="getAll" resultMap="ScoreWithName">
SELECT score.id, s.`name` as student_name, c.`name` as course_name, score.score
FROM score, student as s, course as c
WHERE s.id = score.student_id and c.id = score.course_id
</select>
<resultMap id="ScoreWithName" type="Score">
<id column="id" property="id" />
<result column="score" property="score" />
<association property="student" javaType="Student">
<result column="student_name" property="name" />
</association>
<association property="course" javaType="Course">
<result column="course_name" property="name" />
</association>
</resultMap>
<!-- <select id="getByNo" resultMap="GradeWithName">-->
<!-- SELECT-->
<!-- `no`,-->
<!-- student_id,-->
<!-- course_id,-->
<!-- grade,-->
<!-- g.create_time,-->
<!-- g.update_time,-->
<!-- s.id as uid,-->
<!-- s.`name` as student_name-->
<!-- FROM grade g-->
<!-- JOIN student s ON s.id = g.student_id-->
<!-- WHERE `no` = #{no}-->
<!-- </select>-->
<!-- <resultMap id="GradeWithName" type="Score">-->
<!-- <id column="no" property="no" />-->
<!-- <result column="student_id" property="studentID" />-->
<!-- <result column="course_id" property="courseID" />-->
<!-- <result column="grade" property="grade"></result>-->
<!-- <result column="creat_time" property="createTime" />-->
<!-- <result column="update_time" property="updateTime" />-->
<!-- <association property="student" javaType="Student">-->
<!-- <id column="uid" property="id" />-->
<!-- <result column="student_name" property="name" />-->
<!-- </association>-->
<!-- </resultMap>-->
</mapper>

View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.zrh.mapper.StudentMapper">
<!-- 对select的封装 -->
<sql id="commonSelect">
select id, name, gender, birthday
from student
</sql>
<!-- resultType="" 单条记录所封装的类型-->
<select id="getAll" resultType="Student">
select id, name, gender, birthday from student
<!-- <include refid="commonSelect"></include>-->
</select>
<!-- 根据id查询学生 -->
<select id="getById" resultType="Student">
<include refid="commonSelect"></include>
<where>
id = #{id}
</where>
</select>
<!-- 根据条件查询学生 -->
<select id="getByCondition" resultType="Student">
<include refid="commonSelect"></include>
<where>
<if test="len != null">
char_length(student.name) = #{len}
</if>
<if test="gender != null">
and gender = #{gender};
</if>
</where>
</select>
<!-- 插入学生信息 -->
<insert id="insertStudent" parameterType="Student">
insert into student(id, name, gender, birthday, create_by, create_time)
values(#{id}, #{name}, #{gender}, #{birthday}, #{createBy}, #{createTime})
</insert>
<!-- 更新学生信息 -->
<update id="update">
update student
<set>
<if test="name != null"> name = #{name},</if>
<if test="gender != null"> gender = #{gender},</if>
<if test="birthday != null"> birthday = #{birthday},</if>
<if test="updateBy != null"> update_by = #{updateBy},</if>
<if test="updateTime != null"> update_time = #{updateTime}</if>
</set>
where id = #{id}
</update>
<!-- collection集合名称-->
<!-- item集合遍历出来的元素/项-->
<!-- separator每一次遍历使用的分隔符-->
<!-- open遍历开始前拼接的片段-->
<!-- close遍历结束后拼接的片段-->
<delete id="deleteByIds">
delete from student where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<delete id="deleteById">
delete from student where id = #{id}
</delete>
<!-- 查询学生信息带上性别名称 -->
<select id="getAllWithGender" resultMap="StudentWithGender">
SELECT s.id, s.`name`, g.id as gid, g.name as gname, s.birthday
from student as s
JOIN `gender` as g on g.id = s.gender
</select>
<resultMap id="StudentWithGender" type="Student">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="birthday" property="birthday"/>
<association property="genderDetails" javaType="Gender">
<id column="gid" property="id" />
<result column="gname" property="name"/>
</association>
</resultMap>
<!-- 查询学生的所有成绩信息-->
<select id="getStudentScoresById" resultMap="StudentWithScores">
SELECT s.id as sid, s.`name` as sname, c.id as cid, c.`name` as cname, sc.`id` as scid, sc.score
FROM student as s, score as sc, course as c
where s.id = #{id} and s.id = sc.student_id and c.id = sc.course_id
</select>
<select id="getAllCourseNames" resultType="edu.zrh.pojo.Score"></select>
<resultMap id="StudentWithScores" type="Student">
<id column="sid" property="id" />
<result column="sname" property="name" />
<collection property="scores" ofType="Score">
<id column="gid" property="id" />
<result column="score" property="score" />
<result column="cname" property="course.name" />
<result column="sname" property="student.name" />
<!-- <association property="student" javaType="Student">-->
<!-- <result column="sname" property="name" />-->
<!-- </association>-->
<!-- <association property="course" javaType="Course">-->
<!-- <result column="cname" property="name" />-->
<!-- </association>-->
</collection>
</resultMap>
</mapper>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.zrh.mapper.StudentScoreMapper">
<select id="getByNo" resultMap="StudentWithScores">
SELECT s.id as sid, s.`name` as sname, c.id as cid, c.`name` as cname, sc.`id` as scid, sc.score
FROM student as s, score as sc, course as c
where s.id = #{id} and s.id = sc.student_id and c.id = sc.course_id
</select>
<resultMap id="StudentWithScores" type="StudentScore">
<id column="sid" property="student.id"></id>
<result column="sname" property="student.name"/>
<collection property="scores" ofType="Score">
<id column="scid" property="id"/>
<id column="score" property="score" />
<association property="course" javaType="Course">
<id column="cid" property="id"/>
<id column="cname" property="name"/>
</association>
</collection>
</resultMap>
</mapper>

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<body>
<h1>教务系统</h1>
<h2>学生管理——添加</h2>
<a th:href="@{/students}">查询</a>
<a th:href="@{/addstudentpage}">添加</a>
<form th:action="@{/accountstudent}" th:method="post">
<p>学号: <input type="text" name="id"/></p>
<p>姓名: <input type="text" name="name" /></p>
<p>性别: <input type="text" name="gender" /></p>
<p>出生日期: <input type="date" name="birthday"/></p>
<input type="submit" />
</form>
</body>
</html>

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" xmlns:th="http://www.thymeleaf.org">
<title>教务系统</title>
</head>
<body>
<h1>教务系统</h1>
<div>
<a th:href="@{/studentpage}">学生管理</a>
<a>课程管理</a>
<a>成绩管理</a>
</div>
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1><span th:text="${title}"></span></h1>
<h1>登陆</h1>
<!-- 登陆注册 -->
<form th:action="@{/login}" method="post">
<div><label>账号: <input type="text" name="username" value="admin"/></label></div>
<div><label>密码: <input type="password" name="password" value="admin"/></label></div>
<div><input type="submit" value="登录"/></div>
</form>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<body>
<h1>教务系统</h1>
<h2>学生管理</h2>
<a th:href="@{/students}">查询</a>
<a th:href="@{/addstudentpage}">添加</a>
<table border="1">
<tr>
<td>id</td>
<td>姓名</td>
<td>性别</td>
<td>出生日期</td>
<td>删除操作</td>
<td>更新操作</td>
</tr>
<tr th:each="student:${students}">
<td th:text="${student.id}"></td>
<td th:text="${student.name}"></td>
<td th:text="${student.gender}"></td>
<td th:text="${student.birthday}"></td>
<td>
<a th:href="@{/deleteaccountstudent/{id}(id=${student.id})}">删除</a>
</td>
<td >
<a th:href="@{/updatestudentpage/{id}(id=${student.id})}">更新</a>
</td>
</tr>
</table>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<body>
<h1>教务系统</h1>
<h2>学生管理——更新</h2>
<a th:href="@{/students}">查询</a>
<a th:href="@{/addstudentpage}">添加</a>
<form th:action="@{/updatestudent}" th:method="post">
<p>学号: <input type="text" name="id" th:value="${student.id}"/></p>
<p>姓名: <input type="text" name="name" th:value="${student.name}"/></p>
<p>性别: <input type="text" name="gender" th:value="${student.gender}"/></p>
<p>出生日期: <input type="date" name="birthday" th:value="${student.birthday}"/></p>
<input type="submit" />
</form>
</body>
</html>

View File

@ -0,0 +1,201 @@
package edu.zrh;
import edu.zrh.mapper.AccountMapper;
import edu.zrh.mapper.ScoreMapper;
import edu.zrh.mapper.StudentScoreMapper;
import edu.zrh.mapper.StudentMapper;
import edu.zrh.pojo.*;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
@SpringBootTest
class ApplicationTests {
@Autowired
private StudentMapper studentMapper;
@Autowired
private ScoreMapper scoreMapper;
@Autowired
private StudentScoreMapper studentScoreMapper;
@Autowired
private AccountMapper accountMapper;
@Test
public void testGetAll(){
// 查询所有学生信息
List<Student> stuList = studentMapper.getAll();
for (Student student : stuList) {
// 显示性别为
String gender = student.getGender() == 1 ? "" : "";
System.out.println("学生ID: " + student.getId() + ", 姓名: " + student.getName() + ", 性别: " + gender);
}
}
@Test
public void testGetAllCourses() {
// 查询所有课程名
List<Score> courseNames = scoreMapper.getAll();
for (Score courseName : courseNames) {
System.out.println("课程名: " + courseName);
}
}
@Test
public void testaddAllStudents() {
Score score=new Score();
score.setId(111);
score.setStudentId("1");
score.setCourseId("1");
score.setScore(1);
score.setCreateTime(LocalDateTime.now());
// 添加成绩
score.setStudentId("12138");
score.setCourseId("101");
scoreMapper.insert(score);
}
@Test
public void testDeleteScoreById(){
// 删除一条成绩
scoreMapper.deleteById(28);
}
@Test
public void testDeleteByIds(){
// 删除多条成绩
List<Integer> ids = Arrays.asList(29,30,31);
scoreMapper.deleteByIds(ids);
}
@Test
public void testStudentGrade2(){
//查询学生成绩
StudentScore studentScore = studentScoreMapper.getByNo("12138");
System.out.println("学生:" + studentScore.getStudent().getName());
for (Score score : studentScore.getScores()){
System.out.println("课程:" + score.getCourse().getName() + ",成绩:" + score.getScore());
}
}
@Test
public void testGetById(){
// 根据 id 查学生
Student stu = studentMapper.getById("12138");
System.out.println(stu);
}
@Test
public void testGetByCondition(){
// 学生条件查询
List<Student> stuList = studentMapper.getByCondition(null, null);
System.out.println(stuList);
}
@Test
public void testInsertAccount(){
// 新增账号
Account account = new Account();
account.setAccount("12143");
account.setPassword("123456");
account.setCreateBy(1);
LocalDateTime now = LocalDateTime.now();
account.setCreateTime(now);
accountMapper.insertAccount(account);
}
@Test
public void testInsertStudent(){
Student student = new Student();
student.setId("12143");
student.setName("陆展博");
student.setGender(1);
student.setBirthday(LocalDate.of(2002,10,14));
student.setCreateBy(1);
LocalDateTime now = LocalDateTime.now();
student.setCreateTime(now);
studentMapper.insertStudent(student);
}
@Test
public void testInsertScore(){
Score score = new Score();
score.setStudentId("12142");
score.setCourseId("102");
score.setScore(90);
score.setCreateBy(1);
LocalDateTime now = LocalDateTime.now();
score.setCreateTime(now);
scoreMapper.insert(score);
System.out.println(score.getId());
}
@Test
public void testUpdateStudent(){
Student student = new Student();
student.setId("12141");
student.setName("张益达");
student.setUpdateBy(1);
LocalDateTime now = LocalDateTime.now();
student.setUpdateTime(now);
studentMapper.update(student);
}
@Test
public void testAccountWithDetails(){
// 一对一
List<Account> accounts = accountMapper.getAccountWithDetails();
System.out.println(accounts);
}
@Test
public void testStudentWithGender(){
List<Student> students = studentMapper.getAllWithGender();
System.out.println(students);
}
@Test
public void testScoreWithName(){
List<Score> scores = scoreMapper.getAll();
System.out.println(scores);
}
@Test
public void testStudentGrade(){
Student student = studentMapper.getStudentScoresById("12138");
System.out.println("学生:" + student.getName());
for (Score score : student.getScores()){
System.out.println("课程:" + score.getCourse().getName() + ",成绩:" + score.getScore());
System.out.println(score);
}
}
/*@Test
public void testGradeUpdate(){
Score score = new Score();
score.setStudentID("12142");
score.setCourseID("101");
score.setGrade(90);
score.setUpdateTime(LocalDateTime.now());
gradeMapper.update(score);
System.out.println(score);
}
@Test
public void testGradeDelete(){
gradeMapper.deleteByNo(24);
}
@Test
public void testGetByNo(){
Score score = gradeMapper.getByNo(1);
System.out.println(score);
}
*/
}

View File

@ -0,0 +1,25 @@
spring.application.name=SimpleStudentManagementSystem
spring.devtools.restart.enabled=true
spring.devtools.restart.additional-paths=src/main/java
spring.jackson.time-zone=Asia/Shanghai
spring.devtools.restart.exclude=static/**
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://10.33.66.120:3306/mb202201080137
spring.datasource.username=mb202201080137
spring.datasource.password=KQGTTX732721
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mybatis.configuration.map-underscore-to-camel-case=true
mybatis.mapper-locations=classpath*:mapper/*.xml
mybatis.type-aliases-package=edu.zrh.pojo
spring.transaction.annotation-proxy-target-class=true
server.port=8080
server.servlet.context-path=/
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.mvc.hiddenmethod.filter.enabled=true

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.zrh.mapper.AccountMapper">
<select id="getAccount" resultType="Account">
select id, account, password, role
from account
where account = #{account}
</select>
<delete id="deleteByAccount">
delete from account where account = #{account}
</delete>
<insert id="insertAccount" keyProperty="id" useGeneratedKeys="true">
insert into account(id, account, password, role, create_by)
values(#{id}, #{account}, #{password}, #{role}, #{createBy})
</insert>
<select id="getAccountWithDetails" resultMap="AccountWithDetails">
select a.id, a.account, s.`name`, s.gender, s.birthday
from account as a, student as s
where a.account = s.id
</select>
<resultMap id="AccountWithDetails" type="Account">
<id column="id" property="id" />
<result column="account" property="account" />
<association property="studentDetails" javaType="Student">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="gender" property="gender" />
<result column="birthday" property="birthday" />
</association>
</resultMap>
</mapper>

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.zrh.mapper.ScoreMapper">
<!-- 插入成绩 -->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into score(id, student_id, course_id, score, create_by, create_time)
values(#{id}, #{studentId}, #{courseId}, #{score}, #{createBy}, #{createTime})
</insert>
<update id="update">
update grade
<set>
<if test="grade != null">grade = #{grade},</if>
<if test="updateTime != null"> update_time = #{updateTime}</if>
</set>
where no = #{no}
</update>
<!-- 删除一条成绩 -->
<delete id="deleteById">
delete from score where id = #{id}
</delete>
<!-- 删除多条成绩 -->
<delete id="deleteByIds">
delete from score where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<!-- 查询成绩带上名称 -->
<select id="getAll" resultMap="ScoreWithName">
SELECT score.id, s.`name` as student_name, c.`name` as course_name, score.score
FROM score, student as s, course as c
WHERE s.id = score.student_id and c.id = score.course_id
</select>
<resultMap id="ScoreWithName" type="Score">
<id column="id" property="id" />
<result column="score" property="score" />
<association property="student" javaType="Student">
<result column="student_name" property="name" />
</association>
<association property="course" javaType="Course">
<result column="course_name" property="name" />
</association>
</resultMap>
<!-- <select id="getByNo" resultMap="GradeWithName">-->
<!-- SELECT-->
<!-- `no`,-->
<!-- student_id,-->
<!-- course_id,-->
<!-- grade,-->
<!-- g.create_time,-->
<!-- g.update_time,-->
<!-- s.id as uid,-->
<!-- s.`name` as student_name-->
<!-- FROM grade g-->
<!-- JOIN student s ON s.id = g.student_id-->
<!-- WHERE `no` = #{no}-->
<!-- </select>-->
<!-- <resultMap id="GradeWithName" type="Score">-->
<!-- <id column="no" property="no" />-->
<!-- <result column="student_id" property="studentID" />-->
<!-- <result column="course_id" property="courseID" />-->
<!-- <result column="grade" property="grade"></result>-->
<!-- <result column="creat_time" property="createTime" />-->
<!-- <result column="update_time" property="updateTime" />-->
<!-- <association property="student" javaType="Student">-->
<!-- <id column="uid" property="id" />-->
<!-- <result column="student_name" property="name" />-->
<!-- </association>-->
<!-- </resultMap>-->
</mapper>

View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.zrh.mapper.StudentMapper">
<!-- 对select的封装 -->
<sql id="commonSelect">
select id, name, gender, birthday
from student
</sql>
<!-- resultType="" 单条记录所封装的类型-->
<select id="getAll" resultType="Student">
select id, name, gender, birthday from student
<!-- <include refid="commonSelect"></include>-->
</select>
<!-- 根据id查询学生 -->
<select id="getById" resultType="Student">
<include refid="commonSelect"></include>
<where>
id = #{id}
</where>
</select>
<!-- 根据条件查询学生 -->
<select id="getByCondition" resultType="Student">
<include refid="commonSelect"></include>
<where>
<if test="len != null">
char_length(student.name) = #{len}
</if>
<if test="gender != null">
and gender = #{gender};
</if>
</where>
</select>
<!-- 插入学生信息 -->
<insert id="insertStudent" parameterType="Student">
insert into student(id, name, gender, birthday, create_by, create_time)
values(#{id}, #{name}, #{gender}, #{birthday}, #{createBy}, #{createTime})
</insert>
<!-- 更新学生信息 -->
<update id="update">
update student
<set>
<if test="name != null"> name = #{name},</if>
<if test="gender != null"> gender = #{gender},</if>
<if test="birthday != null"> birthday = #{birthday},</if>
<if test="updateBy != null"> update_by = #{updateBy},</if>
<if test="updateTime != null"> update_time = #{updateTime}</if>
</set>
where id = #{id}
</update>
<!-- collection集合名称-->
<!-- item集合遍历出来的元素/项-->
<!-- separator每一次遍历使用的分隔符-->
<!-- open遍历开始前拼接的片段-->
<!-- close遍历结束后拼接的片段-->
<delete id="deleteByIds">
delete from student where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<delete id="deleteById">
delete from student where id = #{id}
</delete>
<!-- 查询学生信息带上性别名称 -->
<select id="getAllWithGender" resultMap="StudentWithGender">
SELECT s.id, s.`name`, g.id as gid, g.name as gname, s.birthday
from student as s
JOIN `gender` as g on g.id = s.gender
</select>
<resultMap id="StudentWithGender" type="Student">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="birthday" property="birthday"/>
<association property="genderDetails" javaType="Gender">
<id column="gid" property="id" />
<result column="gname" property="name"/>
</association>
</resultMap>
<!-- 查询学生的所有成绩信息-->
<select id="getStudentScoresById" resultMap="StudentWithScores">
SELECT s.id as sid, s.`name` as sname, c.id as cid, c.`name` as cname, sc.`id` as scid, sc.score
FROM student as s, score as sc, course as c
where s.id = #{id} and s.id = sc.student_id and c.id = sc.course_id
</select>
<select id="getAllCourseNames" resultType="edu.zrh.pojo.Score"></select>
<resultMap id="StudentWithScores" type="Student">
<id column="sid" property="id" />
<result column="sname" property="name" />
<collection property="scores" ofType="Score">
<id column="gid" property="id" />
<result column="score" property="score" />
<result column="cname" property="course.name" />
<result column="sname" property="student.name" />
<!-- <association property="student" javaType="Student">-->
<!-- <result column="sname" property="name" />-->
<!-- </association>-->
<!-- <association property="course" javaType="Course">-->
<!-- <result column="cname" property="name" />-->
<!-- </association>-->
</collection>
</resultMap>
</mapper>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.zrh.mapper.StudentScoreMapper">
<select id="getByNo" resultMap="StudentWithScores">
SELECT s.id as sid, s.`name` as sname, c.id as cid, c.`name` as cname, sc.`id` as scid, sc.score
FROM student as s, score as sc, course as c
where s.id = #{id} and s.id = sc.student_id and c.id = sc.course_id
</select>
<resultMap id="StudentWithScores" type="StudentScore">
<id column="sid" property="student.id"></id>
<result column="sname" property="student.name"/>
<collection property="scores" ofType="Score">
<id column="scid" property="id"/>
<id column="score" property="score" />
<association property="course" javaType="Course">
<id column="cid" property="id"/>
<id column="cname" property="name"/>
</association>
</collection>
</resultMap>
</mapper>

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<body>
<h1>教务系统</h1>
<h2>学生管理——添加</h2>
<a th:href="@{/students}">查询</a>
<a th:href="@{/addstudentpage}">添加</a>
<form th:action="@{/accountstudent}" th:method="post">
<p>学号: <input type="text" name="id"/></p>
<p>姓名: <input type="text" name="name" /></p>
<p>性别: <input type="text" name="gender" /></p>
<p>出生日期: <input type="date" name="birthday"/></p>
<input type="submit" />
</form>
</body>
</html>

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" xmlns:th="http://www.thymeleaf.org">
<title>教务系统</title>
</head>
<body>
<h1>教务系统</h1>
<div>
<a th:href="@{/studentpage}">学生管理</a>
<a>课程管理</a>
<a>成绩管理</a>
</div>
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1><span th:text="${title}"></span></h1>
<h1>登陆</h1>
<!-- 登陆注册 -->
<form th:action="@{/login}" method="post">
<div><label>账号: <input type="text" name="username" value="admin"/></label></div>
<div><label>密码: <input type="password" name="password" value="admin"/></label></div>
<div><input type="submit" value="登录"/></div>
</form>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<body>
<h1>教务系统</h1>
<h2>学生管理</h2>
<a th:href="@{/students}">查询</a>
<a th:href="@{/addstudentpage}">添加</a>
<table border="1">
<tr>
<td>id</td>
<td>姓名</td>
<td>性别</td>
<td>出生日期</td>
<td>删除操作</td>
<td>更新操作</td>
</tr>
<tr th:each="student:${students}">
<td th:text="${student.id}"></td>
<td th:text="${student.name}"></td>
<td th:text="${student.gender}"></td>
<td th:text="${student.birthday}"></td>
<td>
<a th:href="@{/deleteaccountstudent/{id}(id=${student.id})}">删除</a>
</td>
<td >
<a th:href="@{/updatestudentpage/{id}(id=${student.id})}">更新</a>
</td>
</tr>
</table>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<body>
<h1>教务系统</h1>
<h2>学生管理——更新</h2>
<a th:href="@{/students}">查询</a>
<a th:href="@{/addstudentpage}">添加</a>
<form th:action="@{/updatestudent}" th:method="post">
<p>学号: <input type="text" name="id" th:value="${student.id}"/></p>
<p>姓名: <input type="text" name="name" th:value="${student.name}"/></p>
<p>性别: <input type="text" name="gender" th:value="${student.gender}"/></p>
<p>出生日期: <input type="date" name="birthday" th:value="${student.birthday}"/></p>
<input type="submit" />
</form>
</body>
</html>