SELECT 
cms_content.id as id,
left(content_title,${titlelen?default(40)}) as title,
content_title as fulltitle,
content_author as author, 
content_source as source, 
content_details as content,
category_title as typetitle,
cms_category.id as typeid,
 ( CASE cms_category.category_img WHEN '' THEN cms_category.category_img ELSE CONVERT ( JSON_UNQUOTE( JSON_EXTRACT( cms_category.category_img -> '$[0]', '$.path' ) ) USING utf8 ) END ) AS typelitpic,
<#--动态链接-->
<#if isDo?? && isDo>
CONCAT("/${modelName}/list.do?typeid=", cms_category.id) as typelink,
<#else>
(SELECT "index.html") as typelink,
</#if>
( CASE cms_content.content_img WHEN '' THEN cms_content.content_img ELSE CONVERT ( JSON_UNQUOTE( JSON_EXTRACT( cms_content.content_img -> '$[0]', '$.path' ) ) USING utf8 ) END ) AS litpic,
<#--内容页动态链接-->
<#if isDo?? && isDo>
CONCAT("/mcms/view.do?id=", cms_content.id) as link,
<#else>
content_url AS link,
</#if>
content_datetime as date,
content_description as descrip,
CONCAT("<script type='text/javascript' src='${url}/cms/content/",cms_content.id,"/hit.do'></script>") as hit,
content_type as flag,
category_title as typetitle,
<#if tableName??>${tableName}.*,</#if>
content_keyword as keyword
FROM cms_content
LEFT JOIN cms_category  ON 
<#--如果是栏目列表页没有文章id所以只取栏目id-->
<#if column??&&column.id??&&!id??> 
 cms_category.id=${column.id}
<#else>
cms_category.id = content_category_id
</#if>
<#--判断是否有自定义模型表-->
<#if tableName??>left join ${tableName} on ${tableName}.link_id=cms_content.id</#if>
WHERE 
 cms_content.del=0
<#if id??> and cms_content.id=${id}</#if>