基于javaweb+mysql的springbootoa办公管理系统oa管理系统(java+springboot+vue+maven+mybatis+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBootoa办公管理系统oa管理系统(java+springboot+vue+maven+mybatis+mysql)
用户分为:经理(管理员)、主管、员工
一、项目运行 环境配置:
Jdk1.8 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。
@PreAuthorize("hasRole('经理')")
@GetMapping("/getUsers")
public Response<PageInfo<User>> getUsers(@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber,
@RequestParam(value = "pageSize", defaultValue = "8") int pageSize) {
System.out.println("执行了...");
System.out.println("跳转到这个页数"+pageNumber);
PageInfo<User> pageInfo = userService.getUsers(pageNumber, pageSize);
return Response.success("获取成功!", pageInfo);
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/updateUser")
public Response<?> updateUser(@RequestBody User user) {
int result = userService.updateUser(user);
if (result == -1) {
return Response.error("用户名已存在!");
}
return Response.success("更新成功!");
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/addUser")
public Response<?> addUser(@RequestBody User user) {
int result = userService.addUser(user);
if (result == -1) {
return Response.error("用户名已存在!");
}
return Response.success("添加成功!");
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/deleteUser")
public Response<?> deleteUser(@RequestBody Integer[] ids) {
userService.deleteUser(ids);
return Response.success("删除成功!");
}
/**
* 修改密码
*/
@PostMapping("/updatePassword")
public Response<?> updatePassword(@RequestBody User user) {
System.out.println("执行了...");
int result = userService.updatePassword(user);
return Response.success("修改密码成功!");
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
PageInfo<Leave> pageInfo = leaveService.getLeaves(pageNumber, pageSize);
return Response.success("获取成功!", pageInfo);
}
}
@RestController
@RequestMapping("/api")
public class NoticeController {
private final NoticeService noticeService;
public NoticeController(NoticeService noticeService) {
this.noticeService = noticeService;
}
@GetMapping("/getNotices")
public Response<List<Notice>> getNotices(@AuthenticationPrincipal User user) {
List<Notice> notices = noticeService.getNotices(user.getUsername());
return Response.success("获取成功!", notices);
}
@PostMapping("/markRead")
public Response<?> markRead(@RequestBody Integer[] ids) {
noticeService.markRead(ids);
return Response.success("成功标记已读!");
}
}
@RestController
@RequestMapping("/api")
public class RoleController {
@RestController
@RequestMapping("/api")
public class NoticeController {
private final NoticeService noticeService;
public NoticeController(NoticeService noticeService) {
this.noticeService = noticeService;
}
@GetMapping("/getNotices")
public Response<List<Notice>> getNotices(@AuthenticationPrincipal User user) {
List<Notice> notices = noticeService.getNotices(user.getUsername());
return Response.success("获取成功!", notices);
}
@PostMapping("/markRead")
public Response<?> markRead(@RequestBody Integer[] ids) {
noticeService.markRead(ids);
return Response.success("成功标记已读!");
}
}
@RestController
@RequestMapping("/api")
public class RoleController {
private final RoleService roleService;
public RoleController(RoleService roleService) {
this.roleService = roleService;
}
@GetMapping("/getRoles")
@RestController
@RequestMapping("/api")
public class LeaveController {
private final LeaveService leaveService;
public LeaveController(LeaveService leaveService) {
this.leaveService = leaveService;
}
@PostMapping("askLeave")
public Response<?> askLeave(@AuthenticationPrincipal User user, @RequestBody Leave leave) {
leave.setUser(user);
leaveService.askLeave(leave);
return Response.success("提交成功!");
}
@PostMapping("checkLeave")
@PreAuthorize("hasRole('经理')")
public Response<?> checkLeave(@RequestBody Leave leave) {
leaveService.checkLeave(leave);
return Response.success("提交成功!");
}
@GetMapping("getLeaves")
public Response<PageInfo<Leave>> getLeaves(@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber,
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
PageInfo<Leave> pageInfo = leaveService.getLeaves(pageNumber, pageSize);
return Response.success("获取成功!", pageInfo);
}
}
@RestController
@RequestMapping("/api")
public class UserController {
private final UserService userService;
public UserController(UserService userService) {
this.userService = userService;
}
@GetMapping("/auth")
public Response<User> getAuthentication(@AuthenticationPrincipal User user) {
user.setPassword(null);
return Response.success("获取成功!", user);
}
@GetMapping("/user/{id}")
public Response<User> getUser(@PathVariable("id") int id) {
User user = userService.getUserById(id);
if (user.getId() == 0) {
return Response.error("此用户不存在!");
}
return Response.success("获取成功!", user);
}
@PreAuthorize("hasRole('经理')")
@GetMapping("/getUsers")
public Response<PageInfo<User>> getUsers(@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber,
@RequestParam(value = "pageSize", defaultValue = "8") int pageSize) {
System.out.println("执行了...");
System.out.println("跳转到这个页数"+pageNumber);
PageInfo<User> pageInfo = userService.getUsers(pageNumber, pageSize);
return Response.success("获取成功!", pageInfo);
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/updateUser")
public Response<?> updateUser(@RequestBody User user) {
int result = userService.updateUser(user);
if (result == -1) {
return Response.error("用户名已存在!");
}
return Response.success("更新成功!");
@PostMapping("/deleteFiles")
public Response<?> deleteNetFiles(@RequestBody Integer[] ids) {
netFileService.deleteNetFiles(ids);
return Response.success("删除成功!");
}
}
@RestController
@RequestMapping("/api")
public class LeaveController {
private final LeaveService leaveService;
public LeaveController(LeaveService leaveService) {
this.leaveService = leaveService;
}
@PostMapping("askLeave")
public Response<?> askLeave(@AuthenticationPrincipal User user, @RequestBody Leave leave) {
leave.setUser(user);
leaveService.askLeave(leave);
return Response.success("提交成功!");
}
@PostMapping("checkLeave")
@PreAuthorize("hasRole('经理')")
public Response<?> checkLeave(@RequestBody Leave leave) {
leaveService.checkLeave(leave);
return Response.success("提交成功!");
}
@GetMapping("getLeaves")
public Response<PageInfo<Leave>> getLeaves(@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber,
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
PageInfo<Leave> pageInfo = leaveService.getLeaves(pageNumber, pageSize);
return Response.success("获取成功!", pageInfo);
}
}
@GetMapping("/auth")
public Response<User> getAuthentication(@AuthenticationPrincipal User user) {
user.setPassword(null);
return Response.success("获取成功!", user);
}
@GetMapping("/user/{id}")
public Response<User> getUser(@PathVariable("id") int id) {
User user = userService.getUserById(id);
if (user.getId() == 0) {
return Response.error("此用户不存在!");
}
return Response.success("获取成功!", user);
}
@PreAuthorize("hasRole('经理')")
@GetMapping("/getUsers")
public Response<PageInfo<User>> getUsers(@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber,
@RequestParam(value = "pageSize", defaultValue = "8") int pageSize) {
System.out.println("执行了...");
System.out.println("跳转到这个页数"+pageNumber);
PageInfo<User> pageInfo = userService.getUsers(pageNumber, pageSize);
return Response.success("获取成功!", pageInfo);
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/updateUser")
public Response<?> updateUser(@RequestBody User user) {
int result = userService.updateUser(user);
if (result == -1) {
return Response.error("用户名已存在!");
}
return Response.success("更新成功!");
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/addUser")
public Response<?> addUser(@RequestBody User user) {
int result = userService.addUser(user);
if (result == -1) {
return Response.error("用户名已存在!");
}
return Response.success("添加成功!");
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/deleteUser")
public Response<?> deleteUser(@RequestBody Integer[] ids) {
userService.deleteUser(ids);
return Response.success("删除成功!");
list.add(map.get("end"));
return Response.success("获取成功!", list);
}
@GetMapping("/setAttendanceTime")
@PreAuthorize("hasAnyRole('主管','经理')")
public Response<?> setAttendanceTime(@RequestParam("begin") String begin, @RequestParam("end") String end) {
attendanceService.setAttendanceTime(begin, end);
return Response.success("设置成功!");
}
@GetMapping("/getAttendance")
public Response<Attendance> getAttendance(@AuthenticationPrincipal User user) {
Attendance attendance = attendanceService.getAttendance(user.getId());
return Response.success("获取成功!", attendance);
}
@GetMapping("/getAttendances")
public Response<List<String>> getAttendances(@AuthenticationPrincipal User user) {
List<String> attendances = attendanceService.getAttendances(user.getId());
return Response.success("获取成功!", attendances);
}
@GetMapping("/signIn")
public Response<?> signIn(@AuthenticationPrincipal User user) throws ParseException {
Map<String, String> map = attendanceService.getAttendanceTime();
LocalTime beginTime = LocalTime.parse(map.get("begin"));
LocalTime localTime = LocalTime.now();
if (localTime.isBefore(beginTime.minusHours(1L))) {
return Response.error("还未到签到时间!");
}
if (localTime.isAfter(beginTime.plusHours(1L))) {
return Response.error("已超过签到时间!");
}
attendanceService.signIn(user.getId());
return Response.success("签到成功!");
}
@GetMapping("/signOut")
public Response<?> signOut(@AuthenticationPrincipal User user) throws ParseException {
if (attendanceService.getAttendance(user.getId()) == null) {
}
@RestController
@RequestMapping("/api")
public class UserController {
private final UserService userService;
public UserController(UserService userService) {
this.userService = userService;
}
@GetMapping("/auth")
public Response<User> getAuthentication(@AuthenticationPrincipal User user) {
user.setPassword(null);
return Response.success("获取成功!", user);
}
@GetMapping("/user/{id}")
public Response<User> getUser(@PathVariable("id") int id) {
User user = userService.getUserById(id);
if (user.getId() == 0) {
return Response.error("此用户不存在!");
}
return Response.success("获取成功!", user);
}
@PreAuthorize("hasRole('经理')")
@GetMapping("/getUsers")
public Response<PageInfo<User>> getUsers(@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber,
@RequestParam(value = "pageSize", defaultValue = "8") int pageSize) {
System.out.println("执行了...");
@RestController
@RequestMapping("/api")
public class AttendanceController {
private final AttendanceService attendanceService;
public AttendanceController(AttendanceService attendanceService) {
this.attendanceService = attendanceService;
}
@GetMapping("/getAttendanceTime")
public Response<List<String>> getAttendanceTime() {
Map<String, String> map = attendanceService.getAttendanceTime();
List<String> list = new ArrayList<>();
list.add(map.get("begin"));
list.add(map.get("end"));
return Response.success("获取成功!", list);
}
@GetMapping("/setAttendanceTime")
@PreAuthorize("hasAnyRole('主管','经理')")
public Response<?> setAttendanceTime(@RequestParam("begin") String begin, @RequestParam("end") String end) {
attendanceService.setAttendanceTime(begin, end);
return Response.success("设置成功!");
}
@GetMapping("/getAttendance")
public Response<Attendance> getAttendance(@AuthenticationPrincipal User user) {
Attendance attendance = attendanceService.getAttendance(user.getId());
return Response.success("获取成功!", attendance);
}
@GetMapping("/getAttendances")
public Response<List<String>> getAttendances(@AuthenticationPrincipal User user) {
List<String> attendances = attendanceService.getAttendances(user.getId());
return Response.success("获取成功!", attendances);
}
@GetMapping("/signIn")
@RestController
@RequestMapping("/api")
public class LeaveController {
private final LeaveService leaveService;
public LeaveController(LeaveService leaveService) {
this.leaveService = leaveService;
}
@PostMapping("askLeave")
public Response<?> askLeave(@AuthenticationPrincipal User user, @RequestBody Leave leave) {
leave.setUser(user);
leaveService.askLeave(leave);
return Response.success("提交成功!");
}
@PostMapping("checkLeave")
@PreAuthorize("hasRole('经理')")
public Response<?> checkLeave(@RequestBody Leave leave) {
leaveService.checkLeave(leave);
return Response.success("提交成功!");
}
@GetMapping("getLeaves")
public Response<PageInfo<Leave>> getLeaves(@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber,
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
PageInfo<Leave> pageInfo = leaveService.getLeaves(pageNumber, pageSize);
return Response.success("获取成功!", pageInfo);
}
}
return Response.success("获取成功!", user);
}
@PreAuthorize("hasRole('经理')")
@GetMapping("/getUsers")
public Response<PageInfo<User>> getUsers(@RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber,
@RequestParam(value = "pageSize", defaultValue = "8") int pageSize) {
System.out.println("执行了...");
System.out.println("跳转到这个页数"+pageNumber);
PageInfo<User> pageInfo = userService.getUsers(pageNumber, pageSize);
return Response.success("获取成功!", pageInfo);
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/updateUser")
public Response<?> updateUser(@RequestBody User user) {
int result = userService.updateUser(user);
if (result == -1) {
return Response.error("用户名已存在!");
}
return Response.success("更新成功!");
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/addUser")
public Response<?> addUser(@RequestBody User user) {
int result = userService.addUser(user);
if (result == -1) {
return Response.error("用户名已存在!");
}
return Response.success("添加成功!");
}
@PreAuthorize("hasRole('经理')")
@PostMapping("/deleteUser")
public Response<?> deleteUser(@RequestBody Integer[] ids) {
userService.deleteUser(ids);
return Response.success("删除成功!");
}
/**
* 修改密码
*/
http.authorizeRequests()
.antMatchers("/api/**").authenticated()
.and().formLogin()
.loginProcessingUrl("/api/login")
.successHandler((request, response, authentication) -> {
response.setContentType("application/json;charset=utf-8");
PrintWriter out = response.getWriter();
out.write("{\"status\":\"success\",\"message\":\"登录成功!\"}");
out.flush();
out.close();
})
.failureHandler((request, response, exception) -> {
response.setContentType("application/json;charset=utf-8");
PrintWriter out = response.getWriter();
out.write("{\"status\":\"error\",\"message\":\"账号或密码错误!\"}");
out.flush();
out.close();
})
.and().exceptionHandling()
.authenticationEntryPoint((request, response, authException) -> {
response.setContentType("application/json;charset=utf-8");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
PrintWriter out = response.getWriter();
out.write("{\"status\":\"error\",\"message\":\"授权已过期,请重新登录。\"}");
out.flush();
out.close();
})
.accessDeniedHandler((request, response, exception) -> {
response.setContentType("application/json;charset=utf-8");
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
PrintWriter out = response.getWriter();
out.write("{\"status\":\"error\",\"message\":\"您没有权限进行此操作!\"}");
out.flush();
out.close();
})
.and().logout()
.logoutUrl("/api/logout")
.logoutSuccessHandler((request, response, authentication) -> {
response.setContentType("application/json;charset=utf-8");
PrintWriter out = response.getWriter();
out.write("{\"status\":\"success\",\"message\":\"注销成功!\"}");
out.flush();
out.close();
})
.and().userDetailsService(userService)
.csrf().disable();
}
}
@RestController
@RequestMapping("/api")
public class NoticeController {
private final NoticeService noticeService;
public NoticeController(NoticeService noticeService) {
this.noticeService = noticeService;
}
@GetMapping("/getNotices")
public Response<List<Notice>> getNotices(@AuthenticationPrincipal User user) {
List<Notice> notices = noticeService.getNotices(user.getUsername());
return Response.success("获取成功!", notices);
}
@PostMapping("/markRead")
public Response<?> markRead(@RequestBody Integer[] ids) {
noticeService.markRead(ids);
return Response.success("成功标记已读!");
}
}
@RestController
@GetMapping("/getAttendances")
public Response<List<String>> getAttendances(@AuthenticationPrincipal User user) {
List<String> attendances = attendanceService.getAttendances(user.getId());
return Response.success("获取成功!", attendances);
}
@GetMapping("/signIn")
public Response<?> signIn(@AuthenticationPrincipal User user) throws ParseException {
Map<String, String> map = attendanceService.getAttendanceTime();
LocalTime beginTime = LocalTime.parse(map.get("begin"));
LocalTime localTime = LocalTime.now();
if (localTime.isBefore(beginTime.minusHours(1L))) {
return Response.error("还未到签到时间!");
}
if (localTime.isAfter(beginTime.plusHours(1L))) {
return Response.error("已超过签到时间!");
}
attendanceService.signIn(user.getId());
return Response.success("签到成功!");
}
@GetMapping("/signOut")
public Response<?> signOut(@AuthenticationPrincipal User user) throws ParseException {
if (attendanceService.getAttendance(user.getId()) == null) {
return Response.error("您未签到,不能签退!");
}
Map<String, String> map = attendanceService.getAttendanceTime();
LocalTime endTime = LocalTime.parse(map.get("end"));
LocalTime localTime = LocalTime.now();
if (localTime.isBefore(endTime.minusHours(1L))) {
return Response.error("还未到签退时间!");
}
if (localTime.isAfter(endTime.plusHours(1L))) {
return Response.error("已超过签退时间!");
}
attendanceService.signOut(user.getId());
return Response.success("签退成功!");
}
}
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
return Response.success("签退成功!");
}
}
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private final UserService userService;
public WebSecurityConfig(UserService userService) {
this.userService = userService;
}
@Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/api/**").authenticated()
.and().formLogin()
.loginProcessingUrl("/api/login")
.successHandler((request, response, authentication) -> {
response.setContentType("application/json;charset=utf-8");
PrintWriter out = response.getWriter();
out.write("{\"status\":\"success\",\"message\":\"登录成功!\"}");
out.flush();
out.close();
})
.failureHandler((request, response, exception) -> {
response.setContentType("application/json;charset=utf-8");
PrintWriter out = response.getWriter();
out.write("{\"status\":\"error\",\"message\":\"账号或密码错误!\"}");
out.flush();
out.close();
})
.and().exceptionHandling()
PrintWriter out = response.getWriter();
out.write("{\"status\":\"error\",\"message\":\"您没有权限进行此操作!\"}");
out.flush();
out.close();
})
.and().logout()
.logoutUrl("/api/logout")
.logoutSuccessHandler((request, response, authentication) -> {
response.setContentType("application/json;charset=utf-8");
PrintWriter out = response.getWriter();
out.write("{\"status\":\"success\",\"message\":\"注销成功!\"}");
out.flush();
out.close();
})
.and().userDetailsService(userService)
.csrf().disable();
}
}
@RestController
@RequestMapping("/api")
public class UserController {
private final UserService userService;
public UserController(UserService userService) {
this.userService = userService;
}
@GetMapping("/auth")
public Response<User> getAuthentication(@AuthenticationPrincipal User user) {
user.setPassword(null);
return Response.success("获取成功!", user);
}
@GetMapping("/user/{id}")
public Response<User> getUser(@PathVariable("id") int id) {
User user = userService.getUserById(id);
if (user.getId() == 0) {
return Response.error("此用户不存在!");
}
return Response.success("获取成功!", user);