基于javaweb的企业员工绩效工资管理系统(java+springboot+freemarker+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+springboot的企业员工绩效工资管理系统(java+SpringBoot+FreeMarker+Mysql)
超级管理员等角色,除基础脚手架外,实现的功能有:
超级管理员:系统管理、用户管理(冻结等)、职称管理、部门管理(工资项)、岗位管理(考核指标管理,可指定部门)、工龄管理等。
普通员工:考勤管理(查看自己的考勤记录)、工资管理(查看自己的工资详情)。
HR人事:员工管理、考勤管理、工资管理。
部门经理:部门绩效考核管理、年度考核管理、考核指标管理。
运行环境:windows/Linux均可、jdk1.8、mysql5.7、idea/eclipse均可。
后台用户管理控制器:
/**
• 后台用户管理控制器
• @author yy
*/
@RequestMapping(“/admin/user”)
@Controller
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private OperaterLogService operaterLogService;
/**
• 用户列表页面
• @param model
• @param user
• @param pageBean
• @return
*/
@RequestMapping(value=“/list”)
public String list(Model model,User user,PageBean pageBean){
model.addAttribute(“title”, “用户列表”);
model.addAttribute(“username”, user.getUsername());
model.addAttribute(“pageBean”, userService.findList(user, pageBean));
return “admin/user/list”;
/**
• 新增用户页面
• @param model
• @return
*/
@RequestMapping(value=“/add”,method=RequestMethod.GET)
public String add(Model model){
model.addAttribute(“roles”, roleService.findAll());
return “admin/user/add”;
/**
• 用户添加表单提交处理
• @param user
• @return
*/
@RequestMapping(value=“/add”,method=RequestMethod.POST)
@ResponseBody
public Result add(User user){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
//判断用户名是否存在
if(userService.isExistUsername(user.getUsername(), 0l)){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
//到这说明一切符合条件,进行数据库新增
if(userService.save(user) == null){
return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
operaterLogService.add(“添加用户,用户名:” + user.getUsername());
return Result.success(true);
/**
• 用户编辑页面
• @param model
• @return
*/
@RequestMapping(value=“/edit”,method=RequestMethod.GET)
public String edit(Model model,@RequestParam(name=“id”,required=true)Long id){
model.addAttribute(“roles”, roleService.findAll());
model.addAttribute(“user”, userService.find(id));
return “admin/user/edit”;
/**
• 编辑用户信息表单提交处理
• @param user
• @return
*/
@RequestMapping(value=“/edit”,method=RequestMethod.POST)
@ResponseBody
public Result edit(User user){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
if(user.getId() == null || user.getId().longValue() <= 0){
return Result.error(CodeMsg.ADMIN_USE_NO_EXIST);
if(userService.isExistUsername(user.getUsername(), user.getId())){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
//到这说明一切符合条件,进行数据库保存
User findById = userService.find(user.getId());
//讲提交的用户信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(user, findById, “id”,“createTime”,“updateTime”);
if(userService.save(findById) == null){
return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
operaterLogService.add(“编辑用户,用户名:” + user.getUsername());
return Result.success(true);
/**
• 删除用户
• @param id
• @return
*/
@RequestMapping(value=“/delete”,method=RequestMethod.POST)
@ResponseBody
public Result delete(@RequestParam(name=“id”,required=true)Long id){
try {
userService.delete(id);
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_USE_DELETE_ERROR);
operaterLogService.add(“删除用户,用户ID:” + id);
return Result.success(true);
后台工龄管理Controller:
/**
• 后台工龄管理Controller
*/
@Controller
@RequestMapping(“/admin/work_years”)
public class WorkingYearsController {
@Autowired
private WorkingYearsService workingYearsService;
@Autowired
private OperaterLogService operaterLogService;
/**
• 分页查询工龄列表
• @param model
• @param pageBean
• @param workingYears
• @return
*/
@RequestMapping(“/list”)
public String list(Model model, PageBean pageBean, WorkingYears workingYears){
model.addAttribute(“title”,“工龄列表”);
model.addAttribute(“years”,workingYears.getYears());
model.addAttribute(“pageBean”,workingYearsService.findList(workingYears, pageBean));
return “/admin/working_years/list”;
/**
• 添加页面
• @return
*/
@RequestMapping(“/add”)
public String add(){
return “/admin/working_years/add”;
/**
• 工龄添加提交处理
• @param workingYears
• @return
*/
@RequestMapping(value = “/add”,method = RequestMethod.POST)
@ResponseBody
public Result add(WorkingYears workingYears){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(workingYears);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
if(workingYearsService.findByYears(workingYears.getYears())!=null){
return Result.error(CodeMsg.ADMIN_WORKING_YEARS_EXIST_ERROR);
if(workingYearsService.save(workingYears) == null){
return Result.error(CodeMsg.ADMIN_WORKING_YEARS_ADD_ERROR);
operaterLogService.add(“添加工龄,工龄补贴为:” + workingYears.getSubsidy());
return Result.success(true);
/**
• 编辑页面
• @param model
• @param id
• @return
*/
@RequestMapping(“/edit”)
public String edit(Model model,@RequestParam(name=“id”,required=true)Long id){
model.addAttribute(“workYears”,workingYearsService.find(id));
return “/admin/working_years/edit”;
/**
• 编辑表单提交处理
• @param workingYears
• @return
*/
@RequestMapping(value = “/edit”,method = RequestMethod.POST)
@ResponseBody
public Result edit(WorkingYears workingYears){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(workingYears);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
if(workingYearsService.isExistYear(workingYears.getYears(),workingYears.getId())){
return Result.error(CodeMsg.ADMIN_WORKING_YEARS_EXIST_ERROR);
//到这说明一切符合条件,进行数据库保存
WorkingYears findById = workingYearsService.find(workingYears.getId());
//讲提交的用户信息指定字段复制到已存在的department对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(workingYears, findById, “id”,“createTime”,“updateTime”);
if(workingYearsService.save(findById) == null){
return Result.error(CodeMsg.ADMIN_WORKING_YEARS_EDIT_ERROR);
operaterLogService.add(“编辑工龄,工龄补贴为:” + workingYears.getSubsidy());
return Result.success(true);
/**
• 工龄删除操作
• @param id
• @return
*/
@RequestMapping(value = “delete”,method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestParam(name=“id”,required=true)Long id){
try{
workingYearsService.delete(id);
}catch (Exception e){
return Result.error(CodeMsg.ADMIN_WORKING_YEARS_DELETE_ERROR);
operaterLogService.add(“删除工龄补贴,工龄ID:” + id);
return Result.success(true);
后台角色管理控制器:
/**
• 后台角色管理控制器
• @author yy
*/
@RequestMapping(“/admin/role”)
@Controller
public class RoleController {
private Logger log = LoggerFactory.getLogger(RoleController.class);
@Autowired
private MenuService menuService;
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private RoleService roleService;
/**
• 分页搜索角色列表
• @param model
• @param role
• @param pageBean
• @return
*/
@RequestMapping(value=“/list”)
public String list(Model model,Role role,PageBean pageBean){
model.addAttribute(“title”, “角色列表”);
model.addAttribute(“name”, role.getName());
model.addAttribute(“pageBean”, roleService.findByName(role, pageBean));
return “admin/role/list”;
/**
• 角色添加页面
• @param model
• @return
*/
@RequestMapping(value=“/add”,method=RequestMethod.GET)
public String add(Model model){
List
findAll = menuService.findAll();
model.addAttribute(“topMenus”,MenuUtil.getTopMenus(findAll));
model.addAttribute(“secondMenus”,MenuUtil.getSecondMenus(findAll));
model.addAttribute(“thirdMenus”,MenuUtil.getThirdMenus(findAll));
return “admin/role/add”;
/**
• 角色添加表单提交处理
• @param role
• @return
*/
@RequestMapping(value=“/add”,method=RequestMethod.POST)
@ResponseBody
public Result add(Role role){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(role);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
if(roleService.save(role) == null){
return Result.error(CodeMsg.ADMIN_ROLE_ADD_ERROR);
log.info(“添加角色【”+role+“】”);
operaterLogService.add(“添加角色【”+role.getName()+“】”);
return Result.success(true);
/**
• 角色编辑页面
• @param id
• @param model
• @return
*/
@RequestMapping(value=“/edit”,method=RequestMethod.GET)
public String edit(@RequestParam(name=“id”,required=true)Long id,Model model){
List
findAll = menuService.findAll();
model.addAttribute(“topMenus”,MenuUtil.getTopMenus(findAll));
model.addAttribute(“secondMenus”,MenuUtil.getSecondMenus(findAll));
model.addAttribute(“thirdMenus”,MenuUtil.getThirdMenus(findAll));
Role role = roleService.find(id);
model.addAttribute(“role”, role);
model.addAttribute(“authorities”,JSONArray.toJSON(role.getAuthorities()).toString());
return “admin/role/edit”;
/**
• 角色修改表单提交处理
• @param request
• @param role
• @return
*/
@RequestMapping(value=“/edit”,method=RequestMethod.POST)
@ResponseBody
public Result edit(Role role){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(role);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
Role existRole = roleService.find(role.getId());
if(existRole == null){
return Result.error(CodeMsg.ADMIN_ROLE_NO_EXIST);
existRole.setName(role.getName());
existRole.setRemark(role.getRemark());
existRole.setStatus(role.getStatus());
existRole.setAuthorities(role.getAuthorities());
if(roleService.save(existRole) == null){
return Result.error(CodeMsg.ADMIN_ROLE_EDIT_ERROR);
log.info(“编辑角色【”+role+“】”);
operaterLogService.add(“编辑角色【”+role.getName()+“】”);
return Result.success(true);
/**
• 删除角色
• @param request
• @param id
• @return
*/
@RequestMapping(value=“delete”,method=RequestMethod.POST)
@ResponseBody
public Result delete(@RequestParam(name=“id”,required=true)Long id){
try {
roleService.delete(id);
} catch (Exception e) {
// TODO: handle exception
return Result.error(CodeMsg.ADMIN_ROLE_DELETE_ERROR);
log.info(“编辑角色ID【”+id+“】”);
operaterLogService.add(“删除角色ID【”+id+“】”);
return Result.success(true);