├── .idea ├── description.html ├── .gitignore ├── copyright │ └── profiles_settings.xml ├── scopes │ └── scope_settings.xml ├── encodings.xml ├── vcs.xml ├── project-template.xml ├── modules.xml ├── artifacts │ └── web_war_exploded.xml ├── libraries │ └── mysql_connector_java_8_0_19.xml ├── inspectionProfiles │ └── Project_Default.xml ├── dataSources.xml ├── misc.xml └── uiDesigner.xml ├── 数据库源码.rar ├── out ├── production │ └── StaffManageSystem │ │ ├── META-INF │ │ └── StaffManageSystem.kotlin_module │ │ ├── pojo │ │ ├── Duty.class │ │ ├── Staff.class │ │ ├── Salary.class │ │ └── Status.class │ │ ├── dao │ │ ├── DutyDao.class │ │ ├── StaffDao.class │ │ ├── SalaryDao.class │ │ └── StatusDao.class │ │ ├── util │ │ └── JDBCUtils.class │ │ ├── service │ │ ├── DutyService.class │ │ ├── StaffService.class │ │ ├── SalaryService.class │ │ └── StatusService.class │ │ └── servlet │ │ ├── DutyServlet.class │ │ ├── StaffServlet.class │ │ ├── SalaryServlet.class │ │ └── StatusServlet.class └── artifacts │ └── web_war_exploded │ ├── WEB-INF │ ├── classes │ │ ├── META-INF │ │ │ └── StaffManageSystem.kotlin_module │ │ ├── dao │ │ │ ├── DutyDao.class │ │ │ ├── SalaryDao.class │ │ │ ├── StaffDao.class │ │ │ └── StatusDao.class │ │ ├── pojo │ │ │ ├── Duty.class │ │ │ ├── Salary.class │ │ │ ├── Staff.class │ │ │ └── Status.class │ │ ├── util │ │ │ └── JDBCUtils.class │ │ ├── service │ │ │ ├── DutyService.class │ │ │ ├── SalaryService.class │ │ │ ├── StaffService.class │ │ │ └── StatusService.class │ │ └── servlet │ │ │ ├── DutyServlet.class │ │ │ ├── SalaryServlet.class │ │ │ ├── StaffServlet.class │ │ │ └── StatusServlet.class │ ├── lib │ │ ├── mysql-connector-java-8.0.19.jar │ │ ├── taglibs-standard-impl-1.2.5.jar │ │ ├── taglibs-standard-spec-1.2.5.jar │ │ └── taglibs-standard-jstlel-1.2.5.jar │ ├── web.xml │ └── jsp │ │ ├── message.jsp │ │ ├── duty │ │ ├── editInfo.jsp │ │ └── dutyInfo.jsp │ │ ├── staff │ │ ├── info.jsp │ │ └── editInfo.jsp │ │ ├── employStatus │ │ ├── editInfo.jsp │ │ └── statusInfo.jsp │ │ └── salary │ │ └── salaryInfo.jsp │ └── index.jsp ├── web ├── WEB-INF │ ├── lib │ │ ├── mysql-connector-java-8.0.19.jar │ │ ├── taglibs-standard-impl-1.2.5.jar │ │ ├── taglibs-standard-jstlel-1.2.5.jar │ │ └── taglibs-standard-spec-1.2.5.jar │ ├── web.xml │ └── jsp │ │ ├── message.jsp │ │ ├── duty │ │ ├── editInfo.jsp │ │ └── dutyInfo.jsp │ │ ├── staff │ │ ├── info.jsp │ │ └── editInfo.jsp │ │ ├── employStatus │ │ ├── editInfo.jsp │ │ └── statusInfo.jsp │ │ └── salary │ │ └── salaryInfo.jsp └── index.jsp ├── src ├── service │ ├── DutyService.java │ ├── SalaryService.java │ ├── StaffService.java │ └── StatusService.java ├── pojo │ ├── Duty.java │ ├── Status.java │ ├── Staff.java │ └── Salary.java ├── dao │ ├── DutyDao.java │ ├── StaffDao.java │ ├── SalaryDao.java │ └── StatusDao.java ├── servlet │ ├── DutyServlet.java │ ├── SalaryServlet.java │ ├── StaffServlet.java │ └── StatusServlet.java └── util │ └── JDBCUtils.java ├── README.md └── StaffManageSystem.iml /.idea/description.html: -------------------------------------------------------------------------------- 1 | Minimal Java Enterprise Web project. -------------------------------------------------------------------------------- /数据库源码.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/数据库源码.rar -------------------------------------------------------------------------------- /out/production/StaffManageSystem/META-INF/StaffManageSystem.kotlin_module: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/META-INF/StaffManageSystem.kotlin_module: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml 3 | # Datasource local storage ignored files 4 | /dataSources.local.xml 5 | /dataSources/ -------------------------------------------------------------------------------- /out/production/StaffManageSystem/pojo/Duty.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/pojo/Duty.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/pojo/Staff.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/pojo/Staff.class -------------------------------------------------------------------------------- /web/WEB-INF/lib/mysql-connector-java-8.0.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/web/WEB-INF/lib/mysql-connector-java-8.0.19.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/taglibs-standard-impl-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/web/WEB-INF/lib/taglibs-standard-impl-1.2.5.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/taglibs-standard-jstlel-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/web/WEB-INF/lib/taglibs-standard-jstlel-1.2.5.jar -------------------------------------------------------------------------------- /web/WEB-INF/lib/taglibs-standard-spec-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/web/WEB-INF/lib/taglibs-standard-spec-1.2.5.jar -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /out/production/StaffManageSystem/dao/DutyDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/dao/DutyDao.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/dao/StaffDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/dao/StaffDao.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/pojo/Salary.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/pojo/Salary.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/pojo/Status.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/pojo/Status.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/dao/SalaryDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/dao/SalaryDao.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/dao/StatusDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/dao/StatusDao.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/util/JDBCUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/util/JDBCUtils.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/service/DutyService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/service/DutyService.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/service/StaffService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/service/StaffService.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/servlet/DutyServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/servlet/DutyServlet.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/servlet/StaffServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/servlet/StaffServlet.class -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /out/production/StaffManageSystem/service/SalaryService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/service/SalaryService.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/service/StatusService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/service/StatusService.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/servlet/SalaryServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/servlet/SalaryServlet.class -------------------------------------------------------------------------------- /out/production/StaffManageSystem/servlet/StatusServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/production/StaffManageSystem/servlet/StatusServlet.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/DutyDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/dao/DutyDao.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/pojo/Duty.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/pojo/Duty.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/pojo/Salary.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/pojo/Salary.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/pojo/Staff.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/pojo/Staff.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/pojo/Status.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/pojo/Status.class -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/SalaryDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/dao/SalaryDao.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/StaffDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/dao/StaffDao.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/dao/StatusDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/dao/StatusDao.class -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/util/JDBCUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/util/JDBCUtils.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/DutyService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/service/DutyService.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/SalaryService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/service/SalaryService.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/StaffService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/service/StaffService.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/service/StatusService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/service/StatusService.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/servlet/DutyServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/servlet/DutyServlet.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/servlet/SalaryServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/servlet/SalaryServlet.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/servlet/StaffServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/servlet/StaffServlet.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/classes/servlet/StatusServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/classes/servlet/StatusServlet.class -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/lib/mysql-connector-java-8.0.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/lib/mysql-connector-java-8.0.19.jar -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/lib/taglibs-standard-impl-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/lib/taglibs-standard-impl-1.2.5.jar -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/lib/taglibs-standard-spec-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/lib/taglibs-standard-spec-1.2.5.jar -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/lib/taglibs-standard-jstlel-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangcanxin/StaffManageSystem/HEAD/out/artifacts/web_war_exploded/WEB-INF/lib/taglibs-standard-jstlel-1.2.5.jar -------------------------------------------------------------------------------- /.idea/project-template.xml: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/artifacts/web_war_exploded.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/web_war_exploded 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/mysql_connector_java_8_0_19.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql.8 6 | true 7 | com.mysql.jdbc.Driver 8 | jdbc:mysql://localhost:3306/staff_manage 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/service/DutyService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import dao.DutyDao; 4 | import pojo.Duty; 5 | 6 | import java.util.List; 7 | 8 | public class DutyService { 9 | 10 | private DutyDao dao = new DutyDao(); 11 | 12 | public Duty getDuty(int id){return dao.get(id); } 13 | 14 | public List getAllDuties(){return dao.showAllDuties();} 15 | 16 | public String UpdateDuty(Duty duty){ 17 | String message = null; 18 | boolean flag = false; 19 | flag = dao.update(duty); 20 | System.out.println("update"); 21 | if(!flag){ 22 | message = "更新职务信息失败!"; 23 | } 24 | return message; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/pojo/Duty.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | 3 | public class Duty implements java.io.Serializable { 4 | 5 | private int id; 6 | private String name; 7 | private int baseSalary; 8 | 9 | public Duty(){} 10 | 11 | public void setId(int id) { 12 | this.id = id; 13 | } 14 | 15 | public int getId() { 16 | return id; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setBaseSalary(int baseSalary) { 28 | this.baseSalary = baseSalary; 29 | } 30 | 31 | public int getBaseSalary() { 32 | return baseSalary; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/pojo/Status.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | 3 | public class Status implements java.io.Serializable { 4 | 5 | private int month; 6 | private String name; 7 | private int attendDay; 8 | private int subsidyDay; 9 | 10 | public Status(){} 11 | 12 | public void setMonth(int month) { 13 | this.month = month; 14 | } 15 | 16 | public int getMonth() { 17 | return month; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setAttendDay(int attendDay) { 29 | this.attendDay = attendDay; 30 | } 31 | 32 | public int getAttendDay() { 33 | return attendDay; 34 | } 35 | 36 | public void setSubsidyDay(int subsidyDay) { 37 | this.subsidyDay = subsidyDay; 38 | } 39 | 40 | public int getSubsidyDay() { 41 | return subsidyDay; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/pojo/Staff.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | 3 | public class Staff implements java.io.Serializable { 4 | 5 | private int id; 6 | private String name; 7 | private String staffDepartment; 8 | private String staffDuty; 9 | 10 | public Staff(){} 11 | 12 | public void setId(int id) { 13 | this.id = id; 14 | } 15 | 16 | public int getId() { 17 | return id; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setStaffDepartment(String staffDepartment) { 29 | this.staffDepartment = staffDepartment; 30 | } 31 | 32 | public String getStaffDepartment() { 33 | return staffDepartment; 34 | } 35 | 36 | public void setStaffDuty(String staffDuty) { 37 | this.staffDuty = staffDuty; 38 | } 39 | 40 | public String getStaffDuty() { 41 | return staffDuty; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # StaffManageSystem 2 | 数据库课程设计 - 员工工资管理系统 3 | 4 | ## 相关配置环境 5 | * 运行系统:Windows10 6 | * 开发环境:IntelliJ IDEA 2019,2,4 7 | * JDK: JDK 11(该版本IDEA自带的) 8 | * web服务器:Tomcat 8.5.23 9 | * 数据库:MySQL 8.0.19 10 | 11 | ## 相关开发技术 12 | * 前端: 13 | - bootstrap 4.4.1(使用CDN调用,需要联网) 14 | - font-awesome 4.7.0(同样需要联网) 15 | - 基础技术:HTML、CSS、JavaScript 16 | * 后端: 17 | - jsp 18 | - servlet 19 | - jdbc 20 | - javabean 21 | * 数据库: 22 | - 基础技术:数据表 23 | - 基础技术:数据视图 24 | - SQL函数脚本 25 | 26 | ## 相关依赖包 27 | * mysql-connector-java-8.0.19.jar 28 | * taglibs-standard-impl-1.2.5.jar 29 | * taglibs-standard-jstlel-1.2.5.jar 30 | * taglibs-standard-spec-1.2.5.jar 31 | 32 | ## 注意 33 | 34 | 由于本项目为笔者大学数据库课程设计,并不是完整项目,service层并没有特别完善,相关的逻辑判断还存在问题(诸如:月份限制在1-12月内,感觉可以使用正则表达式;出勤天数不小于加班天数等等),所以如将此项目作为可运行版本,请自觉完善不足! 35 | 此外,由于时间紧凑,注释内容还有所不足,后续空闲时间将尽可能补充,请见谅! 36 | 37 | **欢迎读者 issue 或者 pull request !** 38 | 39 | ## 鸣谢 40 | 感谢大学老师课堂提供的关于Java连通数据库进行增删查改操作的 demo 代码作为参考;感谢在本次开发过程中,提供无私帮助的热心群友和大量的网上的相关程序报错指导! 41 | 42 | -------------------------------------------------------------------------------- /StaffManageSystem.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /web/WEB-INF/jsp/message.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/1 5 | Time: 22:01 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 提示信息 13 | 14 | 15 | 16 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | ${sessionScope.remove("errMessage")} 46 | ${sessionScope.remove("message")} 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/service/SalaryService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import dao.SalaryDao; 4 | import dao.StaffDao; 5 | import dao.StatusDao; 6 | import pojo.Salary; 7 | import pojo.Staff; 8 | import pojo.Status; 9 | 10 | import java.util.List; 11 | 12 | public class SalaryService { 13 | 14 | private SalaryDao dao = new SalaryDao(); 15 | 16 | public List getAllSalaries(){return dao.showAllSalaries();} 17 | 18 | public List getSalariesByName(String name){return dao.retrieveByName(name); } 19 | 20 | public List getSalariesByMonth(int month){return dao.retrieveByMonth(month);} 21 | 22 | public List getSalariesByDepartment(String department){return dao.retrieveByDepartment(department);} 23 | 24 | public Salary getSalaryByNameAndMonth(String name, int month){ 25 | return dao.retrieveByNameAndMonth(name, month); 26 | } 27 | 28 | public List getSalariesByDepartmentAndName(String department, String name) 29 | { return dao.retrieveByDepartmentAndName(department, name);} 30 | 31 | public List getSalariesByNameMonthAndDepartment(String name, int month, String department){ 32 | return dao.retrieveByNameMonthAndDepartment(name, month, department); 33 | } 34 | 35 | public List getSalariesByDepartmentAndMonth(String department, int month) 36 | { return dao.retrieveByDepartmentAndMonth(department, month);} 37 | 38 | } 39 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/jsp/message.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/1 5 | Time: 22:01 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 提示信息 13 | 14 | 15 | 16 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | ${sessionScope.remove("errMessage")} 46 | ${sessionScope.remove("message")} 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/service/StaffService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import dao.StaffDao; 4 | import pojo.Staff; 5 | 6 | import java.util.List; 7 | 8 | public class StaffService { 9 | 10 | private StaffDao dao = new StaffDao(); 11 | 12 | public Staff getStaff(int id){return dao.get(id); } 13 | 14 | public List getAllStaffs(){return dao.showAllStaffs();} 15 | 16 | public List getStaffsByName(String name){ 17 | return dao.retrieveByName("%" + name + "%"); 18 | } 19 | 20 | public List getStaffsByDepartment(String department){ 21 | return dao.retrieveByDepartment("%" + department + "%"); 22 | } 23 | 24 | public List getStaffsByNameAndDepartment(String name, String department) 25 | { return dao.retrieveByNameAndDepartment("%" + name + "%",department);} 26 | 27 | public String UpdateStaff(Staff staff){ 28 | String message = null; 29 | boolean flag = false; 30 | if(staff.getId() == 0){ 31 | flag = dao.create(staff); 32 | System.out.println("create"); 33 | } else { 34 | flag = dao.update(staff); 35 | System.out.println("update"); 36 | } 37 | if(!flag){ 38 | message = "更新员工信息失败!"; 39 | } 40 | return message; 41 | } 42 | 43 | public String deleteStaff(int id){ 44 | if(dao.delete(id)){ 45 | return null; 46 | } else { 47 | return "删除员工信息失败!"; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/pojo/Salary.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | 3 | public class Salary implements java.io.Serializable { 4 | 5 | private int month; 6 | private int id; 7 | private String name; 8 | private String department; 9 | private int attendSubsidy; 10 | private int overtimeSubsidy; 11 | private int baseSalary; 12 | private int totalSalary; 13 | 14 | public Salary(){} 15 | 16 | public void setMonth(int month){ this.month = month; } 17 | 18 | public int getMonth(){ return month; } 19 | 20 | public void setId(int id){ this.id = id; } 21 | 22 | public int getId(){ return id; } 23 | 24 | public void setName(String name){ this.name = name; } 25 | 26 | public String getName(){ return name; } 27 | 28 | public void setDepartment(String department){ this.department = department; } 29 | 30 | public String getDepartment(){ return department; } 31 | 32 | public void setAttendSubsidy(int attendSubsidy){ this.attendSubsidy = attendSubsidy; } 33 | 34 | public int getAttendSubsidy(){ return attendSubsidy; } 35 | 36 | public void setOvertimeSubsidy(int overtimeSubsidy){ this.overtimeSubsidy = overtimeSubsidy; } 37 | 38 | public int getOvertimeSubsidy(){ return overtimeSubsidy; } 39 | 40 | public void setBaseSalary(int baseSalary){ this.baseSalary = baseSalary; } 41 | 42 | public int getBaseSalary(){ return baseSalary; } 43 | 44 | public void setTotalSalary(int totalSalary){ this.totalSalary = totalSalary; } 45 | 46 | public int getTotalSalary(){ return totalSalary; } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/dao/DutyDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import pojo.Duty; 4 | import util.JDBCUtils; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public class DutyDao { 11 | /** 12 | * 根据主键ID,查询并获得City对象 13 | * 14 | * @param id 主键 15 | * @return null表示查询失败 16 | */ 17 | public Duty get(int id) { 18 | Duty duty= null; 19 | String sql = "SELECT * FROM duty_info WHERE duty_id=?"; 20 | Object[] params = {id}; 21 | List> list = JDBCUtils.prepareSelect(sql, params); 22 | if (list.size() > 0) { 23 | Map map = list.get(0); 24 | duty = new Duty(); 25 | duty.setId((Integer) map.get("duty_id")); 26 | duty.setName((String) map.get("duty_name")); 27 | duty.setBaseSalary((Integer) map.get("base_salary")); 28 | } 29 | return duty; 30 | } 31 | 32 | /** 33 | * 显示所有员工的基本信息 34 | * 35 | * @return 员工对象的信息 36 | */ 37 | public List showAllDuties() { 38 | List duties = new ArrayList<>(); 39 | String sql = "SELECT * FROM duty_info"; 40 | List> list = JDBCUtils.executeSelect(sql); 41 | System.out.println(list); 42 | for (Map map : list) { 43 | Duty duty = new Duty(); 44 | duty.setId((Integer) map.get("duty_id")); 45 | duty.setName((String) map.get("duty_name")); 46 | duty.setBaseSalary((Integer) map.get("base_salary")); 47 | duties.add(duty); 48 | } 49 | return duties; 50 | } 51 | 52 | /** 53 | * 根据Duty对象更新记录 54 | * 55 | * @param duty 56 | * @return true 成功 | false 失败 57 | */ 58 | public boolean update(Duty duty) { 59 | String sql = "UPDATE duty_info SET " + 60 | "duty_name=?," + 61 | "base_salary=? " + 62 | "WHERE duty_id=?"; 63 | Object[] params = {duty.getName(), duty.getBaseSalary(), duty.getId()}; 64 | int rows = JDBCUtils.prepareUpdate(sql, params); 65 | return rows == 1; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /web/WEB-INF/jsp/duty/editInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/11 5 | Time: 22:56 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | Document 15 | 16 | 17 |
18 |
19 | 20 |
21 | 22 |
23 | 24 |
25 |
26 |
27 | 28 |
29 | 30 |
31 |
32 | 33 |
34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/jsp/duty/editInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/11 5 | Time: 22:56 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | Document 15 | 16 | 17 |
18 |
19 | 20 |
21 | 22 |
23 | 24 |
25 |
26 |
27 | 28 |
29 | 30 |
31 |
32 | 33 |
34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/service/StatusService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import dao.StaffDao; 4 | import dao.StatusDao; 5 | import pojo.Staff; 6 | import pojo.Status; 7 | 8 | import java.util.List; 9 | 10 | public class StatusService { 11 | 12 | private StatusDao dao = new StatusDao(); 13 | 14 | public List getAllStatuses(){return dao.showAllStatuses();} 15 | 16 | public List getStatusByName(String name){return dao.retrieveByName(name); } 17 | 18 | public List getStatusByMonth(int month){return dao.retrieveByMonth(month);} 19 | 20 | public List getStatusByDepartment(String department){return dao.retrieveByDepartment(department);} 21 | 22 | public Status getStatusByNameAndMonth(String name, int month){ 23 | return dao.retrieveByNameAndMonth(name, month); 24 | } 25 | 26 | public List getStatusesByDepartmentAndName(String department, String name) 27 | { return dao.retrieveByDepartmentAndName(department, name);} 28 | 29 | public List getStatusesByNameMonthAndDepartment(String name, int month, String department){ 30 | return dao.retrieveByNameMonthAndDepartment(name, month, department); 31 | } 32 | 33 | public List getStatusesByDepartmentAndMonth(String department, int month) 34 | { return dao.retrieveByDepartmentAndMonth(department, month);} 35 | 36 | public String UpdateStatus(Status status){ 37 | String message = null; 38 | boolean flag = false; 39 | System.out.println(status.getAttendDay()+status.getSubsidyDay()+status.getName()+status.getMonth()); 40 | StatusDao dao = new StatusDao(); 41 | if(dao.retrieveByNameAndMonth(status.getName(),status.getMonth()).getMonth()==0){ 42 | flag = dao.create(status); 43 | System.out.println("create"); 44 | } else { 45 | flag = dao.update(status); 46 | System.out.println("update"); 47 | } 48 | if(!flag){ 49 | message = "更新工作信息失败!"; 50 | } 51 | return message; 52 | } 53 | 54 | public String deleteStatus(String name, int month){ 55 | if(dao.delete(name, month)){ 56 | return null; 57 | } else { 58 | return "删除工作信息失败!"; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /web/WEB-INF/jsp/duty/dutyInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/1 5 | Time: 10:11 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 11 | 12 | 13 | 14 | 15 | Document 16 | 17 | 18 | 19 |
20 |
21 |
职务
22 |
23 |

基本职务有:总经理、部门经理、基层员工。

24 |

所任职务不同,相应的基本工资也不同。

25 |

具体差异见下表。

26 |
27 |
28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | 53 | 54 |
30 | 职务信息基本表     31 |
#职务编号职务名称对应基本工资
${status.count}${duty.id}${duty.name}${duty.baseSalary} 49 | 50 |
55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/jsp/duty/dutyInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/1 5 | Time: 10:11 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 11 | 12 | 13 | 14 | 15 | Document 16 | 17 | 18 | 19 |
20 |
21 |
职务
22 |
23 |

基本职务有:总经理、部门经理、基层员工。

24 |

所任职务不同,相应的基本工资也不同。

25 |

具体差异见下表。

26 |
27 |
28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | 53 | 54 |
30 | 职务信息基本表     31 |
#职务编号职务名称对应基本工资
${status.count}${duty.id}${duty.name}${duty.baseSalary} 49 | 50 |
55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /web/WEB-INF/jsp/staff/info.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/1 5 | Time: 9:37 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 11 | 12 | 13 | 14 | 15 | 16 | 17 | Document 18 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 47 | 48 | 49 | 50 | 53 | 54 | 55 |
22 | 员工基本信息一览表     23 | 24 |
#员工号员工姓名所属部门当前职务
${status.count}${staff.id}${staff.name}${staff.staffDepartment}${staff.staffDuty} 44 | 45 | 46 |
51 |    当前的查询结果,共 ${fn:length(staffs)} 条员工信息 52 |
56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/jsp/staff/info.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/1 5 | Time: 9:37 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 11 | 12 | 13 | 14 | 15 | 16 | 17 | Document 18 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 47 | 48 | 49 | 50 | 53 | 54 | 55 |
22 | 员工基本信息一览表     23 | 24 |
#员工号员工姓名所属部门当前职务
${status.count}${staff.id}${staff.name}${staff.staffDepartment}${staff.staffDuty} 44 | 45 | 46 |
51 |    当前的查询结果,共 ${fn:length(staffs)} 条员工信息 52 |
56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /web/WEB-INF/jsp/staff/editInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/1 5 | Time: 19:36 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | Document 15 | 16 | 17 |
18 |
19 | 20 |
21 | 22 |
23 | 24 |
25 |
26 |
27 | 28 | 36 |
37 |
38 | 39 | 48 |
49 | 50 |
51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/jsp/staff/editInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/1 5 | Time: 19:36 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | Document 15 | 16 | 17 |
18 |
19 | 20 |
21 | 22 |
23 | 24 |
25 |
26 |
27 | 28 | 36 |
37 |
38 | 39 | 48 |
49 | 50 |
51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/servlet/DutyServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import pojo.Duty; 4 | import pojo.Staff; 5 | import service.DutyService; 6 | import service.StaffService; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.WebServlet; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | import java.io.IOException; 15 | import java.util.List; 16 | 17 | @WebServlet({"/duty", "/duty/update", "/duty/save", "/duty/info"}) 18 | public class DutyServlet extends HttpServlet { 19 | 20 | private DutyService service = new DutyService(); 21 | 22 | @Override 23 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 24 | req.setCharacterEncoding("utf-8"); 25 | HttpSession session = req.getSession(); 26 | String path = req.getServletPath(); 27 | switch (path){ 28 | case "/duty":{ 29 | 30 | List duties = service.getAllDuties(); 31 | req.setAttribute("duties", duties); 32 | req.getRequestDispatcher("/WEB-INF/jsp/duty/dutyInfo.jsp").forward(req, resp); 33 | break; 34 | } 35 | 36 | case "/duty/update": { 37 | String errMessage = null; 38 | String idStr = req.getParameter("id"); 39 | if (idStr != null && idStr.matches("[0-9]+")) { 40 | Duty duty = service.getDuty(Integer.parseInt(idStr)); 41 | session.setAttribute("duty", duty); 42 | req.getRequestDispatcher("/WEB-INF/jsp/duty/editInfo.jsp").forward(req, resp); 43 | } else { 44 | errMessage = "职务设置参数格式错误!"; 45 | } 46 | if (errMessage != null) { 47 | session.setAttribute("errMessage", errMessage); 48 | } 49 | resp.sendRedirect("/duty/info"); 50 | break; 51 | } 52 | case "/duty/save": { 53 | Duty duty = new Duty(); 54 | duty.setId(Integer.parseInt(req.getParameter("id"))); 55 | duty.setName(req.getParameter("name")); 56 | duty.setBaseSalary(Integer.parseInt(req.getParameter("baseSalary"))); 57 | String errMessage = service.UpdateDuty(duty); 58 | System.out.println(errMessage); 59 | if (errMessage == null) { 60 | session.setAttribute("message", "职务更新保存成功!"); 61 | } else { 62 | session.setAttribute("errMessage", errMessage); 63 | } 64 | resp.sendRedirect("/duty/info"); 65 | break; 66 | } 67 | case "/duty/info": 68 | req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp); 69 | break; 70 | } 71 | } 72 | 73 | @Override 74 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 75 | doGet(req, resp); 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/servlet/SalaryServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import pojo.Salary; 4 | import pojo.Status; 5 | import service.SalaryService; 6 | import service.StatusService; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.WebServlet; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | import java.io.IOException; 15 | import java.util.List; 16 | 17 | @WebServlet({"/salary", "/salary/retrieve"}) 18 | public class SalaryServlet extends HttpServlet { 19 | 20 | private SalaryService service = new SalaryService(); 21 | 22 | @Override 23 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 24 | req.setCharacterEncoding("utf-8"); 25 | HttpSession session = req.getSession(); 26 | String path = req.getServletPath(); 27 | switch (path){ 28 | case "/salary":{ 29 | List salaries = service.getAllSalaries(); 30 | req.setAttribute("salaries", salaries); 31 | req.getRequestDispatcher("/WEB-INF/jsp/salary/salaryInfo.jsp").forward(req, resp); 32 | break; 33 | } 34 | case "/salary/retrieve": { 35 | String queryDepartment = req.getParameter("department"); 36 | String queryMonth = req.getParameter("month"); 37 | String queryName = req.getParameter("name"); 38 | if(queryMonth.equals("所有月份")){ 39 | if(queryDepartment.equals("所有部门")){ 40 | if(queryName.equals("所有员工")){ 41 | List salaries = service.getAllSalaries(); 42 | req.setAttribute("salaries", salaries); 43 | }else{ 44 | List salaries = service.getSalariesByName(queryName); 45 | req.setAttribute("salaries", salaries); 46 | } 47 | }else{ 48 | if(queryName.equals("所有员工")){ 49 | List salaries = service.getSalariesByDepartment(queryDepartment); 50 | req.setAttribute("salaries", salaries); 51 | }else{ 52 | List salaries = service.getSalariesByDepartmentAndName(queryDepartment, queryName); 53 | req.setAttribute("salaries", salaries); 54 | } 55 | } 56 | }else{ 57 | if(queryDepartment.equals("所有部门")){ 58 | if(queryName.equals("所有员工")){ 59 | List salaries = service.getSalariesByMonth(Integer.parseInt(queryMonth)); 60 | req.setAttribute("salaries", salaries); 61 | }else{ 62 | Salary salary = service.getSalaryByNameAndMonth(queryName,Integer.parseInt(queryMonth)); 63 | req.setAttribute("salary", salary); 64 | } 65 | }else{ 66 | if(queryName.equals("所有员工")){ 67 | List salaries = service.getSalariesByDepartmentAndMonth(queryDepartment,Integer.parseInt(queryMonth)); 68 | req.setAttribute("salaries", salaries); 69 | }else{ 70 | List salaries = service.getSalariesByNameMonthAndDepartment(queryName,Integer.parseInt(queryMonth),queryDepartment); 71 | req.setAttribute("salaries", salaries); 72 | } 73 | } 74 | } 75 | req.getRequestDispatcher("/WEB-INF/jsp/salary/salaryInfo.jsp").forward(req, resp); 76 | break; 77 | } 78 | } 79 | } 80 | 81 | @Override 82 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 83 | doGet(req, resp); 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /web/WEB-INF/jsp/employStatus/editInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/12 5 | Time: 18:17 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 13 | 14 | 15 | Document 16 | 17 | 18 | 19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 |
29 | 30 |
31 | 32 |
33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 | 42 |
43 | 44 |
45 |
46 | 47 |
48 |
49 | 50 |
51 |
52 |
53 | 54 |
55 | 56 |
57 |
58 |
59 | 60 |
61 | 62 |
63 |
64 |
65 | 66 |
67 | 68 |
69 |
70 |
71 | 72 |
73 | 74 |
75 |
76 | 77 |
78 |
79 |
80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/jsp/employStatus/editInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/12 5 | Time: 18:17 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 13 | 14 | 15 | Document 16 | 17 | 18 | 19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 |
29 | 30 |
31 | 32 |
33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 | 42 |
43 | 44 |
45 |
46 | 47 |
48 |
49 | 50 |
51 |
52 |
53 | 54 |
55 | 56 |
57 |
58 |
59 | 60 |
61 | 62 |
63 |
64 |
65 | 66 |
67 | 68 |
69 |
70 |
71 | 72 |
73 | 74 |
75 |
76 | 77 |
78 |
79 |
80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /web/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- Created by IntelliJ IDEA. --%> 2 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 40 | 41 | 42 | 58 |
59 | 76 |
77 | 78 |
79 | 80 |
81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- Created by IntelliJ IDEA. --%> 2 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 40 | 41 | 42 | 58 |
59 | 76 |
77 | 78 |
79 | 80 |
81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /web/WEB-INF/jsp/salary/salaryInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/13 5 | Time: 16:47 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 11 | 12 | 13 | 14 | 15 | Document 16 | 17 | 18 | 19 |
20 |
21 | 37 |
38 |
39 | 48 |
49 | 50 | 51 |
52 | 53 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 107 | 108 | 109 | 110 | 111 |
54 | 员工工资表 55 |
#月份员工号员工姓名所属部门考勤奖金加班津贴基本工资总工资
1${salary.month}${salary.id}${salary.name}${salary.department}${salary.attendSubsidy}${salary.overtimeSubsidy}${salary.baseSalary}${salary.totalSalary}
85 |    当前的查询结果,共 1 条员工工作记录信息 86 |
${varStatus.count}${salary.month}${salary.id}${salary.name}${salary.department}${salary.attendSubsidy}${salary.overtimeSubsidy}${salary.baseSalary}${salary.totalSalary}
105 |    当前的查询结果,共 ${fn:length(salaries)} 条员工工作记录信息 106 |
112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/jsp/salary/salaryInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/13 5 | Time: 16:47 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 11 | 12 | 13 | 14 | 15 | Document 16 | 17 | 18 | 19 |
20 |
21 | 37 |
38 |
39 | 48 |
49 | 50 | 51 |
52 | 53 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 107 | 108 | 109 | 110 | 111 |
54 | 员工工资表 55 |
#月份员工号员工姓名所属部门考勤奖金加班津贴基本工资总工资
1${salary.month}${salary.id}${salary.name}${salary.department}${salary.attendSubsidy}${salary.overtimeSubsidy}${salary.baseSalary}${salary.totalSalary}
85 |    当前的查询结果,共 1 条员工工作记录信息 86 |
${varStatus.count}${salary.month}${salary.id}${salary.name}${salary.department}${salary.attendSubsidy}${salary.overtimeSubsidy}${salary.baseSalary}${salary.totalSalary}
105 |    当前的查询结果,共 ${fn:length(salaries)} 条员工工作记录信息 106 |
112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /src/dao/StaffDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import pojo.Staff; 4 | import util.JDBCUtils; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public class StaffDao { 11 | /** 12 | * 根据主键ID,查询并获得Staff对象 13 | * 14 | * @param id 主键 15 | * @return null表示查询失败 16 | */ 17 | public Staff get(int id) { 18 | Staff staff = null; 19 | String sql = "SELECT * FROM staff_info WHERE staff_id=?"; 20 | Object[] params = {id}; 21 | List> list = JDBCUtils.prepareSelect(sql, params); 22 | if (list.size() > 0) { 23 | Map map = list.get(0); 24 | staff = new Staff(); 25 | staff.setId((Integer) map.get("staff_id")); 26 | staff.setName((String) map.get("staff_name")); 27 | staff.setStaffDepartment((String) map.get("staff_department")); 28 | staff.setStaffDuty((String) map.get("staff_duty")); 29 | } 30 | return staff; 31 | } 32 | 33 | /** 34 | * 显示所有员工的基本信息 35 | * 36 | * @return 员工对象的信息 37 | */ 38 | public List showAllStaffs() { 39 | List staffs = new ArrayList<>(); 40 | String sql = "SELECT * FROM staff_info"; 41 | List> list = JDBCUtils.executeSelect(sql); 42 | System.out.println(list); 43 | for (Map map : list) { 44 | Staff staff = new Staff(); 45 | staff.setId((Integer) map.get("staff_id")); 46 | staff.setName((String) map.get("staff_name")); 47 | staff.setStaffDepartment((String) map.get("staff_department")); 48 | staff.setStaffDuty((String) map.get("staff_duty")); 49 | staffs.add(staff); 50 | } 51 | return staffs; 52 | } 53 | 54 | /** 55 | * 根据员工姓名查询员工,模糊查询 56 | * 57 | * @param name 员工姓名的全部或部分 58 | * @return 员工对象的信息 59 | */ 60 | public List retrieveByName(String name) { 61 | List staffs = new ArrayList<>(); 62 | String sql = "SELECT * FROM staff_info WHERE staff_name LIKE ?"; 63 | Object[] params = {name}; 64 | return getStaff(staffs, sql, params); 65 | } 66 | 67 | /** 68 | * 根据员工姓名和所在部门查询员工,模糊查询 69 | * 70 | * @param name,department 员工姓名的全部或部分 71 | * @return 员工对象的信息 72 | */ 73 | public List retrieveByNameAndDepartment(String name, String department) { 74 | List staffs = new ArrayList<>(); 75 | String sql = "SELECT * FROM staff_info WHERE staff_name LIKE ? and staff_department LIKE ?"; 76 | Object[] params = {name, department}; 77 | return getStaff(staffs, sql, params); 78 | } 79 | 80 | /** 81 | * 根据员工姓名和所在部门查询员工,模糊查询 82 | * 83 | * @param department 员工姓名的全部或部分 84 | * @return 员工对象的信息 85 | */ 86 | public List retrieveByDepartment(String department) { 87 | List staffs = new ArrayList<>(); 88 | String sql = "SELECT * FROM staff_info WHERE staff_department LIKE ?"; 89 | Object[] params = {department}; 90 | return getStaff(staffs, sql, params); 91 | } 92 | 93 | private List getStaff(List staffs, String sql, Object[] params) { 94 | List> list = JDBCUtils.prepareSelect(sql, params); 95 | //System.out.println(list); 96 | for (Map map : list) { 97 | Staff staff = new Staff(); 98 | staff.setId((Integer) map.get("staff_id")); 99 | staff.setName((String) map.get("staff_name")); 100 | staff.setStaffDepartment((String) map.get("staff_department")); 101 | staff.setStaffDuty((String) map.get("staff_duty")); 102 | staffs.add(staff); 103 | } 104 | return staffs; 105 | } 106 | 107 | /** 108 | * 将Staff对象插入到表中 109 | * 110 | * @param staff 111 | * @return true 成功 | false 失败 112 | */ 113 | public boolean create(Staff staff) { 114 | // 字段id是auto increment,不用插入值 115 | String sql = "INSERT INTO staff_info(staff_name,staff_department,staff_duty) VALUES(?,?,?)"; 116 | Object[] params = {staff.getName(), staff.getStaffDepartment(), staff.getStaffDuty()}; 117 | int rows = JDBCUtils.prepareUpdate(sql, params); 118 | return rows == 1; 119 | } 120 | 121 | /** 122 | * 根据Staff对象更新记录 123 | * 124 | * @param staff 125 | * @return true 成功 | false 失败 126 | */ 127 | public boolean update(Staff staff) { 128 | String sql = "UPDATE staff_info SET " + 129 | "staff_name=?," + 130 | "staff_department=?," + 131 | "staff_duty=?"+ 132 | "WHERE staff_id=?"; 133 | Object[] params = {staff.getName(), staff.getStaffDepartment(), staff.getStaffDuty(), staff.getId()}; 134 | int rows = JDBCUtils.prepareUpdate(sql, params); 135 | return rows == 1; 136 | } 137 | 138 | /** 139 | * 根据主键id删除员工 140 | * 141 | * @param id 142 | * @return true 成功 | false 失败 143 | */ 144 | public boolean delete(int id) { 145 | String sql = "DELETE FROM staff_info WHERE staff_id=?"; 146 | Object[] params = {id}; 147 | int rows = JDBCUtils.prepareUpdate(sql, params); 148 | return rows == 1; 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /src/dao/SalaryDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import pojo.Salary; 4 | import pojo.Status; 5 | import util.JDBCUtils; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public class SalaryDao { 12 | 13 | /** 14 | * 显示所有员工的基本信息 15 | * 16 | * @return 员工对象的信息 17 | */ 18 | public List showAllSalaries() { 19 | List salaries = new ArrayList<>(); 20 | String sql = "SELECT * FROM salary_view"; 21 | List> list = JDBCUtils.executeSelect(sql); 22 | System.out.println(list); 23 | for (Map map : list) { 24 | Salary salary = new Salary(); 25 | salary.setMonth((Integer) map.get("month")); 26 | salary.setId((Integer)map.get("id")); 27 | salary.setName((String) map.get("name")); 28 | salary.setDepartment((String)map.get("department")); 29 | salary.setAttendSubsidy((Integer)map.get("attend_subsidy")); 30 | salary.setOvertimeSubsidy((Integer) map.get("overtime_subsidy")); 31 | salary.setBaseSalary((Integer)map.get("base_salary")); 32 | salary.setTotalSalary((Integer)map.get("total_salary")); 33 | salaries.add(salary); 34 | } 35 | return salaries; 36 | } 37 | 38 | public List retrieveByMonth(int month) { 39 | List salaries = new ArrayList<>(); 40 | String sql = "SELECT * FROM salary_view WHERE month LIKE ?"; 41 | Object[] params = {month}; 42 | return getSalary(salaries, sql, params); 43 | } 44 | 45 | public List retrieveByName(String name) { 46 | List salaries = new ArrayList<>(); 47 | String sql = "SELECT * FROM salary_view WHERE name LIKE ?"; 48 | Object[] params = {name}; 49 | return getSalary(salaries, sql, params); 50 | } 51 | 52 | public List retrieveByDepartment(String department) { 53 | List salaries = new ArrayList<>(); 54 | String sql = "SELECT * FROM salary_view WHERE department LIKE ?"; 55 | Object[] params = {department}; 56 | return getSalary(salaries, sql, params); 57 | } 58 | 59 | /** 60 | * 根据员工姓名查询员工,模糊查询 61 | * 62 | * @param name, month 员工姓名的全部或部分 63 | * @return 员工对象的信息 64 | */ 65 | public Salary retrieveByNameAndMonth(String name, int month) { 66 | Salary salary = new Salary(); 67 | String sql = "SELECT * FROM salary_view WHERE name LIKE ? and month=?"; 68 | Object[] params = {name, month}; 69 | List> list = JDBCUtils.prepareSelect(sql, params); 70 | if (list.size() > 0) { 71 | Map map = list.get(0); 72 | salary = new Salary(); 73 | salary.setMonth((Integer) map.get("month")); 74 | salary.setId((Integer)map.get("id")); 75 | salary.setName((String) map.get("name")); 76 | salary.setDepartment((String)map.get("department")); 77 | salary.setAttendSubsidy((Integer)map.get("attend_subsidy")); 78 | salary.setOvertimeSubsidy((Integer) map.get("overtime_subsidy")); 79 | salary.setBaseSalary((Integer)map.get("base_salary")); 80 | salary.setTotalSalary((Integer)map.get("total_salary")); 81 | } 82 | return salary; 83 | } 84 | 85 | /** 86 | * 根据员工姓名和所在部门查询员工,模糊查询 87 | * 88 | * @param name,month,department 员工姓名的全部或部分 89 | * @return 员工对象的信息 90 | */ 91 | public List retrieveByNameMonthAndDepartment(String name, int month, String department) { 92 | List salaries = new ArrayList<>(); 93 | String sql = "SELECT * FROM salary_view WHERE name LIKE ? and month LIKE ? and department LIKE ?"; 94 | Object[] params = {name, month, department}; 95 | return getSalary(salaries, sql, params); 96 | } 97 | 98 | /** 99 | * 根据员工姓名和所在部门查询员工,模糊查询 100 | * 101 | * @param department 员工姓名的全部或部分 102 | * @return 员工对象的信息 103 | */ 104 | public List retrieveByDepartmentAndMonth(String department, int month) { 105 | List salaries = new ArrayList<>(); 106 | String sql = "SELECT * FROM salary_view WHERE department like ? and month like ?"; 107 | Object[] params = {department, month}; 108 | return getSalary(salaries, sql, params); 109 | } 110 | 111 | public List retrieveByDepartmentAndName(String department, String name) { 112 | List salaries = new ArrayList<>(); 113 | String sql = "SELECT * FROM salary_view WHERE department like ? and name like ?"; 114 | Object[] params = {department, name}; 115 | return getSalary(salaries, sql, params); 116 | } 117 | 118 | private List getSalary(List salaries, String sql, Object[] params) { 119 | List> list = JDBCUtils.prepareSelect(sql, params); 120 | System.out.println(list); 121 | for (Map map : list) { 122 | Salary salary = new Salary(); 123 | salary.setMonth((Integer) map.get("month")); 124 | salary.setId((Integer)map.get("id")); 125 | salary.setName((String) map.get("name")); 126 | salary.setDepartment((String)map.get("department")); 127 | salary.setAttendSubsidy((Integer)map.get("attend_subsidy")); 128 | salary.setOvertimeSubsidy((Integer) map.get("overtime_subsidy")); 129 | salary.setBaseSalary((Integer)map.get("base_salary")); 130 | salary.setTotalSalary((Integer)map.get("total_salary")); 131 | salaries.add(salary); 132 | } 133 | return salaries; 134 | } 135 | 136 | } 137 | 138 | -------------------------------------------------------------------------------- /src/servlet/StaffServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import pojo.Staff; 4 | import service.StaffService; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import javax.servlet.http.HttpSession; 12 | import java.io.IOException; 13 | import java.util.List; 14 | 15 | @WebServlet({"/staff", "/staff/create", "/staff/delete", "/staff/update", "/staff/retrieve", "/staff/save", "/staff/info"}) 16 | public class StaffServlet extends HttpServlet { 17 | 18 | private StaffService service = new StaffService(); 19 | 20 | @Override 21 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 22 | req.setCharacterEncoding("utf-8"); 23 | HttpSession session = req.getSession(); 24 | String path = req.getServletPath(); 25 | switch (path){ 26 | case "/staff":{ 27 | List staffs = service.getAllStaffs(); 28 | req.setAttribute("staffs", staffs); 29 | req.getRequestDispatcher("/WEB-INF/jsp/staff/info.jsp").forward(req, resp); 30 | break; 31 | } 32 | case "/staff/create":{ 33 | session.removeAttribute("staff"); 34 | Object obj = session.getAttribute("staff"); 35 | if (obj == null){ 36 | Staff staff = new Staff(); 37 | session.setAttribute("staff",staff); 38 | } 39 | req.getRequestDispatcher("/WEB-INF/jsp/staff/editInfo.jsp").forward(req, resp); 40 | break; 41 | } 42 | case "/staff/retrieve": { 43 | String queryDepartment = req.getParameter("staffDepartment"); 44 | //System.out.println(queryDepartment); 45 | String queryName = req.getParameter("name"); 46 | if(queryDepartment.equals("所有部门")){ 47 | if(queryName.equals("所有员工")){ 48 | List staffs = service.getAllStaffs(); 49 | req.setAttribute("staffs", staffs); 50 | } 51 | else if (queryName != null && queryName.trim().length() > 0) { 52 | List staffs = service.getStaffsByName(queryName); 53 | req.setAttribute("staffs", staffs); 54 | } 55 | }else{ 56 | if(queryName.equals("所有员工")){ 57 | List staffs = service.getStaffsByDepartment(queryDepartment); 58 | req.setAttribute("staffs", staffs); 59 | }else{ 60 | List staffs = service.getStaffsByNameAndDepartment(queryName,queryDepartment); 61 | req.setAttribute("staffs", staffs); 62 | } 63 | } 64 | req.getRequestDispatcher("/WEB-INF/jsp/staff/info.jsp").forward(req, resp); 65 | break; 66 | } 67 | case "/staff/update": 68 | case "/staff/delete": { 69 | String errMessage = null; 70 | String idStr = req.getParameter("id"); 71 | if (idStr != null && idStr.matches("[0-9]+")) { 72 | Staff staff = service.getStaff(Integer.parseInt(idStr)); 73 | if (staff == null) { 74 | errMessage = "没有指定编号的员工!"; 75 | } else { 76 | if ("/staff/update".equals(path)) { 77 | session.setAttribute("staff", staff); 78 | req.getRequestDispatcher("/WEB-INF/jsp/staff/editInfo.jsp").forward(req, resp); 79 | } else { 80 | errMessage = service.deleteStaff(staff.getId()); 81 | if (errMessage == null) { 82 | session.setAttribute("message", "员工信息删除成功!"); 83 | } 84 | } 85 | } 86 | } else { 87 | errMessage = "员工设定参数格式错误!"; 88 | } 89 | if (errMessage != null) { 90 | session.setAttribute("errMessage", errMessage); 91 | } 92 | resp.sendRedirect("/staff/info"); 93 | break; 94 | } 95 | case "/staff/save": { 96 | Staff staff = new Staff(); 97 | staff.setId(Integer.parseInt(req.getParameter("id"))); 98 | staff.setName(req.getParameter("name")); 99 | staff.setStaffDepartment(req.getParameter("staffDepartment")); 100 | staff.setStaffDuty(req.getParameter("staffDuty")); 101 | String errMessage = service.UpdateStaff(staff); 102 | System.out.println(errMessage); 103 | if (errMessage == null) { 104 | session.setAttribute("message", "员工信息保存成功!"); 105 | } else { 106 | session.setAttribute("errMessage", errMessage); 107 | } 108 | resp.sendRedirect("/staff/info"); 109 | break; 110 | } 111 | case "/staff/info": 112 | req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp); 113 | break; 114 | } 115 | } 116 | 117 | @Override 118 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 119 | doGet(req, resp); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | 19 | 20 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | Class structure 35 | 36 | 37 | Declaration redundancy 38 | 39 | 40 | Google Web Toolkit issues 41 | 42 | 43 | Inheritance issues 44 | 45 | 46 | Javadoc issues 47 | 48 | 49 | TestNG 50 | 51 | 52 | 53 | 54 | JavaDoc 55 | 56 | 57 | 58 | 59 | 60 | 61 | 63 | 64 | 65 | 66 | 67 | 100 | 101 | 104 | 105 | 106 | 107 | 108 | dom4jrrrrr 109 | 110 | 115 | 116 | 117 | 118 | 119 | 120 | 1.6 121 | 122 | 127 | 128 | 129 | 130 | 131 | 132 | 1.6 133 | 134 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 150 | 151 | 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /web/WEB-INF/jsp/employStatus/statusInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/12 5 | Time: 18:17 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 11 | 12 | 13 | 14 | 15 | Document 16 | 17 | 18 | 19 |
20 |
21 | 37 |
38 |
39 | 48 |
49 | 50 | 51 |
52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 80 | 81 | 82 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 99 | 100 | 101 | 102 | 105 | 106 | 107 | 108 | 109 |
54 | 员工工作情况表 55 |      56 |
#月份员工姓名本月出勤情况本月加班情况
1${status.month}${status.name}本月出勤  ${status.attendDay}  天本月加班  ${status.subsidyDay}  天 77 | 78 | 79 |
83 |    当前的查询结果,共 1 条员工工作记录信息 84 |
${varStatus.count}${status.month}${status.name}本月出勤  ${status.attendDay}  天本月加班  ${status.subsidyDay}  天 96 | 97 | 98 |
103 |    当前的查询结果,共 ${fn:length(statuses)} 条员工工作记录信息 104 |
110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /out/artifacts/web_war_exploded/WEB-INF/jsp/employStatus/statusInfo.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: master 4 | Date: 2020/5/12 5 | Time: 18:17 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 11 | 12 | 13 | 14 | 15 | Document 16 | 17 | 18 | 19 |
20 |
21 | 37 |
38 |
39 | 48 |
49 | 50 | 51 |
52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 80 | 81 | 82 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 99 | 100 | 101 | 102 | 105 | 106 | 107 | 108 | 109 |
54 | 员工工作情况表 55 |      56 |
#月份员工姓名本月出勤情况本月加班情况
1${status.month}${status.name}本月出勤  ${status.attendDay}  天本月加班  ${status.subsidyDay}  天 77 | 78 | 79 |
83 |    当前的查询结果,共 1 条员工工作记录信息 84 |
${varStatus.count}${status.month}${status.name}本月出勤  ${status.attendDay}  天本月加班  ${status.subsidyDay}  天 96 | 97 | 98 |
103 |    当前的查询结果,共 ${fn:length(statuses)} 条员工工作记录信息 104 |
110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /src/util/JDBCUtils.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.sql.*; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | 9 | public class JDBCUtils { 10 | 11 | private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver"; 12 | private static final String DB_URL = "jdbc:mysql://localhost:3306/staff_manage?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true"; 13 | private static final String DB_USERNAME = "user"; 14 | private static final String DB_PASSWORD = "liangcanxin"; 15 | 16 | static { 17 | try { 18 | Class.forName(DB_DRIVER); 19 | } catch (ClassNotFoundException e){ 20 | System.err.println("DBTester Driver load failure..."); 21 | } 22 | } 23 | 24 | /** 25 | * 使用Statement 执行 SQL-SELECT 26 | * 27 | * @param sql 语句 28 | * @return List Of map 29 | */ 30 | public static List> executeSelect(String sql){ 31 | List> list = null; 32 | //自动关闭连接 33 | try (Connection con = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD)){ 34 | Statement statement = con.createStatement(); 35 | ResultSet rs = statement.executeQuery(sql); 36 | list = rs2map(rs); 37 | } catch (SQLException e){ 38 | System.err.printf("Error: %s\n",e.getMessage()); 39 | } 40 | return list; 41 | } 42 | 43 | /** 44 | * 使用Statement 执行 SQL-UPDATE、DELETE、INSERT 45 | * 46 | * @param sql 语句 47 | * @return 影响的记录数 48 | */ 49 | public static int executeUpdate(String sql) { 50 | int affectRows = 0; 51 | // 自动关闭连接 52 | try (Connection con = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD)) { 53 | Statement statement = con.createStatement(); 54 | affectRows = statement.executeUpdate(sql); 55 | } catch (SQLException e) { 56 | System.err.printf("Error: %s\n", e.getMessage()); 57 | } 58 | return affectRows; 59 | } 60 | 61 | /** 62 | * 使用PreparedStatement 执行 SQL-SELECT 63 | * 64 | * @param sql 带参数的语句 65 | * @param params 参数数组 66 | * @return ResultSet 67 | */ 68 | public static List> prepareSelect(String sql, Object[] params) { 69 | List> list = null; 70 | // 自动关闭连接 71 | try (Connection con = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD)) { 72 | PreparedStatement preparedStatement = con.prepareStatement(sql); 73 | // 设置参数, 可以根据情况增加分支 74 | for (int i = 0; i < params.length; i++) { 75 | if (params[i] instanceof Integer) { 76 | preparedStatement.setInt(i + 1, (Integer) params[i]); 77 | } else if (params[i] instanceof String) { 78 | preparedStatement.setString(i + 1, (String) params[i]); 79 | } else if (params[i] instanceof Double) { 80 | preparedStatement.setDouble(i + 1, (Double) params[i]); 81 | } else { 82 | preparedStatement.setObject(i + 1, params[i]); 83 | } 84 | } 85 | ResultSet rs = preparedStatement.executeQuery(); 86 | list = rs2map(rs); 87 | System.out.println(preparedStatement); 88 | } catch (SQLException e) { 89 | System.err.printf("Error: %s\n", e.getMessage()); 90 | } 91 | return list; 92 | } 93 | 94 | /** 95 | * 使用PreparedStatement 执行 SQL-UPDATE、DELETE、INSERT 96 | * 97 | * @param sql 带参数的语句 98 | * @param params 参数数组 99 | * @return ResultSet 100 | */ 101 | public static int prepareUpdate(String sql, Object[] params) { 102 | int affectRows = 0; 103 | // 自动关闭连接 104 | try (Connection con = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD)) { 105 | PreparedStatement preparedStatement = con.prepareStatement(sql); 106 | // 设置参数, 可以根据情况增加分支 107 | for (int i = 0; i < params.length; i++) { 108 | if (params[i] instanceof Integer) { 109 | preparedStatement.setInt(i + 1, (Integer) params[i]); 110 | } else if (params[i] instanceof String) { 111 | preparedStatement.setString(i + 1, (String) params[i]); 112 | } else if (params[i] instanceof Double) { 113 | preparedStatement.setDouble(i + 1, (Double) params[i]); 114 | } else if (params[i] instanceof Long) { 115 | preparedStatement.setLong(i + 1, (Long) params[i]); 116 | } else { 117 | preparedStatement.setObject(i + 1, params[i]); 118 | } 119 | } 120 | affectRows = preparedStatement.executeUpdate(); 121 | System.out.println(preparedStatement); 122 | } catch (SQLException e) { 123 | System.err.printf("Error: %s\n", e.getMessage()); 124 | } 125 | return affectRows; 126 | } 127 | 128 | private static List> rs2map(ResultSet rs) throws SQLException { 129 | if (rs == null) { 130 | return null; 131 | } 132 | List> list = new ArrayList<>(); 133 | int n = rs.getMetaData().getColumnCount(); // 获取结果集的字段数 134 | String[] fieldNames = new String[n]; // 字段名数组 135 | for (int i = 0; i < n; i++) { 136 | fieldNames[i] = rs.getMetaData().getColumnName(i + 1); 137 | } 138 | while (rs.next()) { 139 | Map map = new HashMap<>(); 140 | for (String fieldName : fieldNames) { 141 | map.put(fieldName.toLowerCase().trim(), rs.getObject(fieldName)); 142 | } 143 | list.add(map); 144 | } 145 | return list; 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /src/dao/StatusDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import pojo.Staff; 4 | import pojo.Status; 5 | import util.JDBCUtils; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public class StatusDao { 12 | 13 | /** 14 | * 显示所有员工的基本信息 15 | * 16 | * @return 员工对象的信息 17 | */ 18 | public List showAllStatuses() { 19 | List statuses = new ArrayList<>(); 20 | String sql = "SELECT * FROM employment_status"; 21 | List> list = JDBCUtils.executeSelect(sql); 22 | System.out.println(list); 23 | for (Map map : list) { 24 | Status status = new Status(); 25 | status.setName((String) map.get("staff_name")); 26 | status.setMonth((Integer) map.get("month")); 27 | System.out.println(map.get("attend_day") instanceof Long); 28 | status.setAttendDay((Integer)map.get("attend_day")); 29 | System.out.println(map.get("subsidy_day") instanceof Long); 30 | status.setSubsidyDay((Integer) map.get("subsidy_day")) ; 31 | statuses.add(status); 32 | } 33 | return statuses; 34 | } 35 | 36 | public List retrieveByMonth(int month) { 37 | List statuses = new ArrayList<>(); 38 | String sql = "SELECT * FROM employment_status WHERE month LIKE ?"; 39 | Object[] params = {month}; 40 | return getStatus(statuses, sql, params); 41 | } 42 | 43 | public List retrieveByName(String name) { 44 | List statuses = new ArrayList<>(); 45 | String sql = "SELECT * FROM employment_status WHERE staff_name LIKE ?"; 46 | Object[] params = {name}; 47 | return getStatus(statuses, sql, params); 48 | } 49 | 50 | public List retrieveByDepartment(String department) { 51 | List statuses = new ArrayList<>(); 52 | String sql = "SELECT * FROM employment_status, staff_info WHERE staff_info.staff_name = employment_status.staff_name " 53 | +"and staff_info.staff_department LIKE ?"; 54 | Object[] params = {department}; 55 | return getStatus(statuses, sql, params); 56 | } 57 | 58 | /** 59 | * 根据员工姓名查询员工,模糊查询 60 | * 61 | * @param name, month 员工姓名的全部或部分 62 | * @return 员工对象的信息 63 | */ 64 | public Status retrieveByNameAndMonth(String name, int month) { 65 | Status status = new Status(); 66 | String sql = "SELECT * FROM employment_status WHERE staff_name LIKE ? and month=?"; 67 | Object[] params = {name, month}; 68 | List> list = JDBCUtils.prepareSelect(sql, params); 69 | if (list.size() > 0) { 70 | Map map = list.get(0); 71 | status = new Status(); 72 | status.setMonth((Integer) map.get("month")); 73 | status.setName((String) map.get("staff_name")); 74 | status.setAttendDay((Integer) map.get("attend_day")); 75 | status.setSubsidyDay((Integer) map.get("subsidy_day")); 76 | } 77 | return status; 78 | } 79 | 80 | /** 81 | * 根据员工姓名和所在部门查询员工,模糊查询 82 | * 83 | * @param name,month,department 员工姓名的全部或部分 84 | * @return 员工对象的信息 85 | */ 86 | public List retrieveByNameMonthAndDepartment(String name, int month, String department) { 87 | List statuses = new ArrayList<>(); 88 | String sql = "SELECT * FROM staff_info, employment_status WHERE staff_info.staff_name = employment_status.staff_name " 89 | +"and employment_status.staff_name LIKE ? " 90 | +"and employment_status.month LIKE ? " 91 | +"and staff_info.staff_department LIKE ?"; 92 | Object[] params = {name, month, department}; 93 | return getStatus(statuses, sql, params); 94 | } 95 | 96 | /** 97 | * 根据员工姓名和所在部门查询员工,模糊查询 98 | * 99 | * @param department 员工姓名的全部或部分 100 | * @return 员工对象的信息 101 | */ 102 | public List retrieveByDepartmentAndMonth(String department, int month) { 103 | List statuses = new ArrayList<>(); 104 | String sql = "SELECT * FROM staff_info, employment_status WHERE staff_info.staff_name = employment_status.staff_name " 105 | + "and staff_info.staff_department like ? " 106 | + "and employment_status.month like ?"; 107 | Object[] params = {department, month}; 108 | return getStatus(statuses, sql, params); 109 | } 110 | 111 | public List retrieveByDepartmentAndName(String department, String name) { 112 | List statuses = new ArrayList<>(); 113 | String sql = "SELECT * FROM staff_info, employment_status WHERE staff_info.staff_name = employment_status.staff_name " 114 | + "and staff_info.staff_department like ? " 115 | + "and employment_status.staff_name like ?"; 116 | Object[] params = {department, name}; 117 | return getStatus(statuses, sql, params); 118 | } 119 | 120 | private List getStatus(List statuses, String sql, Object[] params) { 121 | List> list = JDBCUtils.prepareSelect(sql, params); 122 | System.out.println(list); 123 | for (Map map : list) { 124 | Status status = new Status(); 125 | status.setName((String) map.get("staff_name")); 126 | status.setMonth((Integer) map.get("month")); 127 | status.setAttendDay((Integer) map.get("attend_day")); 128 | status.setSubsidyDay((Integer) map.get("subsidy_day")); 129 | statuses.add(status); 130 | } 131 | return statuses; 132 | } 133 | 134 | /** 135 | * 将Staff对象插入到表中 136 | * 137 | * @param status 138 | * @return true 成功 | false 失败 139 | */ 140 | public boolean create(Status status) { 141 | String sql = "INSERT INTO employment_status(month,staff_name,attend_day,subsidy_day) VALUES(?,?,?,?)"; 142 | Object[] params = {status.getMonth(),status.getName(),status.getAttendDay(),status.getSubsidyDay()}; 143 | int rows = JDBCUtils.prepareUpdate(sql, params); 144 | return rows == 1; 145 | } 146 | 147 | /** 148 | * 根据Staff对象更新记录 149 | * 150 | * @param status 151 | * @return true 成功 | false 失败 152 | */ 153 | public boolean update(Status status) { 154 | String sql = "UPDATE employment_status SET " + 155 | "attend_day=?, "+ 156 | "subsidy_day=? "+ 157 | "WHERE staff_name=? and month=?"; 158 | Object[] params = {status.getAttendDay(),status.getSubsidyDay(),status.getName(),status.getMonth()}; 159 | //System.out.println(status.getAttendDay()+status.getSubsidyDay()+status.getName()+status.getMonth()); 160 | int rows = JDBCUtils.prepareUpdate(sql, params); 161 | return rows == 1; 162 | } 163 | 164 | /** 165 | * 根据主键id删除员工 166 | * 167 | * @param name, month 168 | * @return true 成功 | false 失败 169 | */ 170 | public boolean delete(String name, int month) { 171 | String sql = "DELETE FROM employment_status WHERE staff_name=? and month=?"; 172 | Object[] params = {name, month}; 173 | int rows = JDBCUtils.prepareUpdate(sql, params); 174 | return rows == 1; 175 | } 176 | 177 | } 178 | 179 | -------------------------------------------------------------------------------- /src/servlet/StatusServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import pojo.Staff; 4 | import pojo.Status; 5 | import service.StaffService; 6 | import service.StatusService; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.WebServlet; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | import java.io.IOException; 15 | import java.util.List; 16 | 17 | @WebServlet({"/status", "/status/create", "/status/delete", "/status/update", "/status/retrieve", "/status/save", "/status/info", "/status/create/save"}) 18 | public class StatusServlet extends HttpServlet { 19 | 20 | private StatusService service = new StatusService(); 21 | 22 | @Override 23 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 24 | req.setCharacterEncoding("utf-8"); 25 | HttpSession session = req.getSession(); 26 | String path = req.getServletPath(); 27 | switch (path){ 28 | case "/status":{ 29 | List statuses = service.getAllStatuses(); 30 | req.setAttribute("statuses", statuses); 31 | req.getRequestDispatcher("/WEB-INF/jsp/employStatus/statusInfo.jsp").forward(req, resp); 32 | break; 33 | } 34 | case "/status/create":{ 35 | session.removeAttribute("status"); 36 | Object obj = session.getAttribute("status"); 37 | System.out.println(obj); 38 | if (obj == null){ 39 | Status status = new Status(); 40 | session.setAttribute("status",status); 41 | } 42 | req.getRequestDispatcher("/WEB-INF/jsp/employStatus/editInfo.jsp").forward(req, resp); 43 | break; 44 | } 45 | case "/status/retrieve": { 46 | String queryDepartment = req.getParameter("staffDepartment"); 47 | String queryMonth = req.getParameter("month"); 48 | String queryName = req.getParameter("name"); 49 | if(queryMonth.equals("所有月份")){ 50 | if(queryDepartment.equals("所有部门")){ 51 | if(queryName.equals("所有员工")){ 52 | List statuses = service.getAllStatuses(); 53 | req.setAttribute("statuses", statuses); 54 | }else{ 55 | List statuses = service.getStatusByName(queryName); 56 | req.setAttribute("statuses", statuses); 57 | } 58 | }else{ 59 | if(queryName.equals("所有员工")){ 60 | List statuses = service.getStatusByDepartment(queryDepartment); 61 | req.setAttribute("statuses", statuses); 62 | }else{ 63 | List statuses = service.getStatusesByDepartmentAndName(queryDepartment, queryName); 64 | req.setAttribute("statuses", statuses); 65 | } 66 | } 67 | }else{ 68 | if(queryDepartment.equals("所有部门")){ 69 | if(queryName.equals("所有员工")){ 70 | List statuses = service.getStatusByMonth(Integer.parseInt(queryMonth)); 71 | req.setAttribute("statuses", statuses); 72 | }else{ 73 | Status status = service.getStatusByNameAndMonth(queryName,Integer.parseInt(queryMonth)); 74 | req.setAttribute("status", status); 75 | } 76 | }else{ 77 | if(queryName.equals("所有员工")){ 78 | List statuses = service.getStatusesByDepartmentAndMonth(queryDepartment,Integer.parseInt(queryMonth)); 79 | req.setAttribute("statuses", statuses); 80 | }else{ 81 | List statuses = service.getStatusesByNameMonthAndDepartment(queryName,Integer.parseInt(queryMonth),queryDepartment); 82 | req.setAttribute("statuses", statuses); 83 | } 84 | } 85 | } 86 | req.getRequestDispatcher("/WEB-INF/jsp/employStatus/statusInfo.jsp").forward(req, resp); 87 | break; 88 | } 89 | case "/status/update": 90 | case "/status/delete": { 91 | String errMessage = null; 92 | String nameStr = req.getParameter("name"); 93 | String monthStr = req.getParameter("month"); 94 | System.out.println(nameStr+monthStr); 95 | if (nameStr != null && monthStr != null && monthStr.matches("[0-9]+")) { 96 | Status status = service.getStatusByNameAndMonth(nameStr,Integer.parseInt(monthStr)); 97 | if (status == null) { 98 | errMessage = "没有指定编号的员工!"; 99 | } else { 100 | if ("/status/update".equals(path)) { 101 | session.setAttribute("status", status); 102 | req.getRequestDispatcher("/WEB-INF/jsp/employStatus/editInfo.jsp").forward(req, resp); 103 | } else { 104 | errMessage = service.deleteStatus(status.getName(),status.getMonth()); 105 | if (errMessage == null) { 106 | session.setAttribute("message", "员工工作信息删除成功!"); 107 | } 108 | } 109 | } 110 | } else { 111 | errMessage = "员工工作信息参数格式错误!"; 112 | } 113 | if (errMessage != null) { 114 | session.setAttribute("errMessage", errMessage); 115 | } 116 | resp.sendRedirect("/status/info"); 117 | break; 118 | } 119 | case "/status/save": 120 | case "/status/create/save":{ 121 | Status status = new Status(); 122 | status.setMonth(Integer.parseInt(req.getParameter("month"))); 123 | status.setName(req.getParameter("name")); 124 | status.setAttendDay(Integer.parseInt(req.getParameter("attendDay"))); 125 | status.setSubsidyDay(Integer.parseInt(req.getParameter("subsidyDay"))); 126 | String errMessage = service.UpdateStatus(status); 127 | System.out.println(errMessage); 128 | if (errMessage == null) { 129 | session.setAttribute("message", "员工工作信息保存成功!"); 130 | } else { 131 | session.setAttribute("errMessage", errMessage); 132 | } 133 | resp.sendRedirect("/status/info"); 134 | break; 135 | } 136 | case "/status/info": 137 | req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp); 138 | break; 139 | } 140 | } 141 | 142 | @Override 143 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 144 | doGet(req, resp); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | --------------------------------------------------------------------------------