Browse Source

提交代码

JX.Li 1 year ago
parent
commit
da7ca1c95e

+ 3 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/mobile/MSysController.java

@@ -41,10 +41,10 @@ public class MSysController {
       return  AjaxResult.success(map);
    }
 
-   @GetMapping("search")
-   public AjaxResult search(String value)
+   @PostMapping("search")
+   public AjaxResult search(@RequestBody Map<String,Object> map)
    {
-      return  AjaxResult.success(imUserService.search(value));
+      return  AjaxResult.success(imUserService.search(map));
    }
 
 }

+ 5 - 1
ruoyi-mobile/src/main/java/com/ruoyi/mobile/mapper/MUserMapper.java

@@ -2,6 +2,7 @@ package com.ruoyi.mobile.mapper;
 
 import com.ruoyi.common.core.domain.entity.MUser;
 import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -13,6 +14,9 @@ import java.util.Map;
  * @date 2021-11-18
  */
 public interface MUserMapper extends BaseMapperPlus<MUser> {
-    List<Map> search(String value);
+    List<Map> search1(@Param("p") Map<String,Object> map); // 抢险
+    List<Map> search2(@Param("p") Map<String,Object> map); // 调压箱
+    List<Map> search3(@Param("p") Map<String,Object> map); // 庭院
+    List<Map> search4(@Param("p") Map<String,Object> map); // 警示桩
 
 }

+ 1 - 1
ruoyi-mobile/src/main/java/com/ruoyi/mobile/service/IMUserService.java

@@ -16,7 +16,7 @@ import java.util.Map;
  */
 public interface IMUserService extends IServicePlus<MUser, MUserVo> {
 
-	List<Map> search(String value);
+	List<Map> search(Map<String,Object> map);
 	/**
 	 * 查询单个
 	 * @return

+ 16 - 4
ruoyi-mobile/src/main/java/com/ruoyi/mobile/service/impl/MUserServiceImpl.java

@@ -36,12 +36,24 @@ public class MUserServiceImpl extends ServicePlusImpl<MUserMapper, MUser, MUserV
     private MobileTokenService mobileTokenService;
 
     @Override
-    public List<Map> search(String value) {
-        return baseMapper.search(value);
+    public List<Map> search(Map<String, Object> map) {
+        String type = String.valueOf(map.get("type"));
+        Integer page = Integer.valueOf(map.get("page").toString());
+        map.put("page", (page - 1) * Integer.valueOf(map.get("size").toString()));
+        if ("0".equals(type)) {
+            return baseMapper.search1(map);
+        } else if ("1".equals(type)) {
+            return baseMapper.search2(map);
+        } else if ("2".equals(type)) {
+            return baseMapper.search3(map);
+        } else if ("3".equals(type)) {
+            return baseMapper.search4(map);
+        }
+        return null;
     }
 
     @Override
-    public MUser getInfo(){
+    public MUser getInfo() {
         return baseMapper.selectById(1);
     }
 
@@ -94,7 +106,7 @@ public class MUserServiceImpl extends ServicePlusImpl<MUserMapper, MUser, MUserV
      *
      * @param entity 实体类数据
      */
-    private void validEntityBeforeSave(MUser entity){
+    private void validEntityBeforeSave(MUser entity) {
         //TODO 做一些数据校验,如唯一约束
     }
 

+ 65 - 28
ruoyi-mobile/src/main/resources/mapper/mobile/MUserMapper.xml

@@ -17,34 +17,71 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="password" column="password"/>
     </resultMap>
 
-    <select id="search" resultType="java.util.Map">
-        SELECT a.id                    AS id,
-               a.administrative_office AS name,
-               "1"                     AS type
-        FROM `g_regulator_box` a
-        WHERE a.number LIKE concat('%',#{value},'%')
-           OR a.administrative_office LIKE concat('%',#{value},'%')
-        UNION ALL
-        SELECT b.id   AS id,
-               b.remarks AS NAME,
-               "2"    AS type
-        FROM `g_courtyard_network_management` b
-        WHERE b.remarks LIKE concat('%',#{value},'%')
-        UNION ALL
-        SELECT c.id             AS id,
-               c.repair_content AS name,
-               "3"              AS type
-        FROM `g_emergency_repair` c
-        WHERE c.repair_content LIKE concat('%',#{value},'%')
-           OR c.remarks LIKE concat('%',#{value},'%')
-        UNION ALL
-        SELECT d.id   AS id,
-               wp.NAME AS name,
-               "4"    AS type
-        FROM `g_patrol_record` d
-        left join g_warning_pile wp on d.warning_pile_id = wp.id and wp.NAME LIKE concat('%',#{value},'%')
-           OR wp.remarks LIKE concat('%',#{value},'%')
-           OR wp.warning_pile_info LIKE concat('%',#{value},'%')
+    <select id="search1" resultType="java.util.Map">
+        SELECT a.id AS id,
+        a.engin_name AS name,
+        a.create_time AS time
+        FROM
+        g_emergency_repair a
+        WHERE a.del_flag = 0
+        <if test="p.userId != null  and p.userId != ''">
+            AND a.create_by = #{p.userId}
+        </if>
+        <if test="p.value != null  and p.value != ''">
+            AND a.engin_name = #{p.value}
+        </if>
+        ORDER BY create_time DESC limit #{p.page,jdbcType=INTEGER},#{p.size,jdbcType=INTEGER}
+    </select>
+    <select id="search2" resultType="java.util.Map">
+        SELECT
+        a.id AS id,
+        (SELECT name FROM g_area ar WHERE ar.id = a.area_id) AS name,
+        a.create_time AS time
+        FROM
+        g_regulator_box a WHERE a.del_flag =0
+        <if test="p.userId != null  and p.userId != ''">
+            AND a.create_by = #{p.userId}
+        </if>
+        <if test="p.value != null  and p.value != ''">
+            AND a.area_id in (SELECT id FROM g_area WHERE name LIKE concat('%',#{p.value},'%'))
+        </if>
+        ORDER BY create_time DESC limit #{p.page,jdbcType=INTEGER},#{p.size,jdbcType=INTEGER}
+    </select>
+    <select id="search3" resultType="java.util.Map">
+        SELECT
+        a.id AS id,
+        concat(ar.name,'-',bu.name) AS name,
+        a.create_time AS time
+        FROM
+        g_courtyard_network_management a
+        LEFT JOIN g_building bu on bu.id = a.building_id
+        LEFT JOIN g_area ar on bu.area_id = ar.id
+        WHERE a.del_flag = 0
+        <if test="p.userId != null  and p.userId != ''">
+            AND a.create_by = #{p.userId}
+        </if>
+        <if test="p.value != null  and p.value != ''">
+            and ar.name LIKE concat('%',#{p.value},'%')
+        </if>
+        ORDER BY a.create_time DESC limit #{p.page,jdbcType=INTEGER},#{p.size,jdbcType=INTEGER}
+    </select>
+    <select id="search4" resultType="java.util.Map">
+        SELECT
+        a.id AS id,
+        wa.name AS name,
+        a.create_time AS time
+        FROM
+        g_patrol_record a
+        LEFT JOIN g_warning_pile wa on wa.id = a.warning_pile_id
+        WHERE a.del_flag = 0
+        <if test="p.userId != null  and p.userId != ''">
+            AND a.create_by = #{p.userId}
+        </if>
+        <if test="p.value != null  and p.value != ''">
+            and wa.name LIKE concat('%',#{p.value},'%')
+        </if>
+        ORDER BY a.create_time DESC
+        limit #{p.page,jdbcType=INTEGER},#{p.size,jdbcType=INTEGER}
     </select>
 
 </mapper>