# hrms
**Repository Path**: zeroUsr/hrms
## Basic Information
- **Project Name**: hrms
- **Description**: 软件设计与体系结构课程期末大作业
- **Primary Language**: Java
- **License**: GPL-3.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-06-16
- **Last Updated**: 2023-06-16
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
###
人力资源后台管理系统
#### 1.开发环境
- 网站开发环境
- 网站开发环境:IntelliJ IDEA 2020.1.1集成开发环境。
- 网站开发语言:HTML+CSS+JavaScript。
- 网站后台数据库:MySQL8.0.28。
- 开发环境运行平台:Window10/11。
- 服务器端
- 操作系统:Windows11。
- 数据库服务器:MySQL8.0.28。
- 网站服务器运行环境:JDK8。
- 客户端
- 浏览器:Chrome 108.0.5359.125及以上版本。
- 分辨率:最佳效果1920×1080像素。
#### 2.安装说明
##### 2.1.执行数据库/hrms.sql文件安装数据库
##### 2.2.修改 src/main/resources/application.yml
```yml
spring:
datasource:
username: 用户名
password: 密码
```
##### 2.3.执行 src/main/java/com.hrms/HrmsApplication.Java
##### 2.4.管理员账号
- 账号: admin, 密码: 123456
- 账号: cyb, 密码: 123456
#### 3.模块划分
##### 3.1.系统流程图

##### 3.2.E-R图

##### 3.3.数据库设计

##### 3.4.主要模块说明
- login.html页面:管理员登录。
- user.html页面:对管理员的管理。
- appraise.html页面:对员工的绩效评估管理。
- contract.html页面:对员工的合同管理。
- emp.list.html页面:对员工的信息管理。
- emprp.html页面:对员工的奖惩管理。
- salary.html页面:对员工的薪酬管理。
- train.html页面:对员工的培训管理。
#### 4.运行效果说明
##### 4.1.管理员页面
###### 4.1.1.登录展示

###### 4.1.2.登录失败

###### 4.1.3.登录成功

###### 4.1.4.代码设计
```java
@Controller
public class UserController {
@Autowired
IUserService userService;
// 查询所有
@GetMapping("/users")
public String list(Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum) {
if(ObjectUtils.isEmpty(pageNum)){
pageNum= PaginationConstant.CURRENT_NUM;
}
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List users = userService.getAllUsers();
PageInfo pageInfo=new PageInfo<>(users);
model.addAttribute("pageInfo",pageInfo);
return "user/user";
}
// 添加页面
@GetMapping("/user")
public String toAddPage(Model model) {
return "user/add";
}
// 添加
@PostMapping("/user")
public String addUser(User user) {
userService.addUser(user);
return "redirect:/users";
}
// 修改页面
@GetMapping("/user/{id}")
public String toUpdatePage(@PathVariable("id") Integer id, Model model) {
User user = userService.getUserById(id);
model.addAttribute("user",user);
return "user/add";
}
// 修改
@PutMapping("/user")
public String updateUser(User user) {
userService.updateUser(user);
return "redirect:/users";
}
//删除
@DeleteMapping("/user/{id}")
public String deleteUserById(@PathVariable("id") Integer id){
userService.deleteUserById(id);
return "redirect:/users";
}
}
/* 登录验证 */
public class LoginHandlerInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Object user = request.getSession().getAttribute("loginUser");
if(user == null){
request.setAttribute("msg","请登录");
request.getRequestDispatcher("/index.html").forward(request,response);
return false;
}else{
return true;
}
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
```
##### 4.2.员工管理
###### 4.2.1.页面展示

###### 4.2.2.添加员工

###### 4.2.3.修改员工

###### 4.2.4.搜索员工

###### 4.2.5.代码设计
```java
// 员工列表
@GetMapping("/emps")
public String list(Model model,@RequestParam(value="pageNum",defaultValue="1") Integer pageNum) {
if(ObjectUtils.isEmpty(pageNum)){
pageNum= PaginationConstant.CURRENT_NUM;
}
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List emps = empService.getEmpAndDept();
PageInfo pageInfo=new PageInfo<>(emps);
model.addAttribute("pageInfo",pageInfo);
return "emp/list";
}
// 添加页面
@GetMapping("/emp")
public String toAddPage(Model model) {
List depts = deptService.getAllDepts();
model.addAttribute("depts",depts);
List nations = nationService.getAllNations();
model.addAttribute("nations",nations);
List positions = positionService.getAllPositions();
model.addAttribute("positions",positions);
return "emp/add";
}
// 员工添加
@PostMapping("/emp")
public String addEmp(Emp emp) {
empService.addEmp(emp);
return "redirect:/emps";
}
// 修改页面
@GetMapping("/emp/{id}")
public String toUpdatePage(@PathVariable("id") Integer id,Model model) {
Emp emp = empService.getEmpById(id);
model.addAttribute("emp",emp);
List depts = deptService.getAllDepts();
model.addAttribute("depts",depts);
List nations = nationService.getAllNations();
model.addAttribute("nations",nations);
List positions = positionService.getAllPositions();
model.addAttribute("positions",positions);
return "emp/add";
}
// 员工修改
@PutMapping("/emp")
public String updateEmp(Emp emp) {
empService.updateEmp(emp);
return "redirect:/emps";
}
//员工删除
@DeleteMapping("/emp/{id}")
public String deleteEmpById(@PathVariable("id") Integer id){
empService.deleteEmpById(id);
return "redirect:/emps";
}
// 查询员工
@PostMapping("/search")
public String queryEmp(@RequestParam String name, Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum){
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List emps=empService.query(name);
model.addAttribute("emps",emps);
PageInfo pageInfo=new PageInfo<>(emps);
model.addAttribute("pageInfo",pageInfo);
return "emp/list";
}
```
##### 4.3.奖惩管理
###### 4.3.1.页面展示

###### 4.3.2.添加奖惩

###### 4.3.3.修改奖惩

###### 4.3.4.搜索奖惩

###### 4.3.5.代码设计
```java
// 查询所有
@GetMapping("/emprps")
public String list(Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum) {
if(ObjectUtils.isEmpty(pageNum)){
pageNum= PaginationConstant.CURRENT_NUM;
}
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List emprps = emprpService.getEmprpAndEmp();
PageInfo pageInfo=new PageInfo<>(emprps);
model.addAttribute("pageInfo",pageInfo);
return "emprp/emprp";
}
// 添加页面
@GetMapping("/emprp")
public String toAddPage(Model model) {
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
return "emprp/add";
}
// 添加
@PostMapping("/emprp")
public String addEmprp(Emprp emprp) {
emprpService.addEmprp(emprp);
return "redirect:/emprps";
}
// 修改页面
@GetMapping("/emprp/{id}")
public String toUpdatePage(@PathVariable("id") Integer id, Model model) {
Emprp emprp = emprpService.getEmprpById(id);
model.addAttribute("emprp",emprp);
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
return "emprp/add";
}
// 修改
@PutMapping("/emprp")
public String updateEmprp(Emprp emprp) {
emprpService.updateEmprp(emprp);
return "redirect:/emprps";
}
//删除
@DeleteMapping("/emprp/{id}")
public String deleteEmprpById(@PathVariable("id") Integer id){
emprpService.deleteEmprpById(id);
return "redirect:/emprps";
}
@PostMapping("/rpsearch")
public String queryEmprp(@RequestParam String name, Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum){
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List emprps = emprpService.query(name);
PageInfo pageInfo=new PageInfo<>(emprps);
model.addAttribute("pageInfo",pageInfo);
return "emprp/emprp";
}
```
##### 4.4.合同管理
###### 4.4.1.页面展示

###### 4.4.2.添加合同

###### 4.4.3.修改合同

###### 4.4.4.搜索合同

###### 4.4.5.代码设计
```java
// 合同列表
@GetMapping("/contracts")
public String list(Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum) {
if(ObjectUtils.isEmpty(pageNum)){
pageNum= PaginationConstant.CURRENT_NUM;
}
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List contracts = contractService.getContractAndEmp();
PageInfo pageInfo=new PageInfo<>(contracts);
model.addAttribute("pageInfo",pageInfo);
return "contract/contract";
}
@GetMapping("/contract")
public String toAddPage(Model model) {
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
return "contract/add";
}
// 合同添加
@PostMapping("/contract")
public String addContract(Contract contract) {
contractService.addContract(contract);
return "redirect:/contracts";
}
// 修改页面
@GetMapping("/contract/{id}")
public String toUpdatePage(@PathVariable("id") Integer id,Model model) {
Contract contract = contractService.getContractById(id);
model.addAttribute("contract",contract);
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
return "contract/add";
}
// 合同修改
@PutMapping("/contract")
public String updateContract(Contract contract) {
contractService.updateContract(contract);
return "redirect:/contracts";
}
//合同删除
@DeleteMapping("/contract/{id}")
public String deleteContractById(@PathVariable("id") Integer id){
contractService.deleteContractById(id);
return "redirect:/contracts";
}
@PostMapping("/consearch")//提交表单+传回前端的映射
public String queryContract(@RequestParam String name, Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum){
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List contracts = contractService.query(name);
PageInfo pageInfo=new PageInfo<>(contracts);
model.addAttribute("pageInfo",pageInfo);
return "contract/contract";
}
```
##### 4.5.薪酬管理
###### 4.5.1.页面展示

###### 4.5.2.添加薪酬

###### 4.3.3.修改薪酬

###### 4.5.4.搜索薪酬

###### 4.5.5.代码设计
```java
// 查询所有
@GetMapping("/salarys")
public String list(Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum) {
if(ObjectUtils.isEmpty(pageNum)){
pageNum= PaginationConstant.CURRENT_NUM;
}
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List empsalarys = empsalaryService.getAll();
PageInfo pageInfo=new PageInfo<>(empsalarys);
model.addAttribute("pageInfo",pageInfo);
return "salary/salary";
}
// 添加页面
@GetMapping("/salary")
public String toAddPage(Model model) {
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
List salarys = salaryService.getAllSalarys();
model.addAttribute("salarys",salarys);
return "salary/add";
}
// 添加
@PostMapping("/salary")
public String addEmpSalary(Empsalary empsalary) {
empsalaryService.addEmpsalary(empsalary);
return "redirect:/salarys";
}
// 修改页面
@GetMapping("/salary/{id}")
public String toUpdatePage(@PathVariable("id") Integer id, Model model) {
Empsalary empsalary = empsalaryService.getEmpsalaryById(id);
model.addAttribute("empsalary",empsalary);
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
List salarys = salaryService.getAllSalarys();
model.addAttribute("salarys",salarys);
return "salary/add";
}
// 修改
@PutMapping("/salary")
public String updateEmpsalary(Empsalary empsalary) {
empsalaryService.updateEmpsalary(empsalary);
return "redirect:/salarys";
}
//删除
@DeleteMapping("/salary/{id}")
public String deleteEmpsalaryById(@PathVariable("id") Integer id){
empsalaryService.deleteEmpsalaryById(id);
return "redirect:/salarys";
}
@GetMapping("/salaryaccount/{id}")
public String showSalaryAccount(@PathVariable("id") Integer id, Model model) {
Salary salary = salaryService.getSalaryById(id);
model.addAttribute("salary",salary);
return "salary/salaryaccount";
}
@PostMapping("/salsearch")
public String queryEmpsalary(@RequestParam String name, Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum){
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List empsalarys = empsalaryService.query(name);
PageInfo pageInfo=new PageInfo<>(empsalarys);
model.addAttribute("pageInfo",pageInfo);
return "salary/salary";
}
```
##### 4.6.培训管理
###### 4.6.1.页面展示

###### 4.6.2.添加培训

###### 4.6.3.修改培训

###### 4.6.4.搜索培训

###### 4.6.5.代码设计
```java
// 查询所有
@GetMapping("/trains")
public String list(Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum) {
if(ObjectUtils.isEmpty(pageNum)){
pageNum= PaginationConstant.CURRENT_NUM;
}
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List emptrains = emptrainService.getEmptrainAndEmp();
PageInfo pageInfo=new PageInfo<>(emptrains);
model.addAttribute("pageInfo",pageInfo);
return "train/train";
}
// 添加页面
@GetMapping("/train")
public String toAddPage(Model model) {
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
return "train/add";
}
// 添加
@PostMapping("/train")
public String addEmptrain(Emptrain emptrain) {
emptrainService.addEmptrain(emptrain);
return "redirect:/trains";
}
// 修改页面
@GetMapping("/train/{id}")
public String toUpdatePage(@PathVariable("id") Integer id, Model model) {
Emptrain emptrain = emptrainService.getEmptrainById(id);
model.addAttribute("train",emptrain);
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
return "train/add";
}
// 修改
@PutMapping("/train")
public String updateEmptrain(Emptrain emptrain) {
emptrainService.updateEmptrain(emptrain);
return "redirect:/trains";
}
//删除
@DeleteMapping("/train/{id}")
public String deleteEmptrainById(@PathVariable("id") Integer id){
emptrainService.deleteEmptrainById(id);
return "redirect:/trains";
}
@PostMapping("/trasearch")//提交表单+传回前端的映射
public String queryEmptrain(@RequestParam String name, Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum){
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List emptrains = emptrainService.query(name);
PageInfo pageInfo=new PageInfo<>(emptrains);
model.addAttribute("pageInfo",pageInfo);
return "train/train";
}
```
##### 4.7.绩效管理
###### 4.7.1.页面展示

###### 4.7.2.添加绩效

###### 4.7.3.修改绩效

###### 4.7.4.搜索绩效

###### 4.7.5.代码设计
```java
// 查询所有
@GetMapping("/appraises")
public String list(Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum) {
if(ObjectUtils.isEmpty(pageNum)){
pageNum= PaginationConstant.CURRENT_NUM;
}
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List appraises = appraiseService.getAll();
PageInfo pageInfo=new PageInfo<>(appraises);
model.addAttribute("pageInfo",pageInfo);
return "appraise/appraise";
}
// 添加页面
@GetMapping("/appraise")
public String toAddPage(Model model) {
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
return "appraise/add";
}
// 添加
@PostMapping("/appraise")
public String addAppraise(Appraise appraise) {
appraiseService.addAppraise(appraise);
return "redirect:/appraises";
}
// 修改页面
@GetMapping("/appraise/{id}")
public String toUpdatePage(@PathVariable("id") Integer id,Model model) {
Appraise appraise = appraiseService.getAppraiseById(id);
model.addAttribute("appraise",appraise);
List emps = empService.getAllEmps();
model.addAttribute("emps",emps);
return "appraise/add";
}
// 修改
@PutMapping("/appraise")
public String updateAppraise(Appraise appraise) {
appraiseService.updateAppraise(appraise);
return "redirect:/appraises";
}
//删除
@DeleteMapping("/appraise/{id}")
public String deleteAppraiseById(@PathVariable("id") Integer id){
appraiseService.deleteAppraiseById(id);
return "redirect:/appraises";
}
@PostMapping("/appsearch")
public String queryAppraise(@RequestParam String name, Model model,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum){
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);
List appraises = appraiseService.query(name);
PageInfo pageInfo=new PageInfo<>(appraises);
model.addAttribute("pageInfo",pageInfo);
return "appraise/appraise";
}
```