基于javaweb的企业员工绩效工资管理系统(java+springboot+freemarker+mysql)
基于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);
總結
以上是生活随笔為你收集整理的基于javaweb的企业员工绩效工资管理系统(java+springboot+freemarker+mysql)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 启动windows的mysql_MySQ
- 下一篇: 通常网站当中的关键词密度如何控制呢