Springboot+Vue實(shí)現(xiàn)物業(yè)管理系統(tǒng)
項(xiàng)目編號(hào):BS-XX-137
一,項(xiàng)目簡(jiǎn)介
使用SpringBoot+Mybatis+BootStrap+Layui+VUE制作的智慧小區(qū)物業(yè)管理系統(tǒng)。 本系統(tǒng)采用了 B/S 架構(gòu),Java、Html、Css、Js 等技術(shù),使用了主流的后臺(tái)開(kāi)發(fā)框架SpringBoot(SpringMVC+Spring+Mybatis),前端開(kāi)發(fā)框架使用了 LayUI、Vue、JQuery 以及 Vue的前端組件庫(kù) Element-UI,采用了開(kāi)源的輕量級(jí)數(shù)據(jù)庫(kù) Mysql 進(jìn)行開(kāi)發(fā)。實(shí)現(xiàn)了小區(qū)管理、房產(chǎn)管理、設(shè)備管理、業(yè)主管理、服務(wù)管理、車位管理等主要功能。提升物業(yè)管理水平,提高工作效率,降低成本,便于物業(yè)快速回收物業(yè)費(fèi);擴(kuò)大服務(wù)范圍和能力,方便住戶,提升用戶滿意度;為物業(yè)公司擴(kuò)展了新的收入渠道:租賃中介、社區(qū)團(tuán)購(gòu)、物業(yè)服務(wù);為住戶繳納物業(yè)費(fèi)、水電、停車費(fèi)等生活費(fèi)用,提供在線支付,方便快捷。
二,環(huán)境介紹
語(yǔ)言環(huán)境:Java:? jdk1.8
數(shù)據(jù)庫(kù):Mysql: mysql5.7
應(yīng)用服務(wù)器:Tomcat:? tomcat8.5.31
開(kāi)發(fā)工具:IDEA或eclipse
后臺(tái)開(kāi)發(fā)技術(shù):Springboot+Mybatis
前端開(kāi)發(fā)技術(shù):Vue+Layui+Jquery
三,系統(tǒng)展示
用戶登陸

首頁(yè)儀表盤

小區(qū)管理

房產(chǎn)管理

業(yè)主相關(guān)信息管理

車位信息及使用管理

業(yè)務(wù)相關(guān)服務(wù)管理模塊

小區(qū)資產(chǎn)管理

小區(qū)收費(fèi)管理

管理員管理

用戶組角色管理

系統(tǒng)設(shè)置

1.? 導(dǎo)入項(xiàng)目到IDE工具(如Eclipse)2.? 導(dǎo)入數(shù)據(jù)庫(kù)文件estatedb.sql到MySQL3.? 修改src/main/resources/application.yml文件中的數(shù)據(jù)庫(kù)鏈接地址、賬號(hào)密碼4.? 運(yùn)行啟動(dòng)類com.es.estatemanagement.EstateManagementApplication,啟動(dòng)項(xiàng)目,默認(rèn)端口為88885.? 瀏覽器訪問(wèn)http://localhost:8888/,進(jìn)入首頁(yè)
四,核心代碼展示
package com.es.estatemanagement.controller;import com.es.estatemanagement.common.MessageConstant;import com.es.estatemanagement.common.PageResult;import com.es.estatemanagement.common.Result;import com.es.estatemanagement.common.StatusCode;import com.es.estatemanagement.domain.Building;import com.es.estatemanagement.domain.Community;import com.es.estatemanagement.service.BuildingService;import com.es.estatemanagement.service.CommunityService;import com.github.pagehelper.Page;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import java.util.List;import java.util.Map;/**
* @Auth: znz
* @Desc:
*/public class BuildingController { ? ?
? ?private BuildingService buildingService; ? ?
? ?public Result find(){
? ? ? ?List<Building> all = buildingService.findAll(); ? ? ? ?return new Result(false,200,"請(qǐng)求成功adasdasdas",all);
? ?} ? ?
? ?public PageResult search({
? ? ? ?Page<Building> page = buildingService.search(searchMap); ? ? ? ? Map searchMap)return new PageResult(true, StatusCode.OK, MessageConstant.COMMUNITY_SEARCH_SUCCESS,page.getResult(),page.getTotal());
? ?} ? ?
? ?public Result add({ ? ? ? ? Building community)Boolean add = buildingService.add(community); ? ? ? ?return new Result(true,StatusCode.OK,MessageConstant.COMMUNITY_ADD_SUCCESS);
? ?} ? ?
? ?public Result findById(Integer id){ ? ? ? ?Building community = buildingService.findById(id); ? ? ? ?return new Result(true,StatusCode.OK,MessageConstant.COMMUNITY_FIND_BY_ID_SUCCESS,community);
? ?} ? ?
? ?public Result update({ ? ? ? ? Building community)Boolean add = buildingService.update(community); ? ? ? ?return new Result(true,StatusCode.OK,MessageConstant.COMMUNITY_UPDATE_SUCCESS);
? ?} ? ?
? ?public Result del({ ? ? ? ? List<Integer> ids)Boolean flag = buildingService.del(ids); ? ? ? ?return new Result(true,StatusCode.OK,MessageConstant.COMMUNITY_DELETE_SUCCESS);
? ?}
}
package com.es.estatemanagement.controller;import com.es.estatemanagement.common.MessageConstant;import com.es.estatemanagement.common.PageResult;import com.es.estatemanagement.common.Result;import com.es.estatemanagement.common.StatusCode;import com.es.estatemanagement.domain.Community;import com.es.estatemanagement.service.CommunityService;import com.github.pagehelper.Page;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.*;import java.util.List;import java.util.Map;/**
* @Auth: zhuan
* @Desc: 小區(qū)管理控制層:只負(fù)責(zé)接收前端瀏覽器發(fā)送的請(qǐng)求和請(qǐng)求參數(shù),調(diào)用service層獲取業(yè)務(wù)邏輯加工處理后的數(shù)據(jù)
*/public class CommunityController { ? ?
? ?
? ?private CommunityService communityService; ? ?
? ?public Result find(){
? ? ? ?List<Community> all = communityService.findAll(); ? ? ? ?return new Result(false,200,"請(qǐng)求成功adasdasdas",all);
? ?} ? ?
? ?public PageResult search({
? ? ? ?Page<Community> page = communityService.search(searchMap); ? ? ? ? Map searchMap)return new PageResult(true, StatusCode.OK, MessageConstant.COMMUNITY_SEARCH_SUCCESS,page.getResult(),page.getTotal());
? ?} ? ?
? ?public Result add({ ? ? ? ? Community community)Boolean add = communityService.add(community); ? ? ? ?return new Result(true,StatusCode.OK,MessageConstant.COMMUNITY_ADD_SUCCESS);
? ?} ? ?
? ?public Result findById(Integer id){ ? ? ? ?Community community = communityService.findById(id); ? ? ? ?return new Result(true,StatusCode.OK,MessageConstant.COMMUNITY_FIND_BY_ID_SUCCESS,community);
? ?} ? ?
? ?public Result update({ ? ? ? ? Community community)Boolean add = communityService.update(community); ? ? ? ?return new Result(true,StatusCode.OK,MessageConstant.COMMUNITY_UPDATE_SUCCESS);
? ?} ? ?// /community/updateStatus/0/1
? ?
? ?public Result updateStatus({ ? ? ? ? String status, Integer id)Boolean flag = communityService.updateStatus(status,id); ? ? ? ?return new Result(true,StatusCode.OK,MessageConstant.COMMUNITY_UPDATE_STATUS_SUCCESS);
? ?} ? ?
? ?public Result del({ ? ? ? ? List<Integer> ids)Boolean flag = communityService.del(ids); ? ? ? ?return new Result(true,StatusCode.OK,MessageConstant.COMMUNITY_DELETE_SUCCESS);
? ?}
}
package com.es.estatemanagement.controller;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.util.Arrays;import java.util.HashMap;import java.util.Iterator;import java.util.Map;import java.util.UUID;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.es.estatemanagement.common.MessageConstant;import com.es.estatemanagement.common.Result;import com.es.estatemanagement.common.StatusCode;import org.apache.commons.fileupload.servlet.ServletFileUpload;import org.springframework.util.FileCopyUtils;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController;import org.springframework.web.multipart.MultipartFile;import org.springframework.web.multipart.MultipartHttpServletRequest;import com.alibaba.fastjson.JSONObject;/**
* @Auth: zhuan
* @Desc: 文件上傳-控制器
*/public class FileController { /**
* 功能描述: 上傳文件
* @param file 上傳文件的參數(shù)名,必須和前端參數(shù)名稱一致
* @param request 請(qǐng)求對(duì)象
* @param response 響應(yīng)對(duì)象
* @return : com.es.estatemanagement.common.Result
*/
public Result uploads( MultipartFile file, HttpServletRequest request,HttpServletResponse response)throws IOException { //獲取當(dāng)前項(xiàng)目所在絕對(duì)路徑
String absolutePath = System.getProperty("user.dir"); //當(dāng)前項(xiàng)目名稱,可以自定義
String projectName = "/estate-management"; //文件上傳后所在絕對(duì)路徑
String savePath = absolutePath+"/src/main/resources/static/fileupload/"; //保存在數(shù)據(jù)庫(kù)的文件地址
String saveUrl = "/fileupload/"; // 定義允許上傳的文件擴(kuò)展名
HashMap<String, String> extMap = new HashMap<String, String>();
extMap.put("image", "gif,jpg,jpeg,png,bmp"); // 最大文件大小
long maxSize = 10000000; //10M
response.setContentType("text/html; charset=UTF-8"); if (!ServletFileUpload.isMultipartContent(request)) { return new Result(false, StatusCode.ERROR,MessageConstant.NO_FILE_SELECTED);
} File uploadDir = new File(savePath); // 判斷文件夾是否存在,如果不存在則創(chuàng)建文件夾
if (!uploadDir.exists()) {
uploadDir.mkdirs();
} // 檢查目錄寫權(quán)限
if (!uploadDir.canWrite()) { return new Result(false, StatusCode.ERROR,MessageConstant.NO_WRITE_PERMISSION);
} String dirName = request.getParameter("dir"); if (dirName == null) {
dirName = "image";
} if (!extMap.containsKey(dirName)) { return new Result(false, StatusCode.ERROR,MessageConstant.INCORRECT_DIRECTORY_NAME);
} MultipartHttpServletRequest mRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = mRequest.getFileMap(); String fileName = null;
Iterator<Map.Entry<String, MultipartFile>> iter = fileMap.entrySet().iterator(); for (String s : fileMap.keySet()) {
} for (Iterator<Map.Entry<String, MultipartFile>> it = fileMap.entrySet().iterator(); it.hasNext();) {
Map.Entry<String, MultipartFile> entry = it.next(); MultipartFile mFile = entry.getValue();
fileName = mFile.getOriginalFilename(); // 檢查文件大小
if (mFile.getSize() > maxSize) { return new Result(false, StatusCode.ERROR,MessageConstant.SIZE_EXCEEDS__LIMIT);
} String fileExt = fileName.substring(fileName.lastIndexOf(".")+1); if (!Arrays.<String> asList(extMap.get(dirName).split(",")).contains(fileExt)) { return new Result(false, StatusCode.ERROR,MessageConstant.FILE_TYPE_ERROR);
} UUID uuid = UUID.randomUUID(); String path = savePath + uuid.toString() +"."+ fileExt;
System.out.println("文件存儲(chǔ)地址:【"+path+"】");
saveUrl = saveUrl ?+ uuid.toString() +"."+ fileExt; try { BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(path));
FileCopyUtils.copy(mFile.getInputStream(), outputStream);
} catch (IOException e) {
e.printStackTrace();
}
} return new Result(true,StatusCode.OK, MessageConstant.COMMUNITY_PIC_UPLOAD_SUCCESS,saveUrl);
} /**
* 功能描述: 刪除文件
* @param fileName 文件名稱參數(shù),和前臺(tái)傳遞的參數(shù)保持一致
* @return : com.es.estatemanagement.common.Result
*/
public Result fileDel({ String fileName)String name = fileName.replace("/fileupload/",""); //獲取當(dāng)前項(xiàng)目所在絕對(duì)路徑
String absolutePath = System.getProperty("user.dir"); //當(dāng)前項(xiàng)目名稱,可以自定義
String projectName = "/estate-management"; //文件上傳后所在絕對(duì)路徑
String savePath = absolutePath+projectName+"/src/main/resources/static/fileupload/"; File file = new File(savePath+name); if (file.exists()){//文件是否存在
file.delete();//刪除文件
} return new Result(true,StatusCode.OK, MessageConstant.COMMUNITY_PIC_DEL_SUCCESS);
}
}
五,項(xiàng)目總結(jié)
1. 系統(tǒng)上傳的文件會(huì)存放在項(xiàng)目目錄/src/main/resources/static/fileupload2. 項(xiàng)目使用的MySQL驅(qū)動(dòng)版本是5.1.30,如果MySQL版本是8.0以上,需要將pom.xml中的MySQL驅(qū)動(dòng)版本改為8.0以上版本,或者直接將`<version>5.1.30</version>`刪除即可。因?yàn)镾pringboot使用的默認(rèn)MySQL驅(qū)動(dòng)版本為8.0.20? 4. 小區(qū)管理模塊實(shí)現(xiàn)了從前端到控制層、業(yè)務(wù)層、持久層的完整功能,可以參照該模塊實(shí)現(xiàn)其他功能。5. 本系統(tǒng)使用了Mybatis插件TkMapper,TkMapper又名通用 Mapper,封裝了對(duì)單表的 CRUD 操作。通用 Mapper 可以極大的方便開(kāi)發(fā)人員??梢噪S意的按照自己的需要選擇通用方法,還可以很方便的開(kāi)發(fā)自己的通用方法。