<#ftl output_format="JSON">
[<#macro merge name value><#if !.vars[name]??><@"<#assign ${name}=''>"?interpret /></#if><#if value?has_content><@"<#assign ${name}=${name}+'${value},'>"?interpret /></#if></#macro>
<@cms.commentList contentId=content.id replyId=replyId pageIndex=pageIndex>
    <#list page.list as a>
        <@merge 'userIds' a.userId!/>
        <@merge 'userIds' a.replyUserId!/>
    </#list>
    <@sys.user ids=userIds!><#assign userMap=map!/></@sys.user>
    <#list page.list as a>
        {
            "userId":${a.userId},
            "userNickname":"${userMap[a.userId?string].nickname}",
            "createDate":"${a.createDate?string}",
            "replies":${a.replies},
            <#if a.replyId?has_content>
                "replay":{
                <@cms.comment id=a.replyId>
                    "userId":${a.userId},
                    "userNickname":"${userMap[a.replyUserId?string].nickname}",
                    "text":"${object.text!}"
                </@cms.comment>
                },
            </#if>
            "text":"${a.text!}"
        }<#sep>,
    </#list>
</@cms.commentList>]