基于javaweb+mysql的springboot小区物业管理系统(java+springboot+thymeleaf+html+maven+mysql)

基于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

使用说明

  1. 使用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
            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;
    }

    @GetMapping("/api/findRepair")
    public ResBody findRepair(@RequestParam int page,
                                @RequestParam int limit,
                                @RequestParam 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 int getCountByUserId(Integer id) {
        int count = template.queryForObject("select count(*) from tousu where user_id = "+id, Integer.class);
        return count;
    }

    public int getCount(Integer id) {
        int count = template.queryForObject("select count(*) from tousu where user_id = "+id, Integer.class);
        return count;
    }

    public List<Tousu> getAllToususByUser(int page, int limit, Integer id) {
        List<Tousu> list = template.query("select * from tousu where user_id = ? limit ?,?" ,new Object[]{id,(page-1)*limit,limit},
                new BeanPropertyRowMapper(Tousu.class));
        if (!list.isEmpty()){
            return list;
        }else{
            return null;
        }
    }
}
package com.example.demo.dao;

@Repository
public class RepairDao {
        }else{
            resBody.setCode(500);
            resBody.setMsg("删除失败");
        }
        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;
    }
}
package com.example.demo.controller;

        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();
        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;
    }

    @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);
        return count;
    }

    public List<Tousu> getAllToususByUser(int page, int limit, Integer id) {
        List<Tousu> list = template.query("select * from tousu where user_id = ? limit ?,?" ,new Object[]{id,(page-1)*limit,limit},
                new BeanPropertyRowMapper(Tousu.class));
        if (!list.isEmpty()){
            return list;
        }else{
            return null;
        }
    }
}
package com.example.demo.dao;

@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));
        }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{
            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;

@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("修改失败");
        }
        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;
    }
}
package com.example.demo.controller;

@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);
        }else {
            count = service.getCount(name);
            list= service.findTousu(page, limit,name);
        }
        resBody.setCount(count);
        resBody.setData(list);
        resBody.setCode(0);
        return resBody;
    }

}
package com.example.demo.dao;

@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) {

    @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";
    }
        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;
    }

    @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;
            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 {
            resBody.setCode(200);
            resBody.setMsg("修改成功");
        }else{
            resBody.setCode(500);
            resBody.setMsg("修改失败");
        }
        return resBody;
    }

    @GetMapping("/api/delRoom")
    public ResBody delRoom(@RequestParam int id) {
        ResBody resBody = new ResBody();
        int i = service.delRoom(id);
        if (i == 1){
            resBody.setCode(200);
            resBody.setMsg("删除成功");
        }else{
            resBody.setCode(500);
            resBody.setMsg("删除失败");
        }
        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;
    }

    @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{
            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 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);
        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")
    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;
    }
}
package com.example.demo.config;


@RestController
public class User_PaymentController {
    @Autowired
    User_PaymentService service;

    @GetMapping("/api/getAllPaymentDetails")
    public ResBody getAllPaymentDetails(@RequestParam int page,
                                        @RequestParam int limit, HttpSession session) {
        User user = (User) session.getAttribute("user");
        int count = 0;
        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);

@RestController
public class DanyuanController {
    @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.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;
    }

    @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;
    }
}
package com.example.demo.controller;

        ResBody resBody = new ResBody();
        int i = service.delRoom(id);
        if (i == 1){
            resBody.setCode(200);
            resBody.setMsg("删除成功");
        }else{
            resBody.setCode(500);
            resBody.setMsg("删除失败");
        }
        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;
    }
}
package com.example.demo.controller;

    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("删除成功");
        }else{
            resBody.setCode(500);
            resBody.setMsg("删除失败");
        }
        return resBody;
    }

    @GetMapping("/api/findTousu")
    public ResBody findTousu(@RequestParam int page,
                                @RequestParam int limit,
                                @RequestParam String name) {
        ResBody resBody = new ResBody();
        int count = 0;
        List<Tousu> list= new ArrayList<>();
        if (name.isEmpty()){
            count = service.getCount();
            list= service.getAllTousus(page, limit);
        }else {
            count = service.getCount(name);
            list= service.findTousu(page, limit,name);
        }
        resBody.setCount(count);
        resBody.setData(list);
        resBody.setCode(0);
        return resBody;
    }

}
package com.example.demo.dao;
            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;
    }

    @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;
    }
    }

    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 int getCountByUserId(Integer id) {
        int count = template.queryForObject("select count(*) from tousu where user_id = "+id, Integer.class);
        return count;
    }

    public int getCount(Integer id) {
        int count = template.queryForObject("select count(*) from tousu where user_id = "+id, Integer.class);
        }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("修改失败");
        }
        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;
    }


@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;
    }

        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("/ajax/getAllFreeCars")
    public ResBody getAllDanyuans(@RequestParam int type) {
        ResBody resBody = new ResBody();
        List<Car> list= service.getAllFreeCars(type);
        resBody.setData(list);
        resBody.setCode(0);
        return resBody;
    }
}
package com.example.demo.controller;

@RestController

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值