|
@@ -19,8 +19,8 @@
|
|
|
<result property="nickName" column="nick_name"/>
|
|
|
<result property="email" column="email"/>
|
|
|
<result property="avatar" column="avatar"/>
|
|
|
- <collection property="imageList" javaType="java.util.List" resultMap="CommunityArticleImagesResult"/>
|
|
|
- <collection property="comments" resultMap="CommunityCommentsResult"/>
|
|
|
+ <result column="images" property="imageList" javaType="java.util.List" typeHandler="com.ruoyi.common.utils.bean.JSONTypeHandler"/>
|
|
|
+ <result column="comments" property="comments" typeHandler="com.ruoyi.common.utils.bean.JSONTypeHandler"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<resultMap type="CommunityArticleImages" id="CommunityArticleImagesResult">
|
|
@@ -108,38 +108,58 @@
|
|
|
a.create_time as article_create_time,
|
|
|
a.update_by as article_update_by,
|
|
|
a.update_time as article_update_time,
|
|
|
+ COALESCE((
|
|
|
+ SELECT
|
|
|
JSON_ARRAYAGG(
|
|
|
+ CASE
|
|
|
+ WHEN b.id IS NOT NULL THEN
|
|
|
JSON_OBJECT(
|
|
|
- 'image_id', b.id,
|
|
|
- 'images_article_id',b.article_id,
|
|
|
- 'image_url',b.image_url,
|
|
|
- 'images_create_by',b.create_by,
|
|
|
- 'images_create_time',b.create_time,
|
|
|
- 'images_update_by',b.update_by,
|
|
|
- 'images_update_time',b.update_time
|
|
|
+ 'id', IFNULL(b.id,''),
|
|
|
+ 'articleId', IFNULL(b.article_id,''),
|
|
|
+ 'imageUrl', IFNULL(b.image_url,''),
|
|
|
+ 'createBy', IFNULL(b.create_by,''),
|
|
|
+ 'createTime', IFNULL(DATE_FORMAT(b.create_time,'%Y-%m-%d %H:%i:%s'),''),
|
|
|
+ 'updateBy', IFNULL(b.update_by,''),
|
|
|
+ 'updateTime', IFNULL(DATE_FORMAT(b.update_time,'%Y-%m-%d %H:%i:%s'),'')
|
|
|
)
|
|
|
- ) as images,
|
|
|
+ ELSE NULL
|
|
|
+ END
|
|
|
+ )
|
|
|
+ FROM
|
|
|
+ community_article_images b
|
|
|
+ WHERE
|
|
|
+ b.article_id = a.id
|
|
|
+ ), '[]') AS images,
|
|
|
c.user_name as user_name,
|
|
|
c.nick_name as nick_name,
|
|
|
c.email as email,
|
|
|
c.avatar as avatar,
|
|
|
+ COALESCE((
|
|
|
+ SELECT
|
|
|
JSON_ARRAYAGG(
|
|
|
+ CASE
|
|
|
+ WHEN d.id IS NOT NULL THEN
|
|
|
JSON_OBJECT(
|
|
|
- 'comment_id',d.id,
|
|
|
- 'comment_article_id',d.article_id,
|
|
|
- 'comment_user_id',d.user_id,
|
|
|
- 'comment_content',d.content,
|
|
|
- 'comment_create_by',d.create_by,
|
|
|
- 'comment_create_time',d.create_time,
|
|
|
- 'comment_update_by',d.update_by,
|
|
|
- 'comment_update_time',d.update_time
|
|
|
+ 'id', IFNULL(d.id,''),
|
|
|
+ 'articleId', IFNULL(d.article_id,''),
|
|
|
+ 'userId', IFNULL(d.user_id,''),
|
|
|
+ 'content', IFNULL(d.content,''),
|
|
|
+ 'createBy', IFNULL(d.create_by,''),
|
|
|
+ 'createTime', IFNULL(DATE_FORMAT(d.create_time,'%Y-%m-%d %H:%i:%s'),''),
|
|
|
+ 'updateBy', IFNULL(d.update_by,''),
|
|
|
+ 'updateTime', IFNULL(DATE_FORMAT(d.update_time,'%Y-%m-%d %H:%i:%s'),'')
|
|
|
+ )
|
|
|
+ ELSE NULL
|
|
|
+ END
|
|
|
)
|
|
|
- ) as comments
|
|
|
+ FROM
|
|
|
+ community_article_comment d
|
|
|
+ WHERE
|
|
|
+ d.article_id = a.id
|
|
|
+ ), '[]') AS comments
|
|
|
from
|
|
|
community_article a
|
|
|
- left join community_article_images b on a.id = b.article_id
|
|
|
left join sys_user c on a.user_id = c.user_id
|
|
|
- left join community_article_comment d on d.article_id = a.id
|
|
|
<where>
|
|
|
<if test="communityArticle.id != null and communityArticle.id != ''">
|
|
|
AND a.id = #{communityArticle.id}
|