101captain
2021-11-11 78d1c9ee9b0c49f77c29d0535cb93c6d62c42f3a
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?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="com.panzhihua.service_community.dao.ComActNeighborCircleDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActNeighborCircleDO">
        <id column="id" property="id"/>
        <result column="release_id" property="releaseId"/>
        <result column="release_phone" property="releasePhone"/>
        <result column="community_id" property="communityId"/>
        <result column="release_content" property="releaseContent"/>
        <result column="release_images" property="releaseImages"/>
        <result column="status" property="status"/>
        <result column="refuse_reason" property="refuseReason"/>
        <result column="comment_num" property="commentNum"/>
        <result column="fabulous_num" property="fabulousNum"/>
        <result column="forward_num" property="forwardNum"/>
        <result column="views_num" property="viewsNum"/>
        <result column="is_boutique" property="isBoutique"/>
        <result column="create_at" property="createAt"/>
        <result column="reply_at" property="replyAt"/>
        <result column="last_comment_num" property="lastCommentNum"/>
        <result column="last_fabulous_num" property="lastFabulousNum"/>
        <result column="last_views_num" property="lastViewsNum"/>
        <result column="type" property="type"/>
        <result column="topic_id" property="topicId"/>
        <result column="hot_num" property="hotNum"/>
        <result column="is_del" property="isDel"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, release_id, release_phone, community_id, release_content, release_images, status, refuse_reason, comment_num, fabulous_num, forward_num, views_num, is_boutique, create_at, reply_at, last_comment_num, last_fabulous_num, last_views_num, type, topic_id, hot_num, is_del
    </sql>
 
    <select id="pageNeighborByApp" parameterType="com.panzhihua.common.model.dtos.neighbor.ComActNeighborCircleAppDTO"
            resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAppVO">
        SELECT
        canc.id,
        canc.release_content,
        canc.release_images,
        canc.comment_num,
        canc.fabulous_num,
        canc.forward_num,
        canc.views_num,
        canc.is_boutique,
        canc.create_at,
        canc.refuse_reason,
        canc.reply_at,
        canc.last_comment_num,
        canc.last_fabulous_num,
        canc.last_views_num,
        canc.type,
        canc.topic_id,
        canc.hot_num,
        su.nick_name as name,
        su.community_id,
        canct.name as topicName,
        su.image_url as headUrl
        FROM
        com_act_neighbor_circle AS canc
        left join sys_user as su on su.user_id = canc.release_id
        left join com_act_neighbor_circle_topic as canct on canct.id = canc.topic_id
        where canc.status = 2 and is_del = 2 and canc.community_id = #{neighborCircleAppDTO.communityId}
        <if test='neighborCircleAppDTO.topicId != null '>
            and canc.topic_id = #{neighborCircleAppDTO.topicId}
        </if>
        <if test='neighborCircleAppDTO.keyWord != null and neighborCircleAppDTO.keyWord != &quot;&quot;'>
            and (canct.`name` like concat (#{neighborCircleAppDTO.keyWord},'%') or
            su.nick_name like concat (#{neighborCircleAppDTO.keyWord},'%') or
             canc.release_content like concat (#{neighborCircleAppDTO.keyWord},'%'))
        </if>
        order by canc.create_at desc
    </select>
 
    <update id="addHotNum">
        update com_act_neighbor_circle set hot_num = hot_num + #{hotNum} where id = #{circleId}
    </update>
 
    <update id="addTopicHotNum">
        update com_act_neighbor_circle_topic set hot_num = hot_num + 1 where id = (select topic_id from com_act_neighbor_circle where id = #{circleId})
    </update>
 
    <select id="pageNeighborByAdmin" parameterType="com.panzhihua.common.model.dtos.neighbor.ComActNeighborCircleAdminDTO"
            resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAdminVO">
        SELECT
        nc.*,
        u.`nick_name` AS releaseName,u.image_url,canct.`name` as topicName ,u.`type` as userType
        ,u.name as communityName
        FROM
        com_act_neighbor_circle nc
        LEFT JOIN sys_user u ON nc.release_id = u.user_id
        LEFT JOIN com_act_neighbor_circle_topic as canct ON canct.id = nc.topic_id
        <where>
            nc.community_id = #{neighborCircleAdminDTO.communityId} and is_del = 2
            <if test='neighborCircleAdminDTO.releaseContent != null and neighborCircleAdminDTO.releaseContent != &quot;&quot;'>
                and nc.release_content like concat('%',#{neighborCircleAdminDTO.releaseContent},'%')
            </if>
            <if test='neighborCircleAdminDTO.topicName != null and neighborCircleAdminDTO.topicName != &quot;&quot;'>
                and canct.`name` = #{neighborCircleAdminDTO.topicName}
            </if>
            <if test='neighborCircleAdminDTO.keyWord != null and neighborCircleAdminDTO.keyWord != &quot;&quot;'>
                and (canct.`name` like concat(#{neighborCircleAdminDTO.keyWord},'%') or
                u.`nick_name` like concat(#{neighborCircleAdminDTO.keyWord},'%') or
                nc.`release_content` like concat(#{neighborCircleAdminDTO.keyWord},'%') )
            </if>
            <if test='neighborCircleAdminDTO.startAt != null and neighborCircleAdminDTO.endAt !=null '>
                and nc.create_at between #{neighborCircleAdminDTO.startAt} and #{neighborCircleAdminDTO.endAt}
            </if>
            <if test='neighborCircleAdminDTO.status != null '>
                and nc.status = #{neighborCircleAdminDTO.status}
            </if>
        </where>
        order by
        case when nc.`status`=1 then 0 else 1 end,
        nc.`status` asc,nc.create_at desc
    </select>
 
</mapper>