101captain
2021-12-23 5a8a90c095280fbd2106869ecd2bad10e01a57a6
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?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>
    <select id="getAllImages" resultType="java.lang.String">
        SELECT release_images FROM com_act_neighbor_circle
        WHERE community_id = #{communityId} AND `status` = 2 AND release_images IS NOT NULL AND release_images != ''
        ORDER BY create_at DESC limit #{pageSize}
    </select>
    <select id="getContents" resultType="java.lang.String">
        SELECT release_content FROM com_act_neighbor_circle
        WHERE community_id = #{communityId} AND `status` = 2 AND release_content IS NOT NULL AND release_content != ''
        ORDER BY create_at DESC limit #{pageSize}
    </select>
    <select id="getIndexNeighborBaseData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT filed, num, ROUND(num/total,2) AS percent FROM
        (SELECT t2.`name` AS filed, COUNT(1) AS num FROM com_act_neighbor_circle t1
        LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
        WHERE t1.community_id = #{communityId} AND t1.`status` IN (2,3) AND t1.is_del = 2 AND t2.`status` = 1 GROUP BY filed) temp1,
        (SELECT COUNT(t1.id) AS total FROM com_act_neighbor_circle t1
        LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
        WHERE t1.community_id = #{communityId} AND t1.`status` IN (2,3) AND t1.is_del = 2 AND t2.`status` = 1) temp2
    </select>
    <select id="getNeighborAddPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT DATE_FORMAT( t1.create_at, '%m' ) AS filed, COUNT(t1.id) AS num
        FROM com_act_neighbor_circle t1
        LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
        WHERE t1.community_id = #{communityId} AND t1.`status` IN (2,3) AND t1.is_del = 2 AND t2.`status` = 1
        AND DATE_FORMAT( t1.create_at, '%Y' ) = DATE_FORMAT( CURDATE( ) , '%Y' ) GROUP BY filed
    </select>
    <select id="getNeighborTotalPolylineDate"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT COUNT(t1.id) AS num FROM com_act_neighbor_circle t1
        LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
        WHERE t1.community_id = #{communityId} AND t1.`status` IN (2,3) AND t1.is_del = 2 AND t2.`status` = 1 AND DATE_FORMAT( t1.create_at, '%Y%m' ) &lt;= #{date}
    </select>
    <select id="indexNeighborList"
            resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAdminVO">
        SELECT t1.id, t1.release_content, t1.release_images, t1.comment_num, t1.fabulous_num, t2.`name` AS topicName
        FROM com_act_neighbor_circle t1
        LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
        WHERE t1.community_id = #{pageBaseDTO.communityId} AND t1.`status` IN (2,3) AND t1.is_del = 2 AND t2.`status` = 1
        <if test="pageBaseDTO.paramId != null">
            AND t1.topic_id = #{pageBaseDTO.paramId}
        </if>
        ORDER BY t1.id DESC
    </select>
 
</mapper>