# 智慧社区管理系统-基础信息管理-05车位管理

news2024/7/6 19:40:24

一后端

1:entuty

package com.woniu.community.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Parking {
    private int id;
    private String numbers;//车位号
    private int status;//车位状态
    private int ownerId;
    private String remarks;//备注
    private String userName;//业主姓名
    private String tel;//联系方式

}

2:ParkingMapper

package com.woniu.community.mapper;

import com.woniu.community.entity.Parking;

import java.util.List;

public interface ParkingMapper {
    List<Parking> selectAll(String numbers ,int start,int size );
    int count(String numbers) ;
    int insertParking(Parking parking);
    int deleteById(int  id);
    int  updateParking(Parking parking);
    Parking getById(int  id);
}

3:IParlingservice

package com.woniu.community.service;

import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Parking;



public interface IParkingService {
   HttpResult selectAll(String numbers , int pageIndex, int pageSize );
    HttpResult insertParking(Parking parking);
    HttpResult deleteById(int  id);
    HttpResult  updateParking(Parking parking);
    HttpResult getById(int  id);
}

4:ParkingServiceImpl

package com.woniu.community.service.impl;

import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Parking;
import com.woniu.community.mapper.ParkingMapper;
import com.woniu.community.service.IParkingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ParkingServiceImpl implements IParkingService {
    @Autowired(required = false)
    private ParkingMapper parkingMapper;

    @Override
    public HttpResult selectAll(String numbers, int pageIndex, int pageSize) {
        HttpResult result=null;
        List<Parking> parkings = parkingMapper.selectAll(numbers, (pageIndex - 1) * pageSize, pageSize);
        int count = parkingMapper.count(numbers);
        if (parkings!=null&&parkings.size()>0){
            result=new HttpResult(parkings,count,200,null);
        }else{
            result=new HttpResult(null,0,500,"没有更多数据");
        }
        return result;
    }



    @Override
    public HttpResult insertParking(Parking parking) {
        HttpResult result=null;
        int count = parkingMapper.insertParking(parking);
        if (count>0){
            result=new HttpResult(null,0,200,"添加成功");
        }else{
            result=new HttpResult(null,0,500,"添加失败");

        }
        return result;
    }

    @Override
    public HttpResult deleteById(int id) {
        HttpResult result=null;
        int count = parkingMapper.deleteById(id);
        if (count>0){
            result=new HttpResult(null,0,200,"删除成功");
        }else{
            result=new HttpResult(null,0,500,"删除失败");

        }
        return result;
    }

    @Override
    public HttpResult updateParking(Parking parking) {
        HttpResult result=null;
        int count = parkingMapper.updateParking(parking);
        if (count>0){
            result=new HttpResult(null,0,200,"修改成功");
        }else{
            result=new HttpResult(null,0,500,"修改失败");

        }
        return result;
    }

    @Override
    public HttpResult getById(int id) {
        HttpResult result=null;
        Parking parking = parkingMapper.getById(id);
        if (parking!=null){
            result=new HttpResult(parking,0,200,null);
        }else{
            result=new HttpResult(null,0,500,null);
        }
        return result;
    }
}

5:ParkingController

package com.woniu.community.controller;

import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Parking;
import com.woniu.community.service.IParkingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/parking")
@CrossOrigin(origins = "*")
public class ParkingController {
    @Autowired
    private IParkingService iParkingService;
    @RequestMapping("/list")
    HttpResult selectAll(String numbers , int pageIndex, int pageSize ){
        return  iParkingService.selectAll(numbers,pageIndex,pageSize);
    }
    @PostMapping("/add")
    HttpResult insertParking(@RequestBody Parking parking){
        return  iParkingService.insertParking(parking);
    }
    @RequestMapping("/delete")
    HttpResult deleteById(int  id){
        return iParkingService.deleteById(id);

    }
    @PostMapping("/update")
    HttpResult  updateParking( @RequestBody Parking parking){
        return iParkingService.updateParking(parking);

    }
    @RequestMapping("/info")
    HttpResult getById(int  id){
        return iParkingService.getById(id);

    }
}

6:parkingMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.woniu.community.mapper.ParkingMapper">
    <resultMap id="packMap" type="Parking">
        <result column="id" property="id"/>
        <result column="numbers" property="numbers"/>
        <result column="status" property="status"/>
        <result column="owner_id" property="ownerId"/>
        <result column="remarks" property="remarks"/>
        <result column="username" property="userName"/>
        <result column="tel" property="tel"/>
    </resultMap>
    <select id="selectAll" resultMap="packMap">
        select
               p.id, p.numbers,o.username,o.tel,p.status
        from
             parking as p left join owner as o on
                 p.owner_id=o.id
        <where>
            <if test="numbers!=null and  numbers!='null'">
                and numbers=#{numbers}
            </if>
        </where>
      limit #{start},#{size}
    </select>

    <select id="count" resultType="int">
        select
        count(p.id)
        from
        parking as p left join owner as o on
        p.owner_id=o.id
        <where>
            <if test="numbers!=null and  numbers!='null'">
                and numbers=#{numbers}
            </if>
        </where>
    </select>

    <insert id="insertParking">
    insert into
        parking(numbers,status,owner_id)
        values
        (#{numbers},#{status},#{ownerId})

    </insert>

    <delete id="deleteById">
    delete from parking where id=#{id}
    </delete>

    <update id="updateParking">
        update parking
        set numbers=#{numbers},status=#{status},owner_id=#{ownerId} where id=#{id}

    </update>

    <select id="getById" resultMap="packMap">
    select * from parking where id=#{id}
    </select>
</mapper>

二 前端代码


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="assets/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/right.css" rel="stylesheet">
    <script src="assets/jquery-3.5.1.min.js"></script>
    <script src="assets/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script src="assets/vue.min-v2.5.16.js"></script>
    <script src="assets/vue-router.min-2.7.0.js"></script>
    <script src="assets/axios.min.js"></script>
</head>
<body>
<div id="app" class="container">
    <div class="row">
        <div class="col-md-12" style="height: 30px; line-height: 30px;">
            <input type="text" v-model="numbers">
            <button class="btn btn-danger" @click="doLikeQuery()">查询</button>
            <button class="btn btn-info" @click="doAdd">新增</button>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-striped">
                <caption>车位管理</caption>
                <thead>
                    <tr>
                        <th>车位号</th>
                        <th>业主姓名</th>
                        <th>业主电话</th>
                        <th>状态</th>
                        <th>操作</th>

                    </tr>
                </thead>
                <tbody>
                    <tr v-for="p in parkings">
                        <td>{{p.numbers}}</td>
                        <td>{{p.userName}}</td>
                        <td>{{p.tel}}</td>
                        <td>{{p.status==1?"使用":"未使用"}}</td>
                        <td>
                            <button class="btn btn-danger" @click="doUpdate(p.id)">修改</button>
                            <button class="btn btn-primary"@click="doDelete(p.id)">删除</button>
                        </td>
                    </tr>
                </tbody>
            </table>
            <ul class="pagination" v-for="p in pageNum">
                <li v-if="p==pageIndex" class="active"><a @click="doGO(p)">{{p}}</a></li>
                <li v-else="p==pageIndex"><a @click="doGO(p)">{{p}}</a></li>
            </ul>
        </div>
    </div>
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            parkings:null,
            pageIndex:1,//当前页码
            pageSize:5,//每显示的条数
            pageTotal:0,//总条数
            pageNum:0,//分页
            numbers:null,
        },
        methods: {
            requestParkingList(url){
                axios.get(url).then(response=>{
                    console.log(response.data);
                    this.parkings=response.data.data;//用户列表
                    this.pageTotal=response.data.pageTotal;//总条数
                    this.pageNum=Math.ceil(this.pageTotal / this.pageSize);//计算页数
                })
            },
            doUpdate(id){
                window.parent.main_right.location.href="parking_add_update.html?id="+id;
            },
            doDelete(id){
                var  url="http://localhost:8080/parking/delete?id="+id;
                axios.get(url).then(response=>{
                    if (response.data.code==200){
                        this.doGO(1);
                    }else{
                        alert(response.data.msg)
                    }
                })
            },

            doGO(p){
                this.pageIndex=p;
                var  url="http://localhost:8080/parking/list?pageIndex="+this.pageIndex+"&pageSize="+this.pageSize+"&numbers="+this.numbers;
                this. requestParkingList(url);
            },
            doLikeQuery(){
                if (this.numbers!=null){
                    this.doGO(1);
                }

            },
            doAdd(){
                window.parent.main_right.location.href="parking_add_update.html";

            },
        },
        created: function () {
        var  url="http://localhost:8080/parking/list?pageIndex="+this.pageIndex+"&pageSize="+this.pageSize;
        this. requestParkingList(url);
        }
    });
</script>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="assets/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/right.css" rel="stylesheet">
    <script src="assets/jquery-3.5.1.min.js"></script>
    <script src="assets/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script src="assets/vue.min-v2.5.16.js"></script>
    <script src="assets/vue-router.min-2.7.0.js"></script>
    <script src="assets/axios.min.js"></script>
    <script src="assets/date_picker.js"></script>
</head>
<body>
<div id="app" class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="row">
                <div class="col-md-12" style="text-align: center; font-weight: bold; font-size: 18px; height: 80px; line-height: 80px;">
                    {{title}}
                </div>
            </div>
            <div class="row">
                <div class="col-md-6 col-md-offset-3" style="height: 300px;">
                    <label>车位号</label>
                    <input type="text" class="form-control" v-model="numbers">
                    <div style="margin-top: 30px;margin-bottom: 20px">

                        业主姓名<select v-model="ownerId">
                        <option v-for="o in ownerListParking" :value="o.id">{{o.userName}}</option>
                    </select>
                    </div>

                    <div style="margin-top: 30px;">
                        状态<select v-model="status">
                        <option value="1">使用</option>
                        <option value="0">未使用</option>
                    </select>
                    </div>
                </div>
            <div class="row">
                <div class="col-md-6 col-md-offset-3" style="height: 40px;">
                    <button class="btn btn-primary" @click="doSave">保存</button>
                    <button class="btn btn-default" @click="doCancel">取消</button>
                </div>
            </div>
        </div>
    </div>
        </div>
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            title:null,
            parkingId:null,
            status:null,
            numbers:null,
            ownerListParking:null,
            phone:null,
            ownerId:null,
        },
        methods: {
            ownerList(){
            var  url="http://localhost:8080/owner/list?pageIndex=1&pageSize=100";
                axios.get(url).then(response=>{
                    this.ownerListParking=response.data.data;
                })
            },
            getInfo(){
                var  url="http://localhost:8080/parking/info?id="+this.parkingId;
                axios.get(url).then(response=>{
                    console.log(response.data)
                    this.numbers=response.data.data.numbers;
                    this.status-=response.data.data.status;
                    this.ownerId=response.data.data.ownerId;
                });
            },
            doSave(){
               if (this.parkingId==null) {
                   this.title="添加车位";
                   var  url="http://localhost:8080/parking/add";
                   axios.post(url,{
                       numbers:this.numbers,
                       status:this.status,
                       ownerId:this.ownerId,
                   }).then(response=>{
                       if (response.data.code==200){
                           window.parent.main_right.location.href="parking_list.html";

                       }else{
                           alert(response.data.msg)
                       }
                   })


               }else{
                   this.title="修改车位";
                   var  url="http://localhost:8080/parking/update";
                   axios.post(url,{
                       id:this.parkingId,
                       numbers:this.numbers,
                       status:this.status,
                       ownerId:this.ownerId,
                   }).then(response=>{
                       if (response.data.code==200){
                           window.parent.main_right.location.href="parking_list.html";

                       }else{
                           alert(response.data.msg)
                       }
                   })


               }
            },
            doCancel(){
                history.go(-1);
            },

        },
        created: function () {
        this.ownerList();

            var url=window.location.href;
            console.log(url+"**************")
        if (url.indexOf("id")!=-1){
            this.parkingId=url.substring(url.indexOf("=")+1)
                console.log(this.parkingId)
        }
        if (this.parkingId==null){
            this.title="添加车位"
        }else{
            this.title="修改车位"
            this.getInfo();

        }
        }
    });
</script>
</body>
</html>

三 效果图

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/58931.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SQL 专项笔记

SQL语句分类 1.DDL 数据库定义语言 主要是用于来操作数据库 以及数据库表 关键字 alter drop create truncate DQL 数据库查询语言 主要是用于操作数据库表 主要用于查询数据库中的数据 关键字 selectDML 数据库操纵语言 主要是用于操作数据库中数据表 主要是对数据进行 增加…

Sequence和Item

一、概述 sequence指的是uvm_sequence类&#xff0c;而item指的是uvm_sequence_item类。对于激励生成和场景控制&#xff0c;是由sequence来编织的&#xff0c;而对于激励所需要的具体数据和控制要求&#xff0c;则是从item的成员数据得到的。 二、Sequence Item介绍 item是基…

【前端设计】SDC中生成时钟create_generated_clock语法解析

我们的目标是┏ (゜ω゜)=☞芯片前端全栈工程师~喵! 前言 好久没有写前端设计系列的博客了,这次因为要在系统里加入时钟分频器因此复习一下sdc中关于生成时钟的约束语法,以下内容来自《综合与时序分析的设计约束》和一些自己的理解。 生成时钟 在sdc约束中,由端口输入的…

JavaScript -- 07. 面向对象编程

文章目录面向对象编程1 面向对象编程介绍2 类3 属性4 方法5 构造函数6 封装7 多态8 继承9 对象的内存结构10 原型10.1 原型链10.2 原型的作用&#xff1a;11 修改原型12 instanceof和hasOwn12.1 instanceof12.2 in12.3 hasOwnProperty12.4 hasOwn13 旧类14 new运算符面向对象编…

用上了mac才知道的一些事,献给Mac新手

以前电脑用windows&#xff0c;工作后刚用上mac&#xff0c;发现很多使用逻辑挺让人感觉新奇&#xff0c;甚至摸不着头脑,下面一一列举&#xff0c;帮助想要入手Mac的新手&#xff01; 1、鼠标滚轮的逻辑和Windows相反。 Mac上滚动鼠标控制页面上下滚动的逻辑和Windows刚好相…

使用 Learner Lab - 使用 S3 静态网页上传图片,搭配 API Gateway 与 Lambda

使用 Learner Lab - 使用 S3 静态网页上传图片&#xff0c;搭配 API Gateway 与 Lambda AWS Academy Learner Lab 是提供一个帐号让学生可以自行使用 AWS 的服务&#xff0c;让学生可以在 100 USD的金额下&#xff0c;自行练习所要使用的 AWS 服务&#xff0c;如何进入 Learne…

分割研究~~总结

搬来了基于实例分割的最新进展和发展历程&#xff0c;首先介绍了实例分割的基本逻辑,总结了目前主要研究方法及其原理和网络架构&#xff0c;对已发表的主流实例分割方法进行分析&#xff0c;最后对实例分割任务目前面临 的问题以及未来的发展趋势做出了分析,并针对所面临的问题…

磨金石教育插画干货分享|日本插画为什么独树一帜,那么受欢迎

插画的起源很早&#xff0c;在人类诞生文明的初级阶段&#xff0c;就有了岩画与壁画。在古典文明时代&#xff0c;中国印刷行业有了较大的发展&#xff0c;与之伴随的就是插画的长足发展。中国文化对日本起到了极大的影响。 在插画领域也是如此&#xff0c;客观的说&#xff0c…

CCF走进高校

CCF走进高校&#xff08;山东大学-人机专委&#xff09; 陶建华 人工智能与智能交互 人工智能的能力体系 感知智能&#xff1a;发展较快&#xff0c;人机交互场景运用较多&#xff1b; 认知智能&#xff1a;发展相对不成熟。 此外&#xff0c;专用智能领域发展较快&#xff0…

shell编程(一)

shell 简介 Shell 是一个用 C 语言编写的程序,一般我们说的shell编程&#xff0c;是指编写shell脚本。 Shell 负责完成用户与内核之间的交互&#xff08;shell是一个命令解释器&#xff0c;负责将用户的命令解析成操作系 统所能理解的指令&#xff09; 第一个shell脚本 创建…

Vue刷新后页面数据丢失问题的解决过程

在做vue项目的过程中有时候会遇到一个问题,就是进行F5页面刷新的时候,页面的数据会丢失,这篇文章主要给大家介绍了关于Vue刷新后页面数据丢失问题的解决过程,需要的朋友可以参考下&#xff01; 一、为什么刷新后数据会丢失 vuex存储的数据只是在页面中&#xff0c;相当于全局变…

[附源码]计算机毕业设计学习帮扶网站设计与实现Springboot程序

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

Linux文件系统调用接口文件描述符的理解

&#x1f9f8;&#x1f9f8;&#x1f9f8;各位大佬大家好&#xff0c;我是猪皮兄弟&#x1f9f8;&#x1f9f8;&#x1f9f8; 文章目录一、对系统调用进行封装的理由二、文件的系统调用接口① openopen的选项--位图open的权限程序中设置umask权限掩码②close③write④read三、…

字节输入流【InputStream】(读文件)

字节输入流【InputStream】 java.io.InputStream 抽象类是表示字节输入流的所有类的超类&#xff0c;可以读取字节信息到内存中。它定义了字节输入流的基本共性功能方法。 public void close(): 关闭此输入流并释放与此流相关联的任何系统资源。 public abstract int read(): …

Telegraf

Telegraf是什么&#xff1f; Telegraf 是 InfluxData 公司开源的一款十分流行的指标采集软件&#xff0c;可以从数据库、系统和物联网传感器收集和发送度量和事件&#xff0c;它用Go编写&#xff0c;编译成一个没有外部依赖的二进制文件–需要非常少的内存&#xff0c;相…

数仓建模理论(一)

学习目录一、关系建模与维度建模二、维度表和事实表&#xff08;重点&#xff09;三、事实表类型四、维度模型分类一、关系建模与维度建模 &#xff08;1&#xff09;关系建模 关系建模将复杂的数据抽象为两个概念——实体和关系&#xff0c;并使用规范化的方式表示出来。关系…

【计算机毕业设计】73.房屋租赁系统求租合同源码

一、系统截图&#xff08;需要演示视频可以私聊&#xff09; 摘 要 随着科学技术的飞速发展&#xff0c;社会的方方面面、各行各业都在努力与现代的先进技术接轨&#xff0c;通过科技手段来提高自身的优势&#xff0c;房屋租赁系统当然也不能排除在外。房屋租赁系统是以实际…

Mybatis源码解析(八):插件机制

Mybatis源码系列文章 手写源码&#xff08;了解源码整体流程及重要组件&#xff09; Mybatis源码解析(一)&#xff1a;环境搭建 Mybatis源码解析(二)&#xff1a;全局配置文件的解析 Mybatis源码解析(三)&#xff1a;映射配置文件的解析 Mybatis源码解析(四)&#xff1a;s…

flex布局列表页(一行内容比较多,长度比较长)

一、Flex 布局是什么&#xff1f; Flex 是 Flexible Box 的缩写&#xff0c;意为"弹性布局"&#xff0c;用来为盒状模型提供最大的灵活性。任何一个容器都可以指定为 Flex 布局。 二、基本概念 采用 Flex 布局的元素&#xff0c;称为 Flex 容器&#xff08;flex co…

Java开发必须掌握的运维知识 (九)-- Docker容器监控信息可视化仪表:Grafana

一、Grafana 是用来干什么的&#xff1f; Grafana 是一个监控仪表系统&#xff0c;它是由 Grafana Labs 公司开源的的一个系统监测 (System Monitoring) 工具。它可以大大帮助你简化监控的复杂度&#xff0c;你只需要提供你需要监控的数据&#xff0c;它就可以帮你生成各种可视…