作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目为后台管理系统,分为管理员与普通员工两种角色;
管理员角色包含以下功能:
管理员登录,员工账号管理,部门管理,员工管理,薪资管理,薪资发放,招聘管理,员工培训管理等功能。
普通员工角色包含以下功能:
普通员工登录,员工账号查看,部门管理,员工管理,薪资管理,薪资发放等功能。
环境需要
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.数据库:MySql 5.7版本;
6.是否Maven:否;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入http://localhost:8080/ 登录
运行截图
相关代码
员工模块
package manage.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import manage.base.BaseController;
import manage.model.Departments;
import manage.model.User;
import manage.model.UserPo;
import manage.service.DepartmentsService;
import manage.service.UserService;
import manage.util.BiSheUtil;
import manage.util.PageInfo;
import manage.util.PageResult;
/**
* @author 曲文强
* @version 创建时间:2018.04.18
* @describe: 员工模块
*/
@Controller
public class UserController extends BaseController<User, UserService<User>> {
private static Logger logger = LogManager.getLogger(UserController.class);
@Resource
private UserService<User> userServiceImpl;
@Resource
private DepartmentsService<Departments> departmentsServiceImpl;
@RequestMapping("/add")
public String Register() {
return "index";
}
@RequestMapping(value = "/register", produces = "text/html;charset=UTF-8", method = RequestMethod.DELETE)
@ResponseBody
public String delete(@RequestBody String account) {
System.out.println(account);
String userAccount = account;
userServiceImpl.deleteByPrimaryKey(userAccount);
// String returnInfo = JSONObject.toJSONString("删除成功");
return "删除成功";
}
@RequestMapping(value = "/register", produces = "text/html;charset=UTF-8", method = RequestMethod.POST)
@ResponseBody
public String add(User user) throws Exception {
String res = userServiceImpl.validate(user, INSERT);
// String res = userServiceImpl.insertAdd(user);
String returnInfo = JSONObject.toJSONString(res);
return returnInfo;
}
@RequestMapping(value = "/register", produces = "text/html;charset=UTF-8", method = RequestMethod.GET)
@ResponseBody
// 分页查询
public String find(HttpServletRequest request) {
// ,HttpSession session
// 从分页工具中得到数据库查询的数据和page的信息
//int pageSize = Integer.parseInt(PageResult.getName("pageSize"));
String pageSize = request.getParameter("pageSize");
String currentPage = request.getParameter("currentPage");
String depNumber = request.getParameter("depNum");
String userNum = request.getParameter("userNum");
String userName = request.getParameter("userName");
//String userAutho = request.getParameter("userAutho");
if (!BiSheUtil.notNull(depNumber)) {
depNumber = null;
}
if (!BiSheUtil.notNull(userNum)) {
userNum = null;
}
if (!BiSheUtil.notNull(userName)) {
userName = null;
}
/*if (!BiSheUtil.notNull(userAutho)) {
userAutho = null;
}*/
PageInfo page= getPage(pageSize, currentPage);
@SuppressWarnings("unchecked")
List<User> userList = (List<User>) userServiceImpl.selectAll(page,depNumber,userNum,userName);
validate(page);
//默认的pageSize从PageResult中取,如果特定的手动输入
/*int pageSize = Integer.parseInt(PageResult.getName("pageSize"));
String currentPage = request.getParameter("number");
String depNumber = request.getParameter("depNum");
if (!BiSheUtil.notNull(depNumber)) {
depNumber = null;
}
HashMap pageMap = pageList(pageSize, currentPage, userServiceImpl, depNumber);*/
// JSONArray pageData = (JSONArray) pageList.get("pageData");
// pageList从数据库中取出的实体类,可能为空,页面中JS为了防止重复刷新,会根据有没有数据判断
/* @SuppressWarnings("unchecked")
ArrayList<UserPo> userList = (ArrayList<UserPo>) pageMap.get(PageResult.getName("entityList"));
PageEntity pageEntity = (PageEntity) pageMap.get(PageResult.getName("pageEntity"));*/
// 判断是否为空
/*if (userList.isEmpty()) {
// 如果为空的话加入一个实体类,里面的值为-----
UserPo empty = new UserPo();
empty.setAccount("-");
empty.setPassword("-");
empty.setUsername("-");
userList.add(empty);
}
*/
//List<Departments> departmentsList = departmentsServiceImpl.selectAll();
/* for (Departments departments :
departmentsList) { for (User user : userList) {
if(user.equals(departments.getNumber())){
} } }*/
// request.setAttribute("list", userList);
// request.setAttribute("pageEntity", pageEntity);
//HashMap resultMap = new HashMap();
//--------
/*session.setAttribute("list", userList);
session.setAttribute("pageEntity", pageEntity);
session.setAttribute("depNumber", depNumber);
session.setAttribute("userNum", userNum);
session.setAttribute("userName", userName);*/
//-------
//session.setAttribute("userAutho", userAutho);
// String returnInfo = JSONObject.toJSONString("success");
HashMap result = new HashMap();
result.put("arrayList", userList);
result.put("pageInfo", page);
String returnInfo = JSONObject.toJSONString(result);
return returnInfo;
}
@RequestMapping(value = "/registerSelect", produces = "text/html;charset=UTF-8", method = RequestMethod.POST)
@ResponseBody
public String selectByPrimaryKey(@RequestBody String account) {
String userAccount = account;
User user = userServiceImpl.selectByPrimaryKey(userAccount);
String json = JSONObject.toJSONString(user);
return json;
}
@RequestMapping(value = "/register", produces = "text/html;charset=UTF-8", method = RequestMethod.PUT)
@ResponseBody
public String update(User user) throws Exception {
String res = userServiceImpl.validate(user, UPDATE);
// String res = userServiceImpl.updateByPrimaryKeySelective(user);
String returnInfo = JSONObject.toJSONString(res);
return returnInfo;
}
/*
* @RequestMapping(value="/userSelectTree",
* produces="text/html;charset=UTF-8", method=RequestMethod.PUT)
*
* @ResponseBody public String selectByDepNumber( User user) throws
* Exception { String res = userServiceImpl.validate(user, UPDATE); //
* String res = userServiceImpl.updateByPrimaryKeySelective(user); String
* returnInfo = JSONObject.toJSONString(res); return returnInfo; }
*/
@RequestMapping(value = "/departmentsDel", produces = "text/html;charset=UTF-8", method = RequestMethod.DELETE)
@ResponseBody
// 分页查询
public String deleteList(@RequestBody String deleteList) {
String[] delete = deleteList.split(",");
userServiceImpl.deleteList(delete);
return "删除成功";
}
}
如果也想学习本系统,下面领取。关注并回复:155ssm