All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mapper.MkCommunityNoticeMapper.xml Maven / Gradle / Ivy

There is a newer version: 1.0.0-beta10
Show newest version
<?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.github.xujiaji.mk.community.mapper.MkCommunityNoticeMapper">
    <update id="readAll">
        UPDATE mk_community_notice SET state = 1 WHERE to_user_id = ${userId}
    </update>

    <select id="selectCommentNotice" resultType="com.github.xujiaji.mk.community.dto.FrontCommentNoticeDTO">
        SELECT
            cc.parent_id comment_id,
            cn.*,
            cn.from_user_id user_id,
            IF(f.state = 0, f.path, NULL) avatar,
            u.nickname,
            IF(cn.type = 0,'评论了你的故事','回复了你的评论') description,
            cc.content content,
            cn.to_user_id target_user_id,
            u2.nickname target_nickname,
            IF(cn.type = 0,CONCAT('#', ca.title, '#', '\n',IF(ca.content IS NULL, '', ca.content)),ccp.content) target_content
        FROM mk_community_notice cn
                 LEFT JOIN mk_user u ON cn.from_user_id = u.id
                 LEFT JOIN mk_user u2 ON cn.to_user_id = u2.id
                 LEFT JOIN mk_file f ON u.avatar = f.id
                 LEFT JOIN mk_community_article ca ON ca.id = cn.article_id
                 LEFT JOIN mk_community_comment cc ON cc.id = cn.comment_id
                 LEFT JOIN mk_community_comment ccp ON ccp.id = cc.parent_id
        WHERE cn.to_user_id = ${userId} AND (cn.type = 0 OR cn.type = 1) ORDER BY cn.create_time DESC
    </select>
    <select id="selectCollectAndPraiseNotice"
            resultType="com.github.xujiaji.mk.community.dto.FrontCollectAndPraiseDTO">
        SELECT
            cn.*,
            cn.from_user_id user_id,
            IF(f.state = 0, f.path, NULL) avatar,
            u.nickname,
            IF(cn.type = 2,'赞了你的故事',IF(cn.type = 3,'赞了你的留言','收藏了你的故事')) description
        FROM mk_community_notice cn
                 LEFT JOIN mk_user u ON cn.from_user_id = u.id
                 LEFT JOIN mk_file f ON u.avatar = f.id
        WHERE cn.to_user_id = ${userId} AND (cn.type = 2 OR cn.type = 3 OR cn.type = 4) ORDER BY cn.create_time DESC
    </select>
    <select id="selectUnreadNum" resultType="java.lang.Long">
        SELECT COUNT(*) FROM mk_community_notice WHERE to_user_id = ${userId} AND state = 0
    </select>
</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy