赞
踩
基于javaweb+mysql的ssm+maven人事crm管理系统(java+ssm+jsp+layui+jquery+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven人事CRM管理系统(java+ssm+jsp+layui+jquery+mysql)
项目介绍
CRM人事管理系统,主要功能有: 用户管理:用户查询、添加用户、编辑、删除; 职位管理:职位查询、添加职位、删除; 部门管理:部门查询、添加部门、删除; 员工管理:员工查询、添加员工、编辑、删除; 公告管理:公告查询、添加公告、删除; 下载中心:文档查询、上传文档; 系统设置:退出系统;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;
技术栈
使用说明
List<Department> countDept = departmentService.selectAll(keyword); //分页 if (page < 0) { page = 1; } PageHelper.startPage(page, limit); List<Department> listDept = departmentService.selectAll(keyword); //封装json数据 Map<String, Object> resultMap = new HashMap<String, Object>() { { put("code", 0); put("msg", ""); put("count", countDept.size()); put("data", listDept); } }; return resultMap; } } package com.iarchie.crm_v1.web.controller; @Controller @RequestMapping("/admin") public class UserController { @Autowired private IUserService userService; //加载列表界面 @RequestMapping("/userView") public String showUser() { return "user/user"; } //跳转add页面 @RequestMapping("/addView") public String userAddView() {
Employee employee = jsonData(data); if (employee != null) { int insert = employeeService.insert(employee); if (insert != 0) { return "success"; } } return "error"; } //更新 @RequestMapping("/empUpdate") @ResponseBody public String update(@RequestBody JSONObject ob) { System.out.println("ob.toJSONString() = " + ob.toJSONString()); String data = ob.toJSONString(); Employee employee = jsonData(data); if (employee != null) { int index = employeeService.updateByPrimaryKey(employee); if (index != 0) { return "success"; } } return "error"; } //删除 @RequestMapping("/empDelete") @ResponseBody public String delete(@RequestParam("id") Long id) { if (id != null) { int index = employeeService.deleteByPrimaryKey(id); if (index == 0 || index == -1) { return "error"; } } return "success"; } @RequestMapping(value = "/empList", method = RequestMethod.GET) public @ResponseBody Map<String, Object> empList(@RequestParam("page") int page, @RequestParam("limit") int limit) { //查询所有的数据
return null; } //保存数据 @RequestMapping(value = "/empSave", method = RequestMethod.POST) @ResponseBody public String employeeSave(@RequestBody JSONObject ob) { String data = ob.toJSONString(); Employee employee = jsonData(data); if (employee != null) { int insert = employeeService.insert(employee); if (insert != 0) { return "success"; } } return "error"; } //更新 @RequestMapping("/empUpdate") @ResponseBody public String update(@RequestBody JSONObject ob) { System.out.println("ob.toJSONString() = " + ob.toJSONString()); String data = ob.toJSONString(); Employee employee = jsonData(data); if (employee != null) { int index = employeeService.updateByPrimaryKey(employee); if (index != 0) { return "success"; } } return "error"; } //删除 @RequestMapping("/empDelete") @ResponseBody public String delete(@RequestParam("id") Long id) { if (id != null) { int index = employeeService.deleteByPrimaryKey(id); if (index == 0 || index == -1) { return "error"; } } return "success"; } @RequestMapping(value = "/empList", method = RequestMethod.GET) public @ResponseBody Map<String, Object> empList(@RequestParam("page") int page, @RequestParam("limit") int limit) { //查询所有的数据 List<Employee> countEmp = employeeService.selectAll(); //加入分页
* * @ClassName CheckLoginInterceptor * @Description: TODO * @Viersion V1.0.1 */ public class CheckLoginInterceptor extends HandlerInterceptorAdapter { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { //判断用户是否登入 if (UserContext.getCurrentUser() == null) { response.sendRedirect("login.jsp"); System.out.println("CheckLoginInterceptor.preHandle" + "----------------未登入------拦截请求--------------->"); return false; } return true; } } package com.iarchie.crm_v1.web.controller; /** * 类描述信息 下载中心处理类 * * @ClassName DownloadDocController * @Description: TODO * @Viersion V1.0.1 */ @Controller @RequestMapping("/download") public class DownloadDocController { @Autowired private IDownloadService downloadService;
/** * 类描述信息 部门controller类 * * @ClassName DepartmentController * @Description: TODO * @Viersion V1.0.1 */ @Controller @RequestMapping("/department") public class DepartmentController { //注入业务 @Autowired private IDepartmentService departmentService; @RequestMapping("/deptView") public String employeeView() { return "department/department"; } //跳转添加页面 @RequestMapping("/deptAddView") public String departmentAddView() { return "department/departmentAdd"; } //查询部门所有数据 @RequestMapping("/deptOption") @ResponseBody public List<Department> jsonDeptOption(String keyword) { List<Department> list = departmentService.selectAll(keyword); return list; }
@Controller public class LoginController { //依赖Mapper @Autowired private UserMapper mapper; //处理验证码 @RequestMapping("/imageCode") public void imgCode(HttpServletRequest request, HttpServletResponse response) throws IOException { //这个方法实现验证码的生成 BufferedImage bi = new BufferedImage(68, 22, BufferedImage.TYPE_INT_RGB);//创建图像缓冲区 Graphics g = bi.getGraphics(); //通过缓冲区创建一个画布 Color c = new Color(200, 150, 255); //创建颜色 /*根据背景画了一个矩形框 */ g.setColor(c);//为画布创建背景颜色 g.fillRect(0, 0, 68, 22); //fillRect:填充指定的矩形 char[] ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();//转化为字符型的数组 Random r = new Random(); int len = ch.length; int index; //index用于存放随机数字 StringBuffer sb = new StringBuffer(); for (int i = 0; i < 4; i++) { index = r.nextInt(len);//产生随机数字 g.setColor(new Color(r.nextInt(88), r.nextInt(188), r.nextInt(255))); //设置颜色 g.drawString(ch[index] + "", (i * 15) + 3, 18);//画数字以及数字的位置 sb.append(ch[index]); } request.getSession().setAttribute("imgCode", sb.toString()); //将数字保留在session中,便于后续的使用
} else if (user.getState() == 0) { session.setAttribute("errorMsg", user.getLoginname()+"用户被锁定!请联系管理员!"); session.setAttribute("loginname", loginname); // 服务器内部跳转到登录页面 mv.setViewName("forward:/login.jsp"); return mv; } //存储用户登入信息 UserContext.setUserInSession(user); // 客户端跳转到main页面 mv.setViewName("redirect:/main"); return mv; } @RequestMapping("/main") public String main() { return "main"; } //注销处理 @RequestMapping("/loginOut") public String invalidate(HttpSession session) { session.invalidate(); return "redirect:login.jsp"; } } package com.iarchie.crm_v1.web.controller; /** * 类描述信息 部门controller类 * * @ClassName DepartmentController * @Description: TODO * @Viersion V1.0.1 */ @Controller
@Controller @RequestMapping("/notice") public class NoticeController { @Autowired private IDocTestService docTestService; @RequestMapping("/noticeView") public String noticeView(Model model, Integer pageIndex) { int pageSize = 5;//每页显示的记录数 if (pageIndex == null) pageIndex = 1;//第一次访问页面默认页面为第一页 PageHelper.startPage(pageIndex, pageSize); List<DocTest> docTests = docTestService.selectAll(); //得到分页的结果对象 PageInfo<DocTest> personPageInfo = new PageInfo<>(docTests); //得到分页中的person条目对象 List<DocTest> pageList = personPageInfo.getList(); model.addAttribute("docList", pageList); model.addAttribute("page", personPageInfo); return "notice/notice"; } @RequestMapping("/addView") public String updateOrAddView() { return "notice/noticeAddOrUpdate"; } } package com.iarchie.crm_v1.context;
return "success"; } } return "error"; } //更新 @RequestMapping("/empUpdate") @ResponseBody public String update(@RequestBody JSONObject ob) { System.out.println("ob.toJSONString() = " + ob.toJSONString()); String data = ob.toJSONString(); Employee employee = jsonData(data); if (employee != null) { int index = employeeService.updateByPrimaryKey(employee); if (index != 0) { return "success"; } } return "error"; } //删除 @RequestMapping("/empDelete") @ResponseBody public String delete(@RequestParam("id") Long id) { if (id != null) { int index = employeeService.deleteByPrimaryKey(id); if (index == 0 || index == -1) { return "error"; } } return "success"; } @RequestMapping(value = "/empList", method = RequestMethod.GET) public @ResponseBody Map<String, Object> empList(@RequestParam("page") int page, @RequestParam("limit") int limit) { //查询所有的数据 List<Employee> countEmp = employeeService.selectAll(); //加入分页 if (page < 0) { page = 1; } PageHelper.startPage(page, limit); List<Employee> employeeList = employeeService.selectAll(); Map<String, Object> map = new HashMap<>(); map.put("code", 0); map.put("msg", ""); //结果总数 map.put("count", countEmp.size()); //结果对象数据 map.put("data", employeeList);
int index = userService.updateByPrimaryKey(user); if (index > 0) { return "success"; } } return "error"; } } package com.iarchie.crm_v1.web.controller; @Controller @RequestMapping("/position") public class PositionController { //注入业务层 @Autowired private IPositionService positionService; @RequestMapping("/positionView") public String showPosition() { return "position/position"; } //删除 @RequestMapping(value = "/positionDelete", method = RequestMethod.GET) @ResponseBody public String delete(@RequestParam("id") Long id) { System.out.println("id = " + id); int index = positionService.deleteByPrimaryKey(id);
package com.iarchie.crm_v1.web.controller; /** * 类描述信息 部门controller类 * * @ClassName DepartmentController * @Description: TODO * @Viersion V1.0.1 */ @Controller @RequestMapping("/department") public class DepartmentController { //注入业务 @Autowired private IDepartmentService departmentService; @RequestMapping("/deptView") public String employeeView() { return "department/department"; } //跳转添加页面 @RequestMapping("/deptAddView")
@ResponseBody public String positionAdd(@RequestBody Position position) { int insert = positionService.insert(position); if (insert > 0) { return "success"; } return "error"; } @RequestMapping("/positionOption") @ResponseBody public List<Position> positionOption(String keyword) { List<Position> positions = positionService.selectAll(keyword); return positions; } @RequestMapping(value = "/addView") public String positionAddView() { return "position/positionAdd"; } @RequestMapping(value = "/positionList",method = RequestMethod.GET) public @ResponseBody Map<String, Object> positionList(@RequestParam("page") int page, @RequestParam("limit") int limit, String keyword) { System.out.println("keyword = " + keyword); //查询结果集 List<Position> countPos = positionService.selectAll(keyword); //处理分页 if (page < 0) { page = 1; } PageHelper.startPage(page, limit); List<Position> resultData = positionService.selectAll(keyword); //封装列表数据 Map<String, Object> resultMap = new HashMap<String, Object>() { { put("code", 0); put("msg", ""); put("count", countPos.size()); put("data", resultData); } }; return resultMap; } }
/** * 类描述信息 员工Controller处理类 * * @ClassName EmployeeController * @Description: TODO * @Viersion V1.0.1 */ @Controller @RequestMapping("/employee") public class EmployeeController { //注入mapper @Autowired private IEmployeeService employeeService; @RequestMapping("/empView") public String employeeView() { return "employee/employee"; } @RequestMapping("/empAddView") public String employeeAddView() { return "employee/employeeAdd"; } //解析json
int index = userService.updateByPrimaryKey(user); if (index > 0) { return "success"; } } return "error"; } } package com.iarchie.crm_v1.web.controller; @Controller @RequestMapping("/position") public class PositionController { //注入业务层 @Autowired private IPositionService positionService; @RequestMapping("/positionView") public String showPosition() { return "position/position"; } //删除 @RequestMapping(value = "/positionDelete", method = RequestMethod.GET) @ResponseBody public String delete(@RequestParam("id") Long id) { System.out.println("id = " + id); int index = positionService.deleteByPrimaryKey(id); if (index > 0) {
/** * 类描述信息 员工Controller处理类 * * @ClassName EmployeeController * @Description: TODO * @Viersion V1.0.1 */ @Controller @RequestMapping("/employee") public class EmployeeController { //注入mapper @Autowired private IEmployeeService employeeService; @RequestMapping("/empView") public String employeeView() { return "employee/employee"; } @RequestMapping("/empAddView") public String employeeAddView() { return "employee/employeeAdd"; } //解析json private Employee jsonData(String data) { //解析前台传递的json数据 JSONObject json = JSON.parseObject(data); if (json != null) { //{"name":"测试用户1","sex":"男","phone":"18349857548","email":"126@sin.com", //"positionId":"2","eduschool":"专科","idcard":"382859958958946","deptId":"1","address":"广州"} String name = json.getString("name"); String sex = json.getString("sex"); String phone = json.getString("phone"); String email = json.getString("email"); String positionId = json.getString("positionId"); String eduschool = json.getString("eduschool"); String idcard = json.getString("idcard"); String deptId = json.getString("deptId"); String address = json.getString("address"); Position p = new Position(); p.setId(Long.parseLong(positionId));
//校验账号密码 if (user == null) { session.setAttribute("errorMsg", "账号密码错误!请检查!"); session.setAttribute("loginname", loginname); // 服务器内部跳转到登录页面 mv.setViewName("forward:/login.jsp"); return mv; //检验验证码 } else if (!(imgCode.equalsIgnoreCase(imgCode1))) { session.setAttribute("errorMsg", "验证码错误!请重新输入!"); session.setAttribute("loginname", loginname); // 服务器内部跳转到登录页面 mv.setViewName("forward:/login.jsp"); return mv; } else if (user.getState() == 0) { session.setAttribute("errorMsg", user.getLoginname()+"用户被锁定!请联系管理员!"); session.setAttribute("loginname", loginname); // 服务器内部跳转到登录页面 mv.setViewName("forward:/login.jsp"); return mv; } //存储用户登入信息 UserContext.setUserInSession(user); // 客户端跳转到main页面 mv.setViewName("redirect:/main"); return mv; } @RequestMapping("/main") public String main() { return "main"; } //注销处理 @RequestMapping("/loginOut") public String invalidate(HttpSession session) { session.invalidate(); return "redirect:login.jsp"; } } package com.iarchie.crm_v1.web.controller;
return "error"; } //添加 @RequestMapping(value = "/positionAdd", method = RequestMethod.POST) @ResponseBody public String positionAdd(@RequestBody Position position) { int insert = positionService.insert(position); if (insert > 0) { return "success"; } return "error"; } @RequestMapping("/positionOption") @ResponseBody public List<Position> positionOption(String keyword) { List<Position> positions = positionService.selectAll(keyword); return positions; } @RequestMapping(value = "/addView") public String positionAddView() { return "position/positionAdd"; } @RequestMapping(value = "/positionList",method = RequestMethod.GET) public @ResponseBody Map<String, Object> positionList(@RequestParam("page") int page, @RequestParam("limit") int limit, String keyword) { System.out.println("keyword = " + keyword); //查询结果集 List<Position> countPos = positionService.selectAll(keyword); //处理分页 if (page < 0) { page = 1; } PageHelper.startPage(page, limit); List<Position> resultData = positionService.selectAll(keyword); //封装列表数据 Map<String, Object> resultMap = new HashMap<String, Object>() { { put("code", 0); put("msg", ""); put("count", countPos.size()); put("data", resultData); }
@RequestMapping(value = "/userList", method = RequestMethod.GET) public @ResponseBody Map<String, Object> showUserList(@RequestParam("page") int page, @RequestParam("limit") int limit, String keyword1, String keyword2) { System.out.println("keyword1 = " + keyword1); System.out.println("keyword2 = " + keyword2); //查询结果集对象 List<User> countData = userService.selectAll(keyword1, keyword2); //封装json数据 Map<String, Object> resultMap = new HashMap<String, Object>(); //分页 if (page < 0) { page = 1; PageHelper.startPage(page, limit); } List<User> users = userService.selectAll(keyword1, keyword2); resultMap.put("code", 0); resultMap.put("msg", ""); //结果总数 resultMap.put("count", countData.size()); //结果对象数据 resultMap.put("data", users); return resultMap; } @RequestMapping("/delete") @ResponseBody public String delete(@RequestParam("id") Long id) { System.out.println("id = " + id); int index = userService.deleteByPrimaryKey(id); if (index > 0) { return "success"; } //删除失败返回error return "error"; } @RequestMapping("/update") @ResponseBody public String update(@RequestBody User user) {
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。