ALTER TABLE `model` DROP FOREIGN KEY `fk_model_id`;
ALTER TABLE `role_model` DROP FOREIGN KEY `fk_rm_model_id`;
ALTER TABLE `role_model` DROP FOREIGN KEY `fk_rm_role_id`;
ALTER TABLE `cms_content` DROP FOREIGN KEY `fk_category_id`;
UPDATE `mdiy_tag` SET `tag_name` = 'arclist', `tag_type` = 'list', `tag_sql` = '<#assign _typeid=\'\'/>\r\n<#assign _typetitle=\'\'/>\r\n<#-- 分页数，默认返回20条数据 -->\r\n<#assign _size=\'20\'/>\r\n<#if column?? && column.id?? && column.id?number gt 0>\r\n    <#assign  _typeid=\'${column.id}\'>\r\n</#if>\r\n<#if typeid??>\r\n    <#assign  _typeid=\'${typeid}\'>\r\n</#if>\r\n<#if typeids??>\r\n    <#assign  _typeids=\'${typeids}\'>\r\n</#if>\r\n<#if typetitle??>\r\n    <#assign  _typetitle=\'${typetitle}\'>\r\n</#if>\r\n<#if size??>\r\n    <#assign  _size=\'${size}\'>\r\n</#if>\r\n\r\n<#assign  _order=\'desc\'>\r\n\r\n<#if order?? >\r\n    <#if order==\'desc\'>\r\n        <#assign _order=\'desc\'>\r\n    </#if>\r\n    <#if order==\'asc\'>\r\n        <#assign _order=\'asc\'>\r\n    </#if>\r\n</#if>\r\n\r\n<#if orderby?? >\r\n    <#assign  _orderby = \'\'>\r\n    <#list orderby?split(\',\') as order>\r\n    <#-- 防止传空值拼接, -->\r\n        <#if !order?has_content>\r\n            <#continue >\r\n        </#if>\r\n        <#if _orderby?has_content>\r\n            <#assign _orderby += \',\'>\r\n        </#if>\r\n        <#if order==\'date\'>\r\n            <#assign  _orderby += \'cms_content.content_datetime\'>\r\n        <#elseif order==\'updatedate\'>\r\n            <#assign  _orderby += \'cms_content.cms_content.update_date\'>\r\n        <#elseif order==\'hit\'>\r\n            <#assign  _orderby += \'cms_content.content_hit\'>\r\n        <#elseif order==\'sort\'>\r\n            <#assign  _orderby += \'cms_content.content_sort\'>\r\n        </#if>\r\n        <#-- 去除_orderby末尾的逗号（如果存在） -->\r\n        <#if _orderby?has_content && _orderby?last_index_of(\',\') == _orderby?length - 1>\r\n            <#assign _orderby = _orderby?substring(0, _orderby?length - 1)>\r\n        </#if>\r\n        <#if _orderby?has_content>\r\n            <#assign _orderby += \' \' + _order>\r\n        </#if>\r\n    </#list>\r\n    <#-- 容错处理，如果什么都没有匹配到，则默认按文章时间排序 -->\r\n    <#if !_orderby?has_content>\r\n        <#assign _orderby = \'cms_content.content_datetime \' + _order>\r\n    </#if>\r\n<#else>\r\n    <#assign _orderby = \'cms_content.content_datetime \' + _order>\r\n</#if>\r\n\r\n\r\nSELECT\r\ncms_content.id AS \"id\",\r\ncontent_title AS \"title\",\r\ncontent_short_title AS \"shorttitle\",\r\ncontent_author AS \"author\",\r\ncontent_source AS \"source\",\r\ncontent_out_link AS \"outlink\",\r\ncontent_tags AS \"tags\",\r\n\r\ncategory.category_title AS \"typetitle\",\r\ncategory.category_short_title AS \"typeshorttitle\",\r\ncategory.id AS \"typeid\",\r\ncategory.category_path AS \"typepath\",\r\ncategory.category_img AS \"typelitpic\",\r\ncategory.category_ico AS \"typeico\",\r\ncategory.category_keyword as \"typekeyword\",\r\ncategory.top_id as \"topid\",\r\ncategory.category_id as \"parentid\",\r\ncategory.category_parent_ids as \"parentids\",\r\ncategory.category_type AS \"type\",\r\n<#--列表页动态链接-->\r\n<#if isDo?? && isDo>\r\n    CONCAT(\'${modelName}/list.do?style=${templateName!\"\"}&typeid=\', category.category_id) as \"typelink\",\r\n<#else>\r\n<#--栏目类型为链接-->\r\n    <#if shortSwitch?? && shortSwitch>\r\n        CONCAT(category.category_pinyin,\'.html\') AS \"typelink\",\r\n    <#else>\r\n        CONCAT(category.category_path,\'/index.html\') AS \"typelink\",\r\n    </#if>\r\n</#if>\r\ncontent_description AS \"descrip\",\r\ncontent_hit AS \"hit\",\r\ncontent_type AS \"flag\",\r\ncms_content.content_keyword AS \"keyword\",\r\ncontent_img AS \"litpic\",\r\n<#--内容页动态链接-->\r\n<#if isDo?? && isDo>\r\n    CONCAT(\'${modelName}/view.do?style=${templateName!\"\"}&id=\', cms_content.id) as \"link\",\r\n<#else>\r\n    <#if shortSwitch?? && shortSwitch>\r\n        CONCAT(cms_content.id,\'.html\') AS \"link\",\r\n    <#else>\r\n        CONCAT(CONCAT( category.category_path, \'/\' ), CONCAT(CASE category_type WHEN  \'2\' THEN \'index\' ELSE cms_content.id END , \'.html\' )) as \"link\",\r\n    </#if>\r\n</#if>\r\n<#if tableName??>${tableName}.*,</#if>\r\ncontent_datetime AS \"date\"\r\nFROM\r\ncms_content\r\nLEFT JOIN\r\ncms_category as category\r\nON cms_content.category_id = category.id\r\n<#--判断是否有自定义模型表-->\r\n<#if tableName??>\r\n    LEFT JOIN ${tableName} ON ${tableName}.link_id=cms_content.id\r\n</#if>\r\nWHERE\r\ncontent_display=0\r\nand category_display=\'enable\'\r\nand cms_content.del=0\r\n\r\n<#--文章审核-->\r\n<#if contentApprove?? && contentApprove>\r\n    and cms_content.progress_status=\'终审通过\'\r\n</#if>\r\n<#--根据站点编号查询-->\r\n<#if appId?? >\r\n    and cms_content.app_id=${appId}\r\n    and cms_content.id>0\r\n</#if>\r\n<#--判断是否有搜索分类集合，暂时移除 _typeid=\"\" 条件-->\r\n<#if search?? && !typeid??>\r\n    and category_is_search=\'enable\'\r\n<#-- 文章标签 -->\r\n    <#if search.content_tag??>and FIND_IN_SET(\'${search.content_tag}\',content_tags) > 0</#if>\r\n    <#if search.categoryIds?has_content>\r\n        and (\r\n        <#list search.categoryIds?split(\",\") as item>\r\n            <#if item?index gt 0>\r\n                or\r\n            </#if>\r\n            (cms_content.category_id=${item}\r\n            or cms_content.category_id in (select id FROM cms_category where cms_category.del=0\r\n            <#if _typetitle?has_content>\r\n                and cms_category.category_title=\'${_typetitle}\'\r\n            </#if>\r\n            and FIND_IN_SET(${item},CATEGORY_PARENT_IDS) > 0)\r\n            )\r\n        </#list>\r\n        )\r\n    </#if>\r\n<#--标题-->\r\n    <#if search.content_title??> and content_title like CONCAT(CONCAT(\'%\',\'${search.content_title}\'),\'%\')</#if>\r\n<#--作者-->\r\n    <#if search.content_author??> and content_author like CONCAT(CONCAT(\'%\',\'${search.content_author}\'),\'%\')</#if>\r\n<#--来源-->\r\n    <#if search.content_source??> and content_source like CONCAT(CONCAT(\'%\',\'${search.content_source}\'),\'%\')</#if>\r\n<#--属性-->\r\n    <#if search.content_type??>\r\n        and(<#list search.content_type?split(\',\') as item>\r\n        <#if item?index gt 0> or</#if>\r\n        FIND_IN_SET(\'${item}\',cms_content.content_type) > 0\r\n    </#list>)\r\n    </#if>\r\n<#--描述-->\r\n    <#if search.content_description??>\r\n        and content_description like CONCAT(CONCAT(\'%\',\'${search.content_description}\'),\'%\')\r\n    </#if>\r\n<#--关键字-->\r\n    <#if search.content_keyword??> and content_keyword like CONCAT(CONCAT(\'%\',\'${search.content_keyword}\'),\'%\')</#if>\r\n<#--内容-->\r\n    <#if search.content_details??> and content_details like CONCAT(CONCAT(\'%\',\'${search.content_details}\'),\'%\')</#if>\r\n<#--自定义顺序-->\r\n    <#if search.content_sort??> and content_sort=${search.content_sort}</#if>\r\n<#--时间范围-->\r\n    <#if search.content_datetime_start??&&search.content_datetime_end??>\r\n        and content_datetime between \'${search.content_datetime_start}\' and \'${search.content_datetime_end}\'\r\n    </#if>\r\n<#else>\r\n<#--查询栏目-->\r\n    <#if _typeids?has_content>\r\n        and (\r\n        <#list _typeids?split(\",\") as item>\r\n            <#if item?index gt 0>\r\n                or\r\n            </#if>\r\n            (cms_content.category_id=${item}\r\n            or cms_content.category_id in (select id FROM cms_category where cms_category.del=0\r\n            <#if _typetitle?has_content>\r\n                and cms_category.category_title=\'${_typetitle}\'\r\n            </#if>\r\n            and FIND_IN_SET(${item},CATEGORY_PARENT_IDS) > 0)\r\n            )\r\n        </#list>\r\n        )\r\n    <#elseif _typeid?has_content && _typeid?string != \'0\' >\r\n        and (cms_content.category_id=${_typeid}\r\n        or cms_content.category_id in (select id FROM cms_category where cms_category.del=0\r\n        <#if _typetitle?has_content>\r\n            and cms_category.category_title=\'${_typetitle}\'\r\n        </#if>\r\n        and FIND_IN_SET(${_typeid},CATEGORY_PARENT_IDS) > 0))\r\n    </#if>\r\n</#if>\r\n<#--判断搜索分类结束-->\r\n<#--标题-->\r\n<#if content_title??> and content_title like CONCAT(CONCAT(\'%\',\'${content_title}\'),\'%\')</#if>\r\n<#--作者-->\r\n<#if content_author??> and content_author like CONCAT(CONCAT(\'%\',\'${content_author}\'),\'%\')</#if>\r\n<#--来源-->\r\n<#if content_source??> and content_source like CONCAT(CONCAT(\'%\',\'${content_source}\'),\'%\')</#if>\r\n<#--属性-->\r\n<#if content_type??> and content_type like CONCAT(CONCAT(\'%\',\'${content_type}\'),\'%\')</#if>\r\n<#--描述-->\r\n<#if content_description??> and content_description like CONCAT(CONCAT(\'%\',\'${content_description}\'),\'%\')</#if>\r\n<#--关键字-->\r\n<#if content_keyword??> and content_keyword like CONCAT(CONCAT(\'%\',\'${content_keyword}\'),\'%\')</#if>\r\n<#--内容-->\r\n<#if content_details??> and content_details like CONCAT(CONCAT(\'%\',\'${content_details}\'),\'%\')</#if>\r\n<#--自定义顺序-->\r\n<#if content_sort??> and content_sort=${content_sort}</#if>\r\n<#--自定义模型-->\r\n<#if diyModel??>\r\n    <#list diyModel as dm>\r\n        <#assign json=\"${dm}\"?eval />\r\n        and ${tableName}.${json.key} like CONCAT(CONCAT(\'%\',\'${json.value}\'),\'%\')\r\n    </#list>\r\n</#if>\r\n<#--文章属性-->\r\n<#if flag?? >\r\n    and(<#list flag?split(\',\') as item>\r\n    <#if item?index gt 0> or</#if>\r\n    FIND_IN_SET(\'${item}\',cms_content.content_type) > 0\r\n</#list>)\r\n</#if>\r\n<#if noflag??>\r\n    and(<#list noflag?split(\',\') as item>\r\n    <#if item?index gt 0> and</#if>\r\n    FIND_IN_SET(\'${item}\',cms_content.content_type)=0\r\n</#list> or cms_content.content_type is null)\r\n</#if>\r\n\r\n<#--字段排序-->\r\nORDER BY\r\n<#if topflag??>\r\n    CASE\r\n    <#list topflag?split(\",\") as item>\r\n        WHEN FIND_IN_SET(\'${item}\',cms_content.content_type)>0 THEN\r\n        ${item?index}\r\n    </#list>\r\n    ELSE 100\r\n    END,\r\n</#if>\r\n${_orderby}\r\nLIMIT\r\n<#--判断是否分页-->\r\n<#if ispaging?? && (pageTag.pageNo)??>\r\n    ${((pageTag.pageNo-1)*_size?eval)?c},${_size?default(20)}\r\n<#else>\r\n    ${_size?default(20)}\r\n</#if>\r\n\r\n', `tag_class` = NULL, `tag_description` = '文章列表', `UPDATE_BY` = NULL, `UPDATE_DATE` = NULL, `CREATE_BY` = NULL, `CREATE_DATE` = NULL, `DEL` = 0, `NOT_DEL` = 1 WHERE `id` = 3;
UPDATE `mdiy_tag` SET `tag_name` = 'channel', `tag_type` = 'list', `tag_sql` = '<#assign _typeid=\'0\'/>\r\n<#assign _size=\'9999\'/>\r\n<#if column?? && column.id?? && column.id?number gt 0>\r\n    <#assign  _typeid=\'${column.id}\'>\r\n    <#assign  selfid=\'${column.id}\'>\r\n</#if>\r\n\r\n<#if typeid??>\r\n    <#assign  _typeid=\'${typeid}\'>\r\n</#if>\r\n<#if typeids??>\r\n    <#assign  _typeids=\'${typeids}\'>\r\n</#if>\r\n<#if size??>\r\n    <#assign  _size=\'${size}\'>\r\n</#if>\r\n\r\nselect\r\ncms_category.id as \"id\",\r\ncms_category.id as \"typeid\",\r\ncms_category.category_title as \"typetitle\",\r\ncms_category.category_short_title as \"typeshorttitle\",\r\n<#--动态链接-->\r\n<#if isDo?? && isDo>\r\n    IF(cms_category.category_type=2,CONCAT(\'${modelName}/view.do?style=${templateName!\"\"}&typeid=\', cms_category.id),CONCAT(\'${modelName}/list.do?style=${templateName!\"\"}&typeid=\', cms_category.id)) as \"typelink\",\r\n<#else>\r\n<#--栏目类型为链接-->\r\n    <#if shortSwitch?? && shortSwitch>\r\n        CONCAT(cms_category.category_pinyin,\'.html\') AS \"typelink\",\r\n    <#else>\r\n        CONCAT(cms_category.category_path,\'/index.html\') as \"typelink\",\r\n    </#if>\r\n</#if>\r\ncms_category.category_keyword as \"typekeyword\",\r\ncms_category.category_diy_url as \"typeurl\",\r\ncms_category.category_flag as \"flag\",\r\ncms_category.category_id as \"parentid\",\r\ncms_category.category_parent_ids as \"parentids\",\r\ncms_category.category_descrip as \"typedescrip\",\r\ncms_category.category_type as \"type\",\r\ncms_category.category_path as \"typepath\",\r\ncms_category.leaf as \"typeleaf\",\r\ncms_category.category_img as \"typelitpic\" ,\r\ncms_category.category_ico as \"typeico\" ,\r\n<#if tableName??>${tableName}.*,</#if>\r\n( SELECT count(*) FROM cms_category cc WHERE cc.category_id = cms_category.id AND cc.del = 0 ) AS \"childsize\"\r\nfrom\r\ncms_category\r\n<#--判断是否有自定义模型表-->\r\n<#if tableName??>LEFT JOIN ${tableName} ON ${tableName}.link_id=cms_category.id</#if>\r\nwhere\r\ncms_category.del= 0\r\nand  cms_category.category_display = \'enable\'\r\n<#--自定义模型-->\r\n<#if diyModel??>\r\n    <#list diyModel as dm>\r\n        <#assign json=\"${dm}\"?eval />\r\n        and ${tableName}.${json.key} like CONCAT(\'%\',\'${json.value}\',\'%\')\r\n    </#list>\r\n</#if>\r\n<#--根据站点编号查询-->\r\n<#if appId?? >\r\n    and cms_category.app_id=${appId}\r\n</#if>\r\n\r\n<#--栏目属性-->\r\n<#if flag?? >\r\n    and\r\n    (<#list flag?split(\',\') as item>\r\n    <#if item?index gt 0> or</#if>\r\n    FIND_IN_SET(\'${item}\',cms_category.category_flag) > 0\r\n</#list>)\r\n</#if>\r\n\r\n<#if noflag?? >\r\n    and\r\n    (<#list noflag?split(\',\') as item>\r\n    <#if item?index gt 0> and</#if>\r\n    FIND_IN_SET(\'${item}\',cms_category.category_flag)=0\r\n</#list> or cms_category.category_flag is null)\r\n</#if>\r\n\r\n<#--type默认son-->\r\n<#if !type??||!type?has_content>\r\n    <#assign type=\'son\'/>\r\n</#if>\r\n\r\n<#-- 如果有typeids参数，则只查询typeids参数指定的栏目  -->\r\n<#if _typeids?has_content>\r\n    and cms_category.id in (${_typeids})\r\n<#elseif type?has_content>\r\n    <#--顶级栏目（单个）-->\r\n    <#if type==\'top\'>\r\n        <#if _typeid != \'0\'>\r\n            and (cms_category.id = cms_category.top_id or cms_category.top_id = 0)\r\n        </#if>\r\n\r\n    <#elseif type==\'nav\'>\r\n        and(cms_category.category_id=0 or cms_category.category_id is null)\r\n\r\n    <#--同级栏目（多个）-->\r\n    <#elseif type==\'level\'>\r\n        <#if _typeid != \'0\'>\r\n            and cms_category.category_id=(select category_id from cms_category where id=${_typeid})\r\n        </#if>\r\n\r\n    <#--当前栏目（单个）-->\r\n    <#elseif type==\'self\'>\r\n        <#if _typeid != \'0\'>\r\n            and cms_category.id=${_typeid}\r\n        </#if>\r\n\r\n    <#--当前栏目的所属栏目（多个）-->\r\n    <#elseif type==\'path\'>\r\n        <#if _typeid != \'0\'>\r\n            and cms_category.id in\r\n            (<#if column?? && column.categoryParentIds??>${column.categoryParentIds},</#if>${_typeid})\r\n        </#if>\r\n\r\n    <#--子栏目（多个）-->\r\n    <#elseif type==\'son\'>\r\n        <#if _typeid != \'0\'>\r\n            and cms_category.category_id=${_typeid}\r\n        </#if>\r\n\r\n    <#--上一级栏目没有则取当前栏目（单个）-->\r\n    <#elseif type==\'parent\'>\r\n        <#if _typeid != \'0\'>\r\n            and\r\n            <#if column?? && column.categoryId??>\r\n                cms_category.id=${column.categoryId}\r\n            <#else>\r\n                cms_category.id=(select category_id from cms_category where id=${_typeid})\r\n            </#if>\r\n        </#if>\r\n    </#if>\r\n\r\n<#else> <#--默认顶级栏目-->\r\n    and\r\n    <#if _typeid != \'0\'>\r\n        cms_category.id=${_typeid}\r\n    <#else>\r\n        (cms_category.category_id=0 or cms_category.category_id is null)\r\n    </#if>\r\n</#if>\r\n\r\n<#--字段排序-->\r\n<#if type == \'path\'>\r\n    ORDER BY cms_category.category_path asc\r\n<#else>\r\n    <#if orderby?? >\r\n        ORDER BY\r\n        <#if orderby==\'date\'> cms_category.create_date\r\n        <#elseif orderby==\'sort\'> cms_category.category_sort\r\n        <#else>cms_category.id\r\n        </#if>\r\n    </#if>\r\n\r\n    <#if order?? >\r\n        <#if order==\'desc\'> desc</#if>\r\n        <#if order==\'asc\'> asc</#if>\r\n    </#if>\r\n</#if>\r\nLIMIT\r\n${_size?default(9999)}\r\n', `tag_class` = NULL, `tag_description` = '通用栏目', `UPDATE_BY` = NULL, `UPDATE_DATE` = NULL, `CREATE_BY` = NULL, `CREATE_DATE` = NULL, `DEL` = 0, `NOT_DEL` = 1 WHERE `id` = 4;