• 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

    1. package com.property.controller;
    2. import com.alibaba.fastjson.JSON;
    3. import com.github.pagehelper.PageInfo;
    4. import com.property.pojo.Building;
    5. import com.property.service.BuildingServer;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import org.springframework.web.bind.annotation.RestController;
    9. import java.util.List;
    10. @RestController
    11. @RequestMapping("building")
    12. public class BuildingController {
    13. @Autowired
    14. private BuildingServer buildingServer;
    15. //查询所有的楼房信息
    16. @RequestMapping("findAllBuilding")
    17. public String findAllBuilding(){
    18. return JSON.toJSONString(buildingServer.findAllBuilding());
    19. }
    20. //查询所有的楼房和住户
    21. @RequestMapping("findAll")
    22. public String findAll(Integer page){
    23. return buildingServer.findAllBuildingResident(page);
    24. }
    25. //新增房屋
    26. @RequestMapping("saveBuilding")
    27. public String saveBuilding(Building building){
    28. return buildingServer.saveBuilding(building);
    29. }
    30. //根据id查询房屋
    31. @RequestMapping("findBuildBybId")
    32. public String findBuildBybId(Integer bId){
    33. return JSON.toJSONString(buildingServer.findBuildingBybId(bId));
    34. }
    35. //删除房屋信息
    36. @RequestMapping("deleteBuilding")
    37. public String deleteBuilding(Integer bId){
    38. int num = buildingServer.deleteBuilding(bId);
    39. return JSON.toJSONString((num > 0) ? "操作成功":"操作失败");
    40. }
    41. }

    CarController

    1. package com.property.controller;
    2. import com.alibaba.fastjson.JSON;
    3. import com.property.pojo.Car;
    4. import com.property.service.CarService;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.web.bind.annotation.RequestMapping;
    7. import org.springframework.web.bind.annotation.RestController;
    8. @RestController
    9. @RequestMapping("car")
    10. public class CarController {
    11. @Autowired
    12. private CarService carService;
    13. @RequestMapping("findAll")
    14. public String findAll(Integer page){
    15. return carService.findAllCar(page);
    16. }
    17. //新增车位信息
    18. @RequestMapping("saveCar")
    19. public String saveCar(Car car,String rName){
    20. return carService.saveCar(car,rName);
    21. }
    22. //通过id查询车位信息
    23. @RequestMapping("findCarBycId")
    24. public String findCarBycId(Integer cId){
    25. return carService.findCarBycId(cId);
    26. }
    27. //删除车位信息
    28. @RequestMapping("deleteCar")
    29. public String deleteCar(Integer cId){
    30. return carService.deleteCar(cId);
    31. }
    32. }

    ResidentController

    1. package com.property.controller;
    2. import com.alibaba.fastjson.JSON;
    3. import com.property.pojo.Resident;
    4. import com.property.service.ResidentService;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.web.bind.annotation.RequestMapping;
    7. import org.springframework.web.bind.annotation.RestController;
    8. @RestController
    9. @RequestMapping("resident")
    10. public class ResidentController {
    11. @Autowired
    12. private ResidentService residentService;
    13. //显示所有的住户信息
    14. @RequestMapping("findAllResident")
    15. public String findAllResident(Integer page){
    16. return residentService.findAllResident(page);
    17. }
    18. //新增住户
    19. @RequestMapping("saveResident")
    20. public String saveResident(Resident resident){
    21. return residentService.saveResident(resident);
    22. }
    23. //删除住户
    24. @RequestMapping("deleteResident")
    25. public String deleteResident(Integer rId){
    26. int num = residentService.deleteResident(rId);
    27. return JSON.toJSONString((num > 0) ? "操作成功":"操作失败");
    28. }
    29. //通过id查询住户
    30. @RequestMapping("findResidentByrId")
    31. public String findResidentByrId(Integer rId){
    32. return JSON.toJSONString(residentService.findResidentByrId(rId));
    33. }
    34. }

    StaffController

    1. package com.property.controller;
    2. import com.alibaba.fastjson.JSON;
    3. import com.github.pagehelper.PageHelper;
    4. import com.github.pagehelper.PageInfo;
    5. import com.property.pojo.Staff;
    6. import com.property.service.StaffService;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.web.bind.annotation.RequestMapping;
    9. import org.springframework.web.bind.annotation.RestController;
    10. import java.sql.Date;
    11. import java.util.List;
    12. import java.util.regex.Pattern;
    13. @RequestMapping("staff")
    14. @RestController
    15. public class StaffController {
    16. @Autowired
    17. private StaffService staffService;
    18. //查询员工
    19. @RequestMapping("findAllStaff")
    20. public String findAllStaff(Integer page){
    21. return staffService.findAllStaff(page);
    22. }
    23. //新增/更新员工
    24. @RequestMapping("saveUpdateStaff")
    25. public String saveStaff(Staff staff){
    26. return staffService.updateOrSaveStaff(staff);
    27. }
    28. //删除员工
    29. @RequestMapping("deleteStaff")
    30. public String delete(Integer sId){
    31. int num = staffService.deleteStaff(sId);
    32. return JSON.toJSONString(num >0 ?"删除成功":"删除失败");
    33. }
    34. //根据id查询员工
    35. @RequestMapping("findBysId")
    36. public String findBysId(Integer sId){
    37. Staff staff = staffService.findBysId(sId);
    38. return JSON.toJSONString(staff);
    39. }
    40. }

    UserController

    1. package com.property.controller;
    2. import com.alibaba.fastjson.JSON;
    3. import com.github.pagehelper.PageHelper;
    4. import com.github.pagehelper.PageInfo;
    5. import com.property.pojo.User;
    6. import com.property.service.UserService;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.web.bind.annotation.RequestMapping;
    9. import org.springframework.web.bind.annotation.RequestParam;
    10. import org.springframework.web.bind.annotation.RestController;
    11. import javax.servlet.http.HttpSession;
    12. import java.util.List;
    13. @RestController
    14. @RequestMapping("user")
    15. public class UserController {
    16. @Autowired
    17. private UserService userService;
    18. //接收传过来的用户名和密码 登录
    19. @RequestMapping("login")
    20. public String login(@RequestParam("userName") String username, String password,HttpSession session){
    21. String message = "登录成功";
    22. User user = userService.findUserByName(username);
    23. if(username ==null || password ==null || username.equals("")|| password.equals("")){
    24. message="用户名密码不能为空";
    25. //判断用户名是否存在
    26. }else if(user == null){
    27. message="用户不存在";
    28. //判断密码是否正确
    29. }else if(!user.getuPassword().equals(password)){
    30. message="密码不正确";
    31. }else{
    32. session.setAttribute("user",user);
    33. }
    34. return JSON.toJSONString(message);
    35. }
    36. //获取session中的数据
    37. @RequestMapping("getUser")
    38. public String getSession(HttpSession session){
    39. User user = (User) session.getAttribute("user");
    40. return JSON.toJSONString(user);
    41. }
    42. //退出登录
    43. @RequestMapping("loginOut")
    44. public String loginOut(HttpSession session){
    45. session.removeAttribute("user");
    46. return JSON.toJSONString("true");
    47. }
    48. //查询所有的用户
    49. @RequestMapping("findAllUser")
    50. public String findAllUser(Integer page){
    51. return userService.findAllUser(page);
    52. }
    53. //停用启用
    54. @RequestMapping("stopUser")
    55. public String stopUser(Integer uId){
    56. int num = userService.stopUser(uId);
    57. return JSON.toJSONString(num >0 ? "成功":"失败");
    58. }
    59. @RequestMapping("startUser")
    60. public String startUser(Integer uId){
    61. int num = userService.startUser(uId);
    62. return JSON.toJSONString(num >0 ? "成功":"失败");
    63. }
    64. //新增用户
    65. @RequestMapping("addUser")
    66. public String addUser(User user,String password2){
    67. return userService.updateOrSaveUser(user,password2);
    68. }
    69. //删除用户
    70. @RequestMapping("deleteUserByuId")
    71. public String deleteUser(Integer uId){
    72. int num = userService.deleteUserByuId(uId);
    73. return JSON.toJSONString(num >0 ? "成功":"失败");
    74. }
    75. //通过id查询用户 回显数据
    76. @RequestMapping("findByuId")
    77. public String findByuId(Integer uId){
    78. return JSON.toJSONString(userService.findByuId(uId));
    79. }
    80. }

    拦截器

    1. package com.property.interceptor;
    2. import org.springframework.web.servlet.HandlerInterceptor;
    3. import javax.servlet.http.HttpServletRequest;
    4. import javax.servlet.http.HttpServletResponse;
    5. import javax.servlet.http.HttpSession;
    6. public class MyInterceptor implements HandlerInterceptor {
    7. @Override
    8. public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    9. // 在拦截点执行前拦截,如果返回true则不执行拦截点后的操作(拦截成功)
    10. // 返回false则不执行拦截
    11. HttpSession session = request.getSession();
    12. if(session.getAttribute("user")!=null) {
    13. // 登录成功不拦截
    14. return true;
    15. }else {
    16. // 拦截后进入登录页面
    17. response.sendRedirect("/property/login.html");
    18. return false;
    19. }
    20. }
    21. }

    BuildingServerImpl

    1. package com.property.service.impl;
    2. import com.alibaba.fastjson.JSON;
    3. import com.github.pagehelper.PageHelper;
    4. import com.github.pagehelper.PageInfo;
    5. import com.property.mapper.BuildingMapper;
    6. import com.property.mapper.ResidentMapper;
    7. import com.property.pojo.Building;
    8. import com.property.pojo.Resident;
    9. import com.property.service.BuildingServer;
    10. import org.springframework.beans.factory.annotation.Autowired;
    11. import org.springframework.stereotype.Service;
    12. import java.util.List;
    13. @Service
    14. public class BuildingServerImpl implements BuildingServer {
    15. @Autowired
    16. private BuildingMapper buildingMapper;
    17. @Autowired
    18. private ResidentMapper residentMapper;
    19. @Override
    20. public List findAllBuilding() {
    21. return buildingMapper.findAllBuilding();
    22. }
    23. //查询所有的楼房信息
    24. @Override
    25. public String findAllBuildingResident(Integer page) {
    26. PageHelper.startPage(page,10);
    27. List list = buildingMapper.findAllBuilding();
    28. for(Building build : list){
    29. //通过rBid查询resident住户
    30. List residentList = residentMapper.findResidentByrBid(build.getbId());
    31. build.setResidentList(residentList);
    32. }
    33. PageInfo pageInfo = new PageInfo(list);
    34. return JSON.toJSONString(pageInfo);
    35. }
    36. //新增更新房屋信息
    37. @Override
    38. public String saveBuilding(Building building) {
    39. String message ="操作成功";
    40. int num = 0;
    41. //信息不能为空
    42. if(building.getbUnit()== null || building.getbUnit().equals("") || building.getbBuilding()==null || building.getbBuilding().equals("") ||
    43. building.getbRoomid()==null || building.getbRoomid().equals("") || building.getbHousetype() == null || building.getbHousetype().equals("") ||
    44. building.getbArea() == null || building.getbArea()<=0){
    45. message = "数据不能为空";
    46. }else {
    47. if(building.getbId() != null && building.getbId()!=0){
    48. num = buildingMapper.updateBuilding(building);
    49. }else {
    50. num = buildingMapper.saveBuilding(building);
    51. }
    52. if(num == 0){
    53. message="操作失败";
    54. }
    55. }
    56. return JSON.toJSONString(message);
    57. }
    58. @Override
    59. public Building findBuildingBybId(Integer bId) {
    60. return buildingMapper.findBuildingBybId(bId);
    61. }
    62. //删除用户
    63. @Override
    64. public int deleteBuilding(Integer bId) {
    65. return buildingMapper.deleteBuilding(bId);
    66. }
    67. }

    CarServiceImpl

    1. package com.property.service.impl;
    2. import com.alibaba.fastjson.JSON;
    3. import com.github.pagehelper.PageHelper;
    4. import com.github.pagehelper.PageInfo;
    5. import com.property.mapper.CarMapper;
    6. import com.property.mapper.ResidentMapper;
    7. import com.property.pojo.Car;
    8. import com.property.pojo.Resident;
    9. import com.property.service.CarService;
    10. import org.springframework.beans.factory.annotation.Autowired;
    11. import org.springframework.stereotype.Service;
    12. import java.util.List;
    13. @Service
    14. public class CarServiceImpl implements CarService {
    15. @Autowired
    16. private CarMapper carMapper;
    17. @Autowired
    18. private ResidentMapper residentMapper;
    19. @Override
    20. public String findAllCar(Integer page) {
    21. PageHelper.startPage(page,10);
    22. List list = carMapper.findAllCar();
    23. PageInfo pageInfo = new PageInfo(list);
    24. return JSON.toJSONString(pageInfo);
    25. }
    26. //新增车位信息
    27. @Override
    28. public String saveCar(Car car,String rName) {
    29. String message="操作成功";
    30. int num=0;
    31. if(car.getcCoder()==null || car.getcCoder().equals("")|| car.getcStatus() == null || car.getcStatus().equals("无状态")){
    32. message = "不能为空";
    33. }else {
    34. if(car.getcStatus()!= null && !car.getcStatus().equals("空闲")){
    35. Resident resident = residentMapper.findResidentByrName(rName);
    36. if(resident==null){
    37. message = "住户不存在";
    38. return JSON.toJSONString(message);
    39. }else{
    40. car.setcRid(resident.getrId());
    41. }
    42. }
    43. if(car.getcId() != null && car.getcId() != 0 ){
    44. num = carMapper.updateCar(car);
    45. }else{
    46. num = carMapper.saveCar(car);
    47. }
    48. }
    49. return JSON.toJSONString(message);
    50. }
    51. //查询car 通过id
    52. @Override
    53. public String findCarBycId(Integer cId) {
    54. return JSON.toJSONString(carMapper.findCarBycId(cId));
    55. }
    56. //删除车位信息
    57. @Override
    58. public String deleteCar(Integer cId) {
    59. int num = carMapper.deleteCar(cId);
    60. return JSON.toJSONString(num>0?"操作成功":"操作失败");
    61. }
    62. }

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

  • 相关阅读:
    Python 打包技巧分享:彻底解决 pyinstaller 打包exe文件太大的问题
    将Shopee带到巴黎,印尼MSME产品抢走参观者注意力
    主机重启DBUS及POLKIT服务无法启动
    Knox 代理各类组件
    [datawhale202211]跨模态神经搜索实践:跨模态模型
    代理配置及多套环境的解决方案
    BGP笔记
    温馨提示:不注意这几点,PDT(产品开发团队)就得散!
    博迪投资学·资本市场:第9、14、16章的模型总结
    丁鹿学堂:js进阶之异步解决方案:generator迭代器
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126797908