Java项目:SpringBoot小区物业管理系统

作者主页:夜未央5788

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

文末获取源码

项目介绍

很完美的一个小区物业管理系统源码,本项目包含管理员与普通用户两种角色。
包括房屋管理,车位管理,交费管理,社区服务等等功能

使用人群:
正在做毕设的学生,或者需要项目实战练习的Java学习者

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
4.数据库:MySql 5.7版本;

5.是否Maven项目:是;

技术栈

springboot+mybatis+mysql+maven+thymeleaf

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,项目运行成功后在浏览器中访问:
管理员登录地址:http://localhost:8081/login
管理员账号密码:admin@qq.com/123456

用户登录地址:http://localhost:8081/user/login

用户账号密码:17805052221/123456

运行截图

相关代码

管理员控制器

@RestController
public class AdminController {
    @Autowired
    AdminService service;
    private static final Logger LOG = LoggerFactory.getLogger(AdminController.class);

    @PostMapping("/admin/loginByPassword")
    public ResBody loginByPassword(@RequestBody Map<String, Object> params,
                                   HttpSession session) {
        ResBody resBody = new ResBody();
        String email = params.get("email").toString();
        String password = params.get("password").toString();
        Admin admin = service.findAdmin(email,password);
        if (admin == null){
            resBody.setCode(500);
            resBody.setMsg("登录失败,请重新登录");
        }else {
            session.setAttribute("admin",admin);
            LOG.info(admin.toString());
            resBody.setCode(200);
            resBody.setMsg("登录成功");
        }
        return resBody;
    }

    @PostMapping("/admin/updatePass")
    public ResBody updatePass(@RequestBody Map<String, Object> params,
                              HttpSession session) {
        ResBody resBody = new ResBody();
        String newPsw = params.get("newPsw").toString();
        Admin admin = (Admin) session.getAttribute("admin");
        admin.setPassword(newPsw);
        int i = service.updatePass(admin.getId(),newPsw);
        if (i != 1){
            resBody.setCode(500);
            resBody.setMsg("修改失败,后台出错");
        }else {
            session.setAttribute("admin",admin);
            LOG.info(admin.toString());
            resBody.setCode(200);
            resBody.setMsg("修改成功");
        }
        return resBody;
    }
}

首页控制器

@Controller
public class IndexController {
    @Autowired
    IndexService service;
    @Autowired
    GonggaoService gonggaoService;
    @Autowired
    RepairService repairService;
    @Autowired
    TousuService tousuService;
    @Autowired
    UserService userService;
    @Autowired
    User_PaymentService user_paymentService;
    @Autowired
    RoomService roomService;
    @Autowired
    CarService carService;

    @GetMapping("/login")
    public String login() {
        return "page/template/login";
    }

    @GetMapping("/index")
    public String index() {
        return "index";
    }

    @GetMapping("/console")
    public String console(Model model) {
        int gonggaoCount = gonggaoService.getCount();
        int repairCount = repairService.getCount();
        int tousuCount = tousuService.getCount();
        int userCount = userService.getCount();
        int roomCount = roomService.getCount();
        int roomFreeCount = roomService.getFreeCount();
        int carCount = carService.getCount();
        int carFreeCount = carService.getFreeCount();
        int paymentCount = user_paymentService.getCount();
        int paymentFreeCount = user_paymentService.getFreeCount();
        model.addAttribute("gonggaoCount",gonggaoCount);
        model.addAttribute("repairCount",repairCount);
        model.addAttribute("tousuCount",tousuCount);
        model.addAttribute("userCount",userCount);
        model.addAttribute("roomCount",roomCount);
        model.addAttribute("roomFreeCount",roomFreeCount);
        model.addAttribute("carCount",carCount);
        model.addAttribute("carFreeCount",carFreeCount);
        model.addAttribute("paymentCount",paymentCount);
        model.addAttribute("paymentFreeCount",paymentFreeCount);
        return "page/console/console";
    }

    @GetMapping("/tpl-theme")
    public String tpl(){
        return "page/tpl/tpl-theme";
    }

    @GetMapping("/tpl-password")
    public String password(){
        return "page/tpl/tpl-password";
    }

    @GetMapping("/tpl-user-password")
    public String reader_password(){
        return "page/tpl/tpl-user-password";
    }

    @GetMapping("/tpl-note")
    public String note(){
        return "page/tpl/tpl-note";
    }

    @GetMapping("/user-info")
    public String userinfo(){
        return "page/template/user-info";
    }

    @GetMapping("/building")
    public String building(){
        return "page/template/building";
    }

    @GetMapping("/danyuan")
    public String danyuan(){
        return "page/template/danyuan";
    }

    @GetMapping("/room")
    public String room(){
        return "page/template/room";
    }

    @GetMapping("/gonggao")
    public String gonggao(){
        return "page/template/gonggao";
    }

    @GetMapping("/repair")
    public String repair(){
        return "page/template/repair";
    }

    @GetMapping("/tousu")
    public String tousu(){
        return "page/template/tousu";
    }

    @GetMapping("/payment")
    public String payment(){
        return "page/template/payment";
    }

    @GetMapping("/car")
    public String car(){
        return "page/template/car";
    }

    @GetMapping("/user")
    public String user(){
        return "page/template/user";
    }

    @GetMapping("/user/login")
    public String userlogin(){
        return "page/system/login";
    }

    @GetMapping("/user/index")
    public String userindex(){
        return "page/system/index";
    }

    @GetMapping("/user/console")
    public String userconsole(Model model,HttpSession session){
        User user = (User) session.getAttribute("user");
        Gonggao gonggao = gonggaoService.getGonggao();
        int repairCount = repairService.getCount();
        int tousuCount = tousuService.getCount();
        int paymentCount = user_paymentService.getCount();
        int userRepair = repairService.getCountByUserId(user.getId());
        int userTousu = tousuService.getCountByUserId(user.getId());
        int userPayment = user_paymentService.getCountByUserId(user.getId());
        model.addAttribute("gonggao",gonggao);
        model.addAttribute("userTousu",userTousu);
        model.addAttribute("userRepair",userRepair);
        model.addAttribute("userPayment",userPayment);
        model.addAttribute("repairCount",repairCount);
        model.addAttribute("tousuCount",tousuCount);
        model.addAttribute("paymentCount",paymentCount);
        return "page/system/console";
    }

    @GetMapping("/paymentDetail")
    public String paymentDetail(){
        return "page/template/paymentDetail";
    }
}

用户控制器

@RestController
public class UserController {
    @Autowired
    UserService service;

    @GetMapping("/api/getUsers")
    public ResBody getUsers(@RequestParam int page,
                                   @RequestParam int limit) {
        ResBody resBody = new ResBody();
        int count = service.getCount();
        List<User> list= service.getUsers(page, limit);
        resBody.setCount(count);
        resBody.setData(list);
        resBody.setCode(0);
        return resBody;
    }

    @PostMapping("/api/addUser")
    public ResBody addUser(@RequestBody User user) {
        ResBody resBody = new ResBody();
        int i = service.addUser(user);
        if (i == 1){
            resBody.setCode(200);
            resBody.setMsg("添加成功");
        }else{
            resBody.setCode(500);
            resBody.setMsg("添加失败");
        }
        return resBody;
    }

    @PostMapping("/api/updateUser")
    public ResBody updateUser(@RequestBody User user) {
        ResBody resBody = new ResBody();
        int i = service.updateUser(user);
        if (i == 1){
            resBody.setCode(200);
            resBody.setMsg("修改成功");
        }else{
            resBody.setCode(500);
            resBody.setMsg("修改失败");
        }
        return resBody;
    }

    @GetMapping("/api/stopUser")
    public ResBody delBuilding(@RequestParam int id) {
        ResBody resBody = new ResBody();
        int i = service.stopUser(id);
        if (i == 1){
            resBody.setCode(200);
            resBody.setMsg("停用成功");
        }else{
            resBody.setCode(500);
            resBody.setMsg("停用失败");
        }
        return resBody;
    }

    @GetMapping("/api/findUser")
    public ResBody findBuilding(@RequestParam int page,
                                @RequestParam int limit,
                                @RequestParam String name) {
        ResBody resBody = new ResBody();
        int count = service.getCount(name);
        List<User> list= service.findUser(page, limit,name);
        resBody.setCount(count);
        resBody.setData(list);
        resBody.setCode(0);
        return resBody;
    }

    @PostMapping("/api/loginByPassword")
    public ResBody loginByPassword(@RequestBody Map<String, Object> params,
                                   HttpSession session) {
        ResBody resBody = new ResBody();
        String phone = params.get("phone").toString();
        String password = params.get("password").toString();
        User user = service.loginByPassword(phone,password);
        if (user == null){
            resBody.setCode(500);
            resBody.setMsg("登录失败,请重新登录");
        }else {
            session.setAttribute("user",user);
            resBody.setCode(200);
            resBody.setMsg("登录成功");
        }
        return resBody;
    }

    @PostMapping("/api/updatePass")
    public ResBody updatePass(@RequestBody Map<String, Object> params,
                              HttpSession session) {
        ResBody resBody = new ResBody();
        String newPsw = params.get("newPsw").toString();
        User user = (User) session.getAttribute("user");
        user.setPassword(newPsw);
        int i = service.updatePass(user.getId(),newPsw);
        if (i != 1){
            resBody.setCode(500);
            resBody.setMsg("修改失败,后台出错");
        }else {
            session.setAttribute("user",user);
            resBody.setCode(200);
            resBody.setMsg("修改成功");
        }
        return resBody;
    }
}

后台管理控制类

/**
 * 后台管理控制类
 * @author 82320
 *
 */
@RequestMapping("/admin/system")
@Controller
public class SystemController {

	@Autowired 
	private AdminService adminService ;
	
	@Autowired
	private OperaterLogService  operaterLogService; 
	
	
	/**
	 * 后台管理首页
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String list(Model model){
		return "admin/system/index";
	}
	
	/**
	 * 后台管理登录页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/login",method=RequestMethod.GET)
	public String login(Model model){
		return "admin/system/login";
	}
	
	/**
	 * 管理员退出登录
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/logout")
	public String loginout(HttpServletRequest request){
		request.getSession().setAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY , null);
		return "redirect:/admin/systen/login";
	}
	
	
	/**
	 * 登录表单处理
	 * @param admin
	 * @param cpacha
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/login",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> login(Admin admin,String cpacha,HttpServletRequest request)
	{
		if(admin == null)
		{
			return Result.error(CodeMsg.DATA_ERROR);
		}
		//判断用户输入验证码是否为空
		if(cpacha == null)
		{
			return Result.error(CodeMsg.CPACHA_EMPTY);
		}

		//判断用户输入的验证码是否正确
		String systemCpacha = (String) request.getSession().getAttribute("admin_login");
		if(!systemCpacha.toUpperCase().equals(cpacha.toUpperCase()))
		{
			return Result.error(CodeMsg.CPACHA_ERROR);
		}
		
		//判断用户是否存在
		Admin findByAdminName = adminService.findByAdminName(admin.getAdminName());
		if(findByAdminName == null)
		{
			return Result.error(CodeMsg.USER_NO_EXIST);
		}
		//如果存在,判断字段是否符合要求, 用统一验证实体方法验证是否合法
		findByAdminName.setPassword(admin.getPassword());
		CodeMsg validate = ValidateEntityUtil.validate(findByAdminName);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		
		//以上判断都通过后,进行判断密码是否正确
		if(!findByAdminName.getPassword().equals(admin.getPassword()))
		{
			return Result.error(CodeMsg.USER_PASSWORD_ERROR);
		}
		//创建权限
		request.getSession().setAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY, findByAdminName);
		//添加操作日志
		OperaterLog operaterLog  = new OperaterLog();
		operaterLog.setOperator("【"+findByAdminName.getAdminName()+"】:");
		operaterLog.setContent("登录了拉勾网后台管理系统。");
		operaterLogService.save(operaterLog);
		
		return Result.success(true);
	}
	
	
}

如果也想学习本系统,下面领取。回复:101springboot 

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
该资源是一套基于SpringBoot和Vue开发的小区物业管理系统,包含了源代码、部署说明和系统介绍等文件。该小区物业管理系统实现了业主信息管理物业费用管理、报修管理、投诉建议等功能,并拥有管理员后台管理功能。网站采用前后端分离的方式开发,前端使用Vue框架,后端使用SpringBoot框架,代码规范、接口设计清晰。 在该小区物业管理系统中,业主可以进行业主信息管理、查询物业费用信息、进行报修、提交投诉建议等操作。物业管理员可以进行业主信息管理物业费用管理、报修管理、投诉建议管理等操作,以保证小区物业的正常开展。管理员可以管理所有业主信息、查看数据统计、设置权限等操作,以确保系统的安全和运转。 该资源中的部署说明文件详细介绍了如何搭建该小区物业管理系统的环境和部署步骤,支持Windows和Linux两个平台,易于操作。系统介绍文件详细介绍了该小区物业管理系统的功能和特点,以及实现方式和使用效果,让用户可以更好地了解该项目小区物业管理系统主要面向小区业主和物业管理人员,为小区居民提供高效、便捷的物业管理服务,对保障小区居民的生活质量和小区物业管理水平具有重要价值。此资源的开发具有很强的实用性和推广意义,对于学习前后端分离开发、小区物业管理相关项目的用户来说是一份不错的参考资料。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

夜未央5788

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

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

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

打赏作者

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

抵扣说明:

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

余额充值