基于javaweb+mysql的springboot兼职平台系统(java+springboot+ssm+html+maven+ajax+mysql)

基于javaweb+mysql的springboot兼职平台系统(java+springboot+ssm+html+maven+ajax+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明


管理员:后台管理

雇主:发布兼职任务、指派兼职人

兼职者:竞标接单

基于javaweb+mysql的SpringBoot兼职平台系统(java+springboot+ssm+html+maven+ajax+mysql)

一、项目运行 环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

HTML +Springboot+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + maven等等.

    @PostMapping("skill/add")
    @ResponseBody
    public String addSkill(String skillName, HttpSession session) {
        Employee employee = (Employee) session.getAttribute("employee");
        if (!"".equals(skillName)) {
            employeeService.addSkill(employee.getId(), skillName);
        }
        return "添加技能";
    }

    /**
     * 删除技能
     *
     * @param skillId
     * @return
     */
    @PostMapping("skill/delete")
    @ResponseBody
    public String deleteSkill(Long skillId) {
        employeeService.deleteSkill(skillId);
        return "删除技能";
    }

}

        // 查询雇员总完成任务数
        Integer completeCount = taskService.getCompletedByEmployeeId(employeeId).size();

        // 如果雇主登录了,主页访问次数加 1
        Employer employer = (Employer) session.getAttribute("employer");
        if (employer != null) {
            employeeService.bower(employeeId, employer.getId());
        }

        // 主页总浏览次数
        Integer bowerCount = employeeService.getBowerCount(employee.getId());
        model.addAttribute("employee", employee);
        model.addAttribute("tasks", taskVos);
        model.addAttribute("completeCount", completeCount);
        model.addAttribute("bowerCount", bowerCount);
        return "employee_profile";
    }

    /**
     * 添加技能
     *
     * @param skillName 技能名称
     * @return
     */
    @PostMapping("skill/add")
    @ResponseBody
    public String addSkill(String skillName, HttpSession session) {
        Employee employee = (Employee) session.getAttribute("employee");
        if (!"".equals(skillName)) {
            employeeService.addSkill(employee.getId(), skillName);
        }
        return "添加技能";
    }

    /**
     * 删除技能
     *
     * @param skillId
     * @return
     */
    @PostMapping("skill/delete")
    @ResponseBody
    public String deleteSkill(Long skillId) {
        employeeService.deleteSkill(skillId);

        // 添加到 Model 域对象中,供页面展示
        model.addAttribute("taskCategories", taskCategoryVos);
        model.addAttribute("taskCount", taskCount);
        model.addAttribute("employeeCount", employeeCount);
        model.addAttribute("employerCount", employerCount);
        model.addAttribute("popularCategories", popularCategories);
        model.addAttribute("recentTasks", recentTaskVos);

        return "index";
    }

    /**
     * 跳转到注册页面
     *
     * @return
     */
    @GetMapping("register")
    public String register() {
        return "register";
    }

    /**
     * 用户注册,包括雇员和雇主,通过传过来的 accountType 判断
     *
     * @return
     */
    @PostMapping("register")
    public String register(Integer accountType, String username, String password, RedirectAttributes redirectAttributes) {
        // 如果传过来的 accountType 为 0 则为雇员注册
        if (accountType == 0) {
            // 先判断用户名是否注册过
            Employee employee = employeeService.getByUsername(username);
            // 如果 employee 不为 null,说明该用户名已经被注册过了,不能注册
            if (employee != null) {
                // 设置到重定向的域对象中,供页面提示
                redirectAttributes.addFlashAttribute("msg", "用户名已被注册");
                // 重定向到注册页
                return "redirect:/register";
            }

        // 查询所有未中标的信息
        List<BidVo> bidVos = bidService.getNoBitByEmployeeId(employee.getId());

        // 放置域对象中,供页面展示
        model.addAttribute("bids", bidVos);

        return "employee/my_bids";
    }

    /**
     * 删除竞标信息
     *
     * @param bid
     * @return
     */
    @GetMapping("bid/delete")
    public String deleteBid(Long bid) {
        bidService.deleteById(bid);
        return "redirect:/employee/mybids";
    }

    /**
     * 跳转到个人信息设置页面
     *
     * @return
     */
    @GetMapping("settings/base")
    public String settings(HttpSession session, Model model) {

        // 获取 session 中的雇员信息
        Employee employee = (Employee) session.getAttribute("employee");

        // 获取视图展示对象,主要是为了展示技能信息,因为 Employee 中只有 技能 ID 没有技能名称
        EmployeeVo employeeVo = employeeService.getById(employee.getId());

        model.addAttribute("employee", employeeVo);
        return "employee/settings_base";
    }

    /**
     * 保存个人基本信息
     *
     * @param employee
     * @return
     */
    @PostMapping("settings/base/save")
    public String saveBase(Employee employee, HttpSession session) {
        // 更新个人信息到数据库
        Employee currEmployee = employeeService.save(employee);

        // 更新 session 中的个人信息
        session.setAttribute("employee", currEmployee);
        return "redirect:/employee/settings/base";
    }

    /**
     * 跳转到雇员简介页面
     *
     * @return
     */
        @GetMapping("profile")
    public String profile(Long employeeId, Model model, HttpSession session) {
        // 查询雇员信息
        EmployeeVo employee = employeeService.getById(employeeId);

        // 查询历史完成任务
        List<TaskVo> taskVos = taskService.getByEmployeeId(employeeId);

        // 查询雇员总完成任务数
        Integer completeCount = taskService.getCompletedByEmployeeId(employeeId).size();

        // 如果雇主登录了,主页访问次数加 1
        Employer employer = (Employer) session.getAttribute("employer");
        if (employer != null) {
            employeeService.bower(employeeId, employer.getId());
        }

        // 主页总浏览次数
        Integer bowerCount = employeeService.getBowerCount(employee.getId());
        model.addAttribute("employee", employee);
        model.addAttribute("tasks", taskVos);
        model.addAttribute("completeCount", completeCount);
        model.addAttribute("bowerCount", bowerCount);
        return "employee_profile";
    }

    /**
     * 添加技能
     *
     * @param skillName 技能名称
     * @return
     */
    @PostMapping("skill/add")
    @ResponseBody
    public String addSkill(String skillName, HttpSession session) {
        Employee employee = (Employee) session.getAttribute("employee");
        if (!"".equals(skillName)) {
            employeeService.addSkill(employee.getId(), skillName);
        }
        return "添加技能";
    public String index(Model model) {

        // 查询所有任务分类, 为什么要用 Vo 对象,因为首页展示的热门分类中需要显示,该分类的任务数量,所以需要创建一个 Vo 对象,来包含分类任务数量信息
        List<TaskCategoryVo> taskCategoryVos = taskCategoryService.getAll();

        // 查询任务发布总数
        Integer taskCount = taskService.getAllCount();

        // 查询自由职业者(雇员)总数
        Integer employeeCount = employeeService.getAllCount();

        // 雇主数量
        Integer employerCount = employerService.getAllCount();

        // 查询热门分类,分类状态为 1 则为人们分类
        List<TaskCategoryVo> popularCategories = taskCategoryService.getPopular();

        // 查询近期任务(查询 5 条),根据创建时间来查询
        List<TaskVo> recentTaskVos =  taskService.getRecently();

        // 添加到 Model 域对象中,供页面展示
        model.addAttribute("taskCategories", taskCategoryVos);
        model.addAttribute("taskCount", taskCount);
        model.addAttribute("employeeCount", employeeCount);
        model.addAttribute("employerCount", employerCount);
        model.addAttribute("popularCategories", popularCategories);
        model.addAttribute("recentTasks", recentTaskVos);

        return "index";
    }

    /**
     * 跳转到注册页面
     *
     * @return
     */
    @GetMapping("register")
    public String register() {
        return "register";
    }

    /**
     * 用户注册,包括雇员和雇主,通过传过来的 accountType 判断
     *
     * @return
     */
    @PostMapping("register")
    public String register(Integer accountType, String username, String password, RedirectAttributes redirectAttributes) {
        // 如果传过来的 accountType 为 0 则为雇员注册
        if (accountType == 0) {
            // 先判断用户名是否注册过
            Employee employee = employeeService.getByUsername(username);
            // 如果 employee 不为 null,说明该用户名已经被注册过了,不能注册
        // 放置域对象中,供页面展示
        model.addAttribute("bids", bidVos);

        return "employee/my_bids";
    }

    /**
     * 删除竞标信息
     *
     * @param bid
     * @return
     */
    @GetMapping("bid/delete")
    public String deleteBid(Long bid) {
        bidService.deleteById(bid);
        return "redirect:/employee/mybids";
    }

    /**
     * 跳转到个人信息设置页面
     *
     * @return
     */
    @GetMapping("settings/base")
    public String settings(HttpSession session, Model model) {

        // 获取 session 中的雇员信息
        Employee employee = (Employee) session.getAttribute("employee");

        // 获取视图展示对象,主要是为了展示技能信息,因为 Employee 中只有 技能 ID 没有技能名称
        EmployeeVo employeeVo = employeeService.getById(employee.getId());

        model.addAttribute("employee", employeeVo);
        return "employee/settings_base";
    }

    /**
     * 保存个人基本信息
     *
     * @param employee
     * @return
     */
    @PostMapping("settings/base/save")
    public String saveBase(Employee employee, HttpSession session) {
        // 更新个人信息到数据库
        Employee currEmployee = employeeService.save(employee);

/**
 * 管理员管理任务分类控制器
 *
 * @Classname AdminTaskCategoryController
 * @see com.yuu.recruit.controller
 */
@Controller
@RequestMapping("admin/task/category")
public class AdminTaskCategoryController {

    @Resource
    private TaskCategoryService taskCategoryService;

    /**
     * 跳转到任务分类列表页
     *
     * @return
     */
    @GetMapping("")
    public String taskCategory(Model model) {
        // 查询所有分类
        List<TaskCategoryVo> taskCategories = taskCategoryService.getAll();

        // 设置到域对象中,提供给页面展示
        model.addAttribute("taskCategories", taskCategories);
        return "admin/task_category";
    }

    /**
     * 跳转到任务分类列表页,添加/编辑都在这个页面,通过 ID 判断是编辑还是删除
     *
     * @return
     */
    @GetMapping("form")
    public String form(Long id, Model model) {

        // 如果 ID 不为空则编辑任务分类,用 ID 去数据库查询出分类信息
        if (id != null) {
        redirectAttributes.addFlashAttribute("msg", "发布任务成功,等待管理员审核!");
        return "redirect:/employer/task/post";
    }

    /**
     * 跳转到我的任务页面
     *
     * @param session
     * @return
     */
    @GetMapping("myTasks")
    public String myTask(HttpSession session, Model model) {
        // 查询雇主信息
        Employer employer = (Employer) session.getAttribute("employer");

        // 查询雇主的所有任务
        List<TaskVo> taskVos = taskService.getByEmployerId(employer.getId());

        model.addAttribute("tasks", taskVos);

        return "employer/my_task";
    }

    /**
     * 跳转到雇主修改任务页面
     *
     * @param taskId 任务 ID
     * @return
     */
    @GetMapping("task/update")
    public String updateTask(Long taskId, Model model) {
        // 查询所有任务
        List<TaskCategoryVo> categorys = taskCategoryService.getAll();

        TaskVo taskVo = taskService.getById(taskId);

        model.addAttribute("task", taskVo);
        model.addAttribute("taskCategories", categorys);
        return "employer/update_task";
    }

    /**
     * 添加技能
     *
     * @param skillName 技能名称
     * @return
     */
    @PostMapping("skill/add")
    @ResponseBody
    public String addSkill(String skillName, Long taskId, HttpSession session) {
        if (!"".equals(skillName)) {
            employerService.addSkill(taskId, skillName);

        // 任务提交完成
        List<TaskVo> taskVos = taskService.getRecentlySubmit(employer.getId());

        // 放置域对象中
        model.addAttribute("taskCount", taskCount);
        model.addAttribute("bidCount", bidCount);
        model.addAttribute("tasks", taskVos);

        return "employer/dashboard";
    }

    /**
     * 跳转到任务发布页面
     *
     * @return
     */
    @GetMapping("task/post")
    public String postTask(Model model) {
        // 查询出所有任务分类信息
        List<TaskCategoryVo> taskCategoryVos = taskCategoryService.getAll();
        model.addAttribute("taskCategories", taskCategoryVos);
        return "employer/post_task";
    }

    /**
     * 雇主发布一个任务
     *
     * @param session
     * @return
     */
    @PostMapping("task/post")
    public String postTask(HttpSession session, Task task, String skills, String upload, RedirectAttributes redirectAttributes) {
        // 获取雇主信息
        Employer employer = (Employer) session.getAttribute("employer");

        // 添加任务
        task.setEmployerId(employer.getId());
        taskService.postTask(task, skills, upload);

        // 提示消息

    /**
     * 收藏或取消收藏任务
     *
     * @param taskId
     * @return
     */
    @PostMapping("bookmarked")
    @ResponseBody
    public EmployeeBookmarked bookmarked(Long taskId, HttpSession session) {
        // 获取雇员的登录信息
        Employee employee = (Employee) session.getAttribute("employee");
        // 收藏或取消收藏任务
        EmployeeBookmarked employeeBookmarked = employeeBookmarkedService.bookmarked(employee.getId(), taskId);
        return employeeBookmarked;
    }

    /**
     * 跳转到我的收藏页面
     *
     * @return
     */
    @GetMapping("bookmarks")
    public String bookmarks(HttpSession session, Model model) {
        // 获取雇员登录信息
        Employee employee = (Employee) session.getAttribute("employee");

        // 获取收藏的任务集合
        List<EmployeeBookmarkedVo> bookMarks = employeeBookmarkedService.getByEmployeeId(employee.getId());

        // 放置到域对象中,方便页面展示
        model.addAttribute("bookMarks", bookMarks);

        return "employee/bookmarks";
    }

    /**
     * 删除收藏任务
     *
     * @param taskId 任务 ID
     * @return
     */
    @PostMapping("bookmarks/remove")
    @ResponseBody
     * @return
     */
    @GetMapping("checkSuccess")
    public String checkSuccess(Long taskId) {
        // 通过审核
        taskService.checkSuccess(taskId);
        return "redirect:/admin/task/check";
    }

    /**
     * 审核失败
     *
     * @param taskId 任务 ID
     * @return
     */
    @GetMapping("unCheckSuccess")
    public String unCheckSuccess(Long taskId) {
        // 审核失败
        taskService.unCheckSuccess(taskId);
        return "redirect:/admin/task/check";
    }
}

/**
 * 雇主登录蓝机器
 *
 * @Classname EmployerLoginInterceptor
 * @see com.yuu.recruit.interceptor
 */
public class EmployerLoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
    @GetMapping("index")
    public String index(Model model) {

        // 总雇主数量
        Integer employerCount = employerService.getAllCount();

        // 总雇员数量
        Integer employeeCount = employeeService.getAllCount();

        // 总任务成交数量
        Integer allTaskCompleteCount = taskService.getAllCompleteCount();

        // 总任务成交金额
        Double allTaskCompletePrice = taskService.getAllCompletePrice();

        // 最近 10 个注册雇员
        List<Employee> employees = employeeService.getRecently();

        // 获取最近成交的 10 个任务
        List<TaskVo> taskVos = taskService.getRecentlyComplete();

        // 将查询出来的数据,放置域对象中,供页面展示
        model.addAttribute("employerCount", employerCount);
        model.addAttribute("employeeCount", employeeCount);
        model.addAttribute("allTaskCompleteCount", allTaskCompleteCount);
        model.addAttribute("allTaskCompletePrice", allTaskCompletePrice);
        model.addAttribute("employees", employees);
        model.addAttribute("taskVos", taskVos);

        // 跳转到管理员首页
        return "admin/index";
    }

    /**
     * 退出登录
     *
     * @return
     */
    @GetMapping("logout")
    public String logout(HttpSession session) {
        // 退出登录,只需要删除存放在 session 中的 admin 信息即可
        session.removeAttribute("admin");

        // 更新 session 中的个人信息
        session.setAttribute("employee", currEmployee);
        return "redirect:/employee/settings/base";
    }

    /**
     * 跳转到修改密码页
     *
     * @return
     */
    @GetMapping("settings/password")
    public String updatePass() {
        return "employee/settings_pass";
    }

    /**
     * 修改密码
     *
     * @param password 原来的密码
     * @param newPassword 新密码
     * @return
     */
    @PostMapping("settings/password")
    public String updatePass(String password, String newPassword, HttpSession session, RedirectAttributes redirectAttributes) {
        // 查询雇员登录信息
        Employee employee = (Employee) session.getAttribute("employee");
        String msg = employeeService.updatePass(employee.getId(), password, newPassword);
        redirectAttributes.addFlashAttribute("msg", msg);
        return "redirect:/employee/settings/password";
    }

    /**
     * 跳转到雇员简介页面
     *
     * @return
     */
        @GetMapping("profile")
    public String profile(Long employeeId, Model model, HttpSession session) {
        // 查询雇员信息
        EmployeeVo employee = employeeService.getById(employeeId);

        // 查询历史完成任务
     * @return
     */
    @GetMapping("myTasks")
    public String myTask(HttpSession session, Model model) {
        // 查询雇主信息
        Employer employer = (Employer) session.getAttribute("employer");

        // 查询雇主的所有任务
        List<TaskVo> taskVos = taskService.getByEmployerId(employer.getId());

        model.addAttribute("tasks", taskVos);

        return "employer/my_task";
    }

    /**
     * 跳转到雇主修改任务页面
     *
     * @param taskId 任务 ID
     * @return
     */
    @GetMapping("task/update")
    public String updateTask(Long taskId, Model model) {
        // 查询所有任务
        List<TaskCategoryVo> categorys = taskCategoryService.getAll();

        TaskVo taskVo = taskService.getById(taskId);

        model.addAttribute("task", taskVo);
        model.addAttribute("taskCategories", categorys);
        return "employer/update_task";
    }

    /**
     * 添加技能
     *
     * @param skillName 技能名称
     * @return
     */
    @PostMapping("skill/add")
    @ResponseBody
    public String addSkill(String skillName, Long taskId, HttpSession session) {
        if (!"".equals(skillName)) {
            employerService.addSkill(taskId, skillName);
        }
        return "添加技能";
    }

    /**
     * 删除技能
     *
     * @param skillId

/**
 * 雇员投标控制器
 *
 * @Classname EmployeeBidController
 * @see com.yuu.recruit.controller
 */
@Controller
public class EmployeeBidController {

    @Resource
    private BidService bidService;

    @Resource
    private TaskService taskService;

    /**
     * 雇员投标任务
     *
     * @param taskId 任务 ID
     * @param bidPrice 投标价格
     * @param timeNumber 完成时间
     * @param timType 完成时间类型
     * @param session
     * @return
     */
    @PostMapping("employee/bid")
    public String bid(Long taskId, Double bidPrice, int timeNumber, String timeType, HttpSession session, RedirectAttributes redirectAttributes) {
        // 获取 session 中的雇员信息
        Employee employee = (Employee) session.getAttribute("employee");

        // 判断雇员是否已经投标该任务
        boolean flag = bidService.getBidByTaskIdAndEmployeeId(taskId, employee.getId());
        if (flag) {
            // 该雇员已经投标过该任务,返回错误信息
            redirectAttributes.addFlashAttribute("msg", "您已投标过该任务!");
            // 重定向到任务页面
    private EmployeeBookmarkedService employeeBookmarkedService;

    /**
     * 跳转到分类列表页
     *
     * @param categoryId 分类列表页
     * @param key 查询条件
     * @param page
     * @return
     */
    @GetMapping("list")
    public String list(@RequestParam(defaultValue = "0") Long categoryId,
                       @RequestParam(defaultValue = "") String key,
                       @RequestParam(defaultValue = "1") int page,
                       HttpSession session,
                       Model model) {
        // 如果雇员登录了,查询出雇员收藏信息
        Employee employee = (Employee) session.getAttribute("employee");
        List<Long> bookMarkedIds = new ArrayList<>();
        if (employee != null) {
            // 查询雇员收藏信息
            Long employeeId = employee.getId();
            // 查询雇员收藏任务ID集合
            bookMarkedIds = employeeBookmarkedService.getIdsByEmployeeId(employeeId);
        }

        // 查询出所有分类信息,因为选择分类的时候,需要分类信息
        List<TaskCategoryVo> taskCategories = taskCategoryService.getAll();

        // 调用 TaskService 进行分页查询,得到分页结果
        PageResult<TaskVo> tasksPage = taskService.page(categoryId, key, page);

        // 将查询结果放置到域对象中,供页面查询
        model.addAttribute("taskCategories", taskCategories);
        model.addAttribute("tasksPage", tasksPage);
        // 将查询条件页放置到域对象中,方便页面读取
        model.addAttribute("categoryId", categoryId);
        model.addAttribute("key", key);
        model.addAttribute("bookMarkedIds", bookMarkedIds);

        return "task_list";
    }
    private static final String BUCKET_NAME = "ce11211";

    /**
     * 图片上传
     *
     * @param dropzFile
     * @param request
     * @return
     */
    @PostMapping("upload")
    @ResponseBody
    public Map<String, Object> upload(MultipartFile dropzFile, HttpServletRequest request, HttpServletResponse response) {

        Map<String, Object> result = new HashMap<>();
        String fileName = dropzFile.getOriginalFilename();
        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
        String newName = UUID.randomUUID() + "." + suffix;
        OSS client = new OSSClientBuilder().build(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
        try {
            client.putObject(new PutObjectRequest(BUCKET_NAME, newName, new ByteArrayInputStream(dropzFile.getBytes())));
            // 上传文件路径 = http://BUCKET_NAME.ENDPOINT/自定义路径/fileName
            String filePath = "http://" + BUCKET_NAME + "." + ENDPOINT + "/" + newName;
            result.put("filePath", filePath);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            client.shutdown();
        }
        return result;
    }

    /**
     * 文件上传
     *
     * @param uploadFile
     * @param request
     * @return
     */
    @PostMapping("uploadFile")
    @ResponseBody
    public Map<String, Object> uploadFile(MultipartFile upload, HttpServletRequest request, HttpServletResponse response) {

        Map<String, Object> result = new HashMap<>();
        String fileName = upload.getOriginalFilename();
        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
        String newName = UUID.randomUUID() + "." + suffix;
        OSS client = new OSSClientBuilder().build(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
        try {
            client.putObject(new PutObjectRequest(BUCKET_NAME, newName, new ByteArrayInputStream(upload.getBytes())));
            // 上传文件路径 = http://BUCKET_NAME.ENDPOINT/自定义路径/fileName
            String filePath = "http://" + BUCKET_NAME + "." + ENDPOINT + "/" + newName;
            result.put("filePath", filePath);
        } catch (IOException e) {
            e.printStackTrace();

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值