任务二

This commit is contained in:
LeeMONG 2024-10-10 14:18:59 +08:00
commit 55bf880029
26 changed files with 249 additions and 0 deletions

View File

@ -0,0 +1,21 @@
spring.application.name=springboot
#server.port=80
spring.web.resources.static-locations=classpath:/img/,file:D:/data/
spring.servlet.multipart.max-file-size=1000MB
spring.servlet.multipart.max-request-size=100000MB
#???????
# ??????
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# ?????
spring.datasource.name=defaultDataSource
# ???????
spring.datasource.url=jdbc:mysql://106.53.194.250:63306/mybatis1004712?serverTimezone=UTC
# ??????&???
spring.datasource.username=1004712
spring.datasource.password=@hnucm1254
#??Mybatis?Mapper??
mybatis.mapper-locations=classpath:mapper/*.xml
#??Mybatis?????
mybatis.type-aliases-package=com.hnucm.springboot.springboot.model
# ????
logging.level.com.hnucm.springboot.springboot = debug

BIN
target/classes/img/1234.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnucm.springboot.springboot.dao.PersonMapper">
<!--id=方法的名字-->
<select id="getAllPerson" resultMap="personMap">
select * from person
</select>
<resultMap id="personMap" type="com.hnucm.springboot.springboot.model.Person">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="age" property="age"/>
<association property="stuCard"
javaType="com.hnucm.springboot.springboot.model.StuCard"
column="stucardid"
select="com.hnucm.springboot.springboot.dao.StuCardMapper.findStuCardById"/>
</resultMap>
<insert id="addPerson" parameterType="com.hnucm.springboot.springboot.model.Person">
insert into person(name,age,stucardid) values(#{name},#{age},#{stuCard.id})
</insert>
<delete id="deletePerson" parameterType="int">
delete from person where id=#{id}
</delete>
<update id="updatePerson" parameterType="com.hnucm.springboot.springboot.model.Person">
update person set name=#{name},age=#{age} where id=#{id}
</update>
</mapper>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnucm.springboot.springboot.dao.StuCardMapper">
<select id="findStuCardById" resultType="com.hnucm.springboot.springboot.model.StuCard">
select * from stucard where id = #{id}
</select>
<!--useGeneratedKeys新增数据主键返回-->
<insert id="addStuCard"
useGeneratedKeys="true"
keyProperty="id"
parameterType="com.hnucm.springboot.springboot.model.StuCard">
insert into stucard(classname,stuid) values(#{classname},#{stuid})
</insert>
<delete id="deleteStuCard" parameterType="integer">
delete from stucard where id=#{id}
</delete>
<update id="updateStuCard" parameterType="com.hnucm.springboot.springboot.model.StuCard">
update stucard set classname=#{classname},stuid=#{stuid} where id=#{id}
</update>
</mapper>

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>添加用户页面</h1>
<form action="/addpersoncommit" method="post">
<input type="text" name="name" placeholder="请输入用户名"/></br>
<input type="text" name="age" placeholder="请输入用户年龄"/></br>
<input type="text" name="classname" placeholder="请输入用户班级"/></br>
<input type="text" name="stuid" placeholder="请输入用户学号"/></br>
<input type="submit" value="添加用户"/>
</form>
<a href="/personpage">返回用户列表</a>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>登录失败</h1>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>登录页面</h1>
<form action="/uploadcommit" method="post" enctype="multipart/form-data">
<input type="file" name="file" /></br>
<input type="submit" value="上传文件"/>
</form>
<img src="/1.png" style="width: 100px; height: 100px" >
<video src="/1.mp4" style="width: 400px; height: 300px"></video>
<form action="/logincommit" method="post">
<input type="text" name="username" placeholder="请输入用户名"/></br>
<input type="password" name="password" placeholder="请输入密码"/></br>
<input type="submit" value="登录"/>
</form>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>主界面</h1>
<div th:text="${username}"></div>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>新闻页面</h1>
<div th:text="${newsid}"></div>
</body>
</html>

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>Person列表页面</h1>
<a href="/addpersonpage">添加用户</a>
<table border="1">
<tr>
<td>id</td>
<td>姓名</td>
<td>年龄</td>
<td>班级</td>
<td>学号</td>
<td>删除操作</td>
<td>更新操作</td>
</tr>
<tr th:each="person:${personList}">
<td th:text="${person.id}"></td>
<td th:text="${person.name}"></td>
<td th:text="${person.age}"></td>
<div th:if="${person.stuCard}!=null">
<td th:text="${person.stuCard.classname}"></td>
<td th:text="${person.stuCard.stuid}"></td>
<td>
<a th:href="@{/deleteperson(id=${person.id},stuid=${person.stuCard.id})}">删除</a>
</td>
<td>
<a th:href="@{/updatepersonpage(
id=${person.id},
name=${person.name} ,
age=${person.age},
stucardid=${person.stuCard.id},
stuid=${person.stuCard.stuid},
classname=${person.stuCard.classname}
)}">更新</a>
</td>
</div>
</tr>
</table>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>上传成功</h1>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>hello world!!!!</h1>
<div th:text="${name}"></div>
<table border="1">
<tr>
<td>id</td>
<td>姓名</td>
<td>年龄</td>
</tr>
<tr th:each="user:${userList}">
<td th:text="${user.id}"></td>
<td th:text="${user.name}"></td>
<td th:text="${user.age}"></td>
</tr>
</table>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>更新页面</h1>
<div th:text="${id}"></div>
<form action="/updatepersoncommit" method="post">
<input type="text" name="id" hidden th:value="${id}" placeholder="请输入id"/></br>
<input type="text" name="name" th:value="${name}" placeholder="请输入用户名"/></br>
<input type="text" name="age" th:value="${age}" placeholder="请输入用户年龄"/></br>
<input type="text" name="stucardid" hidden th:value="${stucardid}" placeholder="请输入用户名"/></br>
<input type="text" name="stuid" th:value="${stuid}" placeholder="请输入学号"/></br>
<input type="text" name="classname" th:value="${classname}" placeholder="请输入班级"/></br>
<input type="submit" value="更新用户"/>
</form>
</body>
</html>