Bladeren bron

新增后端接口,分页查询办理事项

hyx 2 jaren geleden
bovenliggende
commit
ba67a0be85

+ 22 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/controller/MapDataController.java

@@ -96,4 +96,26 @@ public class MapDataController {
         return SendUtil.send(false, ConstStr.ADD_FAILED);
     }
 
+    /**
+     * 通过当前页码和条数分页查询办理事项
+     * @param page
+     * @param limit
+     * @param type
+     * @param itemName
+     * @param matterDept
+     * @return
+     */
+    @GetMapping("/getHandMatterPage")
+    public Map<String, Object> getHandMatterPage(int page, int limit, int type, String itemName, String matterDept) {
+        try {
+            if (Blank.isNotEmpty(page) && Blank.isNotEmpty(limit)&& Blank.isNotEmpty(type) && page > 0 && limit > 0) {
+                return mapDataService.getHandMatterPage(page, limit, type, itemName, matterDept);
+            }
+            return SendUtil.send(true, null, "page和limit不能为空,且要大于0");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return SendUtil.send(false, ConstStr.DATA_NOT_FOUND);
+    }
+
 }

+ 4 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/MapDataDao.java

@@ -63,4 +63,8 @@ public interface MapDataDao {
 	List<String> getDictType();
 
 	Integer saveErrorLog(Map<String, Object> mapErrorLog);
+
+	Integer getHandMatterCount(int type, String itemName, String matterDept);
+
+	List<Map<String, Object>> getHandMatterPage(int startRows, int rows, int type, String itemName, String matterDept);
 }

+ 2 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/MapDataService.java

@@ -48,4 +48,6 @@ public interface MapDataService {
 	Map<String, Object> getMapDataAll();
 
 	Map<String, Object> saveErrorLog(Map<String, Object> mapErrorLog);
+
+    Map<String, Object> getHandMatterPage(int page, int limit, int type, String itemName, String matterDept);
 }

+ 10 - 1
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/MapDataServiceImpl.java

@@ -100,7 +100,7 @@ public class MapDataServiceImpl implements MapDataService {
 
     @Override
     public Map<String, Object> saveErrorLog(Map<String, Object> mapErrorLog) {
-        if(Blank.isEmpty(mapErrorLog.get("sMapId"))){
+        if (Blank.isEmpty(mapErrorLog.get("sMapId"))) {
             return SendUtil.send(false, ConstStr.ADD_FAILED, "sMapId为空");
         }
         mapErrorLog.put("errorState", 0);
@@ -111,4 +111,13 @@ public class MapDataServiceImpl implements MapDataService {
         return SendUtil.send(true, ConstStr.ADD_SUCCESS, "");
     }
 
+    @Override
+    public Map<String, Object> getHandMatterPage(int page, int limit, int type, String itemName, String matterDept) {
+        int startRows = (page - 1) * limit;
+        int count = mapDataDao.getHandMatterCount(type, itemName, matterDept);
+        if (count > 0) {
+            return SendUtil.layuiTable(count, mapDataDao.getHandMatterPage(startRows, limit, type, itemName, matterDept));
+        }
+        return SendUtil.layuiTable(0, null);
+    }
 }

+ 33 - 0
nngkxxdp/src/main/resources/mapper/MapDataDao.xml

@@ -56,4 +56,37 @@
             #{newAddress},#{newLongitude},#{newLatitude},#{errorState},#{createTime})
     </insert>
 
+    <select id="getHandMatterCount" resultType="java.lang.Integer">
+        select count(*)
+        from t_handling_matters
+        <where>
+            type=#{type}
+            <if test="itemName != null">
+                AND item_name LIKE CONCAT('%', #{itemName}, '%')
+            </if>
+            <if test="matterDept != null">
+                AND matter_dept LIKE CONCAT('%', #{matterDept}, '%')
+            </if>
+        </where>
+    </select>
+
+    <select id="getHandMatterPage" resultType="java.util.Map">
+        SELECT id,
+        type,
+        item_name,
+        matter_dept,
+        matter_url
+        FROM t_handling_matters
+        <where>
+            type=#{type}
+            <if test="itemName != null">
+                AND item_name LIKE CONCAT('%', #{itemName}, '%')
+            </if>
+            <if test="matterDept != null">
+                AND matter_dept LIKE CONCAT('%', #{matterDept}, '%')
+            </if>
+        </where>
+        order by id DESC
+        limit #{startRows},#{rows}
+    </select>
 </mapper>

+ 2 - 0
nngkxxdp/src/main/resources/mapper/YxnnDao.xml

@@ -53,6 +53,7 @@
         is_anonymous
         FROM impression_nanan
         <where>
+            1=1
             <if test="pictureType != null">
                 AND picture_type LIKE CONCAT('%', #{pictureType}, '%')
             </if>
@@ -90,6 +91,7 @@
         is_anonymous
         FROM impression_nanan
         <where>
+            1=1
             <if test="pictureType != null">
                 AND picture_type LIKE CONCAT('%', #{pictureType}, '%')
             </if>