Ver código fonte

fix 新增提供省市区镇村接口

tjf 3 anos atrás
pai
commit
ed88f24d7e

+ 7 - 5
boman-web-core/src/main/java/com/boman/web/core/controller/SysRegionController.java

@@ -10,6 +10,7 @@ import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -54,8 +55,8 @@ public class SysRegionController {
                 String href = a.attr("href");     // 11.html
                 String name = a.text();           // 浙江省
 
-                Long id = 18L;
-                if ("湖南省".equals(name)) {
+                Long id = 20L;
+                if ("广西壮族自治区".equals(name)) {
                     SysRegion region = new SysRegion();
                     region.setId(id);
                     region.setPid(0L);
@@ -84,8 +85,9 @@ public class SysRegionController {
 
 
     @PostMapping("/select")
-    public AjaxResult selectSysRegion(SysRegion sysRegion) throws IOException {
-        return AjaxResult.success(sysRegionMapper.selectSysRegion(sysRegion));
+    public AjaxResult selectSysRegion(@RequestBody SysRegion sysRegion){
+        List<SysRegion> list = sysRegionMapper.selectSysRegion(sysRegion);
+        return AjaxResult.success(list);
     }
 
 
@@ -111,7 +113,7 @@ public class SysRegionController {
             String name = nametd.select("a").text();        // 衢州市
             System.out.println("开始爬取" + name);
 
-            if ("益阳市".equals(name) || "郴州市".equals(name)||"永州市".equals(name)||"怀化市".equals(name)) {
+            if ("南宁市".equals(name) || "柳州市".equals(name)|| "桂林市".equals(name)|| "梧州市".equals(name)||"北海市".equals(name)) {
                 SysRegion region = new SysRegion();
                 region.setId(Long.valueOf(code));
                 region.setPid(i);

+ 11 - 2
boman-web-core/src/main/java/com/boman/web/core/domain/SysRegion.java

@@ -15,6 +15,11 @@ public class SysRegion implements Serializable {
 
     private Long id;
 
+    /**
+     * 数据库字段id
+     */
+    private Long areaId;
+
     /**
      * 上级ID,一级为0
      */
@@ -45,8 +50,12 @@ public class SysRegion implements Serializable {
 
     private Long sort;
 
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
+    public Long getAreaId() {
+        return areaId;
+    }
+
+    public void setAreaId(Long areaId) {
+        this.areaId = areaId;
     }
 
     public Long getId() {

+ 3 - 1
boman-web-core/src/main/java/com/boman/web/core/mapper/SysRegionMapper.java

@@ -4,6 +4,8 @@ import com.boman.domain.VaccineInfoUser;
 import com.boman.web.core.domain.SysRegion;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * @author tjf
  * @Date: 2022/01/05/15:19
@@ -22,5 +24,5 @@ public interface SysRegionMapper {
      * @param sysRegion
      * @return
      */
-    SysRegion selectSysRegion(SysRegion sysRegion);
+    List<SysRegion> selectSysRegion(SysRegion sysRegion);
 }

+ 1 - 6
boman-web-core/src/main/resources/mapper/SysRegionMapper.xml

@@ -15,12 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         INSERT INTO  `qianshan_data_bureau`.`china_area`(`area_id`, `name`, `pid`, `sort`) VALUES (#{id}, #{name}, #{pid}, #{sort}) on duplicate key update sort = #{sort}
     </insert>
     <select id="selectSysRegion" parameterType="SysRegion" resultMap="SysRegionResult">
-        select area_id,name,pid,sort from china_area
-        <where>
-            <if test="areaId != null"> and area_id = #{areaId}</if>
-            <if test="name != null  and name != ''"> and name = #{name}</if>
-            <if test="pid != null  and pid != ''"> and pid = #{pid}</if>
-        </where>
+        select area_id,name,pid,sort from china_area where pid = #{pid}
     </select>
 
 </mapper>