作者主页:夜未央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
- 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) ? "操作成功":"操作失败");
- }
- }
- 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);
- }
- }
- 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));
- }
-
-
- }
- 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);
- }
- }
- 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;
- }
- }
- }
- 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
findAllBuilding() { - return buildingMapper.findAllBuilding();
- }
-
- //查询所有的楼房信息
- @Override
- public String findAllBuildingResident(Integer page) {
- PageHelper.startPage(page,10);
- List
list = buildingMapper.findAllBuilding(); - for(Building build : list){
- //通过rBid查询resident住户
- List
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);
- }
- }
- 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
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