基于javaweb的SpringBoot人事管理系统(java+springboot+mysql+thymeleaf+html+mysql+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

082123250309

092123250309

102123250309

112123250309

基于javaweb的SpringBoot人事管理系统(java+springboot+mysql+thymeleaf+html+mysql+maven)

登录:
admin 123456

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
public class EmpController {
@Autowired
IEmpService empService;

@Autowired
IDeptService deptService;

@Autowired
INationService nationService;

@Autowired
IPositionService positionService;

// 查询所有员工返回列表页面
@GetMapping("/emps")
public String list(Model model,@RequestParam(value="pageNum",defaultValue="1") Integer pageNum) {
// List<Emp> emps = empService.getAllEmps();
// List<Emp> emps = empService.getEmpAndDept();

// 放在请求域中
// model.addAttribute("emps",emps);
// thymleaf默认就会拼串
// classpath:/templates/xxx.html
if(ObjectUtils.isEmpty(pageNum)){
pageNum= PaginationConstant.CURRENT_NUM;
}
//设置分页(当前页,和每页显示数据条数)
PageHelper.startPage(pageNum, PaginationConstant.PAGE_SIZE);

//查找数据
List<Emp> emps = empService.getEmpAndDept();
//将查找出的结果封装到PageInfo对象中,这个对象包含了 emps集合和关于分页的方法,如下
//pageInfo.getPageNum();
//pageInfo.getPages(); 得到总页数
//pageInfo.getNextPage(); 得到下一页
//pageInfo.getPrePage(); 得到前一页
PageInfo<Emp> pageInfo=new PageInfo<>(emps);
// model.addAttribute("emps",emps);
//用Model传递对象到page页面
model.addAttribute("pageInfo",pageInfo);
return "emp/list";
}

// 来到员工添加页面
@GetMapping("/emp")
public String toAddPage(Model model) {
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
// 合同添加
// SpringMVC 自动将请求参数和入参对象的属性进行一一绑定,要求了请求参数的名字和javaBean入参的对象里面的属性名是一样的
@PostMapping("/contract")
public String addContract(Contract contract) {
// 保存合同
contractService.addContract(contract);
// 来到合同列表页面
// redirect: 表示重定向到一个地址 /代表当前项目路径
// forward: 表示转发到一个地址
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<Emp> emps = empService.getAllEmps();
model.addAttribute("emps",emps);
// 回到修改页面(add是一个修改添加二合一的页面)
return "contract/add";
}

// 合同修改,需要提交合同id
@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<Contract> contracts = contractService.query(name);

PageInfo<Contract> pageInfo=new PageInfo<>(contracts);
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

// 来到修改页面
@GetMapping("/train/{id}")
public String toUpdatePage(@PathVariable("id") Integer id, Model model) {
Emptrain emptrain = emptrainService.getEmptrainById(id);
model.addAttribute("train",emptrain);

List<Emp> emps = empService.getAllEmps();
model.addAttribute("emps",emps);

// 回到修改页面(add是一个修改添加二合一的页面)
return "train/add";
}

// 修改,需要提交id
@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<Emptrain> emptrains = emptrainService.query(name);

PageInfo<Emptrain> pageInfo=new PageInfo<>(emptrains);

model.addAttribute("pageInfo",pageInfo);
return "train/train";
}
}
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


@Controller
public class EmptrainController {
@Autowired
IEmptrainService emptrainService;

@Autowired
IEmpService empService;
// 查询所有
@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<Emptrain> emptrains = emptrainService.getEmptrainAndEmp();

PageInfo<Emptrain> pageInfo=new PageInfo<>(emptrains);

//用Model传递对象到page页面
model.addAttribute("pageInfo",pageInfo);
return "train/train";
}

// 来到添加页面
@GetMapping("/train")
public String toAddPage(Model model) {
// 来到添加页面
List<Emp> emps = empService.getAllEmps();
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
        //pageInfo.getPageNum();
//pageInfo.getPages(); 得到总页数
//pageInfo.getNextPage(); 得到下一页
//pageInfo.getPrePage(); 得到前一页
PageInfo<Emp> pageInfo=new PageInfo<>(emps);
// model.addAttribute("emps",emps);
//用Model传递对象到page页面
model.addAttribute("pageInfo",pageInfo);
return "emp/list";
}

// 来到员工添加页面
@GetMapping("/emp")
public String toAddPage(Model model) {
// 来到添加页面,查出所有的部门,在页面显示
List<Dept> depts = deptService.getAllDepts();
model.addAttribute("depts",depts);
// 查出所有民族
List<Nation> nations = nationService.getAllNations();
model.addAttribute("nations",nations);
// 查出所有职位
List<Position> positions = positionService.getAllPositions();
model.addAttribute("positions",positions);
return "emp/add";
}

// 员工添加
// SpringMVC 自动将请求参数和入参对象的属性进行一一绑定,要求了请求参数的名字和javaBean入参的对象里面的属性名是一样的
@PostMapping("/emp")
public String addEmp(Emp emp) {
// System.out.println("保存的员工信息"+emp);
// 保存员工
empService.addEmp(emp);
// 来到员工列表页面
// redirect: 表示重定向到一个地址 /代表当前项目路径
// forward: 表示转发到一个地址
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<Dept> depts = deptService.getAllDepts();
model.addAttribute("depts",depts);
// 查出所有民族
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



@Controller
public class EmprpController {
@Autowired
IEmprpService emprpService;

@Autowired
IEmpService empService;
// 查询所有
@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<Emprp> emprps = emprpService.getEmprpAndEmp();

PageInfo<Emprp> pageInfo=new PageInfo<>(emprps);

//用Model传递对象到page页面
model.addAttribute("pageInfo",pageInfo);
return "emprp/emprp";
}

// 来到添加页面
@GetMapping("/emprp")


项目链接:
https://javayms.github.io?id=072123250309201dx
https://javayms.pages.dev?id=072123250309201dx