Browse Source

增加初始化省市区sql文件

peiguo 5 years ago
parent
commit
fb8f28e2fb

+ 1 - 1
whepi-doc/login.sql

@@ -122,7 +122,7 @@ CREATE TABLE sys_uptown  (
   uptown_addr       varchar(100)  NOT NULL DEFAULT '' COMMENT '小区地址',
   uptown_addr       varchar(100)  NOT NULL DEFAULT '' COMMENT '小区地址',
   longitude         varchar(20)  NOT NULL DEFAULT '' COMMENT '经度',
   longitude         varchar(20)  NOT NULL DEFAULT '' COMMENT '经度',
   latitude          varchar(20)  NOT NULL DEFAULT '' COMMENT '纬度',
   latitude          varchar(20)  NOT NULL DEFAULT '' COMMENT '纬度',
-  area              varchar(20)  NOT NULL DEFAULT '' COMMENT '区',
+  area              int(11)  NOT NULL DEFAULT '0' COMMENT '区',
   status            int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
   status            int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
   time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
   time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
   time_update       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
   time_update       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',

+ 59 - 18
whepi-ui/templates/user/home.ftl

@@ -3,7 +3,7 @@
 
 
 <div class="weui-tab">
 <div class="weui-tab">
     <div class="weui-tab__bd">
     <div class="weui-tab__bd">
-        <div id="first">
+        <div id="first" hidden="hidden">
             <div class="weui-tab__bd-item weui-tab__bd-item--active">
             <div class="weui-tab__bd-item weui-tab__bd-item--active">
                 <div class="page__bd">
                 <div class="page__bd">
                     <header class="user-header">
                     <header class="user-header">
@@ -149,11 +149,16 @@
                             <label for="" class="weui-label">小区</label>
                             <label for="" class="weui-label">小区</label>
                         </div>
                         </div>
                         <div class="weui-cell__bd">
                         <div class="weui-cell__bd">
-<#--                            <select class="weui-select" name="select3">-->
-<#--                                <option value="1">武汉</option>-->
-<#--                            </select>-->
-
-                            <select class="weui-select combobox" id="uptownId" name="select3" data-options="editable:false">
+                            <select class="weui-select" id="uptownId" name="select3">
+                            </select>
+                        </div>
+                    </div>
+                    <div class="weui-cell weui-cell_select weui-cell_select-after">
+                        <div class="weui-cell__hd">
+                            <label for="" class="weui-label">栋/单元/门牌</label>
+                        </div>
+                        <div class="weui-cell__bd">
+                            <select class="weui-select" id="houseId" name="select4">
                             </select>
                             </select>
                         </div>
                         </div>
                     </div>
                     </div>
@@ -239,29 +244,65 @@
 <#include "/home/frag.foot.ftl" />
 <#include "/home/frag.foot.ftl" />
 <script>
 <script>
 
 
-    $(document).ready(function() {
+    $(document).ready(function () {
         $("#area").on("change", function () {
         $("#area").on("change", function () {
             var area = $("#area").val();
             var area = $("#area").val();
-            console.log(area)
-
-            $("#uptownId").combobox({
-                multiple: false,//是否允许多选
-                editable: false,
-                url: '/admin/supplier/getTheSupBranch.json?supplierId=' + supplierId+'&isAll=1',
-                valueField: 'branchId',
-                textField: 'shortName'
-            });
+            $("#uptownId").empty();
+            $("#houseId").empty();
+            getUptownData(area);
+            getUptownHouseData();
+        });
+        $("#uptownId").on("change", function () {
+            getUptownHouseData();
+            $("#houseId").empty();
         })
         })
     })
     })
 
 
-    <#if user ??>var userId = ${user.userId!''}</#if>;
+    function getUptownData(area) {
+        $.ajax({
+            type: "GET",
+            url: "/home/getUptownData.json?area=" + area,
+            dataType: "json",
+            success: function (data) {
+                if (data.length > 0) {
+                    $("#uptownId").empty();
+                    var html = "";
+                    for (var i = 0; i < data.length; i++) {
+                        html += '<option value="' + data[i].uptownId + '">' + data[i].uptownName + '</option>';
+                    }
+                    $('#uptownId').append(html);
+                }
+            }
+        });
+    }
+
+    function getUptownHouseData() {
+        $.ajax({
+            type: "GET",
+            url: "/home/getUptownHouseData.json?uptownId=" + $("#uptownId").val(),
+            data: {},
+            dataType: "json",
+            success: function (data) {
+                if (data.length > 0) {
+                    $("#houseId").empty();
+                    var html = "";
+                    for (var i = 0; i < data.length; i++) {
+                        html += '<option value="' + data[i].houseId + '">'+data[i].ridgepole+'栋'+data[i].unit+'单元'+data[i].doorplate+'号' + '</option>';
+                    }
+                    $('#houseId').append(html);
+                }
+            }
+        });
+    }
+
+        <#if user ??>var userId = ${user.userId!''}</#if>;
 
 
     function save() {
     function save() {
         var city = $("#city").val();
         var city = $("#city").val();
         var area = $("#area").val();
         var area = $("#area").val();
         console.log(city)
         console.log(city)
         console.log(area)
         console.log(area)
-        console.log(uptownId)
+        // console.log(uptownId)
     }
     }
 
 
     // function initBranchCommobox(){
     // function initBranchCommobox(){

+ 11 - 0
whepi-web/src/main/java/com/bofeng/dao/UptownHouseMapper.java

@@ -2,6 +2,17 @@ package com.bofeng.dao;
 
 
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 import com.bofeng.entity.UptownHouse;
 import com.bofeng.entity.UptownHouse;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
 
 
+import java.util.List;
+
+@Mapper
+@Repository
 public interface UptownHouseMapper extends BaseMapper<UptownHouse> {
 public interface UptownHouseMapper extends BaseMapper<UptownHouse> {
+
+    @Select("select * from sys_uptown_house where status = 1 and uptown_id = #{uptownId}")
+    List<UptownHouse> getAllUptownHouse(@Param("uptownId") Long uptownId);
 }
 }

+ 18 - 0
whepi-web/src/main/java/com/bofeng/dao/UptownMapper.java

@@ -0,0 +1,18 @@
+package com.bofeng.dao;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.Uptown;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface UptownMapper extends BaseMapper<Uptown> {
+
+    @Select("select * from sys_uptown where status = 1 and area = #{area}")
+    List<Uptown> getAllUptown(@Param("area") Integer area);
+}

+ 52 - 0
whepi-web/src/main/java/com/bofeng/entity/Uptown.java

@@ -0,0 +1,52 @@
+package com.bofeng.entity;
+
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.baomidou.mybatisplus.annotations.TableName;
+import lombok.Getter;
+import lombok.Setter;
+import org.joda.time.DateTime;
+
+/**
+ * 小区表
+ */
+@Getter
+@Setter
+@TableName("sys_uptown")
+public class Uptown {
+
+    @TableField("uptown_id")
+    private Long uptownId;
+
+    @TableField("uptown_name")
+    private String uptownName;
+
+    @TableField("uptown_addr")
+    private String uptownAddr;
+
+    @TableField("longitude")
+    private String longitude;
+
+    @TableField("latitude")
+    private String latitude;
+
+    @TableField("area")
+    private Integer area;
+
+    /**
+     * 状态:1正常,0草稿,-1删除
+     */
+    @TableField("status")
+    private Integer status;
+
+    @TableField("user_create")
+    private Long userCreate;
+
+    @TableField(exist = false)
+    private DateTime timeCreate;
+
+    @TableField("user_update")
+    private Long userUpdate;
+
+    @TableField(exist = false)
+    private DateTime timeUpdate;
+}

+ 0 - 3
whepi-web/src/main/java/com/bofeng/entity/UptownHouse.java

@@ -22,9 +22,6 @@ public class UptownHouse {
     @TableField("uptown_id")
     @TableField("uptown_id")
     private Long uptownId;
     private Long uptownId;
 
 
-    @TableField("linkman")
-    private String linkman;
-
     @TableField("ridgepole")
     @TableField("ridgepole")
     private String ridgepole;
     private String ridgepole;
 
 

+ 20 - 9
whepi-web/src/main/java/com/bofeng/wx/controller/UserOpenController.java

@@ -1,16 +1,23 @@
 package com.bofeng.wx.controller;
 package com.bofeng.wx.controller;
 
 
+import com.bofeng.dao.UptownHouseMapper;
+import com.bofeng.dao.UptownMapper;
+import com.bofeng.entity.Uptown;
+import com.bofeng.entity.UptownHouse;
 import com.bofeng.entity.UserOpen;
 import com.bofeng.entity.UserOpen;
 import com.bofeng.service.HomeService;
 import com.bofeng.service.HomeService;
 import com.bofeng.service.UserOpenService;
 import com.bofeng.service.UserOpenService;
+import com.yvan.Model;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.ui.ModelMap;
 import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.ModelAndView;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 
 
 @RestController
 @RestController
 public class UserOpenController {
 public class UserOpenController {
@@ -19,6 +26,10 @@ public class UserOpenController {
     private HomeService homeService;
     private HomeService homeService;
     @Autowired
     @Autowired
     private UserOpenService userOpenService;
     private UserOpenService userOpenService;
+    @Autowired
+    private UptownMapper uptownMapper;
+    @Autowired
+    private UptownHouseMapper uptownHouseMapper;
 
 
     @GetMapping("/user/home.html")
     @GetMapping("/user/home.html")
     public ModelAndView home(ModelMap model) {
     public ModelAndView home(ModelMap model) {
@@ -27,15 +38,15 @@ public class UserOpenController {
         return new ModelAndView("/user/home.ftl", model);
         return new ModelAndView("/user/home.ftl", model);
     }
     }
 
 
-//    @GetMapping("/home/getUptown.json")
-//    public Model<List<Map<>>> getUptown(HttpServletRequest request) {
-//        Long userId = Long.parseLong(request.getParameter("userId"));
-//        Integer userType = Integer.parseInt(request.getParameter("userType"));
-//        String linkman = request.getParameter("linkman");
-//        String phone = request.getParameter("phone");
-//        userOpenService.saveUserInfo(userId,userType,linkman,phone);
-//        return new ModelAndView("/home/home.ftl");
-//    }
+    @GetMapping("/home/getUptownData.json")
+    public List<Uptown> getUptownData(HttpServletRequest request, @RequestParam(value = "area") Integer area) {
+        return uptownMapper.getAllUptown(area);
+    }
+
+    @GetMapping("/home/getUptownHouseData.json")
+    public List<UptownHouse> getUptownHouseData(HttpServletRequest request, @RequestParam(value = "uptownId") Long uptownId) {
+        return uptownHouseMapper.getAllUptownHouse(uptownId);
+    }
 
 
     @PostMapping("/home/saveUser.json")
     @PostMapping("/home/saveUser.json")
     public ModelAndView saveUser(HttpServletRequest request) {
     public ModelAndView saveUser(HttpServletRequest request) {