# 智慧社区管理系统-基础管理-04业主管理

news2024/7/4 5:23:59

一后端

1entity

package com.woniu.community.entity;

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

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Owner {
    private  int id;
    private  String userName;
    private String tel;//联系方式
    private String sex;
    private String identity;//身份证号
    private int houseId;
    private String remarks;//备注
    private  String password;//密码
    private String houseNumbers;
}

2:OwnerMapper

package com.woniu.community.mapper;

import com.woniu.community.entity.Owner;

import java.util.List;

public interface OwnerMapper {
    List<Owner> selectAll(String tel,String identity,int start,int size);
    int  count(String tel,String identity);
    int insertOwner(Owner owner);
    int  deleteOwner(int id);
    int  updateOwner(Owner owner);
    Owner selectById(int  id);
}

3:IOwnerService

package com.woniu.community.service;

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

import java.util.List;

public interface IOwnerService {
    /**
     * 查询所有
     * @param tel
     * @param identity
     * @param pageIndex
     * @param pageSize
     * @return
     */
   HttpResult selectAll(String tel, String identity, int pageIndex, int pageSize);

    /**
     * 添加
     * @param owner
     * @return
     */
    HttpResult insertOwner(Owner owner);

    /**
     * 删除
     * @param id
     * @return
     */
    HttpResult  deleteOwner(int id);

    /**
     * 修改
     * @param owner
     * @return
     */
    HttpResult  updateOwner(Owner owner);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    HttpResult selectById(int  id);

}

4:OwnerServiceImpl

package com.woniu.community.service.impl;

import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Owner;
import com.woniu.community.mapper.OwnerMapper;
import com.woniu.community.service.IOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OwnerServiceImpl implements IOwnerService {
    @Autowired(required = false)
    private OwnerMapper ownerMapper;
    /**
     * 查询所有
     *
     * @param tel
     * @param identity
     * @param pageIndex
     * @param pageSize
     * @return
     */
    @Override
    public HttpResult selectAll(String tel, String identity, int pageIndex, int pageSize) {
        HttpResult result=null;
        List<Owner> owners = ownerMapper.selectAll(tel, identity, (pageIndex - 1) * pageSize, pageSize);
        int count = ownerMapper.count(tel, identity);
        if (owners!=null&&owners.size()>0){
            result=new HttpResult(owners,count,200,null);
        }else{
            result=new HttpResult(null,0,500,"没有更多数据");
        }
        return result;
    }

    /**
     * 添加
     *
     * @param owner
     * @return
     */
    @Override
    public HttpResult insertOwner(Owner owner) {
        HttpResult result=null;
        int count = ownerMapper.insertOwner(owner);
        if (count>0){
            result=new HttpResult(null,0,200,"添加成功");
        }else{
            result=new HttpResult(null,0,500,"添加失败");
        }
        return result;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public HttpResult deleteOwner(int id) {
        HttpResult result=null;
        int count = ownerMapper.deleteOwner(id);
        if (count>0){
            result=new HttpResult(null,0,200,"删除成功");
        }else{
            result=new HttpResult(null,0,500,"删除失败");
        }
        return result;
    }

    /**
     * 修改
     *
     * @param owner
     * @return
     */
    @Override
    public HttpResult updateOwner(Owner owner) {
        HttpResult result=null;
        int count = ownerMapper.updateOwner(owner);
        if (count>0){
            result=new HttpResult(null,0,200,"修改成功");
        }else{
            result=new HttpResult(null,0,500,"修改失败");
        }
        return result;

    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Override
    public HttpResult selectById(int id) {
        HttpResult result=null;
        Owner owner = ownerMapper.selectById(id);
        if (owner!=null){
            result=new HttpResult(owner,0,200,null);
        }else{
            result=new HttpResult(null,0,500,null);
        }
        return result;
    }
}

5:OwnerCOntroller

package com.woniu.community.controller;

import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Owner;
import com.woniu.community.service.IOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/owner")
@CrossOrigin(origins = "*")
public class OwnerController {
    @Autowired
    private IOwnerService iOwnerService;
    @RequestMapping("/list")
    HttpResult selectAll(String tel, String identity, int pageIndex, int pageSize){
        return iOwnerService.selectAll(tel,identity,pageIndex,pageSize);
    }

    @RequestMapping("/add")
    HttpResult insertOwner(Owner owner){
        return iOwnerService.insertOwner(owner);
    }

    @RequestMapping("/delete")
    HttpResult  deleteOwner(int id){
        return iOwnerService.deleteOwner(id);
    }

    @RequestMapping("/update")
    HttpResult  updateOwner(Owner owner){
        return iOwnerService.updateOwner(owner);
    }

    @RequestMapping("/info")
    HttpResult selectById(int  id){
        return iOwnerService.selectById(id);
    }
}

前端代码


<!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">

                电话:
                <input type="text"  v-model="tel"/>
                身份证号:
                <input type="text"  v-model="identity"/>
                <button class="btn btn-info" @click="doQuery">查询</button>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12" style="height: 50px; line-height: 50px;margin-top: 40px">
            <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>ID</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>联系方式</th>
                    <th>身份证号</th>
                    <th>房屋编号</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="o in owners">
                    <td>{{o.id}}</td>
                    <td>{{o.userName}}</td>
                    <td>{{o.sex}}</td>
                    <td>{{o.tel}}</td>
                    <td>{{o.identity}}</td>
                    <td>{{o.houseNumbers}}</td>
                    <td>
                        <button class="btn btn-danger" @click="doUpdate(o.id)">修改</button>
                        <button class="btn btn-primary" @click="doDelete(o.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: {
            owners:null,
            pageIndex:1,
            pageSize:3,
            pageTotal:0,
            pageNum:0,
            tel:null,
            identity:'',
        },
        methods: {
            requestOwnerList(url){
            axios.get(url).then(response=>{
                this.owners=response.data.data;
                this.pageTotal = response.data.pageTotal; //给总条数赋值

                this.pageNum = Math.ceil(this.pageTotal / this.pageSize);
            })
            },
            doAdd(){
            window.parent.main_right.location.href="owner_add_update.html";
            },
            doUpdate(id){
                window.parent.main_right.location.href="owner_add_update.html?id="+id;
            },
            doDelete(id){
                var  url= "http://localhost:8080/owner/delete?id="+id;
                axios.get(url).then(response=>{
                    if (response.data.code==200){
                        var  url="http://localhost:8080/owner/list?pageIndex="+this.pageIndex+"&pageSize="+this.pageSize;
                        this.requestOwnerList(url);
                    }else{
                        alert(response.data.msg)
                    }
                })
            },

            doQuery(){
               this.doGO(1) ;
            },
            doGO(p){
                this.pageIndex=p;
                var  url="http://localhost:8080/owner/list?pageIndex="+p+"&pageSize="+this.pageSize+"&tel="+this.tel+"&identity="+this.identity;
                this.requestOwnerList(url);
            },
        },
        created: function () {
        var  url="http://localhost:8080/owner/list?pageIndex="+this.pageIndex+"&pageSize="+this.pageSize;
        this.requestOwnerList(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="userName">
                    <label>性别</label>
                    <input type="text" class="form-control" v-model="sex">
                    <label>电话</label>
                    <input type="text" class="form-control" v-model="tel">
                    <label>身份证号</label>
                    <input type="text" class="form-control" v-model="identity">
                    房屋编号<select v-model="houseId">
                        <option v-for="o in houseList" :value="o.id">{{o.numbers}}</option>
                    </select>

                </div>
            </div>
            <div class="row">
                <div class="col-md-6 col-md-offset-3" style="height: 80px;">
                    <button class="btn btn-primary" @click="doSave">保存</button>
                    <button class="btn btn-default"@click="doCancel">取消</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            title: null,
            userName:null,
            sex:null,
            tel:null,
            identity:null,
            houseId:null,
            houseList:null,
            ownerId:null,
        },
        methods: {
            //通过获取房屋信息,拿到房屋id
            requestHouse(){
                var  url="http://localhost:8080/house/list?pageIndex=1&pageSize=100";
                axios.get(url).then(response=>{
                    this.houseList=response.data.data;
                })
            },
            doSave(){
                if (this.ownerId==null){//添加
                    this.title="添加业主"
                    var  url="http://localhost:8080/owner/add?userName="+this.userName+"&tel="+this.tel+"&identity="+this.identity+"&houseId="+this.houseId;
                    axios.get(url).then(response=>{
                        if (response.data.code==200){
                            window.parent.main_right.location.href="owner_list.html";
                        }else{
                            alert(response.data.msg);
                        }
                    })
                }else{//修改
                    this.title="修改业主"
                    var  url="http://localhost:8080/owner/update?userName="+this.userName+"&tel="+this.tel+"&identity="+this.identity+"&houseId="+this.houseId+"&id="+this.ownerId;
                    axios.get(url).then(response=>{
                        if (response.data.code==200){
                            window.parent.main_right.location.href="owner_list.html";
                        }else{
                            alert(response.data.msg);
                        }
                    })
                }
            },
            doCancel(){
                history.go(-1);//返回上一界面
            }

        },
        created: function () {
            this.requestHouse();
            var  url=window.location.href;
            if (url.indexOf("id")!=-1){
                this.ownerId=url.substring(url.indexOf("=")+1)
            }
            if (this.ownerId==null){
                this.title="添加业主"
            }else{
                this.title="修改业主"
                var url="http://localhost:8080/owner/info?id="+this.ownerId;
                axios.get(url).then(response=>{
                    this.userName=response.data.data.userName;
                    this.sex=response.data.data.sex;
                    this.tel=response.data.data.tel;
                    this.identity=response.data.data.identity;
                    this.houseId=response.data.data.houseId;
                })
            }

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

在这里插入图片描述
在这里插入图片描述

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

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

相关文章

Linux I2C驱动框架, 调试神奇I2C-Tools介绍

1. IIC协议 2. Linux的I2C体系结构分为3个组成部分&#xff1a; I2C核心( i2c-core.c )&#xff1a;   I2C核心提供了I2C总线驱动和设备驱动的注册、注销方法、I2C通信方法(”algorithm”)、与具体适配器无关的代码、探测设备、检测设备地址的上层代码等。 …

在线PDF查看器和PDF编辑器:GrapeCity Documents PDF (GcPdf)

跨平台 JavaScript PDF 查看器 使用我们的 JavaScript PDF 查看器在网络上阅读和编辑 PDF。跨浏览器和框架打开和打印。GrapeCity Documents PDF (GcPdf) 全功能的 JavaScript PDF 查看器和 PDF 编辑器 适用于所有现代浏览器和框架&#xff0c;包括 Edge、Chrome、Firefox、Op…

UML类图中 前缀符号 + - # ~ 的含义

UML类图中有各种符号&#xff0c;新手看着一脸懵逼&#xff0c;今天我就来讲一下各个符号到底是啥意思。 其实这些符号都是在描述类属性的可见性&#xff1a; UML中&#xff0c;可见性分为4级 1、public public 公用的用 前缀表示 &#xff0c;该属性对所有类可见 2、prote…

算法篇-----回溯1

文章目录什么是回溯呢&#xff1f;力扣690-----员工的重要性&#xff08;中等&#xff09;力扣733-----图像渲染&#xff08;简单&#xff09;力扣463-----岛屿的周长&#xff08;简单)力扣130------被围绕的区域&#xff08;中等&#xff09;力扣17--------电话号码的组合 &am…

kafka-consumer-offset位移

目录 1 offset的默认维护位置 1.1 消费offset案例 2 自动提交offset 3 手动提交offset 3.1 原理 3.2 代码示例 3.2.1 同步提交 3.2.2 异步提交(生产常用) 4 指定offset消费 5 指定时间消费 6 漏消费和重复消费分析 6.1 重复消费 6.2 漏消费 6.3 消费者事务 7 数据…

高通开发系列 - ALSA声卡驱动中tinymix返回时间过慢

By: fulinux E-mail: fulinux@sina.com Blog: https://blog.csdn.net/fulinus 喜欢的盆友欢迎点赞和订阅! 你的喜欢就是我写作的动力! 目录 问题背景问题分析验证第一个猜测验证第二个猜测问题原因解决方案问题背景 我们一个高通平台上出现一个问题: tingmix命令需要几秒钟…

一文带你深入理解Linux端口重用这一特性

【好文推荐】 需要多久才能看完linux内核源码&#xff1f; 概述Linux内核驱动之GPIO子系统API接口 一篇长文叙述Linux内核虚拟地址空间的基本概括 轻松学会Linux下查看内存频率,内核函数,cpu频率 大家好&#xff0c;我是Linux吴彦祖&#xff01; 开篇我先考大家一个小问题&…

Golang Map 基本原理

Go 语言中的 map 即哈希表。哈希表把元素分到多个桶里&#xff0c;每个桶里最多放8个元素。在访问元素时&#xff0c;首先用哈希算法根据 key 和哈希表种子获得哈希值(暂将其命名为 h)&#xff0c;然后利用 h 的低 bbb 位得到桶的序号。其中桶的个数为 2b2^b2b 个&#xff0c;是…

乐趣国学—品读“富润屋,德润身。”中的智慧

✅作者简介&#xff1a;热爱国学的Java后端开发者&#xff0c;修心和技术同步精进。 &#x1f34e;个人主页&#xff1a;Java Fans博客 &#x1f34a;个人信条&#xff1a;不迁怒&#xff0c;不贰过。小知识&#xff0c;大智慧。 ✨当前专栏&#xff1a;国学周更-心性养成之路 …

java 基于 SpringMVC+Mybaties+ easyUI 快递公司管理系统 的 设计与实现

一.项目介绍 本系统 角色 权限 动态配置 默认配置了三种 第一种&#xff1a; 超级管理员 第二种&#xff1a; 运输公司 第三种&#xff1a; 订单跟踪人员 超级管理员拥有所有权限&#xff0c;包括车子、路线、订单、是否送达以及交易的统计报表 运输公司&#xff1a;车辆管理权…

使用 Python 和 Streamlit 创建一个很棒的 Web 应用程序

“我们如何制作一个机器学习脚本并将其转换为一个尽可能简单的应用程序,让它基本上感觉像是一个脚本练习?” — Adrien Treuille(Streamlit 的发明者) Web 应用程序是显示数据科学或机器学习项目结果的好方法。从头开始开发 Web 应用程序需要大量时间、精力和技术技能。另一…

世界杯海信再出圈,三星:“谈不上愉悦”

作者 | 曾响铃 文 | 响铃说 本届世界杯作为第一次在北半球冬季举行的世界杯&#xff0c;给全世界球迷带去了一次全新体验。且随着赛程的推进&#xff0c;更多的“惊喜”也一一浮现。 其一便是超多的爆冷&#xff0c;虽然没有具体统计&#xff0c;但此次应该是近几届爆冷最多…

[激光原理与应用-32]:典型激光器 -4- 半导体泵浦固体激光器

目录 第1章 概述 1.1 什么是半导体泵浦固体激光器 1.2 优势 1.3 典型的波长 第2章 半导体泵浦固体激光器的种类 2.1 端面泵浦固体激光器 2.2 侧面泵浦固体激光器 第1章 概述 1.1 什么是半导体泵浦固体激光器 半导体泵浦固体激光器&#xff08;Diode Pump Solid State …

Python函数

一、函数介绍 函数&#xff1a;是组织好的&#xff0c;可重复使用的&#xff0c;用来实现特定功能的代码段。 使用函数的好处是&#xff1a; 将功能封装在函数内&#xff0c;可供随时随地重复利用提高代码的复用性&#xff0c;减少重复代码&#xff0c;提高开发效率二、函数…

学习python第一天

关于Python的数据类型 Python数据类型包括&#xff1a; 数字类型&#xff0c;字符类型&#xff0c;布尔类型&#xff0c;空类型&#xff0c;列表类型&#xff0c;元组类型&#xff0c;字典类型 1、数字类型 包括&#xff1a;整型int 浮点型float(有小数位的都是是浮点型) 注…

代码随想录刷题|LeetCode 1143.最长公共子序列 1035.不相交的线 53. 最大子序和 动态规划

目录 1143.最长公共子序列 思路 1、确定dp数组 2、确定递推公式 3、dp数组初始化 4、遍历顺序 5、推导dp数组 最长公共子序列 1035.不相交的线 思路 不相交的线 53. 最大子序和 思路 最大子序列 动态规划 贪心算法 1143.最长公共子序列 题目链接&#xff1a;力扣 思路 不知道…

你在终端启动的进程,最后都是什么下场?(下)

你在终端启动的进程&#xff0c;最后都是什么下场&#xff1f;&#xff08;下&#xff09; 在上期文章你在终端启动的进程&#xff0c;最后都是什么下场&#xff1f;&#xff08;上&#xff09;当中我们介绍了前台进程最终结束的几种情况&#xff0c;在本篇文章当中主要给大家…

好书分享丨区块链的骨骼——密码技术

开放隐私计算 开放隐私计算 开放隐私计算OpenMPC是国内第一个且影响力最大的隐私计算开放社区。社区秉承开放共享的精神&#xff0c;专注于隐私计算行业的研究与布道。社区致力于隐私计算技术的传播&#xff0c;愿成为中国 “隐私计算最后一公里的服务区”。 180篇原创内容 …

darknet框架GPU编译安装

Darknet: Open Source Neural Networks in C 1、darknet下载 git clone https://github.com/pjreddie/darknet.git cd darknet设置makefile gpu1 cudnn1 opencv1【1】GPU1;需要设置显卡驱动、cuda 使用nvidia-smi 查看显卡型号和支持的cuda版本号 nvidia官网下载cuda,以及…

计算机网络学习笔记(Ⅱ):物理层

目录 1 物理层概念 1.1 物理层基本概念 1.定义 2.主要任务 3.特性 1.2 数据通信基础 1.典型模型 2.相关术语 3.三种通信方式 4.数据传输方式 1.3 物理层内容 1.码元 2.速率 3.带宽 1.4 奈氏准则与香农定理 1.失真 2.码间串扰 3.奈氏准则 4.香农定理 1.5 …