基于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
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,
@RequestParam int limit) {
ResBody resBody = new ResBody();
int count = service.getCount();
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) {
@Autowired
DanyuanService service;
@GetMapping("/api/getAllDanyuans")
public ResBody getAllDanyuans(@RequestParam int page,
@RequestParam int limit) {
ResBody resBody = new ResBody();
int count = service.getCount();
List<Danyuan> list= service.getAllDanyuans(page, limit);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/addDanyuan")
public ResBody addDanyuan(@RequestBody Danyuan danyuan) {
ResBody resBody = new ResBody();
int i = service.addDanyuan(danyuan);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updateDanyuan")
public ResBody updateDanyuan(@RequestBody Danyuan danyuan) {
ResBody resBody = new ResBody();
int i = service.updateDanyuan(danyuan);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}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{
}
@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 resBody;
}
@GetMapping("/api/findRoom")
public ResBody findBuilding(@RequestParam int page,
@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;
}
}
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@GetMapping("/api/getAllToususByUser")
public ResBody getAllToususByUser(@RequestParam int page,
@RequestParam int limit, HttpSession session){
ResBody resBody = new ResBody();
User user = (User) session.getAttribute("user");
int count = service.getCount(user.getId());
List<Tousu> list= service.getAllToususByUser(page, limit,user.getId());
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/addTousu")
public ResBody addTousu(@RequestBody Tousu tousu,HttpSession session) {
ResBody resBody = new ResBody();
User user = (User) session.getAttribute("user");
if (user!=null){
tousu.setUser_id(user.getId());
}
int i = service.addTousu(tousu);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updateTousu")
public ResBody updateTousu(@RequestBody Tousu tousu) {
ResBody resBody = new ResBody();
int i = service.updateTousu(tousu);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
resBody.setMsg("修改失败");
}
@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){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
resBody.setMsg("修改失败");
resBody.setMsg("修改失败");
}
return resBody;
}
@GetMapping("/api/delPayment")
public ResBody delPayment(@RequestParam int id) {
ResBody resBody = new ResBody();
int i = service.delPayment(id);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("删除成功");
}else{
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;
}
}
public int updateRepair(Repair repair) {
return template.update("update repair set `status` = ?,`result` = ? where id = ?",
repair.getStatus(),repair.getResult(),repair.getId());
}
public int delRepair(int id) {
return template.update("DELETE from repair where id=?",id);
}
public int getCount(String name) {
int count = template.queryForObject("select count(*) from repair where content like '%"+name+"%' ", Integer.class);
return count;
}
public List<Repair> findRepair(int page, int limit, String name) {
List<Repair> list = template.query("select * from repair where status = "+name+" 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 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;
}
}
}
resBody.setCode(0);
return resBody;
}
@GetMapping("/api/getAllRepairsByUser")
public ResBody getAllRepairsByUser(@RequestParam int page,
@RequestParam int limit, HttpSession session){
ResBody resBody = new ResBody();
User user = (User) session.getAttribute("user");
int count = service.getCountByUserId(user.getId());
List<Repair> list= service.getAllRepairsByUser(page, limit,user.getId());
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/addRepair")
public ResBody addRepair(@RequestBody Repair repair,HttpSession session) {
ResBody resBody = new ResBody();
User user = (User) session.getAttribute("user");
if (user!=null){
repair.setUser_id(user.getId());
}
int i = service.addRepair(repair);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updateRepair")
public ResBody updateRepair(@RequestBody Repair repair) {
ResBody resBody = new ResBody();
int i = service.updateRepair(repair);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
@RequestParam int limit, HttpSession session){
ResBody resBody = new ResBody();
User user = (User) session.getAttribute("user");
int count = service.getCount(user.getId());
List<Tousu> list= service.getAllToususByUser(page, limit,user.getId());
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/addTousu")
public ResBody addTousu(@RequestBody Tousu tousu,HttpSession session) {
ResBody resBody = new ResBody();
User user = (User) session.getAttribute("user");
if (user!=null){
tousu.setUser_id(user.getId());
}
int i = service.addTousu(tousu);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updateTousu")
public ResBody updateTousu(@RequestBody Tousu tousu) {
ResBody resBody = new ResBody();
int i = service.updateTousu(tousu);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
resBody.setMsg("修改失败");
}
return resBody;
}
@GetMapping("/api/delTousu")
public ResBody delTousu(@RequestParam int id) {
ResBody resBody = new ResBody();
int i = service.delTousu(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());
}
public int delRepair(int id) {
return template.update("DELETE from repair where id=?",id);
}
public int getCount(String name) {
int count = template.queryForObject("select count(*) from repair where content like '%"+name+"%' ", Integer.class);
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,
@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);
}
@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";
}
repair.setUser_id(user.getId());
}
int i = service.addRepair(repair);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updateRepair")
public ResBody updateRepair(@RequestBody Repair repair) {
ResBody resBody = new ResBody();
int i = service.updateRepair(repair);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
resBody.setMsg("修改失败");
}
return resBody;
}
@GetMapping("/api/delRepair")
public ResBody delRepair(@RequestParam int id) {
ResBody resBody = new ResBody();
int i = service.delRepair(id);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("删除成功");
}else{
resBody.setCode(500);
resBody.setMsg("删除失败");
}
return resBody;
}
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("成功");
}else{
resBody.setCode(500);
resBody.setMsg("失败");
}
return resBody;
}
@PostMapping("/api/fenpeiCar")
}
@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";
}
@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")