Update README.md

pull/2/head
hql 4 months ago
parent 972a58400a
commit eab82acbf6

@ -10,8 +10,7 @@
</component>
<component name="ChangeListManager">
<list default="true" id="0ffa26fe-3275-4667-90ad-c688ca600b30" name="Default Changelist" comment="&#10;Update README.md">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/controller/deptadmin/DeptAddTeaServlet.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/controller/deptadmin/DeptAddTeaServlet.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/controller/deptadmin/DeptAlterStuPunchServlet.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/controller/deptadmin/DeptAlterStuPunchServlet.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -362,7 +361,7 @@
<workItem from="1745050261322" duration="1665000" />
<workItem from="1745132180317" duration="4054000" />
<workItem from="1745152233098" duration="1401000" />
<workItem from="1745221944690" duration="599000" />
<workItem from="1745221944690" duration="901000" />
</task>
<task id="LOCAL-00001" summary="Update README.md">
<option name="closed" value="true" />
@ -468,7 +467,15 @@
<option name="project" value="LOCAL" />
<updated>1745135922838</updated>
</task>
<option name="localTasksCounter" value="14" />
<task id="LOCAL-00014" summary="&#10;Update README.md">
<option name="closed" value="true" />
<created>1745222555582</created>
<option name="number" value="00014" />
<option name="presentableId" value="LOCAL-00014" />
<option name="project" value="LOCAL" />
<updated>1745222555582</updated>
</task>
<option name="localTasksCounter" value="15" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">

@ -1,45 +1,49 @@
package com.controller.deptadmin;
package com.controller.deptadmin;//这一行定义了当前类所在的包com.controller.deptadmin 表示该类是 deptadmin 包下的控制器类。
import com.dao.DeptAdminDao;
import com.dao.DeptAdminDao;//导入 DeptAdminDao 类,这个类通常包含与数据库交互的代码。它用于执行数据库操作,比如执行 update 或 select 操作。
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.ServletException;//ServletException 用于处理 Servlet 的异常。
import javax.servlet.annotation.WebServlet;//WebServlet 是用于定义 Servlet 的注解。
//HttpServlet, HttpServletRequest, HttpServletResponse 是 HTTP 协议相关的 Servlet 类,处理请求和响应。
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.IOException;//IOException 用于处理输入输出相关的异常。
@WebServlet("/DeptAlterStuPunchServlet")
public class DeptAlterStuPunchServlet extends HttpServlet {
@WebServlet("/DeptAlterStuPunchServlet")//这是一个注解,用来声明这个 Servlet 的 URL 映射路径。用户访问 /DeptAlterStuPunchServlet 路径时会触发该 Servlet。
public class DeptAlterStuPunchServlet extends HttpServlet {//这是定义一个 DeptAlterStuPunchServlet 类,它继承自 HttpServlet说明这是一个处理 HTTP 请求的 Servlet 类。
//这是重写的 doGet 方法,处理 HTTP GET 请求。每当用户通过 GET 请求访问该 Servlet 时doGet 方法会被调用。
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
resp.setCharacterEncoding("utf-8");
resp.setContentType("text/html;charset=utf-8");
//获取表单请求的参数
String sno = req.getParameter("sno");
String sispunch = req.getParameter("sispunch");
String spunchdate = req.getParameter("spunchdate");
String spunchtime = req.getParameter("spunchtime");
String sishot = req.getParameter("sishot");
String siscough = req.getParameter("siscough");
String sisseem = req.getParameter("sisseem");
String sisdiagnose = req.getParameter("sisdiagnose");
String sstatus = req.getParameter("sstatus");
resp.setContentType("text/html;charset=utf-8");//设置请求和响应的字符编码为 UTF-8确保请求和响应的文本内容能够正确处理中文字符。
//从 HTTP 请求中获取用户提交的表单参数
String sno = req.getParameter("sno");//学生学号
String sispunch = req.getParameter("sispunch");//是否打卡
String spunchdate = req.getParameter("spunchdate");//打卡日期
String spunchtime = req.getParameter("spunchtime");//打卡时间
String sishot = req.getParameter("sishot");//是否发热
String siscough = req.getParameter("siscough");//是否咳嗽
String sisseem = req.getParameter("sisseem");//是否有乏力
String sisdiagnose = req.getParameter("sisdiagnose");//诊断结果
String sstatus = req.getParameter("sstatus");//打卡状态
//构造了一个 SQL 更新语句,用于修改 stupunchin 表中的数据。更新的字段包括打卡状态、时间、症状信息等,查询条件是 sno学生学号和 spunchdate打卡日期
String sql = "update stupunchin set sispunch = ?, spunchtime = ?, sishot = ?, siscough = ?, sisseem = ?, sisdiagnose = ?, sstatus = ? where sno = ? and spunchdate = ?";
Object[] objects = {sispunch, spunchtime, sishot, siscough, sisseem, sisdiagnose, sstatus, sno, spunchdate};
Object[] objects = {sispunch, spunchtime, sishot, siscough, sisseem, sisdiagnose, sstatus, sno, spunchdate};//创建一个对象数组 objects该数组包含了 SQL 更新语句中使用的参数。数组中的值会被传递给数据库操作。
int num = DeptAdminDao.executeUpdate(sql, objects);
int num = DeptAdminDao.executeUpdate(sql, objects);//调用 DeptAdminDao 类中的 executeUpdate 方法执行 SQL 更新操作。该方法会返回受影响的行数(更新成功的记录数),并将其赋值给 num 变量。
System.out.println(num);
System.out.println(num);//打印更新操作影响的记录行数,通常用于调试和查看更新操作的效果。
req.getRequestDispatcher("/DeptQueryStuPunchByPageServlet?currentPage=1&rows=7&sname=&sclass=&spunchdate=").forward(req, resp);
req.getRequestDispatcher("/DeptQueryStuPunchByPageServlet?currentPage=1&rows=7&sname=&sclass=&spunchdate=").forward(req, resp);//调用 RequestDispatcher 的 forward 方法,将请求转发到另一个 Servlet通常是用于显示更新后的学生打卡信息。这会将用户重定向到 DeptQueryStuPunchByPageServlet并附带了一些查询参数。
}
//这是重写的 doPost 方法。由于 doPost 方法的实现只是调用了 doGet这意味着该 Servlet 支持同时处理 GET 和 POST 请求。实际上POST 请求会被当作 GET 请求处理。
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);

Loading…
Cancel
Save