mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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.ComActNeighborCircleTopicWestMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActNeighborCircleTopicWestDO">
        <id column="id" property="id" />
        <result column="community_id" property="communityId" />
        <result column="name" property="name" />
        <result column="status" property="status" />
        <result column="create_at" property="createAt" />
        <result column="create_by" property="createBy" />
        <result column="count" property="count" />
        <result column="hot_num" property="hotNum" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, community_id, name, status, create_at, create_by, count, hot_num
    </sql>
 
    <select id="pageNeighborTopicByAdmin" parameterType="com.panzhihua.common.model.dtos.neighbor.ComActNeighborCircleTopicAdminDTO"
            resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleTopicAdminVO">
        SELECT
            canct.id,
            canct.`name`,
            canct.`status`,
            canct.create_at,
            ( SELECT count( id ) FROM com_act_neighbor_circle_west WHERE is_del = 2 AND `status` = 2 and topic_id = canct.id) AS `count`,
            su.`name` as createBy
        FROM
            com_act_neighbor_circle_topic_west AS canct
            LEFT JOIN sys_user AS su ON su.user_id = canct.create_by
        <where>
            canct.belong_type = 1
            <if test="circleTopicAdminDTO.communityId != null">
                and canct.community_id = ${circleTopicAdminDTO.communityId}
            </if>
            <if test="circleTopicAdminDTO.status != null">
                and canct.status = #{circleTopicAdminDTO.status}
            </if>
            <if test="circleTopicAdminDTO.name != null and circleTopicAdminDTO.name != &quot;&quot;">
                and canct.name like concat(#{circleTopicAdminDTO.name},'%')
            </if>
        </where>
        order by canct.create_at desc
    </select>
 
    <select id="getNeighborTopicByApp" resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleTopicAppVO">
        SELECT canct.id, canct.`name`, canct.hot_num,( SELECT count( id ) FROM com_act_neighbor_circle_west WHERE is_del = 2 AND `status` = 2 and topic_id = canct.id) AS `count`
         from com_act_neighbor_circle_topic_west as canct where canct.`status` = 1 and canct.community_id = ${communityId} AND canct.belong_type = 1
        <if test="isZero != null and isZero == 1">
            and `count` > 0
        </if>
        <if test="name != null and name != &quot;&quot;">
            and canct.`name` like concat('%',#{name},'%')
        </if>
        order by `count` desc
    </select>
 
    <update id="addHotNum">
        update com_act_neighbor_circle_topic_west set hot_num = hot_num + #{hotNum} where id = #{circleTopicId}
    </update>
 
    <update id="addCount">
        update com_act_neighbor_circle_topic_west set `count` = `count` + 1 where id = #{circleTopicId}
    </update>
</mapper>