linwe
2024-08-09 8b7258c9427882bb1798f1502eaa35184c6e374e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.community.mapper.CommunityMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="communityResultMap" type="org.springblade.modules.community.entity.CommunityEntity">
        <result column="id" property="id"/>
        <result column="street_code" property="streetCode"/>
        <result column="code" property="code"/>
        <result column="name" property="name"/>
        <result column="pic_url" property="picUrl"/>
        <result column="address" property="address"/>
        <result column="res_police_user_id" property="resPoliceUserId"/>
        <result column="lng" property="lng"/>
        <result column="lat" property="lat"/>
        <result column="remark" property="remark"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
    <!--自定义分页列表查询-->
    <select id="selectCommunityPage" resultType="org.springblade.modules.community.vo.CommunityVO">
        select
        jc.id,
        jc.street_code,
        jc.code,
        jc.name,
        jc.pic_url,
        jc.address,
        jc.res_police_user_id,
        jc.lng,
        jc.lat,
        jc.remark,
        br.town_name townName
        from jczz_community jc
        left join blade_region br on br.code = jc.code
        where jc.is_deleted = 0
        <if test="community.name !=null and community.name!=''">
            and jc.name like concat('%',#{community.name},'%')
        </if>
        <if test="community.code !=null and community.code!=''">
            and jc.code like concat('%',#{community.code},'%')
        </if>
        <if test="community.streetCode !=null and community.streetCode!=''">
            and jc.street_code like concat('%',#{community.streetCode},'%')
        </if>
        <if test="community.townName !=null and community.townName !=''">
            and br.town_name like concat('%',#{community.townName},'%')
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                    and jc.code in
                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                        #{code}
                    </foreach>
                </when>
                <otherwise>
                    and jc.code in ('')
                </otherwise>
            </choose>
        </if>
    </select>
 
    <!--自定义分页列表查询-->
    <select id="getCommunityCodeListByUserId" resultType="java.lang.String">
        select code from jczz_community
        where is_deleted = 0 and res_police_user_id like concat('%',#{userId},'%')
    </select>
 
    <!--自定义分页列表查询-->
    <select id="getDetail" resultType="org.springblade.modules.community.vo.CommunityVO">
        select
        jc.id,
        jc.street_code,
        jc.code,
        jc.name,
        jc.pic_url,
        jc.address,
        jc.res_police_user_id,
        jc.lng,
        jc.lat,
        jc.remark,
        br.town_name townName
        from jczz_community jc
        left join blade_region br on br.code = jc.code
        where jc.is_deleted = 0
        and jc.id = #{community.id}
    </select>
 
 
</mapper>