基于javaweb的SSM公司员工管理系统(java+ssm+jsp+easyui+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

490023292402

500023292402

510023292402

530023292402

540023292402

550023292402

基于javaweb的SSM公司员工管理系统(java+ssm+jsp+easyui+mysql)

项目介绍

程序开发软件:IDEA/Eclipse/MyEclipse 数据库:mysql5.7

后台采用技术: SSM框架(SpringMVC + Spring + Mybatis) 前台采用技术: div + css + easyui框架

技术要点:

1 此系统采用了目前最流行的ssm框架,其中的spingMVC框架相对于struts2框架更灵活,更安全。 2 本项目springMVC框架采用了注解映射器,使用了RESTful风格的url对系统发起http请求,开发更灵活。 3 同时使用了了hibernate提供的校验框架,对客户端数据进行校验! 4 Mybati数据库DAO层采用的是Mapper代理开发方法,输入映射采用的是POJO包装类型实现,输出映射采用了resultMap类型,实现了数据库多对一映射。 5 spring容器内部使用拦截器,以Spring AOP的方式实现事务控制管理。

系统实体对象:

部门: 部门编号,部门名称 职位: 职位id,所属部门,职位名称,基本工资,销售提成

员工: 员工编号,职位,姓名,性别,员工照片,出生日期,学历,员工介绍

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
       PrintWriter out = response.getWriter();
//将要被返回到客户端的对象
JSONObject jsonDepartment = department.getJsonObject();
out.println(jsonDepartment.toString());
out.flush();
out.close();
}

/*ajax方式更新部门信息*/
@RequestMapping(value = "/{departmentNo}/update", method = RequestMethod.POST)
public void update(@Validated Department department, BindingResult br,
Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
String message = "";
boolean success = false;
if (br.hasErrors()) {
message = "输入的信息有错误!";
writeJsonResponse(response, success, message);
return;
}
try {
departmentService.updateDepartment(department);
message = "部门更新成功!";
success = true;
writeJsonResponse(response, success, message);
} catch (Exception e) {
e.printStackTrace();
message = "部门更新失败!";
writeJsonResponse(response, success, message);
}
}
/*删除部门信息*/
@RequestMapping(value="/{departmentNo}/delete",method=RequestMethod.GET)
public String delete(@PathVariable String departmentNo,HttpServletRequest request) throws UnsupportedEncodingException {
try {
departmentService.deleteDepartment(departmentNo);
request.setAttribute("message", "部门删除成功!");
return "message";
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("error", "部门删除失败!");
return "error";

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

/*ajax方式按照查询条件分页查询员工信息*/
@RequestMapping(value = { "/listAll" }, method = {RequestMethod.GET,RequestMethod.POST})
public void listAll(HttpServletResponse response) throws Exception {
List<Employee> employeeList = employeeService.queryAllEmployee();
response.setContentType("text/json;charset=UTF-8");
PrintWriter out = response.getWriter();
JSONArray jsonArray = new JSONArray();
for(Employee employee:employeeList) {
JSONObject jsonEmployee = new JSONObject();
jsonEmployee.accumulate("employeeNo", employee.getEmployeeNo());
jsonEmployee.accumulate("name", employee.getName());
jsonArray.put(jsonEmployee);
}
out.println(jsonArray.toString());
out.flush();
out.close();
}

/*前台按照查询条件分页查询员工信息*/
@RequestMapping(value = { "/frontlist" }, method = {RequestMethod.GET,RequestMethod.POST})
public String frontlist(String employeeNo,@ModelAttribute("positionObj") Position positionObj,String name,String birthday,Integer currentPage, Model model, HttpServletRequest request) throws Exception {
if (currentPage==null || currentPage == 0) currentPage = 1;
if (employeeNo == null) employeeNo = "";
if (name == null) name = "";
if (birthday == null) birthday = "";
List<Employee> employeeList = employeeService.queryEmployee(employeeNo, positionObj, name, birthday, currentPage);
/*计算总的页数和总的记录数*/
employeeService.queryTotalPageAndRecordNumber(employeeNo, positionObj, name, birthday);
/*获取到总的页码数目*/
int totalPage = employeeService.getTotalPage();
/*当前查询条件下总记录数*/
int recordNumber = employeeService.getRecordNumber();
request.setAttribute("employeeList", employeeList);
request.setAttribute("totalPage", totalPage);
request.setAttribute("recordNumber", recordNumber);
request.setAttribute("currentPage", currentPage);
request.setAttribute("employeeNo", employeeNo);
request.setAttribute("positionObj", positionObj);
request.setAttribute("name", name);
request.setAttribute("birthday", birthday);
List<Position> positionList = positionService.queryAllPosition();
request.setAttribute("positionList", positionList);
return "Employee/employee_frontquery_result";
}

/*前台查询Employee信息*/
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
		return ;
}
try {
employee.setEmployeePhoto(this.handlePhotoUpload(request, "employeePhotoFile"));
} catch(UserException ex) {
message = "图片格式不正确!";
writeJsonResponse(response, success, message);
return ;
}
employeeService.addEmployee(employee);
message = "员工添加成功!";
success = true;
writeJsonResponse(response, success, message);
}
/*ajax方式按照查询条件分页查询员工信息*/
@RequestMapping(value = { "/list" }, method = {RequestMethod.GET,RequestMethod.POST})
public void list(String employeeNo,@ModelAttribute("positionObj") Position positionObj,String name,String birthday,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
if (page==null || page == 0) page = 1;
if (employeeNo == null) employeeNo = "";
if (name == null) name = "";
if (birthday == null) birthday = "";
if(rows != 0)employeeService.setRows(rows);
List<Employee> employeeList = employeeService.queryEmployee(employeeNo, positionObj, name, birthday, page);
/*计算总的页数和总的记录数*/
employeeService.queryTotalPageAndRecordNumber(employeeNo, positionObj, name, birthday);
/*获取到总的页码数目*/
int totalPage = employeeService.getTotalPage();
/*当前查询条件下总记录数*/
int recordNumber = employeeService.getRecordNumber();
response.setContentType("text/json;charset=UTF-8");
PrintWriter out = response.getWriter();
//将要被返回到客户端的对象
JSONObject jsonObj=new JSONObject();
jsonObj.accumulate("total", recordNumber);
JSONArray jsonArray = new JSONArray();
for(Employee employee:employeeList) {
JSONObject jsonEmployee = employee.getJsonObject();
jsonArray.put(jsonEmployee);
}
jsonObj.accumulate("rows", jsonArray);
out.println(jsonObj.toString().replace("[[","[").replace("]]","]"));
out.flush();
out.close();
}

/*ajax方式按照查询条件分页查询员工信息*/
@RequestMapping(value = { "/listAll" }, method = {RequestMethod.GET,RequestMethod.POST})
public void listAll(HttpServletResponse response) throws Exception {
List<Employee> employeeList = employeeService.queryAllEmployee();
response.setContentType("text/json;charset=UTF-8");
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


//Position管理控制层
@Controller
@RequestMapping("/Position")
public class PositionController extends BaseController {

/*业务层对象*/
@Resource PositionService positionService;

@Resource DepartmentService departmentService;
@InitBinder("departmentObj")
public void initBinderdepartmentObj(WebDataBinder binder) {
binder.setFieldDefaultPrefix("departmentObj.");
}
@InitBinder("position")
public void initBinderPosition(WebDataBinder binder) {
binder.setFieldDefaultPrefix("position.");
}
/*跳转到添加Position视图*/
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add(Model model,HttpServletRequest request) throws Exception {
model.addAttribute(new Position());
/*查询所有的Department信息*/
List<Department> departmentList = departmentService.queryAllDepartment();
request.setAttribute("departmentList", departmentList);
return "Position_add";
}

/*客户端ajax方式提交添加职位信息*/
@RequestMapping(value = "/add", method = RequestMethod.POST)
public void add(@Validated Position position, BindingResult br,
Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
String message = "";
boolean success = false;
if (br.hasErrors()) {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16







//Employee管理控制层
@Controller
@RequestMapping("/Employee")
public class EmployeeController extends BaseController {

/*业务层对象*/
@Resource EmployeeService employeeService;

@Resource PositionService positionService;
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
 
@Controller
@SessionAttributes("username")
public class SystemController {

@Resource AdminService adminService;

@RequestMapping(value="/login",method=RequestMethod.GET)
public String login(Model model) {
model.addAttribute(new Admin());
return "login";
}

@RequestMapping(value="/login",method=RequestMethod.POST)
public void login(@Validated Admin admin,BindingResult br,Model model,HttpServletRequest request,HttpServletResponse response,HttpSession session) throws Exception {
boolean success = true;
String msg = "";
if(br.hasErrors()) {
msg = br.getAllErrors().toString();
success = false;
}
if (!adminService.checkLogin(admin)) {
msg = adminService.getErrMessage();
success = false;
}
if(success) {
session.setAttribute("username", admin.getUsername());
}
response.setContentType("text/json;charset=UTF-8");
PrintWriter out = response.getWriter();
//将要被返回到客户端的对象
JSONObject json=new JSONObject();
json.accumulate("success", success);
json.accumulate("msg", msg);
out.println(json.toString());
out.flush();
out.close();
}




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