基于javaweb+mysql的springboot小区物业管理系统(java+springboot+thymeleaf+html+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot小区物业管理系统(java+springboot+thymeleaf+html+maven+mysql)
项目介绍
很完美的一个小区物业管理系统源码,本项目包含管理员与普通用户两种角色。 包括房屋管理,车位管理,交费管理,社区服务等等功能
环境需要
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
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,项目运行成功后在浏览器中访问: 管理员登录地址:http://localhost:8081/login 管理员账号密码:adminqq.com/123456 用户登录地址:http://localhost:8081/user/login 用户账号密码:17805052221/123456
if (i == 1){
resBody.setCode(200);
resBody.setMsg("删除成功");
}else{
resBody.setCode(500);
resBody.setMsg("删除失败");
}
return resBody;
}
@GetMapping("/api/findBuilding")
public ResBody findBuilding(@RequestParam int page,
@RequestParam int limit,
@RequestParam String name) {
ResBody resBody = new ResBody();
int count = service.getCount(name);
List<Building> list= service.findBuilding(page, limit,name);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@GetMapping("/ajax/getAllBuildings")
public ResBody getAllDanyuans() {
ResBody resBody = new ResBody();
List<Building> list= service.getAllBuildings();
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
}
@Repository
public class TousuDao {
@Autowired
JdbcTemplate template;
public int getCount() {
int count = template.queryForObject("select count(*) from tousu", Integer.class);
return count;
}
public List<Tousu> getAllTousus(int page, int limit) {
List<Tousu> list = template.query("select * from tousu limit ?,?" ,new Object[]{(page-1)*limit,limit},
new BeanPropertyRowMapper(Tousu.class));
if (list!=null){
for (Tousu tousu:list){
List<User> users = template.query("select * from user where id = ?" ,
new Object[]{tousu.getUser_id()}, new BeanPropertyRowMapper(User.class));
tousu.setUser(users.get(0));
}
return list;
}else{
return null;
}
}
public int addTousu(Tousu tousu) {
return template.update("insert into tousu values(null,?,?,?,?,?)",
tousu.getContent(),tousu.getUser_id(),0,new Date(),tousu.getResult());
}
public int updateTousu(Tousu tousu) {
return template.update("update tousu set `status` = ?,`result` = ? where id = ?",
tousu.getStatus(),tousu.getResult(),tousu.getId());
}
public int delTousu(int id) {
return template.update("DELETE from tousu where id=?",id);
}
public int getCount(String name) {
int count = template.queryForObject("select count(*) from tousu where content like '%"+name+"%' ", Integer.class);
return count;
}
}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;
}
}
@RestController
}
}
@Repository
public class TousuDao {
@Autowired
JdbcTemplate template;
public int getCount() {
int count = template.queryForObject("select count(*) from tousu", Integer.class);
return count;
}
public List<Tousu> getAllTousus(int page, int limit) {
List<Tousu> list = template.query("select * from tousu limit ?,?" ,new Object[]{(page-1)*limit,limit},
new BeanPropertyRowMapper(Tousu.class));
if (list!=null){
for (Tousu tousu:list){
List<User> users = template.query("select * from user where id = ?" ,
new Object[]{tousu.getUser_id()}, new BeanPropertyRowMapper(User.class));
tousu.setUser(users.get(0));
}
return list;
}else{
return null;
}
}
public int addTousu(Tousu tousu) {
return template.update("insert into tousu values(null,?,?,?,?,?)",
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";
}
}
resBody.setCode(500);
resBody.setMsg("删除失败");
}
return resBody;
}
@GetMapping("/api/findPayment")
public ResBody findPayment(@RequestParam int page,
@RequestParam int limit,
@RequestParam String name) {
ResBody resBody = new ResBody();
int count = service.getCount(name);
List<Payment> list= service.findPayment(page, limit,name);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@GetMapping("/ajax/getAllPayments")
public ResBody getAllPayments() {
ResBody resBody = new ResBody();
List<Payment> list= service.getAllPayments();
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
}
@RestController
public class CarController {
@Autowired
CarService service;
@GetMapping("/api/getAllCars")
public ResBody getAllCars(@RequestParam int page,
@RequestParam int limit) {
ResBody resBody = new ResBody();
int count = service.getCount();
List<Car> list= service.getAllCars(page, limit);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
}
return resBody;
}
@PostMapping("/api/updateCar")
public ResBody updateCar(@RequestBody Car car) {
ResBody resBody = new ResBody();
int i = service.updateCar(car);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
resBody.setMsg("修改失败");
}
return resBody;
}
@GetMapping("/api/delCar")
public ResBody delCar(@RequestParam int id) {
ResBody resBody = new ResBody();
int i = service.delCar(id);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("删除成功");
}else{
resBody.setCode(500);
resBody.setMsg("删除失败");
}
return resBody;
}
@GetMapping("/api/findCar")
public ResBody findCar(@RequestParam int page,
@RequestParam int limit,
@RequestParam String name) {
ResBody resBody = new ResBody();
int count = service.getCount(name);
List<Car> list= service.findCar(page, limit,name);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
}
@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";
}
}
int i = service.fenpei(user_room.getUser_id(),user_room.getRoom_id());
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
}
@RestController
public class User_CarController {
@Autowired
User_CarService service;
@GetMapping("/api/findCarRecordById")
public ResBody findCarRecordById(@RequestParam int id,@RequestParam int page,@RequestParam int limit){
ResBody resBody = new ResBody();
int count = service.getCarRecordCount(id);
List<User_Car> list= service.findCarRecordById(id,page,limit);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@GetMapping("/api/stopCarByUserId")
public ResBody stopCarByUserId(@RequestParam int id){
ResBody resBody = new ResBody();
int i = service.stopCarByUserId(id);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("成功");
@Repository
public class RepairDao {
@Autowired
JdbcTemplate template;
public int getCount() {
int count = template.queryForObject("select count(*) from repair", Integer.class);
return count;
}
public List<Repair> getAllRepairs(int page, int limit) {
List<Repair> list = template.query("select * from repair limit ?,?" ,new Object[]{(page-1)*limit,limit},
new BeanPropertyRowMapper(Repair.class));
if (list!=null){
for (Repair repair:list){
List<User> users = template.query("select * from user where id = ?" ,
new Object[]{repair.getUser_id()}, new BeanPropertyRowMapper(User.class));
repair.setUser(users.get(0));
}
return list;
}else{
return null;
}
}
public int addRepair(Repair repair) {
return template.update("insert into repair values(null,?,?,?,?,?)",
repair.getContent(),repair.getUser_id(),0,new Date(),repair.getResult());
}
public int updateRepair(Repair repair) {
return template.update("update repair set `status` = ?,`result` = ? where id = ?",
repair.getStatus(),repair.getResult(),repair.getId());
}
resBody.setMsg("成功");
}else {
resBody.setCode(500);
resBody.setMsg("失败");
}
return resBody;
}
}
@RestController
public class BuildingController {
@Autowired
BuildingService service;
@GetMapping("/api/getAllBuildings")
public ResBody getAllBuildings(@RequestParam int page,
@RequestParam int limit) {
ResBody resBody = new ResBody();
int count = service.getCount();
List<Building> list= service.getAllBuildings(page, limit);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/addBuilding")
public ResBody addBuilding(@RequestBody Building building) {
ResBody resBody = new ResBody();
int i = service.addBuilding(building);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updateBuilding")
public ResBody updateBuilding(@RequestBody Building building) {
}else{
resBody.setCode(500);
resBody.setMsg("修改失败");
}
return resBody;
}
@GetMapping("/api/delDanyuan")
public ResBody delDanyuan(@RequestParam int id) {
ResBody resBody = new ResBody();
int i = service.delDanyuan(id);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("删除成功");
}else{
resBody.setCode(500);
resBody.setMsg("删除失败");
}
return resBody;
}
@GetMapping("/api/findDanyuan")
public ResBody findBuilding(@RequestParam int page,
@RequestParam int limit,
@RequestParam String name) {
ResBody resBody = new ResBody();
int count = service.getCount(name);
List<Danyuan> list= service.findDanyuan(page, limit,name);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@GetMapping("/ajax/getAllDanyuans")
public ResBody getAllDanyuans() {
ResBody resBody = new ResBody();
List<Danyuan> list= service.getAllDanyuans();
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
}
@RestController
public class CarController {
@Autowired
CarService service;
@GetMapping("/api/getAllCars")
public ResBody getAllCars(@RequestParam int page,
@RequestParam int limit) {
ResBody resBody = new ResBody();
int count = service.getCount();
List<Car> list= service.getAllCars(page, limit);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/addCar")
public ResBody addBuilding(@RequestBody Car car) {
ResBody resBody = new ResBody();
int i = service.addCar(car);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updateCar")
public ResBody updateCar(@RequestBody Car car) {
ResBody resBody = new ResBody();
int i = service.updateCar(car);
if (i == 1){
new BeanPropertyRowMapper(Repair.class));
if (list!=null){
for (Repair repair:list){
List<User> users = template.query("select * from user where id = ?" ,
new Object[]{repair.getUser_id()}, new BeanPropertyRowMapper(User.class));
repair.setUser(users.get(0));
}
return list;
}else{
return null;
}
}
public int getCountByUserId(Integer id) {
int count = template.queryForObject("select count(*) from repair where user_id = "+id, Integer.class);
return count;
}
public List<Repair> getAllRepairsByUser(int page, int limit, Integer id) {
List<Repair> list = template.query("select * from repair where user_id = ? limit ?,?" ,new Object[]{id,(page-1)*limit,limit},
new BeanPropertyRowMapper(Repair.class));
if (!list.isEmpty()){
return list;
}else{
return null;
}
}
}
@RestController
public class RoomController {
@Autowired
RoomService service;
List<User_Payment> list = new ArrayList<>();
if (user!=null){
int user_id=user.getId();
count = service.getCount(user_id);
list= service.getAllPaymentDetails(page, limit,user_id);
}else {
count = service.getCount();
list= service.getAllPaymentDetails(page, limit);
}
ResBody resBody = new ResBody();
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@GetMapping("/api/findPaymentDetail")
public ResBody findPaymentDetail(@RequestParam int page,
@RequestParam int limit,
@RequestParam String name) {
int count = 0;
List<User_Payment> list= new ArrayList<>();
ResBody resBody = new ResBody();
if (name.isEmpty()){
count = service.getCount();
list= service.getAllPaymentDetails(page, limit);
}else {
count = service.getCount(name);
list= service.getAllPaymentDetails(page, limit,name);
}
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/fenpeiPayment")
public ResBody fenpeiPayment(@RequestBody User_Payment user_payment) {
ResBody resBody = new ResBody();
user_payment.setUser_id(user_payment.getId());
int i = service.fenpei(user_payment.getUser_id(),user_payment.getPayment_id(),user_payment.getValue());
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
@RequestParam int limit,
@RequestParam String name) {
int count = 0;
List<Room> list= new ArrayList<>();
ResBody resBody = new ResBody();
if (name.isEmpty()){
count = service.getCount();
list= service.getAllRooms(page, limit);
}else {
count = service.getCount(name);
list= service.findRoom(page, limit,name);
}
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@GetMapping("/ajax/getAllFreeRooms")
public ResBody getAllFreeRooms(@RequestParam int danyuan_id) {
ResBody resBody = new ResBody();
List<Room> list = service.getAllFreeRooms(danyuan_id);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
}
@RestController
public class GonggaoController {
@Autowired
GonggaoService service;
@GetMapping("/api/getAllGonggaos")
public ResBody getAllGonggaos(@RequestParam int page,
@RestController
public class GonggaoController {
@Autowired
GonggaoService service;
@GetMapping("/api/getAllGonggaos")
public ResBody getAllGonggaos(@RequestParam int page,
@RequestParam int limit) {
ResBody resBody = new ResBody();
int count = service.getCount();
List<Gonggao> list= service.getAllGonggaos(page, limit);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/addGonggao")
public ResBody addGonggao(@RequestBody Gonggao gonggao, HttpSession session) {
ResBody resBody = new ResBody();
Admin admin = (Admin) session.getAttribute("admin");
gonggao.setCreateTime(new Date());
gonggao.setCreateBy(admin.getId());
int i = service.addGonggao(gonggao);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updateGonggao")
public ResBody updateGonggao(@RequestBody Gonggao gonggao, HttpSession session) {
ResBody resBody = new ResBody();
Admin admin = (Admin) session.getAttribute("admin");
gonggao.setUpdateTime(new Date());
gonggao.setUpdateBy(admin.getId());
int i = service.updateGonggao(gonggao);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
resBody.setMsg("失败");
}
return resBody;
}
@PostMapping("/api/fenpeiCar")
public ResBody fenpeiCar(@RequestBody User_Car user_car) {
ResBody resBody = new ResBody();
System.out.println(user_car);
user_car.setUser_id(user_car.getId());
//判断该用户当前有无房间,如果有,先退房再入住。
int count = service.findCar(user_car.getUser_id());
if (count == 1){
service.outCar(user_car.getUser_id());
}
int i = service.fenpei(user_car.getUser_id(),user_car.getCar_id());
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
}
public class SessionInterceptor implements HandlerInterceptor {
@Override
public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
throws Exception {
}
@Override
public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
throws Exception {
}
@Override