基于javaweb+mysql的springbootoa办公管理系统oa管理系统(java+springboot+vue+maven+mybatis+mysql)

基于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+mysql的SpringBootoa办公管理系统(java+springboot+vue+maven+mybatis+mysql)

用户分为:经理(管理员)、主管、员工

一、项目运行 环境配置:

Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。

        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 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")

@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()
                .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\":\"授权已过期,请重新登录。\"}");

@RestController
@RequestMapping("/api")
public class NetFileController {

    private final NetFileService netFileService;

    public NetFileController(NetFileService netFileService) {
        this.netFileService = netFileService;
    }

    @GetMapping("/getFiles")
    public Response<PageInfo<NetFile>> getNetFiles(@AuthenticationPrincipal User user, @RequestParam("parentId") int parentId, @RequestParam("personal") boolean personal,
                                                   @RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        PageInfo<NetFile> pageInfo = netFileService.getNetFiles(user.getId(), parentId, personal, pageNumber, pageSize);
        return Response.success("获取成功!", pageInfo);
    }

    @GetMapping("/addFolder")
    public Response<?> addFolder(@AuthenticationPrincipal User user, @RequestParam("parentId") int parentId,
                                 @RequestParam("folderName") String folderName, @RequestParam("personal") boolean personal) {
        netFileService.addFolder(folderName, user, parentId, personal);
        return Response.success("添加成功!");
    }

    @PostMapping("/uploadFile")
    public Response<?> uploadFile(@RequestParam("parentId") int parentId, @RequestParam("personal") boolean personal,
                                  @AuthenticationPrincipal User user, @RequestParam("file") MultipartFile multipartFile) throws IOException {
        netFileService.uploadFile(multipartFile, user, parentId, personal);
        return Response.success("上传成功!");
    }

    @GetMapping("/renameFile")
    public Response<?> renameNetFile(@RequestParam("id") int id, @RequestParam("newName") String newName) {
        netFileService.renameNetFile(id, newName);
        return Response.success("重命名成功!");
        }
        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)
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()
@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")
    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("签到成功!");
    }

    }

    @PostMapping("/uploadFile")
    public Response<?> uploadFile(@RequestParam("parentId") int parentId, @RequestParam("personal") boolean personal,
                                  @AuthenticationPrincipal User user, @RequestParam("file") MultipartFile multipartFile) throws IOException {
        netFileService.uploadFile(multipartFile, user, parentId, personal);
        return Response.success("上传成功!");
    }

    @GetMapping("/renameFile")
    public Response<?> renameNetFile(@RequestParam("id") int id, @RequestParam("newName") String newName) {
        netFileService.renameNetFile(id, newName);
        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) {
    }
}

@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()
                .authenticationEntryPoint((request, response, authException) -> {
                    response.setContentType("application/json;charset=utf-8");
                    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
                    PrintWriter out = response.getWriter();
    }

    @GetMapping("/getFiles")
    public Response<PageInfo<NetFile>> getNetFiles(@AuthenticationPrincipal User user, @RequestParam("parentId") int parentId, @RequestParam("personal") boolean personal,
                                                   @RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        PageInfo<NetFile> pageInfo = netFileService.getNetFiles(user.getId(), parentId, personal, pageNumber, pageSize);
        return Response.success("获取成功!", pageInfo);
    }

    @GetMapping("/addFolder")
    public Response<?> addFolder(@AuthenticationPrincipal User user, @RequestParam("parentId") int parentId,
                                 @RequestParam("folderName") String folderName, @RequestParam("personal") boolean personal) {
        netFileService.addFolder(folderName, user, parentId, personal);
        return Response.success("添加成功!");
    }

    @PostMapping("/uploadFile")
    public Response<?> uploadFile(@RequestParam("parentId") int parentId, @RequestParam("personal") boolean personal,
                                  @AuthenticationPrincipal User user, @RequestParam("file") MultipartFile multipartFile) throws IOException {
        netFileService.uploadFile(multipartFile, user, parentId, personal);
        return Response.success("上传成功!");
    }

    @GetMapping("/renameFile")
    public Response<?> renameNetFile(@RequestParam("id") int id, @RequestParam("newName") String newName) {
        netFileService.renameNetFile(id, newName);
        return Response.success("重命名成功!");
    }

    @PostMapping("/deleteFiles")
    public Response<?> deleteNetFiles(@RequestBody Integer[] ids) {
        netFileService.deleteNetFiles(ids);
        return Response.success("删除成功!");
    }
}

@RestController
@RequestMapping("/api")
public class LeaveController {
                    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);
    }

    @PreAuthorize("hasRole('经理')")
    @GetMapping("/getUsers")

@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")
    }

    @GetMapping("/addFolder")
    public Response<?> addFolder(@AuthenticationPrincipal User user, @RequestParam("parentId") int parentId,
                                 @RequestParam("folderName") String folderName, @RequestParam("personal") boolean personal) {
        netFileService.addFolder(folderName, user, parentId, personal);
        return Response.success("添加成功!");
    }

    @PostMapping("/uploadFile")
    public Response<?> uploadFile(@RequestParam("parentId") int parentId, @RequestParam("personal") boolean personal,
                                  @AuthenticationPrincipal User user, @RequestParam("file") MultipartFile multipartFile) throws IOException {
        netFileService.uploadFile(multipartFile, user, parentId, personal);
        return Response.success("上传成功!");
    }

    @GetMapping("/renameFile")
    public Response<?> renameNetFile(@RequestParam("id") int id, @RequestParam("newName") String newName) {
        netFileService.renameNetFile(id, newName);
        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;
    @PostMapping("/findUser")
    public Response<?> findUser(@RequestBody User user1) {

        System.out.println("一致性了");
        System.out.println(user1.getUsername());

        User user=userService.findUser(user1);

        return Response.success("获取成功!", user);
    }

}

@RestController
@RequestMapping("/api")
public class NetFileController {

    private final NetFileService netFileService;

    public NetFileController(NetFileService netFileService) {
        this.netFileService = netFileService;
    }

    @GetMapping("/getFiles")
    public Response<PageInfo<NetFile>> getNetFiles(@AuthenticationPrincipal User user, @RequestParam("parentId") int parentId, @RequestParam("personal") boolean personal,
                                                   @RequestParam(value = "pageNumber", defaultValue = "1") int pageNumber, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        PageInfo<NetFile> pageInfo = netFileService.getNetFiles(user.getId(), parentId, personal, pageNumber, pageSize);
@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("更新成功!");

@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()
                .authenticationEntryPoint((request, response, authException) -> {

    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 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("/findUser")
    public Response<?> findUser(@RequestBody User user1) {

        System.out.println("一致性了");
        System.out.println(user1.getUsername());

        User user=userService.findUser(user1);

        return Response.success("获取成功!", user);
    }

}

@RestController
@RequestMapping("/api")
public class NetFileController {

    private final NetFileService netFileService;

    public NetFileController(NetFileService netFileService) {
        this.netFileService = netFileService;
    }

            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("修改密码成功!");
    }

    /**
     * 查询个人信息
     */
    @PostMapping("/findUser")
    public Response<?> findUser(@RequestBody User user1) {

        System.out.println("一致性了");
        System.out.println(user1.getUsername());

        User user=userService.findUser(user1);

        return Response.success("获取成功!", user);
    }

}

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值