linwe
2024-05-29 c10d6358b9f014375a13821465bc978d0c0da22e
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
<?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.circle.mapper.CircleMapper">
 
    <resultMap type="org.springblade.modules.circle.vo.CircleVO" id="CircleVOResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="circleText"    column="circle_text"    />
        <result property="circleImages"    column="circle_images"    />
        <result property="circleVideo"    column="circle_video"    />
        <result property="deletedFalg"    column="deleted_falg"    />
        <result property="circleType"    column="circle_type"    />
        <result property="eventId"    column="event_id"    />
        <result property="evenType"    column="even_type"    />
        <result property="communityCode"    column="community_code"    />
        <result property="houseCode"    column="house_code"    />
    </resultMap>
 
    <sql id="selectCircle">
        select
            id,
            user_id,
            create_time,
            circle_text,
            circle_images,
            circle_video,
            deleted_falg,
            circle_type,
            event_id,
            even_type,
            community_code,
            house_code
        from
            jczz_circle
    </sql>
 
    <select id="selectCircleById" parameterType="int" resultMap="CircleVOResult">
        <include refid="selectCircle"/>
        where
        id = #{id}
    </select>
 
    <select id="selectCircleList" parameterType="org.springblade.modules.circle.dto.CircleDTO" resultMap="CircleVOResult">
        <include refid="selectCircle"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="circleText != null  and circleText != ''"> and circle_text = #{circleText}</if>
            <if test="circleImages != null  and circleImages != ''"> and circle_images = #{circleImages}</if>
            <if test="circleVideo != null  and circleVideo != ''"> and circle_video = #{circleVideo}</if>
            <if test="deletedFalg != null "> and deleted_falg = #{deletedFalg}</if>
            <if test="circleType != null "> and circle_type = #{circleType}</if>
        </where>
    </select>
 
 
    <select id="selectCirclePage" resultMap="CircleVOResult">
        select jc.*,
        bu.name,
        bu.avatar,
        (select count(1) from jczz_circle_like jcl where jcl.circle_id = jc.id and jcl.user_id = #{circle.userIds} and
        jcl.delete_flag = 0 ) likeFlag
        from jczz_circle jc left join blade_user bu on jc.user_id = bu.id
        <where>
            <if test="circle.id != null ">and jc.id = #{circle.id}</if>
            <if test="circle.userId != null ">and jc.user_id = #{circle.userId}</if>
            <if test="circle.createTime != null ">and jc.create_time = #{circle.createTime}</if>
            <if test="circle.circleText != null  and circle.circleText != ''">and jc.circle_text like concat
                ('%',#{circle.circleText},'%')
            </if>
            <if test="circle.circleImages != null  and circle.circleImages != ''">and jc.circle_images =
                #{circle.circleImages}
            </if>
            <if test="circle.circleVideo != null  and circle.circleVideo != ''">and jc.circle_video =
                #{circle.circleVideo}
            </if>
            <if test="circle.deletedFalg != null ">and jc.deleted_falg = #{circle.deletedFalg}</if>
            <if test="circle.circleType != null ">and jc.circle_type = #{circle.circleType}</if>
            <if test="circle.eventId != null "> and event_id = #{circle.eventId}</if>
            <if test="circle.evenType != null "> and even_type = #{circle.evenType}</if>
            <if test="circle.communityCode != null  and circle.communityCode != ''"> and community_code = #{circle.communityCode}</if>
            <if test="circle.houseCode != null  and circle.houseCode != ''"> and house_code = #{circle.houseCode}</if>
        </where>
        order by jc.create_time desc
    </select>
 
 
</mapper>