基于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
}
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;
}
}
}
}
return resBody;
}
@GetMapping("/api/delGonggao")
public ResBody delBuilding(@RequestParam int id) {
ResBody resBody = new ResBody();
int i = service.delGonggao(id);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("删除成功");
}else{
resBody.setCode(500);
resBody.setMsg("删除失败");
}
return resBody;
}
@GetMapping("/api/findGonggao")
public ResBody findBuilding(@RequestParam int page,
@RequestParam int limit,
@RequestParam String name) {
ResBody resBody = new ResBody();
int count = service.getCount(name);
List<Gonggao> list= service.findGonggao(page, limit,name);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
}
@RestController
public class DanyuanController {
@Autowired
DanyuanService service;
@GetMapping("/api/getAllDanyuans")
public ResBody getAllDanyuans(@RequestParam int page,
@RequestParam int limit) {
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updatePayment")
public ResBody updatePayment(@RequestBody Payment payment) {
ResBody resBody = new ResBody();
int i = service.updatePayment(payment);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
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);
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;
}
public List<Tousu> findTousu(int page, int limit, String name) {
List<Tousu> list = template.query("select * from tousu where status = "+name+" 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 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);
public class RepairController {
@Autowired
RepairService service;
@GetMapping("/api/getAllRepairs")
public ResBody getAllRepairs(@RequestParam int page,
@RequestParam int limit) {
ResBody resBody = new ResBody();
int count = service.getCount();
List<Repair> list= service.getAllRepairs(page, limit);
resBody.setCount(count);
resBody.setData(list);
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("添加失败");
@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("添加失败");
}
return resBody;
}
@GetMapping("/api/jiaofei")
public ResBody jiaofei(@RequestParam int id) {
ResBody resBody = new ResBody();
int i = service.jiaofei(id);
if (i == 1){
resBody.setCode(200);
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);
@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) {
ResBody resBody = new ResBody();
int i = service.updateBuilding(building);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
resBody.setMsg("修改失败");
}
return resBody;
}
@GetMapping("/api/delBuilding")
public ResBody delBuilding(@RequestParam int id) {
ResBody resBody = new ResBody();
int i = service.delBuilding(id);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("删除成功");
}else{
}
}
@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("添加成功");
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;
}
@GetMapping("/api/findRepair")
public ResBody findRepair(@RequestParam int page,
@RequestParam int limit,
@RequestParam String name) {
ResBody resBody = new ResBody();
int count = 0;
List<Repair> list= new ArrayList<>();
if (name.isEmpty()){
count = service.getCount();
list= service.getAllRepairs(page, limit);
}else {
count = service.getCount(name);
list= service.findRepair(page, limit,name);
}
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
}
public class PaymentController {
@Autowired
PaymentService service;
@GetMapping("/api/getAllPayments")
public ResBody getAllPayments(@RequestParam int page,
@RequestParam int limit) {
ResBody resBody = new ResBody();
int count = service.getCount();
List<Payment> list= service.getAllPayments(page, limit);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@PostMapping("/api/addPayment")
public ResBody addBuilding(@RequestBody Payment payment) {
ResBody resBody = new ResBody();
int i = service.addPayment(payment);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("添加成功");
}else{
resBody.setCode(500);
resBody.setMsg("添加失败");
}
return resBody;
}
@PostMapping("/api/updatePayment")
public ResBody updatePayment(@RequestBody Payment payment) {
ResBody resBody = new ResBody();
int i = service.updatePayment(payment);
if (i == 1){
resBody.setCode(200);
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) {
ResBody resBody = new ResBody();
int i = service.updateBuilding(building);
if (i == 1){
resBody.setCode(200);
resBody.setMsg("修改成功");
}else{
resBody.setCode(500);
resBody.setMsg("修改失败");
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
public class User_RoomController {
@Autowired
User_RoomService service;
@GetMapping("/api/findRoomRecordById")
public ResBody findRoomRecordById(@RequestParam int id,@RequestParam int page,@RequestParam int limit){
ResBody resBody = new ResBody();
int count = service.getRoomRecordCount(id);
List<User_Room> list= service.findRoomRecordById(id,page,limit);
resBody.setCount(count);
resBody.setData(list);
resBody.setCode(0);
return resBody;
}
@GetMapping("/api/stopRoomByUserId")
public ResBody stopRoomByUserId(@RequestParam int id){
ResBody resBody = new ResBody();
}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
public class User_RoomController {
@Autowired
User_RoomService service;
@GetMapping("/api/findRoomRecordById")
public ResBody findRoomRecordById(@RequestParam int id,@RequestParam int page,@RequestParam int limit){
ResBody resBody = new ResBody();
int count = service.getRoomRecordCount(id);
List<User_Room> list= service.findRoomRecordById(id,page,limit);
resBody.setCount(count);
resBody.setData(list);
}
resBody.setCount(count);
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,?,?,?,?,?)",
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("修改成功");
}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){
@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";