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=\'\'/>\n<#assign _typetitle=\'\'/>\n<#-- 分页数，默认返回20条数据 -->\n<#assign _size=\'20\'/>\n<#if column?? && column.id?? && column.id?number gt 0>\n  <#assign  _typeid=\'${column.id}\'>\n</#if>\n<#if typeid??>\n  <#assign  _typeid=\'${typeid}\'>\n</#if>\n<#if typetitle??>\n  <#assign  _typetitle=\'${typetitle}\'>\n</#if>\n<#if size??>\n  <#assign  _size=\'${size}\'>\n</#if>\n\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 += \'content_datetime\'>\r\n        <#elseif order==\'updatedate\'>\r\n            <#assign  _orderby += \'cms_content.update_date\'>\r\n        <#elseif order==\'hit\'>\r\n            <#assign  _orderby += \'content_hit\'>\r\n        <#elseif order==\'sort\'>\r\n            <#assign  _orderby += \'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    </#list>\r\n    <#-- 容错处理，如果什么都没有匹配到，则默认按文章时间排序 -->\r\n    <#if !_orderby?has_content>\r\n        <#assign _orderby = \'cms_content.content_datetime\'>\r\n    </#if>\r\n<#else>\r\n    <#assign _orderby = \'cms_content.content_datetime\'>\r\n</#if>\r\n\n\nSELECT\n  cms_content.id AS \"id\",\n  content_title AS \"title\",\n  content_short_title AS \"shorttitle\",\n  content_author AS \"author\",\n  content_source AS \"source\",\n  content_out_link AS \"outlink\",\n  content_tags AS \"tags\",\n\n  category.category_title AS \"typetitle\",\n  category.category_short_title AS \"typeshorttitle\",\n  category.id AS \"typeid\",\n  category.category_path AS \"typepath\",\n  category.category_img AS \"typelitpic\",\n  category.category_ico AS \"typeico\",\n  category.category_keyword as \"typekeyword\",\n  category.top_id as \"topid\",\n  category.category_id as \"parentid\",\n  category.category_parent_ids as \"parentids\",\n  category.category_type AS \"type\",\n  <#--列表页动态链接-->\n  <#if isDo?? && isDo>\n    CONCAT(\'${modelName}/list.do?style=${templateName!\"\"}&typeid=\', category.category_id) as \"typelink\",\n  <#else>\n  <#--栏目类型为链接-->\n    <#if shortSwitch?? && shortSwitch>\n      CONCAT(category.category_pinyin,\'.html\') AS \"typelink\",\n    <#else>\n      CONCAT(category.category_path,\'/index.html\') AS \"typelink\",\n    </#if>\n  </#if>\n  content_description AS \"descrip\",\n  content_hit AS \"hit\",\n  content_type AS \"flag\",\n  cms_content.content_keyword AS \"keyword\",\n  content_img AS \"litpic\",\n  <#--内容页动态链接-->\n  <#if isDo?? && isDo>\n    CONCAT(\'${modelName}/view.do?style=${templateName!\"\"}&id=\', cms_content.id) as \"link\",\n  <#else>\n    <#if shortSwitch?? && shortSwitch>\n      CONCAT(cms_content.id,\'.html\') AS \"link\",\n    <#else>\n      CONCAT(CONCAT( category.category_path, \'/\' ), CONCAT(CASE category_type WHEN  \'2\' THEN \'index\' ELSE cms_content.id END , \'.html\' )) as \"link\",\n    </#if>\n  </#if>\n  <#if tableName??>${tableName}.*,</#if>\n  content_datetime AS \"date\"\nFROM\n  cms_content\nLEFT JOIN\n  cms_category as category\nON cms_content.category_id = category.id\n<#--判断是否有自定义模型表-->\n<#if tableName??>\n  LEFT JOIN ${tableName} ON ${tableName}.link_id=cms_content.id\n</#if>\nWHERE\n  content_display=0\n  and category_display=\'enable\'\n  and cms_content.del=0\n\n<#--文章审核-->\n<#if contentApprove?? && contentApprove>\n  and cms_content.progress_status=\'终审通过\'\n</#if>\n<#--根据站点编号查询-->\n<#if appId?? >\n  and cms_content.app_id=${appId}\n  and cms_content.id>0\n</#if>\n<#--判断是否有搜索分类集合，暂时移除 _typeid=\"\" 条件-->\n<#if search?? && !typeid??>\n  and category_is_search=\'enable\'\n  <#-- 文章标签 -->\n  <#if search.content_tag??>and FIND_IN_SET(\'${search.content_tag}\',content_tags) > 0</#if>\n  <#if search.categoryIds?has_content>\n  and (\n    <#list search.categoryIds?split(\",\") as item>\n    <#if item?index gt 0>\n   or\n    </#if>\n    (cms_content.category_id=${item}\n   or cms_content.category_id in (select id FROM cms_category where cms_category.del=0\n    <#if _typetitle?has_content>\n  and cms_category.category_title=\'${_typetitle}\'\n    </#if>\n  and FIND_IN_SET(${item},CATEGORY_PARENT_IDS) > 0)\n    )\n    </#list>\n    )\n  </#if>\n  <#--标题-->\n  <#if search.content_title??> and content_title like CONCAT(CONCAT(\'%\',\'${search.content_title}\'),\'%\')</#if>\n  <#--作者-->\n  <#if search.content_author??> and content_author like CONCAT(CONCAT(\'%\',\'${search.content_author}\'),\'%\')</#if>\n  <#--来源-->\n  <#if search.content_source??> and content_source like CONCAT(CONCAT(\'%\',\'${search.content_source}\'),\'%\')</#if>\n  <#--属性-->\n  <#if search.content_type??>\n    and(<#list search.content_type?split(\',\') as item>\n    <#if item?index gt 0> or</#if>\n      FIND_IN_SET(\'${item}\',cms_content.content_type) > 0\n    </#list>)\n  </#if>\n  <#--描述-->\n  <#if search.content_description??>\n    and content_description like CONCAT(CONCAT(\'%\',\'${search.content_description}\'),\'%\')\n  </#if>\n  <#--关键字-->\n  <#if search.content_keyword??> and content_keyword like CONCAT(CONCAT(\'%\',\'${search.content_keyword}\'),\'%\')</#if>\n  <#--内容-->\n  <#if search.content_details??> and content_details like CONCAT(CONCAT(\'%\',\'${search.content_details}\'),\'%\')</#if>\n  <#--自定义顺序-->\n  <#if search.content_sort??> and content_sort=${search.content_sort}</#if>\n  <#--时间范围-->\n  <#if search.content_datetime_start??&&search.content_datetime_end??>\n    and content_datetime between \'${search.content_datetime_start}\' and \'${search.content_datetime_end}\'\n  </#if>\n<#else>\n  <#--查询栏目-->\n  <#if _typeid?has_content && _typeid?string != \'0\'>\n  and (cms_content.category_id=${_typeid}\n  or cms_content.category_id in (select id FROM cms_category where cms_category.del=0\n    <#if _typetitle?has_content>\n      and cms_category.category_title=\'${_typetitle}\'\n    </#if>\n  and FIND_IN_SET(${_typeid},CATEGORY_PARENT_IDS) > 0))\n  <#elseif typeids?has_content>\n  and (\n    <#list typeids?split(\",\") as item>\n      <#if item?index gt 0>\n        or\n      </#if>\n  (cms_content.category_id=${item}\n   or cms_content.category_id in (select id FROM cms_category where cms_category.del=0\n    <#if _typetitle?has_content>\n  and cms_category.category_title=\'${_typetitle}\'\n    </#if>\n  and FIND_IN_SET(${item},CATEGORY_PARENT_IDS) > 0)\n    )\n    </#list>\n    )\n  </#if>\n</#if>\n<#--判断搜索分类结束-->\n<#--标题-->\n<#if content_title??> and content_title like CONCAT(CONCAT(\'%\',\'${content_title}\'),\'%\')</#if>\n<#--作者-->\n<#if content_author??> and content_author like CONCAT(CONCAT(\'%\',\'${content_author}\'),\'%\')</#if>\n<#--来源-->\n<#if content_source??> and content_source like CONCAT(CONCAT(\'%\',\'${content_source}\'),\'%\')</#if>\n<#--属性-->\n<#if content_type??> and content_type like CONCAT(CONCAT(\'%\',\'${content_type}\'),\'%\')</#if>\n<#--描述-->\n<#if content_description??> and content_description like CONCAT(CONCAT(\'%\',\'${content_description}\'),\'%\')</#if>\n<#--关键字-->\n<#if content_keyword??> and content_keyword like CONCAT(CONCAT(\'%\',\'${content_keyword}\'),\'%\')</#if>\n<#--内容-->\n<#if content_details??> and content_details like CONCAT(CONCAT(\'%\',\'${content_details}\'),\'%\')</#if>\n<#--自定义顺序-->\n<#if content_sort??> and content_sort=${content_sort}</#if>\n<#--自定义模型-->\n<#if diyModel??>\n  <#list diyModel as dm>\n  <#assign json=\"${dm}\"?eval />\n    and ${tableName}.${json.key} like CONCAT(CONCAT(\'%\',\'${json.value}\'),\'%\')\n  </#list>\n</#if>\n<#--文章属性-->\n<#if flag?? >\n  and(<#list flag?split(\',\') as item>\n  <#if item?index gt 0> or</#if>\n  FIND_IN_SET(\'${item}\',cms_content.content_type) > 0\n  </#list>)\n</#if>\n<#if noflag??>\n  and(<#list noflag?split(\',\') as item>\n  <#if item?index gt 0> and</#if>\n  FIND_IN_SET(\'${item}\',cms_content.content_type)=0\n  </#list> or cms_content.content_type is null)\n</#if>\n\n  <#--字段排序-->\n    ORDER BY\n      <#if topflag??>\n        CASE\n        <#list topflag?split(\",\") as item>\n            WHEN FIND_IN_SET(\'${item}\',cms_content.content_type)>0 THEN\n            ${item?index}\n        </#list>\n        ELSE 100\n        END,\n      </#if>\n      ${_orderby}\n  <#if order?? >\n    <#if order==\'desc\'> desc</#if>\n    <#if order==\'asc\'> asc</#if>\n  <#else>\n    desc\n  </#if>\n  LIMIT\n  <#--判断是否分页-->\n  <#if ispaging?? && (pageTag.pageNo)??>\n    ${((pageTag.pageNo-1)*_size?eval)?c},${_size?default(20)}\n  <#else>\n    ${_size?default(20)}\n  </#if>\n\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    <#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;