瀏覽代碼

修复获取路段方法

crazycat 2 年之前
父節點
當前提交
cd7081a9e0

+ 3 - 2
src/main/java/com/welampiot/dao/SectionDao.java

@@ -1,12 +1,13 @@
 package com.welampiot.dao;
 
 import com.welampiot.dto.SectionDTO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
 
 public interface SectionDao {
     List<SectionDTO> getAllList();
-    List<SectionDTO> getListByPid(Integer pid);
-    List<SectionDTO> getLIstByPidList(List pidList);
+    List<SectionDTO> getListByPid(@Param("pid") Integer pid);
+    List<SectionDTO> getLIstByPidList(@Param("pidList") List pidList);
 }

+ 14 - 4
src/main/java/com/welampiot/utils/ToolUtils.java

@@ -34,9 +34,17 @@ public class ToolUtils {
      */
     public List getSectionList(HttpServletRequest request){
         String username = request.getParameter("username");
-        if (username == null || username.toString().length() == 0) return Collections.singletonList(new int[]{0});
+        ArrayList<Object> sectionList = new ArrayList<>();
+
+        if (username == null || username.toString().length() == 0) {
+            sectionList.add(0);
+            return sectionList;
+        }
         UserDTO user1 = userService.findUserByUserName(username);
-        if (user1 == null) return Collections.singletonList(new int[]{0});
+        if (user1 == null) {
+            sectionList.add(0);
+            return sectionList;
+        }
 
         String provinceid = request.getParameter("provinceid");
         provinceid = provinceid == null || provinceid.equals("0") ? request.getParameter("provinceId") : provinceid;
@@ -47,7 +55,7 @@ public class ToolUtils {
         String sectionid = request.getParameter("sectionid");
         sectionid = sectionid == null || sectionid.equals("0") ? request.getParameter("sectionId") : sectionid;
 
-        ArrayList<Object> sectionList = new ArrayList<>();
+
         if (sectionid != null && sectionid.length() != 0 && !sectionid.equals("0")){
             sectionList.add(sectionid);
             return sectionList;
@@ -97,7 +105,9 @@ public class ToolUtils {
                     return Arrays.asList(zone.split(","));
                 }
             }else {
-                maps = sectionService.getListByPid(Integer.valueOf(areaid));
+                System.out.println(areaid);
+                int areaid2 = Integer.valueOf(areaid);
+                maps = sectionService.getListByPid(areaid2);
             }
         }
         for (SectionDTO map:maps) {

+ 1 - 1
src/main/resources/mapper/SectionMapper.xml

@@ -4,7 +4,7 @@
     <select id="getAllList" resultType="com.welampiot.dto.SectionDTO">
         select id,name from section
     </select>
-    <select id="getListByPid" parameterType="java.lang.String" resultType="com.welampiot.dto.SectionDTO">
+    <select id="getListByPid" parameterType="java.lang.Integer" resultType="com.welampiot.dto.SectionDTO">
         select id,name from section
         where pid = #{pid,jdbcType=INTEGER}
     </select>