Java项目:公司员工管理系统(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,所属部门,职位名称,基本工资,销售提成

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

 

 

 

 

 

员工管理控制层:

@RestController
@RequestMapping("/employee")
@CrossOrigin
@Slf4j
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private JobService jobService;
    @Autowired
    private EduLevelMapper eduLevelMapper;
    @Autowired
    private EmployeeMapper employeeMapper;
    /**
     * 搜索接口
     */
    @GetMapping("/search")
    public Result search(@RequestParam(name = "name", required = false,defaultValue = "") String name,
                         @RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                         @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, name);
    }

    /**
     * 分页查询接口
     *
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                       @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, null);
    }

    /**
     * 根据id获取员工具体信息
     * @param id
     * @return
     */
    @GetMapping("/getUserById")
    public EmployeeDTO getUserAllInfoById(@RequestParam(name = "id") Integer id) {
        return employeeService.getUserById(id);
    }

    /**
     * 根据员工获取信息
     * @param id
     * @return
     */
    @GetMapping("/getEmployeeById")
    public Employee getUserById(@RequestParam(name = "id") Integer id) {
        return employeeMapper.selectById(id);
    }
    /**
     * 增加员工接口
     *
     * @param employee
     * @return
     */
    @PostMapping("/add")
    public Map<String, Object> addUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.add(employee);
    }

    /**
     * 更新用户
     * @param employee
     * @return
     */
    @PostMapping("/update")
    public Map<String, Object> updateUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.update(employee);
    }

    /**
     * 删除用户
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public Result deleteEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.deleteEmployeeById(id);
    }

    /**
     * 辞退员工
     *
     * @param id
     * @return
     */
    @GetMapping("/dismiss")
    public Map<String, Object> dismissEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.dismissEmployeeById(id);
    }

    /**
     * 得到所以工作,部门,学历信息
     *
     * @return
     */
    @GetMapping("/otherInfo")
    public Result getAllOtherInfo() {
        Map<String, Object> info = new HashMap<>();
        info.put("departments", departmentService.selectAll());
        info.put("jobs", jobService.selectAll());
        info.put("eduLevels", eduLevelMapper.selectList(null));
        return Result.success(info);
    }

    @GetMapping("/map")
    public Result getMap() {
        return employeeService.getMap();
    }
}

用户管理控制层:

@Controller
public class UserController {
	@Autowired
	@Qualifier("RainService")
	private RainService rainservice;
	// 如果在目录下输入为空,则跳转到指定链接
		@RequestMapping(value="/user/")
		 public ModelAndView index2(ModelAndView mv){
			mv.setViewName("/user/list");
			return mv;
		}
//		退出功能
		@RequestMapping(value="/user/logout")
		 public ModelAndView logout(ModelAndView mv, HttpSession session){
			session.setAttribute(Constants.USER_SESSION, null);
			session.setAttribute("tip", null);
			mv.setViewName("redirect:/index");
			
			return mv;
		}
		@RequestMapping(value="/login")
		 public ModelAndView login(@RequestParam("loginname") String loginname,
				 @RequestParam("password") String password,@RequestParam("tip") String tip,
				 HttpSession session,
				 ModelAndView mv){
			// 调用业务逻辑组件判断用户是否可以登录
			boolean flag = false;
			if("1".equals(tip)) {
				User user = rainservice.login(loginname, password);
				if(user!=null){
					// 将用户保存到HttpSession当中
					System.out.println("HttpSession");
					session.setAttribute(Constants.USER_SESSION, user);
					session.setAttribute("tip", "1");
					// 客户端跳转到main页面
					mv.setViewName("redirect:/index");
				}else{
					// 设置登录失败提示信息
					System.out.println("设置登录失败提示信息");
					mv.addObject("message", "登录名或密码错误!请重新输入");
					// 服务器内部跳转到登录页面
					mv.setViewName("forward:/loginForm");
				}
			}else {
				Employee user = rainservice.login2(loginname, password);
				if(user!=null){
					// 将用户保存到HttpSession当中
					System.out.println("HttpSession");
					session.setAttribute(Constants.USER_SESSION, user);
					session.setAttribute("tip", "2");
					// 客户端跳转到main页面
					mv.setViewName("redirect:/indexcustomer/");
				}else{
					// 设置登录失败提示信息
					System.out.println("设置登录失败提示信息");
					mv.addObject("message", "登录名或密码错误!请重新输入");
					// 服务器内部跳转到登录页面
					mv.setViewName("forward:/loginForm");
				}
				
			}
			return mv;
		}
		// 如果在目录下输入任何不存在的参数,则跳转到list
		@RequestMapping(value="/user/{formName}")
		 public String index2(@PathVariable String formName){
			String blank = "/user/list";
			return blank;
		}
		@RequestMapping(value="/user/list",method=RequestMethod.GET)
		 public String index(Model model,String content){
			List<User> job_list = rainservice.get_UserList();
			if (content!=null){
				job_list = rainservice.get_UserLikeList(content);
			}
			model.addAttribute("list",job_list);
			return "user/list";
		}
		@RequestMapping(value="/user/add",method=RequestMethod.GET)
		 public String add(Model model,Integer id){
			if(id!=null){
				User job = rainservice.get_UserInfo(id);
				model.addAttribute("job",job);
			}
			return "/user/add";
		}
		@RequestMapping(value="/user/add",method=RequestMethod.POST)
		 public ModelAndView add(ModelAndView mv,@ModelAttribute User notice ,Integer id){
			System.out.println(id);
			if(id!=null){
				rainservice.update_UserInfo(notice);
			}else{
				rainservice.insert_UserInfo(notice);
			}
			mv.setViewName("redirect:/user/list");
			return mv;
		}
		@RequestMapping(value="/user/delete",method=RequestMethod.GET)
		 public void delete(Integer id){
			System.out.println(id);
			if(id!=null){
				rainservice.delete_UserInfo(id);
			}
		}
//		管理员自己修改密码时跳转的页面 
		@RequestMapping(value="/user/myupdate",method=RequestMethod.GET)
		 public String update(Model model,HttpSession session){
			User user = (User) session.getAttribute(Constants.USER_SESSION);
			model.addAttribute("job",user);
			return "/user/myupdate";
		}
		@RequestMapping(value="/user/myupdate",method=RequestMethod.POST)
		 public ModelAndView update(ModelAndView mv,Model model,HttpSession session,User notice){
			User user = (User) session.getAttribute(Constants.USER_SESSION);
//			如果是自己修改自己的密码,则更新session
			user.setLoginname(notice.getLoginname());
			user.setPassword(notice.getPassword());
			user.setUsername(notice.getUsername());
			rainservice.update_UserInfo(user);
				session.setAttribute(Constants.USER_SESSION, user);
				mv.setViewName("redirect:/user/myupdate");
				return mv;
		}
}

部门管理控制层: 

@Controller
public class DeptController {
	@Autowired
	@Qualifier("RainService")
	private RainService rainservice;
	
	// 如果在目录下输入为空,则跳转到指定链接
	@RequestMapping(value="/dept/")
	 public ModelAndView index2(ModelAndView mv){
		mv.setViewName("dept/list");
		return mv;
	}
	// 如果在目录下输入任何不存在的参数,则跳转到list
	@RequestMapping(value="/dept/{formName}")
	 public String index2(@PathVariable String formName){
//		return formName;
		String blank = "/dept/list";
		return blank;
	}
	
	@RequestMapping(value="/dept/list",method=RequestMethod.GET)
	 public String index(Model model,String content){
//		System.out.println("4234");
		List<Dept> dept_list = rainservice.findAllDept();
		if (content!=null){
			dept_list = rainservice.findAllDept(content);
		}
		
		model.addAttribute("list",dept_list);
//		for(Dept attribute : dept_list) {
//			  System.out.println(attribute.getName());
//			}
		return "dept/list";
	}
	@RequestMapping(value="/dept/add",method=RequestMethod.GET)
	 public String add(Model model,Integer id){
//		System.out.println(id);
		if(id!=null){
			Dept dept = rainservice.get_Info(id);
			model.addAttribute("dept",dept);
//			System.out.println(dept.getName());
		}
		return "/dept/add";
	}
	@RequestMapping(value="/dept/add",method=RequestMethod.POST)
	 public ModelAndView add(ModelAndView mv,@ModelAttribute Dept dept ,Integer id){
		System.out.println(id);
//		System.out.println(dept.getId());
		if(id!=null){
			rainservice.update_Info(dept);
			System.out.println(dept.getId());
		}else{
			rainservice.addDept(dept);
		}
//		System.out.println(dept.getName());
		mv.setViewName("redirect:/dept/list");
		return mv;
	}
	@RequestMapping(value="/dept/delete",method=RequestMethod.GET)
	 public void delete(Integer id){
		System.out.println(id);
		if(id!=null){
			rainservice.delete_Info(id);
		}
	}
}

源码获取:博客首页 "资源" 里下载! 

  • 6
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq1334611189

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值