基于javaweb+mysql的springboot家政服务平台系统(java+ssm+jsp+mysql+maven)

基于javaweb+mysql的springboot家政服务平台系统(java+ssm+jsp+mysql+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SpringBoot家政服务平台系统(java+ssm+jsp+mysql+maven)

一、项目简述

功能包括: 家政服务网站系统,用户注册,登录,分为家政人员,普 通用户,以及最高管理员,包括家政分类查询,展示,线 上预约服务,家政申请,评论,留言沟通・,联系家政服 务,家政人员的认证,职业认证,以及后台的维护等等功能。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + maven等等。


    /**
     * 获取种类之间的相似度
     * @return 二维矩阵
     */
    private List<List<Integer>> getTypeSimilarity () {
        // 调用上方函数,获取到用户与种类之间的评分矩阵
        List<List<Integer>> orderNum = getOrderNum();

        // 作为种类相似度的返回矩阵
        List<List<Integer>> result = new ArrayList<>();

        // 种类与种类之间的关系,假如 种类1 和 种类2 同时存在于用户A、用户B和用户C中,那么则种类之间的相似度为3
        for (int i = 0; i < orderNum.get(0).size(); i ++) {
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < orderNum.get(0).size(); j ++) {
                int single = 0;
                // 这里表示通过遍历用户,来取的种类与种类之间的相似度
                for (int n = 0; n < orderNum.size(); n ++) {
                    if (orderNum.get(n).get(i) > 0 && orderNum.get(n).get(j) > 0) {
                        single ++;
                    }
                }
                list.add(single);
            }
            result.add(list);
        }
        return result;
    }

    /**
     * 获取 list 中某个元素的下标
     * @return 下标
     */
    private int getIndex (int num, List<Integer> list) {
        int index = 0;
        for (int i = 0; i < list.size(); i ++) {
            if (list.get(i) == num) {
                index = i;
            }
    @PostMapping("/certifyCompanyByID")
    @ResponseBody
    public ResponseResult<Void> certifyCompanyByID (
            @RequestParam("id") String id
    ) {
        adminService.updateCompanyStatusByID(Integer.parseInt(id), 1);
        return new ResponseResult<>();
    }

    @PostMapping("/getUserByPhone")
    @ResponseBody
    public ResponseResult<List<User>> getUserByPhone (
            @RequestParam("phone") String phone
    ) {
        ResponseResult<List<User>> result = new ResponseResult<>();
        List<User> list = adminService.getUserByPhone(phone);
        result.setData(list);
        return result;
    }

    @PostMapping("/updatePassword")
    @ResponseBody
    public ResponseResult<Void> updatePassword (
            HttpSession session,
            @RequestParam("oldPassword") String oldPassword,
            @RequestParam("newPassword") String newPassword
    ) {
        adminService.updatePassword(session, oldPassword, newPassword);
        return new ResponseResult<Void>();
    }

}

    @ResponseBody
    public ResponseResult<List<HouseKeeper>> getTopRepair () {
        ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
        List<HouseKeeper> list = indexService.getTopHousekeeper(9);
        result.setData(list);
        return result;
    }

    @RequestMapping("/getTopMove")
    @ResponseBody
    public ResponseResult<List<HouseKeeper>> getTopMove () {
        ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
        List<HouseKeeper> list = indexService.getTopHousekeeper(13);
        result.setData(list);
        return result;
    }

    @RequestMapping("/getRecommend")
    @ResponseBody
    public ResponseResult<List<HouseKeeper>> getRecommend (
            HttpSession session
    ) {
        ResponseResult<List<HouseKeeper>> result = new ResponseResult<>();
        List<HouseKeeper> list = indexService.getRecommend(session);
        result.setData(list);
        return result;
    }

    @PostMapping("/getTypeID")
    @ResponseBody
    public ResponseResult<Integer> getTypeID (
            @RequestParam("param") String param
    ) {
        ResponseResult<Integer> result = new ResponseResult<>();
        int id = indexService.getTypeID(param);
        result.setData(id);
        return result;
    }

}

    }

    @Override
    public Customer getCustomerByID(int id) {
        return personMapper.getCustomerByID(id);
    }

    @Override
    public HouseKeeper getHousekeeperByID(int id) {
        return hkPersonMapper.getHousekeeperByID(id);
    }

    @Override
    public Company getCompanyByID(int id) {
        return companyMapper.getCompanyByID(id);
    }

    @Override
    public void updateCustomerStatusByID(int id, int status) {
        personMapper.updateCustomerStatusByID(id, status);
    }

    @Override
    public void updateHousekeeperStatusByID(int id, int status) {
        hkPersonMapper.updateHousekeeperStatusByID(id, status);
    }

    @Override
    public void updateCompanyStatusByID(int id, int status) {
        companyMapper.updateCompanyStatusByID(id, status);
    }

    @Override
    public List<User> getUserByPhone(String phone) throws ContentException {

        if (StringUtils.isEmpty(phone)) {
            throw new ContentException("输入的内容为空");
        } else if (adminMapper.getUserByPhone(phone).size() <= 0) {
            throw new ContentException("没有相关内容");
        } else {
            return adminMapper.getUserByPhone(phone);
        }
    }

    @Override
    public Integer updatePassword(HttpSession session, String oldPassword, String newPassword) throws UserNoLoginException, PasswordIsErrorException {
        Integer result = 0;
 * Created by IntelliJ IDEA 2020.1.
 * Project: house
 * Description:用户Controller
 */
@Controller
@RequestMapping("/person")
public class PersonController extends BaseController{
    @Autowired
    private PersonService personService;

    /**
     * 跳转用户页面
     * @return 用户页面
     */
    @GetMapping("/toPerson")
    public String toPerson(HttpSession session) {
        int role = (int) session.getAttribute("role");
        if (0 == role){
            return "xfz/person";
        }
        return "person";
    }

    /**
     * 跳转用户信息编辑页面
     * @return 信息页面
     */
    @GetMapping("/toEditPerson")
    public String toEditPerson() {
        return "person/edit-person";
    }

    /**
     * 跳转用户认证页面
     * @return 认证页面
     */
    @GetMapping("/toCertifyPerson")
    public String toCertifyPerson() {
        return "person/certify-person";
    }

    /**
     * 跳转用户密码编辑页面
     * @return 密码编辑页面
     */
    @PostMapping("/getAllApp")
    @ResponseBody
    public ResponseResult<PageInfo<Appointment>> getAllApp (
            HttpSession session,
            @RequestParam(required = false,defaultValue = "1",value = "pageNum")Integer currentPage
    ) {
        ResponseResult<PageInfo<Appointment>> result = new ResponseResult<>();
        if (session == null) {
            throw new UserNoLoginException("用户未登录");
        } else {
            PageInfo<Appointment> list = appService.getAllApp(session,currentPage);
            result.setData(list);
        }
        return result;
    }

    @PostMapping("/getAppCustomer")
    @ResponseBody
    public ResponseResult<PageInfo<Appointment>> getAppCustomer (
            HttpSession session,
            @RequestParam(required = false,defaultValue = "1",value = "pageNum")Integer currentPage
    ) {
        ResponseResult<PageInfo<Appointment>> result = new ResponseResult<>();
        if (session == null) {
            throw new UserNoLoginException("用户未登录");
        } else {
            PageInfo<Appointment> list = appService.getAllAppCustomer(session,currentPage);
            result.setData(list);
        }

        return result;
    }

    @PostMapping("/apply")
    @ResponseBody
    public ResponseResult<Void> apply (
            HttpSession session,
            Integer id
    ) {
        appService.insertApplyList(session, id);
        return new ResponseResult<Void>();
    }


/**
 * Created by IntelliJ IDEA 2020.1.
 * Project: house
 * Description:家政人员Controller
 */
@Controller
@RequestMapping("/hk")
public class HKPersonController extends BaseController {

    @Autowired
    private HKPersonService hkPersonService;
    @Autowired
    private CompanyService companyService;
    @Autowired
    private CommentService commentService;

    /**
     * 跳转至商家资料页面
     * @return 商家资料页面
     */
    @GetMapping("/toHkPerson")
    public String toHkPerson() {
        return "hk_person";
    }

    List<Company> getAllCompanyCertify ();

    /**
     * 通过消费者的编号获取消费者
     * @param id 消费者的编号
     * @return 消费者信息
     */
    Customer getCustomerByID(int id);

    /**
     * 通过家政人员编号获取家政人员
     * @param id 家政人员的编号
     * @return 家政人员信息
     */
    HouseKeeper getHousekeeperByID (int id);

    /**
     * 通过公司编号获取公司信息
     * @param id 公司编号
     * @return 公司信息
     */
    Company getCompanyByID (int id);

    /**
     * 更新消费者的认证状态
     * @param id 用户编号
     * @param status 用户的认证状态
     */
    void updateCustomerStatusByID (int id, int status);

    /**
     * 更新家政人员的认证状态
     * @param id 家政人员编号
     * @param status 家政人员的认证状态
     */
    void updateHousekeeperStatusByID (int id, int status);

    /**
     * 更改公司的认证状态
     * @param id 公司编号
     * @param status 公司的认证状态
    }

    @Override
    public HouseKeeper getHousekeeperByID(int id) {
        return hkPersonMapper.getHousekeeperByID(id);
    }

    @Override
    public Company getCompanyByID(int id) {
        return companyMapper.getCompanyByID(id);
    }

    @Override
    public void updateCustomerStatusByID(int id, int status) {
        personMapper.updateCustomerStatusByID(id, status);
    }

    @Override
    public void updateHousekeeperStatusByID(int id, int status) {
        hkPersonMapper.updateHousekeeperStatusByID(id, status);
    }

    @Override
    public void updateCompanyStatusByID(int id, int status) {
        companyMapper.updateCompanyStatusByID(id, status);
    }

    @Override
    public List<User> getUserByPhone(String phone) throws ContentException {

        if (StringUtils.isEmpty(phone)) {
            throw new ContentException("输入的内容为空");
        } else if (adminMapper.getUserByPhone(phone).size() <= 0) {
            throw new ContentException("没有相关内容");
        } else {
            return adminMapper.getUserByPhone(phone);
        }
    }

    @Override
    @ResponseBody
    public ResponseResult<Customer> getCustomerByID (
            @RequestParam("id") String id
    ) {
        ResponseResult<Customer> result = new ResponseResult<>();
        Customer customer = adminService.getCustomerByID(Integer.parseInt(id));
        result.setData(customer);
        return result;
    }

    @PostMapping("/getHousekeeperByID")
    @ResponseBody
    public ResponseResult<HouseKeeper> getHousekeeperByID (
            @RequestParam("id") String id
    ) {
        ResponseResult<HouseKeeper> result = new ResponseResult<>();
        HouseKeeper houseKeeper = adminService.getHousekeeperByID(Integer.parseInt(id));
        result.setData(houseKeeper);
        return result;
    }

    @PostMapping("/getCompanyByID")
    @ResponseBody
    public ResponseResult<Company> getCompanyByID (
            @RequestParam("id") String id
    ) {
        ResponseResult<Company> result = new ResponseResult<>();
        Company company = adminService.getCompanyByID(Integer.parseInt(id));
        result.setData(company);
        return result;
    }

    @PostMapping("/cancelCustomerByID")
    @ResponseBody
    public ResponseResult<Void> cancelCustomerByID (
            @RequestParam("id") String id
    ) {
        adminService.updateCustomerStatusByID(Integer.parseInt(id), 2);
        return new ResponseResult<>();
    }

    @PostMapping("/certifyCustomerByID")
    @ResponseBody
    public ResponseResult<Void> certifyCustomerByID (
            @RequestParam("id") String id
    ) {
        adminService.updateCustomerStatusByID(Integer.parseInt(id), 1);
        return new ResponseResult<>();
    }

/**
 * Created by IntelliJ IDEA 2020.1.
 * Project: house
 * Description:预约Controller
 */
@Controller()
@RequestMapping("/app")
public class AppointmentController extends BaseController{

    @Autowired
    private AppointmentService appService;

    /**
     * 跳转我的预约页面
     * @return 我的预约页面
     */
    @GetMapping("/toCmApp")
    public String toCmApp() {
        return "cm_app";
    }

    /**
     * 跳转预约列表页面
     * @return 预约列表页面
     */
    @GetMapping("/toHkApp")
    public String toHkApp() {
        return "hk_app";
    }

    @PostMapping("/mkApp")
    @ResponseBody
    public ResponseResult<Void> makeAppoint(
            HttpSession session,
            @RequestParam("app_type") String appType,
            @RequestParam("app_address_city") String appAddressCity,
            @RequestParam("app_address_area") String appAddressArea,
            @RequestParam("app_address_detail") String appAddressDetail,
            @RequestParam("app_phone") String appPhone,
            @RequestParam("app_time") String appTime
    ) {
        ResponseResult<Void> response = new ResponseResult<Void>();
        String username = new String();
        String key = "username";
        if (session.getAttribute(key) == null) {
    ) {
        ResponseResult<PageInfo<Appointment>> result = new ResponseResult<>();
        if (session == null) {
            throw new UserNoLoginException("用户未登录");
        } else {
            PageInfo<Appointment> list = appService.getAllApp(session,currentPage);
            result.setData(list);
        }
        return result;
    }

    @PostMapping("/getAppCustomer")
    @ResponseBody
    public ResponseResult<PageInfo<Appointment>> getAppCustomer (
            HttpSession session,
            @RequestParam(required = false,defaultValue = "1",value = "pageNum")Integer currentPage
    ) {
        ResponseResult<PageInfo<Appointment>> result = new ResponseResult<>();
        if (session == null) {
            throw new UserNoLoginException("用户未登录");
        } else {
            PageInfo<Appointment> list = appService.getAllAppCustomer(session,currentPage);
            result.setData(list);
        }

        return result;
    }

    @PostMapping("/apply")
    @ResponseBody
    public ResponseResult<Void> apply (
            HttpSession session,
            Integer id
    ) {
        appService.insertApplyList(session, id);
        return new ResponseResult<Void>();
    }

    @PostMapping("/getSingleApp")
    @ResponseBody
    public ResponseResult<Appointment> getSingleApp (
            @RequestParam("id") Integer id
    ) {
        ResponseResult<Appointment> result = new ResponseResult<>();
        Appointment app = appService.selectAppointByID(id);
                List<Integer> applyList = JsonUtil.json2List(app.getApplyJson(), Integer.class);
                app.setApplyList(applyList);
            }
            return pageInfo;
        }
    }

    /**
     * 家政人员获得预约列表
     * @param session
     * @return
     */
    @Override
    public PageInfo<Appointment> getAllApp(HttpSession session, int currentPage) {
        int hkID = 0;
        String username = (String)session.getAttribute("username");
        if (StringUtils.isEmpty(username)) {
            throw new UserNoLoginException("用户未登录");
        } else {
            hkID = userMapper.selectHKIDByPhone(username);
            if (currentPage <= 0) {
                currentPage = 1;
            }
            PageHelper.startPage(currentPage, PAGESIZE);
            List<Appointment> list = appMapper.getAllApp();
            PageInfo<Appointment> pageInfo = new PageInfo<>(list);
            for (Appointment app : list) {
                List<Integer> applyList = JsonUtil.json2List(app.getApplyJson(), Integer.class);
                app.setApplyList(applyList);
                app.setHkID(hkID);
            }
            return pageInfo;
        }
    }

    /**
     * 家政人员获得预约列表
     * @param session
     * @return
     */
    @Override
    public List<Appointment> getAllApp(HttpSession session) {
        int hkID = 0;
        String username = (String)session.getAttribute("username");

/**
 * Created by IntelliJ IDEA 2020.1.
 * Project: house
 * Description:用户Service实现类
 */
@Service
public class PersonServiceImpl implements PersonService {

    @Resource
    private PersonMapper personMapper;
    @Resource
    private UserMapper userMapper;

    @Override
    public Customer selectCustomer(HttpSession session) throws UserNoLoginException {
        String phone = (String)session.getAttribute("username");
        if (StringUtils.isEmpty(phone)) {
            throw new UserNoLoginException("用户未登录!");
        } else {
            return personMapper.selectCustomer(phone);
        }
    }

    @Override
    public Integer updateCustomer(HttpSession session, Customer cm) {
        Integer result = 0;
        if (session == null) {
            throw new UserNoLoginException("用户未登录...");
        } else {
            String username = session.getAttribute("username").toString();
            result = personMapper.updateCustomer(cm.getCmNickname(), cm.getCmPhone(), cm.getCmEmail(), cm.getCmHeadPhoto(), username);
        }
        return result;
    }

    @Override
    public Integer updatePassword(HttpSession session, String oldPassword, String newPassword) throws UserNoLoginException, PasswordIsErrorException {
        Integer result = 0;

/**
 * Created by IntelliJ IDEA 2020.1.
 * Project: house
 * Description:用户Controller
 */
@Controller
@RequestMapping("/person")
public class PersonController extends BaseController{
    @Autowired
    private PersonService personService;

    /**
     * 跳转用户页面
     * @return 用户页面
     */
    @GetMapping("/toPerson")
    public String toPerson(HttpSession session) {
        int role = (int) session.getAttribute("role");
        if (0 == role){
            return "xfz/person";
        }
        return "person";
    }

    /**
     * 家政人员获得预约列表
     * @param session
     * @return
     */
    @Override
    public List<Appointment> getAllApp(HttpSession session) {
        int hkID = 0;
        String username = (String)session.getAttribute("username");
        if (StringUtils.isEmpty(username)) {
            throw new UserNoLoginException("用户未登录");
        } else {
            hkID = userMapper.selectHKIDByPhone(username);
        }
        List<Appointment> list = appMapper.getAllApp();
        for (Appointment app : list) {
            List<Integer> applyList = JsonUtil.json2List(app.getApplyJson(), Integer.class);
            app.setApplyList(applyList);
            app.setHkID(hkID);
        }
        return list;
    }

    @Override
    public Integer insertApplyList(HttpSession session, int id) throws UserNoLoginException {
        // 通过订单的 id 来获得订单的申请列表
        String applyList = appMapper.getApplyList(id);
        System.out.println(applyList);
        // 通过 工具类将 json 转换为集合
        List<Integer> list = new ArrayList<>();
        list =  JsonUtil.json2List(applyList, Integer.class);
        // 在集合中添加家政人员的编号
        if (session == null) {
            throw new UserNoLoginException("用户未登录");
        } else {
            String username = session.getAttribute("username").toString();
            // 通过手机号判断家政人员是否已经认证,若未认证,则填写认证信息
            if (hkPersonMapper.selectHKStatusByPhone(username) == 0) {
                throw new NoApplyPermission("请填写认证信息");
            } else if (hkPersonMapper.selectHKStatusByPhone(username) == 2) {
                throw new NoApplyPermission("请等待认证结果");
            } else {
                int hkID = userMapper.selectHKIDByPhone(username);
                System.out.println(hkID);
                list.add(new Integer(hkID));
            }
        }
    ) {
        ResponseResult<Company> result = new ResponseResult<>();
        Company company = adminService.getCompanyByID(Integer.parseInt(id));
        result.setData(company);
        return result;
    }

    @PostMapping("/cancelCustomerByID")
    @ResponseBody
    public ResponseResult<Void> cancelCustomerByID (
            @RequestParam("id") String id
    ) {
        adminService.updateCustomerStatusByID(Integer.parseInt(id), 2);
        return new ResponseResult<>();
    }

    @PostMapping("/certifyCustomerByID")
    @ResponseBody
    public ResponseResult<Void> certifyCustomerByID (
            @RequestParam("id") String id
    ) {
        adminService.updateCustomerStatusByID(Integer.parseInt(id), 1);
        return new ResponseResult<>();
    }

    @PostMapping("/cancelHousekeeperByID")
    @ResponseBody
    public ResponseResult<Void> cancelHousekeeperByID (
            @RequestParam("id") String id
    ) {
        adminService.updateHousekeeperStatusByID(Integer.parseInt(id), 2);
        return new ResponseResult<>();
    }

    @PostMapping("/certifyHousekeeperByID")
    @ResponseBody
    public ResponseResult<Void> certifyHousekeeperByID (
            @RequestParam("id") String id
    ) {
        adminService.updateHousekeeperStatusByID(Integer.parseInt(id), 1);
        return new ResponseResult<>();
    }

    @PostMapping("/cancelCompanyByID")
    @ResponseBody
    public ResponseResult<Void> cancelCompanyByID (
            @RequestParam("id") String id
    ) {
        adminService.updateCompanyStatusByID(Integer.parseInt(id), 2);
        return new ResponseResult<>();
    }


/**
 * Created by IntelliJ IDEA 2020.1.
 * Project: house
 * Description:用户服务层
 */
public interface PersonService {
    /**
     * 得到消费者的基本资料
     * @param session 通过session 获得手机号
     * @return 消费者
     */
    Customer selectCustomer(HttpSession session) throws UserNoLoginException;

    /**
     * 更新消费者的基本资料
     * @param session
     * @param customer 前台得到的基本信息
     * @return 受影响的行数
     */
    Integer updateCustomer (HttpSession session, Customer customer);

    /**
     * 更新消费者的密码
     * @param session
     * @param oldPassword 消费者的老密码
     * @param newPassword 消费者的新密码
     * @return
     */
    Integer updatePassword (HttpSession session, String oldPassword, String newPassword) throws UserNoLoginException, PasswordIsErrorException;

    /**
     * 获得登录用户的认证信息
     * @param session
     * @return 认证信息
     */
    Customer selectCertifyCustomer (HttpSession session) throws UserNoLoginException;

    /**
     * 消费者的认证
     * @param session
     * @param customer 消费者的信息
     * @return
     */
    Integer certifyCustomer (HttpSession session, Customer customer) throws UserNoLoginException;

    /**
     * 获得消费者的认证状态

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值