package com.cs.springbootmb2212.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cs.springbootmb2212.entity.Department;
import com.cs.springbootmb2212.entity.Job;
import com.cs.springbootmb2212.service.DepartmentService;
import com.cs.springbootmb2212.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;
@Controller //作用: 1.@Compoment的子注解,把当前类放到springboot的容器里 2.说明当前类是控制层 3.说明当前类返回的是视图对象(HTML页面) @RestController返回的是数据对象
public class JobController {
@Autowired
private JobService jobService;
@Autowired
private DepartmentService departmentService;
@GetMapping("/job_list/{page}") ///{page}变量,用@PathVariable注解通过占位符获取对应的变量值
public String JobList(@PathVariable("page") int page,
@RequestParam(value = "searchName", required = false, defaultValue = "") String searchName,
@RequestParam(value = "searchDept", required = false, defaultValue = "") String searchDept,
HttpSession session,
Map<String, Object> map) {
if (session.getAttribute("user") == null) {
return "redirect:/error";
}
List<Department> departments = departmentService.departmentList();
IPage<Job> pe = jobService.pageJob(page, searchName, searchDept);
//通过Map把数据放到返回视图对象的上下文中(list.html),得到当前页员工的集合
map.put("departments", departments);
// System.out.println(departments);
map.put("jobList", pe.getRecords());
//把当前页放到上下文中
map.put("currentPage", pe.getCurrent());
//把总页数放到上下文中
map.put("totalPage", pe.getPages());
return "jobList";
}
@GetMapping("/toAddJobPage")
public String toAddEmpPage(Map<String, Object> map, HttpSession session) {
if (session.getAttribute("user") == null) {
return "redirect:/error";
}
// List<Job> jobs = jobService.jobList();
// map.put("jobs", jobs);
List<Department> departments = departmentService.departmentList();
map.put("departments", departments);
return "jobAdd";
}
@PostMapping("/addJob")
public String addJob(Job job) {
jobService.addJob(job);
return "redirect:/job_list/1";
}
@GetMapping("/toUpdateJobPage/{jobId}/{page}")
public String toUpdateDepPage(@PathVariable("jobId") int jobId, @PathVariable("page") int page, Map<String, Object> map, HttpSession session) {
if (session.getAttribute("user") == null) {
return "redirect:/error";
}
List<Department> departments = departmentService.departmentList();
Job job = jobService.getJob(jobId);
map.put("departments", departments);
map.put("job", job);
map.put("page", page);
return "jobUpdate";
}
@PostMapping("/updateJob")
public String updateDep(Job job, int page) {
jobService.updateJob(job);
return "redirect:/job_list/" + page;
}
@GetMapping("/deleteJob/{jobId}/{page}")
public String deleteJob(@PathVariable("jobId") int jobId, @PathVariable("page") int page, HttpSession session) {
if (session.getAttribute("user") == null) {
return "redirect:/error";
}
jobService.deleteJob(jobId);
return "redirect:/job_list/" + page;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
员工管理系统是一款高效、便捷的管理工具,旨在帮助企业实现员工信息的集中管理、查询和更新。该系统具备以下特点: 1.员工信息集中管理:通过员工管理系统,企业可以将员工信息集中存储在一个平台上,方便随时查看和更新。 2.查询功能强大:系统支持多种查询条件,方便用户快速找到所需员工信息,提高工作效率。 用户表(用户编号,用户名,登陆密码,联系方式,创建时间);用户编号为主键。 员工表(员工编号,员工姓名,员工性别,员工邮箱,员工薪资,职位名称,部门编号);员工编号为主键,部门编号为外键。 部门表(部门编号,部门名称);部门编号为主键。 职位表(职位编号,职位名称,部门编号);职位编号为主键,部门编号为外键。
资源推荐
资源详情
资源评论
收起资源包目录
JAVA、Spring Boot和Maven构成的员工管理系统(源码及数据库文件) (171个子文件)
Springbootmb2212ApplicationTests.class 5KB
EmployeeController.class 5KB
JobController.class 5KB
DepartmentController.class 5KB
Employee.class 4KB
User.class 4KB
LoginController.class 3KB
DepartmentService.class 3KB
JobService.class 3KB
EmployeeService.class 3KB
Job.class 3KB
UserService.class 2KB
Department.class 2KB
TestUser.class 1KB
MybatisPlusConfig.class 1KB
Springbootmb2212Application.class 888B
EmployeeMapper.class 699B
DepartmentMapper.class 636B
JobMapper.class 594B
MsgException.class 514B
UserMapper.class 402B
mvnw.cmd 7KB
bootstrap.css 156KB
bootstrap.css 156KB
font-awesome.min.css 38KB
font-awesome.min.css 38KB
bootstrapstyle.css 6KB
bootstrapstyle.css 6KB
login.css 5KB
login.css 5KB
index.css 4KB
index.css 4KB
bootstrapValidator.css 600B
bootstrapValidator.css 600B
jquery.pagination.css 549B
jquery.pagination.css 549B
config.css 173B
config.css 173B
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
base.gif 1KB
base.gif 1KB
loading.gif 381B
loading.gif 381B
empty.gif 62B
empty.gif 62B
.gitignore 395B
.gitignore 184B
update.html 15KB
update.html 15KB
add.html 14KB
add.html 14KB
jobUpdate.html 13KB
jobUpdate.html 13KB
jobList.html 12KB
jobList.html 12KB
jobAdd.html 12KB
jobAdd.html 12KB
departmentUpdate.html 10KB
departmentUpdate.html 10KB
departmentAdd.html 9KB
departmentAdd.html 9KB
list.html 9KB
list.html 9KB
departmentList.html 8KB
departmentList.html 8KB
error.html 6KB
error.html 6KB
index.html 4KB
index.html 4KB
update_.html 2KB
update_.html 2KB
add_.html 2KB
add_.html 2KB
login.html 1KB
login.html 1KB
manage_system.iml 344B
JobController.java 4KB
EmployeeController.java 4KB
Springbootmb2212ApplicationTests.java 4KB
DepartmentController.java 4KB
LoginController.java 2KB
DepartmentService.java 1KB
EmployeeService.java 1KB
JobService.java 1KB
UserService.java 1KB
Job.java 987B
EmployeeMapper.java 985B
Employee.java 956B
TestUser.java 876B
MybatisPlusConfig.java 842B
User.java 747B
Springbootmb2212Application.java 505B
DepartmentMapper.java 485B
JobMapper.java 443B
Department.java 440B
UserMapper.java 406B
MsgException.java 217B
bg1.jpg 84KB
bg1.jpg 84KB
共 171 条
- 1
- 2
资源评论
新人菜鸟请多多指教
- 粉丝: 218
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 原生微信小程序源码 - -滴滴公交-查公交
- 人工智能实验四 感知器算法的设计实现
- java小项目多线程多线程 复制文件 冒泡排序 群聊
- 四数之和(java代码).docx
- 701837906919458TapScanner v3.0.10 (Pro).apk
- 青岛大学人工智能实验二 利用α-β搜索的博弈树算法编写一字棋游戏
- ### 1、项目介绍 本项目Scrapy进行数据爬取,并使用Django框架+PyEcharts实现可视化大屏 效果如下:
- # 微信小程序-健康菜谱 基于微信小程序的一个查找检索菜谱的应用 ### 效果 !动态图(./res/gif/demo
- zabbix-get命令包资源
- 289ssm-mysql-jsp 计算机课程实验管理系统.zip(可运行源码+数据库文件+文档)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功