Java项目:ssm物业管理系统

作者主页:夜未央5788

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

物业管理系统,包含登录信息统计、物业人员管理,住户管理,房屋管理、车位管理等功能;

环境要求

JDK >= 1.8 (推荐1.8版本)

Mysql >= 5.5.0 (推荐5.7版本)

Maven >= 3.0

开发工具:IDEA/Eclipse

Tomcat: 8.0及以上

技术栈:

后端Spring+Spring MVC+MyBatis

前端:html+JQuery

运行截图

 

 

 

 

 

 

 

相关代码 

BuildingController

package com.property.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.property.pojo.Building;
import com.property.service.BuildingServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("building")
public class BuildingController {
    @Autowired
    private BuildingServer buildingServer;

    //查询所有的楼房信息
    @RequestMapping("findAllBuilding")
    public String findAllBuilding(){
        return JSON.toJSONString(buildingServer.findAllBuilding());
    }

    //查询所有的楼房和住户
    @RequestMapping("findAll")
    public String findAll(Integer page){
        return buildingServer.findAllBuildingResident(page);
    }
    //新增房屋
    @RequestMapping("saveBuilding")
    public String saveBuilding(Building building){
        return buildingServer.saveBuilding(building);
    }
    //根据id查询房屋
    @RequestMapping("findBuildBybId")
    public String findBuildBybId(Integer bId){
        return JSON.toJSONString(buildingServer.findBuildingBybId(bId));
    }
    //删除房屋信息
    @RequestMapping("deleteBuilding")
    public String deleteBuilding(Integer bId){
        int num = buildingServer.deleteBuilding(bId);
        return JSON.toJSONString((num > 0) ? "操作成功":"操作失败");
    }
}

CarController

package com.property.controller;

import com.alibaba.fastjson.JSON;
import com.property.pojo.Car;
import com.property.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("car")
public class CarController {
    @Autowired
    private CarService carService;

    @RequestMapping("findAll")
    public String findAll(Integer page){
        return carService.findAllCar(page);
    }

    //新增车位信息
    @RequestMapping("saveCar")
    public String saveCar(Car car,String rName){
        return carService.saveCar(car,rName);
    }

    //通过id查询车位信息
    @RequestMapping("findCarBycId")
    public String findCarBycId(Integer cId){
        return carService.findCarBycId(cId);
    }

    //删除车位信息
    @RequestMapping("deleteCar")
    public String deleteCar(Integer cId){
        return carService.deleteCar(cId);
    }
}

ResidentController

package com.property.controller;

import com.alibaba.fastjson.JSON;

import com.property.pojo.Resident;
import com.property.service.ResidentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
@RequestMapping("resident")
public class ResidentController {

    @Autowired
    private ResidentService residentService;
    //显示所有的住户信息
    @RequestMapping("findAllResident")
    public String findAllResident(Integer page){
        return residentService.findAllResident(page);
    }
    //新增住户
    @RequestMapping("saveResident")
    public String saveResident(Resident resident){
        return residentService.saveResident(resident);
    }
    //删除住户
    @RequestMapping("deleteResident")
    public String deleteResident(Integer rId){
        int num = residentService.deleteResident(rId);
        return JSON.toJSONString((num > 0) ? "操作成功":"操作失败");
    }
    //通过id查询住户
    @RequestMapping("findResidentByrId")
    public String findResidentByrId(Integer rId){
        return JSON.toJSONString(residentService.findResidentByrId(rId));
    }


}

StaffController

package com.property.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.property.pojo.Staff;
import com.property.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;
import java.util.List;
import java.util.regex.Pattern;

@RequestMapping("staff")
@RestController
public class StaffController {
    @Autowired
    private StaffService staffService;
    //查询员工
    @RequestMapping("findAllStaff")
    public String findAllStaff(Integer page){
        return staffService.findAllStaff(page);
    }

    //新增/更新员工
    @RequestMapping("saveUpdateStaff")
    public String saveStaff(Staff staff){
        return staffService.updateOrSaveStaff(staff);
    }

    //删除员工
    @RequestMapping("deleteStaff")
    public String delete(Integer sId){
        int num = staffService.deleteStaff(sId);
        return JSON.toJSONString(num >0 ?"删除成功":"删除失败");
    }
    //根据id查询员工
    @RequestMapping("findBysId")
    public String findBysId(Integer sId){
        Staff staff = staffService.findBysId(sId);
        return JSON.toJSONString(staff);
    }
}

UserController

package com.property.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.property.pojo.User;
import com.property.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    //接收传过来的用户名和密码 登录
    @RequestMapping("login")
    public String login(@RequestParam("userName") String username, String password,HttpSession session){
            String message = "登录成功";
            User user = userService.findUserByName(username);
           if(username ==null || password ==null || username.equals("")|| password.equals("")){
               message="用户名密码不能为空";
               //判断用户名是否存在
           }else if(user == null){
                message="用户不存在";
                //判断密码是否正确
           }else if(!user.getuPassword().equals(password)){
               message="密码不正确";
           }else{
               session.setAttribute("user",user);
           }
        return JSON.toJSONString(message);
    }

    //获取session中的数据
    @RequestMapping("getUser")
    public String getSession(HttpSession session){
        User user = (User) session.getAttribute("user");
        return JSON.toJSONString(user);
    }

    //退出登录
    @RequestMapping("loginOut")
    public String loginOut(HttpSession session){
        session.removeAttribute("user");
        return JSON.toJSONString("true");
    }

    //查询所有的用户
    @RequestMapping("findAllUser")
    public String findAllUser(Integer page){
        return userService.findAllUser(page);
    }
    //停用启用
    @RequestMapping("stopUser")
    public String stopUser(Integer uId){
        int num = userService.stopUser(uId);
        return JSON.toJSONString(num >0 ? "成功":"失败");
    }
    @RequestMapping("startUser")
    public String startUser(Integer uId){
        int num = userService.startUser(uId);
        return JSON.toJSONString(num >0 ? "成功":"失败");
    }
    //新增用户
    @RequestMapping("addUser")
    public String addUser(User user,String password2){
        return userService.updateOrSaveUser(user,password2);
    }
    //删除用户
    @RequestMapping("deleteUserByuId")
    public String deleteUser(Integer uId){
        int num = userService.deleteUserByuId(uId);
        return JSON.toJSONString(num >0 ? "成功":"失败");
    }
    //通过id查询用户 回显数据
    @RequestMapping("findByuId")
    public String findByuId(Integer uId){
        return JSON.toJSONString(userService.findByuId(uId));
    }



}

拦截器

package com.property.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // 在拦截点执行前拦截,如果返回true则不执行拦截点后的操作(拦截成功)
        // 返回false则不执行拦截
        HttpSession session = request.getSession();
        if(session.getAttribute("user")!=null) {
            // 登录成功不拦截
            return true;
        }else {
            // 拦截后进入登录页面
            response.sendRedirect("/property/login.html");
            return false;
        }
    }
}

BuildingServerImpl

package com.property.service.impl;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.property.mapper.BuildingMapper;
import com.property.mapper.ResidentMapper;
import com.property.pojo.Building;
import com.property.pojo.Resident;
import com.property.service.BuildingServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BuildingServerImpl implements BuildingServer {
    @Autowired
    private BuildingMapper buildingMapper;

    @Autowired
    private ResidentMapper residentMapper;
    @Override
    public List<Building> findAllBuilding() {
        return buildingMapper.findAllBuilding();
    }

    //查询所有的楼房信息
    @Override
    public String findAllBuildingResident(Integer page) {
        PageHelper.startPage(page,10);
        List<Building> list = buildingMapper.findAllBuilding();
        for(Building build : list){
            //通过rBid查询resident住户
            List<Resident> residentList = residentMapper.findResidentByrBid(build.getbId());
            build.setResidentList(residentList);
        }
        PageInfo pageInfo = new PageInfo(list);
        return JSON.toJSONString(pageInfo);
    }

    //新增更新房屋信息
    @Override
    public String saveBuilding(Building building) {
        String message ="操作成功";
        int num = 0;
        //信息不能为空
        if(building.getbUnit()== null || building.getbUnit().equals("") || building.getbBuilding()==null || building.getbBuilding().equals("") ||
        building.getbRoomid()==null || building.getbRoomid().equals("") || building.getbHousetype() == null || building.getbHousetype().equals("") ||
        building.getbArea() == null || building.getbArea()<=0){
            message = "数据不能为空";
        }else {
            if(building.getbId() != null && building.getbId()!=0){
                num = buildingMapper.updateBuilding(building);
            }else {
                num = buildingMapper.saveBuilding(building);
            }
            if(num == 0){
                message="操作失败";
            }
        }
        return JSON.toJSONString(message);
    }

    @Override
    public Building findBuildingBybId(Integer bId) {
        return buildingMapper.findBuildingBybId(bId);
    }

    //删除用户
    @Override
    public int deleteBuilding(Integer bId) {
        return buildingMapper.deleteBuilding(bId);
    }
}

CarServiceImpl

package com.property.service.impl;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.property.mapper.CarMapper;
import com.property.mapper.ResidentMapper;
import com.property.pojo.Car;
import com.property.pojo.Resident;
import com.property.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarServiceImpl implements CarService {
    @Autowired
    private CarMapper carMapper;
    @Autowired
    private ResidentMapper residentMapper;
    @Override
    public String findAllCar(Integer page) {
        PageHelper.startPage(page,10);
        List<Car> list = carMapper.findAllCar();
        PageInfo pageInfo = new PageInfo(list);
        return JSON.toJSONString(pageInfo);
    }
    //新增车位信息
    @Override
    public String saveCar(Car car,String rName) {
        String message="操作成功";
        int num=0;
        if(car.getcCoder()==null || car.getcCoder().equals("")|| car.getcStatus() == null || car.getcStatus().equals("无状态")){
            message = "不能为空";
        }else {
            if(car.getcStatus()!= null && !car.getcStatus().equals("空闲")){
                Resident resident = residentMapper.findResidentByrName(rName);
                if(resident==null){
                    message = "住户不存在";
                    return JSON.toJSONString(message);
                }else{
                    car.setcRid(resident.getrId());
                }
            }
            if(car.getcId() != null && car.getcId() != 0 ){
                num = carMapper.updateCar(car);
            }else{
                num = carMapper.saveCar(car);
            }
        }
        return JSON.toJSONString(message);
    }

    //查询car 通过id
    @Override
    public String findCarBycId(Integer cId) {
        return JSON.toJSONString(carMapper.findCarBycId(cId));
    }

    //删除车位信息
    @Override
    public String deleteCar(Integer cId) {
        int num = carMapper.deleteCar(cId);
        return JSON.toJSONString(num>0?"操作成功":"操作失败");
    }
}

如果也想学习本系统,下面领取。关注并回复:016ssm 

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
项目使用IDEA作为IDE,bootstrap(HTML5 CSS JS)做前端,springMVC做后端,mySQL做数据库。 UI请使用蓝色和白色为主色调。不用做得太华丽,做得像一个正常的毕设就行。 首先是登录,分为业主和管理员两种身份。不同的身份看到的模块数量和内容不一样。 系统管理模块,我设想的是每个人对自己这个账户的基本信息的修改。这一部分我不太确定,可以适当自由添加一点功能。 楼盘管理,业主只能看到自己的住房信息。管理员这边,可以显示这个小区有哪些大楼,选择大楼可以看到大楼内部有哪些房间,还可以显示这些房间与哪些业主相关联(即被谁买下),可以查找指定业主的住房。管理员可以添加、删除、更新业主和房屋的关联(表示入住或者搬离)。 收费管理,初步想法是管理员向业主发出收费通知(物业、水电等),可以向所有业主群发,也可以向指定业主发送。业主的界面会收到通知,业主线下缴费后线上确认,然后管理员确认即可完成缴费全过程。 停车管理,业主只能看到自己的车位信息。管理员界面显示小区内所有车位,以及这些车位的状态,无人归属或者归谁所有,可以查找指定业主的车位,或者指定车位的业主。可以添加、更新和删除业主和车位的关联(表示购买车位、车位转让、车位到期等)。 业主管理,业主看不到这个模块。业主注册时向管理员发出信号,管理员批准后业主注册正式完成。该模块可以显示有哪些业主,业主的基本信息。管理员也可以删除业主的账号(表示业主已经搬离该小区,与小区没有关联了)。 保修和投诉两个模块是类似的,业主在自己这里发出具体的请求,管理员界面可以看到这些请求。管理员可以接受请求,等待线下任务完成后,业主确认完成后,管理员确认完成,即正式完成,本次保修、投诉结束。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值