linwei
2024-01-08 ad2ec97fe0c60eee4bb7c8cdacff7c876f280ea7
src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.xml
@@ -3,14 +3,15 @@
<mapper namespace="org.springblade.modules.discuss.mapper.UserTopicsMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="userTopicsResultMap" type="org.springblade.modules.discuss.entity.UserTopicsEntity">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="topicsId"    column="topics_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="deleteFlag"    column="delete_flag"    />
        <result property="publicDiscussId"    column="public_discuss_id"    />
    <resultMap id="userTopicsResultMap" type="org.springblade.modules.discuss.vo.UserTopicsVO">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="topicsId" column="topics_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="deleteFlag" column="delete_flag"/>
        <result property="publicDiscussId" column="public_discuss_id"/>
        <result property="selected" column="selected"/>
    </resultMap>
    <sql id="selectUserTopics">
@@ -21,6 +22,7 @@
            create_time,
            update_time,
            delete_flag,
            selected,
            public_discuss_id
        from
            jczz_user_topics
@@ -28,19 +30,47 @@
    <select id="selectUserTopicsPage" resultMap="userTopicsResultMap">
        select * from jczz_user_topics where deleted_flag = 0
        SELECT
        jut.article_id,
        bu.avatar,
        bu.`name`,
        bu.phone,
        jda.address_name,
        jda.aoi_name
        FROM
        jczz_user_topics as jut
        LEFT JOIN blade_user bu ON jut.user_id = bu.id
        LEFT JOIN jczz_household jh ON jh.associated_user_id = jut.user_id
        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jh.house_code
        <where>
            <if test="userTopics.id != null ">and jut.id = #{userTopics.id}</if>
            <if test="userTopics.userId != null ">and jut.user_id = #{userTopics.userId}</if>
            <if test="userTopics.topicsId != null ">and jut.topics_id = #{userTopics.topicsId}</if>
            <if test="userTopics.createTime != null ">and jut.create_time = #{userTopics.createTime}</if>
            <if test="userTopics.updateTime != null ">and jut.update_time = #{userTopics.updateTime}</if>
            <if test="userTopics.deleteFlag != null ">and jut.delete_flag = #{userTopics.deleteFlag}</if>
            <if test="userTopics.articleId != null ">and jut.article_id = #{userTopics.articleId}
                GROUP BY jut.article_id,
                bu.avatar,
                bu.`name`,
                bu.phone,
                jda.address_name,
                jda.aoi_name
            </if>
        </where>
    </select>
    <select id="selectUserTopicsList" parameterType="org.springblade.modules.discuss.dto.UserTopicsDTO" resultMap="userTopicsResultMap">
    <select id="selectUserTopicsList" parameterType="org.springblade.modules.discuss.dto.UserTopicsDTO"
            resultMap="userTopicsResultMap">
        <include refid="selectUserTopics"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="topicsId != null "> and topics_id = #{topicsId}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="deleteFlag != null "> and delete_flag = #{deleteFlag}</if>
            <if test="publicDiscussId != null "> and public_discuss_id = #{publicDiscussId}</if>
            <if test="id != null ">and id = #{id}</if>
            <if test="userId != null ">and user_id = #{userId}</if>
            <if test="topicsId != null ">and topics_id = #{topicsId}</if>
            <if test="createTime != null ">and create_time = #{createTime}</if>
            <if test="updateTime != null ">and update_time = #{updateTime}</if>
            <if test="deleteFlag != null ">and delete_flag = #{deleteFlag}</if>
            <if test="publicDiscussId != null ">and public_discuss_id = #{publicDiscussId}</if>
        </where>
    </select>