diff --git a/README.md b/README.md index 31124511..f8e8fc18 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@

铭飞平台 在线演示 - 在线使用手册 + 在线使用手册 腾讯课堂在线视频
代码生成器视频教程
Windows一键运行版本\Linux一键运行版本 @@ -90,7 +90,7 @@ git clone https://gitee.com/mingSoft/MCMS.git
5、创建数据库db-mcms-open(数据库使用utf-8编码),导入doc/mcms-版本号.sql,如果升级现有系统请使用*-up-*.sql升级,如果导入了系统对应的完整版SQL,sql升级补丁不需要重复导入;
6、修改src\main\resources\application-dev.yml文件中的数据库设置参数;
7、运行MSApplication.java main方法
-8、首先先访问后台地址:http://ip|域名/项目发布名/ms/login.do,管理员账号,用户名:msopen 密码:msopen,进入后台点击内容管理->静态化菜单,进行"生成主页","生成栏目","生成文章"操作一遍 (注意!!!是后台登录界面,不是会员中心登录界面) +8、首先先访问后台地址:http://localhost:8080/ms/login.do,管理员账号,用户名:msopen 密码:msopen,进入后台点击内容管理->静态化菜单,进行"生成主页","生成栏目","生成文章"操作一遍 (注意!!!是后台登录界面,不是会员中心登录界面) # 技术选型 @@ -152,7 +152,7 @@ git clone https://gitee.com/mingSoft/MCMS.git
# 文档 -* 使用手册 http://doc.mingsoft.net/plugs-cms/ +* 使用手册 http://doc.mingsoft.net/mcms/ # 软件截图 diff --git a/doc/5.2.0-up-5.2.1.sql b/doc/5.2.0-up-5.2.1.sql index a6b6cb55..971719ee 100644 --- a/doc/5.2.0-up-5.2.1.sql +++ b/doc/5.2.0-up-5.2.1.sql @@ -33,3 +33,5 @@ UPDATE `mdiy_tag_sql` SET `tag_id` = 7, `tag_sql` = 'SELECT\ncms_content.id as i UPDATE `mdiy_tag_sql` SET `tag_id` = 8, `tag_sql` = '<#assign select=\"(SELECT \'\')\"/>\n<#if orderby?? >\n <#if orderby==\"date\">\n <#assign _orderby=\"content_datetime\">\n <#elseif orderby==\"updatedate\">\n <#assign _orderby=\"content_updatetime\">\n <#elseif orderby==\"hit\">\n <#assign _orderby=\"content_hit\">\n <#elseif orderby==\"sort\">\n <#assign _orderby=\"content_sort\">\n <#else><#assign _orderby=\"cms_content.id\">\n <#else>\n <#assign _orderby=\"cms_content.id\">\n \n<#if pageTag.preId??>\nSELECT\ncms_content.id as id,\nleft(content_title,${titlelen?default(40)}) as title,\ncontent_title as fulltitle,\ncontent_author as author, \ncontent_source as source, \ncontent_details as content,\ncategory.category_title as typename,\ncategory.category_id as typeid,\n(SELECT \'index.html\') as typelink,\ncontent_img as litpic,\n<#--内容页动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\n <#else>\n CONCAT(category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\n \ncontent_datetime as \"date\",\ncontent_description as descrip,\ncontent_hit as hit,\ncontent_type as flag,\ncontent_keyword as keyword \nFROM cms_content\nLEFT JOIN cms_category as category ON cms_content.category_id=category.id\nWHERE cms_content.id=${pageTag.preId}\n<#else>\nSELECT\n${select} as id,\n${select} as title,\n${select} as fulltitle,\n${select} as author, \n${select} as source, \n${select} as content,\n${select} as typename,\n${select} as typeid,\n${select} as typelink,\n${select} as litpic,\n${select} as \"link\",\n${select} as \"date\",\n${select} as descrip,\n${select} as hit,\n${select} as flag,\n${select} as keyword FROM cms_content\n', `sort` = NULL, `UPDATE_BY` = NULL, `UPDATE_DATE` = NULL, `CREATE_BY` = NULL, `CREATE_DATE` = NULL, `DEL` = 0 WHERE `id` = 9; UPDATE `mdiy_tag_sql` SET `tag_id` = 9, `tag_sql` = 'select\n<#if !(pageTag.indexUrl??)>\n <#--判断是否有栏目对象,用于搜索不传栏目-->\n <#if column??>\n <#assign path=column.categoryPath/>\n <#else>\n <#assign path=\"\"/>\n \n <#--总记录数、总页数-->\n (SELECT ${pageTag.total}) as \"total\",\n (SELECT ${pageTag.size}) as \"size\",\n\n <#--记录总数-->\n (SELECT ${pageTag.rcount}) as \"rcount\",\n <#--当前页码-->\n (SELECT ${pageTag.pageNo}) as \"cur\",\n <#--首页-->\n CONCAT(\'${path}\', \'/index.html\') as \"index\",\n <#--上一页-->\n <#if (pageTag.pageNo?eval-1) gt 1>\n CONCAT(\'${path}\',\'/list-${pageTag.pageNo?eval-1}.html\') as \"pre\",\n <#else>\n CONCAT(\'${path}\',\'/index.html\') as \"pre\",\n \n\n <#--下一页-->\n <#if pageTag.total==1>\n CONCAT(\'${path}\', \'/index.html\') as \"next\",\n CONCAT(\'${path}\', \'/index.html\') as \"last\"\n <#else>\n <#if pageTag.pageNo?eval gte pageTag.total>\n CONCAT(\'${path}\',\'/list-${pageTag.total}.html\') as \"next\",\n <#else>\n CONCAT(\'${path}\',\'/list-${pageTag.pageNo?eval+1}.html\') as \"next\",\n \n <#--最后一页-->\n CONCAT(\'${path}\',\'/list-${pageTag.total}.html\') as \"last\"\n \n\n<#else>\n <#--判断是否是搜索页面-->\n \'${pageTag.indexUrl}\' as \"index\",\n \'${pageTag.lastUrl}\' as \"last\",\n \'${pageTag.preUrl}\' as \"pre\",\n \'${pageTag.nextUrl}\' as \"next\",\n \'${pageTag.total}\' as \"total\",\n \'${pageTag.size}\' as \"size\",\n \'${pageTag.rcount}\' as \"rcount\",\n \'${pageTag.pageNo}\' as \"cur\"\n', `sort` = NULL, `UPDATE_BY` = NULL, `UPDATE_DATE` = NULL, `CREATE_BY` = NULL, `CREATE_DATE` = NULL, `DEL` = 0 WHERE `id` = 10; UPDATE `mdiy_tag_sql` SET `tag_id` = 10, `tag_sql` = '<#assign select=\"(SELECT \'\')\"/>\n<#if orderby?? >\n <#if orderby==\"date\">\n <#assign _orderby=\"content_datetime\">\n <#elseif orderby==\"updatedate\">\n <#assign _orderby=\"content_updatetime\">\n <#elseif orderby==\"hit\">\n <#assign _orderby=\"content_hit\">\n <#elseif orderby==\"sort\">\n <#assign _orderby=\"content_sort\">\n <#else><#assign _orderby=\"cms_content.id\">\n <#else>\n <#assign _orderby=\"cms_content.id\">\n \n<#if pageTag.nextId??>\nSELECT\ncms_content.id as id,\nleft(content_title,${titlelen?default(40)}) as title,\ncontent_title as fulltitle,\ncontent_author as author, \ncontent_source as source, \ncontent_details as content,\ncategory.category_title as typename,\ncategory.category_id as typeid,\n(SELECT \'index.html\') as typelink,\ncontent_img as litpic,\n<#--内容页动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\n <#else>\n CONCAT(category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\n \ncontent_datetime as \"date\",\ncontent_description as descrip,\ncontent_hit as hit,\ncontent_type as flag,\ncontent_keyword as keyword \nFROM cms_content\nLEFT JOIN cms_category as category ON cms_content.category_id=category.id\nWHERE cms_content.id=${pageTag.nextId}\n<#else>\nSELECT\n${select} as id,\n${select} as title,\n${select} as fulltitle,\n${select} as author, \n${select} as source, \n${select} as content,\n${select} as typename,\n${select} as typeid,\n${select} as typelink,\n${select} as litpic,\n${select} as \"link\",\n${select} as \"date\",\n${select} as descrip,\n${select} as hit,\n${select} as flag,\n${select} as keyword FROM cms_content\n', `sort` = NULL, `UPDATE_BY` = NULL, `UPDATE_DATE` = NULL, `CREATE_BY` = NULL, `CREATE_DATE` = NULL, `DEL` = 0 WHERE `id` = 11; + +ALTER TABLE `cms_content` MODIFY COLUMN `content_display` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '是否显示0显示 1不显示'; diff --git a/doc/mcms-5.2.1.sql b/doc/mcms-5.2.1.sql index 6742e25d..921fb2ac 100644 --- a/doc/mcms-5.2.1.sql +++ b/doc/mcms-5.2.1.sql @@ -1,3 +1,4 @@ + SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; @@ -64,7 +65,8 @@ CREATE TABLE `cms_category` ( `create_date` datetime DEFAULT NULL COMMENT '创建时间', `create_by` varchar(11) DEFAULT NULL COMMENT '创建人', `del` int(1) DEFAULT '0' COMMENT '删除标记', - PRIMARY KEY (`id`) USING BTREE + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_category_id` (`category_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分类'; -- ---------------------------- @@ -99,7 +101,7 @@ CREATE TABLE `cms_content` ( `content_img` varchar(1000) DEFAULT NULL COMMENT '文章缩略图', `content_source` varchar(255) DEFAULT NULL COMMENT '文章来源', `content_author` varchar(255) DEFAULT NULL COMMENT '文章作者', - `content_display` varchar(10) DEFAULT NULL COMMENT '是否显示', + `content_display` varchar(10) DEFAULT '0' COMMENT '是否显示0显示 1不显示', `content_type` varchar(100) DEFAULT NULL COMMENT '文章类型', `content_datetime` datetime DEFAULT NULL COMMENT '发布时间', `content_sort` int(11) DEFAULT NULL COMMENT '自定义顺序', @@ -533,12 +535,12 @@ CREATE TABLE `mdiy_tag_sql` ( -- ---------------------------- BEGIN; INSERT INTO `mdiy_tag_sql` VALUES (5, 3, '<#assign _typeid=\'\'/>\n<#assign _typetitle=\'\'/>\n<#assign _size=\'20\'/>\n\n<#if column?? && column.id?? && column.id?number gt 0>\n <#assign _typeid=\'${column.id}\'>\n\n\n<#if typeid??>\n <#assign _typeid=\'${typeid}\'>\n\n\n<#if typetitle??>\n <#assign _typetitle=\'${typetitle}\'>\n\n\n<#if size??>\n <#assign _size=\'${size}\'>\n\n\n<#if orderby?? >\n <#if orderby==\'date\'>\n <#assign _orderby=\'content_datetime\'>\n <#elseif orderby==\'updatedate\'>\n <#assign _orderby=\'content_updatetime\'>\n <#elseif orderby==\'hit\'>\n <#assign _orderby=\'content_hit\'>\n <#elseif orderby==\'sort\'>\n <#assign _orderby=\'content_sort\'>\n <#else>\n <#assign _orderby=\'cms_content.id\'>\n \n<#else>\n <#assign _orderby=\'cms_content.id\'>\n\n\nSELECT\n cms_content.id AS id,\n content_title AS title,\n content_title AS fulltitle,\n content_author AS author,\n content_source AS source,\n content_details AS content,\n category.category_title AS typetitle,\n category.id AS typeid,\ncategory.category_path AS typepath,\n category.category_img AS typelitpic,\n category.category_keyword as typekeyword,\n category.top_id as topId,\n category.category_parent_ids as parentids,\n category.category_type AS \"type\",\n\n <#--列表页动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/list.do?typeid=\', category.category_id) as typelink,\n <#else>\n (SELECT \'index.html\') AS typelink,\n \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 <#--内容页动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\n <#else>\n CONCAT(category.category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\n \n\n <#if tableName??>${tableName}.*,\n content_datetime AS \"date\"\nFROM\n cms_content LEFT JOIN cms_category as category\n ON cms_content.category_id = category.id\n\n <#--判断是否有自定义模型表-->\n <#if tableName??>\n LEFT JOIN ${tableName} ON ${tableName}.link_id=cms_content.id\n \n WHERE \n content_display=0\n and cms_content.del=0\n <#--根据站点编号查询-->\n <#if appId?? >\n and cms_content.app_id=${appId}\n and cms_content.id>0\n \n <#--判断是否有搜索分类集合-->\n <#if search?? && _typeid==\"\">\n <#if search.categoryIds?has_content>and FIND_IN_SET(category.id,\'${search.categoryIds}\')\n <#--标题-->\n <#if search.content_title??> and content_title like CONCAT(\'%\',\'${search.content_title}\',\'%\')\n <#--作者-->\n <#if search.content_author??> and content_author like CONCAT(\'%\',\'${search.content_author}\',\'%\')\n <#--来源-->\n <#if search.content_source??> and content_source like CONCAT(\'%\',\'${search.content_source}\',\'%\')\n <#--属性-->\n <#if search.content_type??> and (\n <#list search.content_type?split(\',\') as item>\n <#if item?index gt 0> or\n FIND_IN_SET(\'${item}\',cms_content.content_type)\n )\n \n\n <#--描述-->\n <#if search.content_description??>\n and content_description like CONCAT(\'%\',\'${search.content_description}\',\'%\')\n \n\n <#--关键字-->\n <#if search.content_keyword??> and content_keyword like CONCAT(\'%\',\'${search.content_keyword}\',\'%\')\n\n <#--内容-->\n <#if search.content_details??> and content_details like CONCAT(\'%\',\'${search.content_details}\',\'%\')\n\n <#--自定义顺序-->\n <#if search.content_sort??> and content_sort=${search.content_sort}\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 \n <#else>\n <#--查询栏目-->\n <#if _typeid?has_content> \n and (cms_content.category_id=${_typeid} 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}\' and FIND_IN_SET(${_typeid},CATEGORY_PARENT_IDS))) \n \n \n <#--标题-->\n <#if content_title??> and content_title like CONCAT(\'%\',\'${content_title}\',\'%\')\n <#--作者-->\n <#if content_author??> and content_author like CONCAT(\'%\',\'${content_author}\',\'%\')\n <#--来源-->\n <#if content_source??> and content_source like CONCAT(\'%\',\'${content_source}\',\'%\')\n <#--属性-->\n <#if content_type??> and content_type like CONCAT(\'%\',\'${content_type}\',\'%\')\n <#--描述-->\n <#if content_description??> and content_description like CONCAT(\'%\',\'${content_description}\',\'%\')\n <#--关键字-->\n <#if content_keyword??> and content_keyword like CONCAT(\'%\',\'${content_keyword}\',\'%\')\n <#--内容-->\n <#if content_details??> and content_details like CONCAT(\'%\',\'${content_details}\',\'%\')\n <#--自定义顺序-->\n <#if content_sort??> and content_sort=${content_sort}\n <#--自定义模型-->\n <#if diyModel??>\n <#list diyModel as dm>\n and ${tableName}.${dm.key} like CONCAT(\'%\',\'${dm.value}\',\'%\') \n \n \n <#--文章属性-->\n <#if flag?? >\n and(\n <#list flag?split(\',\') as item>\n <#if item?index gt 0> or\n FIND_IN_SET(\'${item}\',cms_content.content_type)\n )\n \n <#if noflag??>\n and(\n <#list noflag?split(\',\') as item>\n <#if item?index gt 0> and\n FIND_IN_SET(\'${item}\',cms_content.content_type)=0\n or cms_content.content_type is null)\n \n\n <#--字段排序-->\n <#if orderby?? >\n ORDER BY\n <#if orderby==\'date\'> content_datetime\n <#elseif orderby==\'updatedate\'> content_updatetime\n <#elseif orderby==\'hit\'> content_hit\n <#elseif orderby==\'sort\'> content_sort\n <#else>\n cms_content.id\n \n <#else>\n ORDER BY cms_content.id\n \n\n <#if order?? >\n <#if order==\'desc\'> desc\n <#if order==\'asc\'> asc\n <#else>\n desc\n \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 ', 1, NULL, NULL, NULL, NULL, 0); -INSERT INTO `mdiy_tag_sql` VALUES (6, 4, '<#assign _typeid=\'0\'/>\n<#if column?? && column.id?? && column.id?number gt 0>\n <#assign _typeid=\'${column.id}\'>\n <#assign selfid=\'${column.id}\'>\n\n\n<#if typeid??>\n <#assign _typeid=\'${typeid}\'>\n\n\nselect\n id,\n id as typeid,\n category_title as typetitle,\n <#--动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/list.do?typeid=\', id) as typelink,\n <#else>\n <#--栏目类型为链接-->\n CONCAT(category_path,\'/index.html\') as typelink,\n \n category_keyword as typekeyword,\n category_diy_url as typeurl,\n category_flag as flag,\n category_parent_ids as parentids,\n category_descrip as typedescrip,\n category_type as type,\n category_path as typepath,\n leaf as typeleaf,\n category_img as typelitpic ,\n (select count(*) from cms_category where cms_category.category_id=id and cms_category.del=0) as childsize\n from cms_category\n where\n cms_category.del=0\n <#--根据站点编号查询-->\n <#if appId?? >\n and cms_category.app_id=${appId}\n \n\n <#--栏目属性-->\n <#if flag?? >\n and\n (<#list flag?split(\',\') as item>\n <#if item?index gt 0> or\n FIND_IN_SET(\'${item}\',category_flag)\n )\n \n\n <#if noflag?? >\n and\n (<#list noflag?split(\',\') as item>\n <#if item?index gt 0> and\n FIND_IN_SET(\'${item}\',category_flag)=0\n or category_flag is null)\n \n\n <#--type默认son-->\n <#if !type??||!type?has_content>\n <#assign type=\'son\'/>\n \n\n <#if type?has_content>\n <#--顶级栏目(单个)-->\n <#if type==\'top\'>\n <#if _typeid != \'0\'>\n and (id = top_id or top_id = 0)\n \n\n <#elseif type==\'nav\'>\n and(category_id=0 or category_id is null)\n\n <#--同级栏目(多个)-->\n <#elseif type==\'level\'>\n and\n <#if _typeid != \'0\'>\n category_id=(select category_id from cms_category where id=${_typeid})\n <#else>\n 1=1\n \n\n <#--当前栏目(单个)-->\n <#elseif type==\'self\'>\n and\n <#if _typeid != \'0\'>\n id=${_typeid}\n <#else>\n 1=1\n \n\n <#--当前栏目的所属栏目(多个)-->\n <#elseif type==\'path\'>\n and\n <#if _typeid != \'0\'>\n id in (<#if column?? && column.categoryParentIds??>${column.categoryParentIds},${_typeid})\n <#else>\n 1=1\n \n <#--子栏目(多个)-->\n\n <#elseif type==\'son\'>\n and\n <#if _typeid != \'0\'>\n category_id=${_typeid}\n <#else>\n 1=1\n \n\n <#--上一级栏目没有则取当前栏目(单个)-->\n <#elseif type==\'parent\'>\n and\n <#if _typeid != \'0\'>\n <#if column?? && column.categoryId??>\n id=${column.categoryId}\n <#else>\n id=${_typeid}\n \n <#else>\n 1=1\n \n \n\n<#else> <#--默认顶级栏目-->\n and\n <#if _typeid != \'0\'>\n id=${_typeid}\n <#else>\n (category_id=0 or category_id is null)\n \n\n\n\n<#--字段排序-->\n<#if orderby?? >\n ORDER BY\n <#if orderby==\'date\'> category_datetime\n <#elseif orderby==\'sort\'> category_sort\n <#else>id\n\n\n<#if order?? >\n <#if order==\'desc\'> desc\n <#if order==\'asc\'> asc\n', 1, NULL, NULL, NULL, NULL, 0); +INSERT INTO `mdiy_tag_sql` VALUES (6, 4, '<#assign _typeid=\'0\'/>\n<#if column?? && column.id?? && column.id?number gt 0>\n <#assign _typeid=\'${column.id}\'>\n <#assign selfid=\'${column.id}\'>\n\n\n<#if typeid??>\n <#assign _typeid=\'${typeid}\'>\n\n\nselect\n id,\n id as typeid,\n category_title as typetitle,\n <#--动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/list.do?typeid=\', id) as typelink,\n <#else>\n <#--栏目类型为链接-->\n CONCAT(category_path,\'/index.html\') as typelink,\n \n category_keyword as typekeyword,\n category_diy_url as typeurl,\n category_flag as flag,\n category_parent_ids as parentids,\n category_descrip as typedescrip,\n category_type as type,\n category_path as typepath,\n leaf as typeleaf,\n category_img as typelitpic ,\n ( SELECT count(*) FROM cms_category cc WHERE cc.category_id = cms_category.id AND cc.del = 0 ) AS childsize \n from cms_category\n where\n cms_category.del=0\n <#--根据站点编号查询-->\n <#if appId?? >\n and cms_category.app_id=${appId}\n \n\n <#--栏目属性-->\n <#if flag?? >\n and\n (<#list flag?split(\',\') as item>\n <#if item?index gt 0> or\n FIND_IN_SET(\'${item}\',category_flag)\n )\n \n\n <#if noflag?? >\n and\n (<#list noflag?split(\',\') as item>\n <#if item?index gt 0> and\n FIND_IN_SET(\'${item}\',category_flag)=0\n or category_flag is null)\n \n\n <#--type默认son-->\n <#if !type??||!type?has_content>\n <#assign type=\'son\'/>\n \n\n <#if type?has_content>\n <#--顶级栏目(单个)-->\n <#if type==\'top\'>\n <#if _typeid != \'0\'>\n and (id = top_id or top_id = 0)\n \n\n <#elseif type==\'nav\'>\n and(category_id=0 or category_id is null)\n\n <#--同级栏目(多个)-->\n <#elseif type==\'level\'>\n and\n <#if _typeid != \'0\'>\n category_id=(select category_id from cms_category where id=${_typeid})\n <#else>\n 1=1\n \n\n <#--当前栏目(单个)-->\n <#elseif type==\'self\'>\n and\n <#if _typeid != \'0\'>\n id=${_typeid}\n <#else>\n 1=1\n \n\n <#--当前栏目的所属栏目(多个)-->\n <#elseif type==\'path\'>\n and\n <#if _typeid != \'0\'>\n id in (<#if column?? && column.categoryParentIds??>${column.categoryParentIds},${_typeid})\n <#else>\n 1=1\n \n <#--子栏目(多个)-->\n\n <#elseif type==\'son\'>\n and\n <#if _typeid != \'0\'>\n category_id=${_typeid}\n <#else>\n 1=1\n \n\n <#--上一级栏目没有则取当前栏目(单个)-->\n <#elseif type==\'parent\'>\n and\n <#if _typeid != \'0\'>\n <#if column?? && column.categoryId??>\n id=${column.categoryId}\n <#else>\n id=${_typeid}\n \n <#else>\n 1=1\n \n \n\n<#else> <#--默认顶级栏目-->\n and\n <#if _typeid != \'0\'>\n id=${_typeid}\n <#else>\n (category_id=0 or category_id is null)\n \n\n\n\n<#--字段排序-->\n<#if orderby?? >\n ORDER BY\n <#if orderby==\'date\'> category_datetime\n <#elseif orderby==\'sort\'> category_sort\n <#else>id\n\n\n<#if order?? >\n <#if order==\'desc\'> desc\n <#if order==\'asc\'> asc\n', 1, NULL, NULL, NULL, NULL, 0); INSERT INTO `mdiy_tag_sql` VALUES (7, 5, 'select\nAPP_NAME as name,\napp_logo as logo,\napp_keyword as keyword,\napp_description as descrip,\napp_copyright as copyright,\n<#--动态解析 -->\n<#if isDo?? && isDo>\nCONCAT(\'${url}\',\'/${html}/\',app_dir) as url,\n\'${url}\' as host,\n<#--使用地址栏的域名 -->\n<#elseif url??>\nCONCAT(\'${url}\',\'/${html}/\',app_dir) as url,\n\'${url}\' as host,\n<#else>\nCONCAT(REPLACE(REPLACE(TRIM(substring_index(app_url,\'\\n\',1)), CHAR(10),\'\'), CHAR(13),\'\'),\'/html/\',app_dir) as url,\nREPLACE(REPLACE(TRIM(substring_index(app_url,\'\\n\',1)), CHAR(10),\'\'), CHAR(13),\'\') as host,\n\nCONCAT(\'template/\',id,\'/\',app_style) as \"style\" <#-- 判断是否为手机端 -->\nfrom app\n<#--根据站点编号查询-->\n<#if appId?? >\n where id = ${appId}\n', 1, NULL, NULL, NULL, NULL, 0); INSERT INTO `mdiy_tag_sql` VALUES (8, 7, 'SELECT\ncms_content.id as id,\nleft(content_title,${titlelen?default(40)}) as title,\ncontent_title as fulltitle,\ncontent_author as author, \ncontent_source as source, \ncontent_details as content,\ncategory_title as typetitle,\ncms_category.id as typeid,\ncms_category.leaf as typeleaf,\ncms_category.category_img AS typelitpic,\ncms_category.category_path AS typepath,\ncms_category.top_id as topId,\ncms_category.category_flag as typeflag,\ncms_category.category_parent_ids as parentids,\ncms_category.category_keyword as typekeyword,\ncms_category.category_descrip as typedescrip,\n<#--动态链接-->\n<#if isDo?? && isDo>\nCONCAT(\'/${modelName}/list.do?typeid=\', cms_category.id) as typelink,\n<#else>\n(SELECT \'index.html\') as typelink,\n\ncms_content.content_img AS litpic,\n<#--内容页动态链接-->\n<#if isDo?? && isDo>\nCONCAT(\'/mcms/view.do?id=\', cms_content.id) as \"link\",\n<#else>\ncontent_url AS \"link\",\n\ncontent_datetime as \"date\",\ncontent_description as descrip,\nCONCAT(\'\') as hit,\ncontent_type as flag,\ncategory_title as typetitle,\n<#if tableName??>${tableName}.*,\ncontent_keyword as keyword\nFROM cms_content\nLEFT JOIN cms_category ON\ncms_category.id = cms_content.category_id\n<#--判断是否有自定义模型表-->\n<#if tableName??>left join ${tableName} on ${tableName}.link_id=cms_content.id\nWHERE\n<#--如果是栏目列表页没有文章id所以只取栏目id-->\n<#if column??&&column.id??&&!id??>\ncms_category.id=${column.id} and\n\n cms_content.del=0\n<#if id??> and cms_content.id=${id}', 1, NULL, NULL, NULL, NULL, 0); -INSERT INTO `mdiy_tag_sql` VALUES (9, 8, '<#assign select=\"(SELECT \'\')\"/>\n<#if orderby?? >\n <#if orderby==\"date\">\n <#assign _orderby=\"content_datetime\">\n <#elseif orderby==\"updatedate\">\n <#assign _orderby=\"content_updatetime\">\n <#elseif orderby==\"hit\">\n <#assign _orderby=\"content_hit\">\n <#elseif orderby==\"sort\">\n <#assign _orderby=\"content_sort\">\n <#else><#assign _orderby=\"cms_content.id\">\n <#else>\n <#assign _orderby=\"cms_content.id\">\n \n<#if pageTag.preId??>\nSELECT\ncms_content.id as id,\nleft(content_title,${titlelen?default(40)}) as title,\ncontent_title as fulltitle,\ncontent_author as author, \ncontent_source as source, \ncontent_details as content,\ncategory.category_title as typename,\ncategory.category_id as typeid,\n(SELECT \'index.html\') as typelink,\ncontent_img as litpic,\n<#--内容页动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\n <#else>\n CONCAT(category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\n \ncontent_datetime as \"date\",\ncontent_description as descrip,\ncontent_hit as hit,\ncontent_type as flag,\ncontent_keyword as keyword \nFROM cms_content\nLEFT JOIN cms_category as category ON cms_content.category_id=category.id\nWHERE cms_content.id=${pageTag.preId}\n<#else>\nSELECT\n${select} as id,\n${select} as title,\n${select} as fulltitle,\n${select} as author, \n${select} as source, \n${select} as content,\n${select} as typename,\n${select} as typeid,\n${select} as typelink,\n${select} as litpic,\n${select} as \"link\",\n${select} as \"date\",\n${select} as descrip,\n${select} as hit,\n${select} as flag,\n${select} as keyword FROM cms_content\n', NULL, NULL, NULL, NULL, NULL, 0); +INSERT INTO `mdiy_tag_sql` VALUES (9, 8, '<#assign select=\"(SELECT \'\')\"/>\n<#if orderby?? >\n <#if orderby==\"date\">\n <#assign _orderby=\"content_datetime\">\n <#elseif orderby==\"updatedate\">\n <#assign _orderby=\"content_updatetime\">\n <#elseif orderby==\"hit\">\n <#assign _orderby=\"content_hit\">\n <#elseif orderby==\"sort\">\n <#assign _orderby=\"content_sort\">\n <#else><#assign _orderby=\"cms_content.id\">\n <#else>\n <#assign _orderby=\"cms_content.id\">\n \n<#if pageTag.preId??>\nSELECT\ncms_content.id as id,\nleft(content_title,${titlelen?default(40)}) as title,\ncontent_title as fulltitle,\ncontent_author as author, \ncontent_source as source, \ncontent_details as content,\ncategory.category_title as typename,\ncategory.category_id as typeid,\n(SELECT \'index.html\') as typelink,\ncontent_img as litpic,\n<#--内容页动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\n <#else>\n CONCAT(category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\n \ncontent_datetime as \"date\",\ncontent_description as descrip,\ncontent_hit as hit,\ncontent_type as flag,\ncontent_keyword as keyword \nFROM cms_content\nLEFT JOIN cms_category as category ON cms_content.category_id=category.id\nWHERE cms_content.id=${pageTag.preId}\n<#else>\nSELECT\n${select} as id,\n${select} as title,\n${select} as fulltitle,\n${select} as author, \n${select} as source, \n${select} as content,\n${select} as typename,\n${select} as typeid,\n${select} as typelink,\n${select} as litpic,\n${select} as \"link\",\n${select} as \"date\",\n${select} as descrip,\n${select} as hit,\n${select} as flag,\n${select} as keyword\n', NULL, NULL, NULL, NULL, NULL, 0); INSERT INTO `mdiy_tag_sql` VALUES (10, 9, 'select\n<#if !(pageTag.indexUrl??)>\n <#--判断是否有栏目对象,用于搜索不传栏目-->\n <#if column??>\n <#assign path=column.categoryPath/>\n <#else>\n <#assign path=\"\"/>\n \n <#--总记录数、总页数-->\n (SELECT ${pageTag.total}) as \"total\",\n (SELECT ${pageTag.size}) as \"size\",\n\n <#--记录总数-->\n (SELECT ${pageTag.rcount}) as \"rcount\",\n <#--当前页码-->\n (SELECT ${pageTag.pageNo}) as \"cur\",\n <#--首页-->\n CONCAT(\'${path}\', \'/index.html\') as \"index\",\n <#--上一页-->\n <#if (pageTag.pageNo?eval-1) gt 1>\n CONCAT(\'${path}\',\'/list-${pageTag.pageNo?eval-1}.html\') as \"pre\",\n <#else>\n CONCAT(\'${path}\',\'/index.html\') as \"pre\",\n \n\n <#--下一页-->\n <#if pageTag.total==1>\n CONCAT(\'${path}\', \'/index.html\') as \"next\",\n CONCAT(\'${path}\', \'/index.html\') as \"last\"\n <#else>\n <#if pageTag.pageNo?eval gte pageTag.total>\n CONCAT(\'${path}\',\'/list-${pageTag.total}.html\') as \"next\",\n <#else>\n CONCAT(\'${path}\',\'/list-${pageTag.pageNo?eval+1}.html\') as \"next\",\n \n <#--最后一页-->\n CONCAT(\'${path}\',\'/list-${pageTag.total}.html\') as \"last\"\n \n\n<#else>\n <#--判断是否是搜索页面-->\n \'${pageTag.indexUrl}\' as \"index\",\n \'${pageTag.lastUrl}\' as \"last\",\n \'${pageTag.preUrl}\' as \"pre\",\n \'${pageTag.nextUrl}\' as \"next\",\n \'${pageTag.total}\' as \"total\",\n \'${pageTag.size}\' as \"size\",\n \'${pageTag.rcount}\' as \"rcount\",\n \'${pageTag.pageNo}\' as \"cur\"\n', NULL, NULL, NULL, NULL, NULL, 0); -INSERT INTO `mdiy_tag_sql` VALUES (11, 10, '<#assign select=\"(SELECT \'\')\"/>\n<#if orderby?? >\n <#if orderby==\"date\">\n <#assign _orderby=\"content_datetime\">\n <#elseif orderby==\"updatedate\">\n <#assign _orderby=\"content_updatetime\">\n <#elseif orderby==\"hit\">\n <#assign _orderby=\"content_hit\">\n <#elseif orderby==\"sort\">\n <#assign _orderby=\"content_sort\">\n <#else><#assign _orderby=\"cms_content.id\">\n <#else>\n <#assign _orderby=\"cms_content.id\">\n \n<#if pageTag.nextId??>\nSELECT\ncms_content.id as id,\nleft(content_title,${titlelen?default(40)}) as title,\ncontent_title as fulltitle,\ncontent_author as author, \ncontent_source as source, \ncontent_details as content,\ncategory.category_title as typename,\ncategory.category_id as typeid,\n(SELECT \'index.html\') as typelink,\ncontent_img as litpic,\n<#--内容页动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\n <#else>\n CONCAT(category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\n \ncontent_datetime as \"date\",\ncontent_description as descrip,\ncontent_hit as hit,\ncontent_type as flag,\ncontent_keyword as keyword \nFROM cms_content\nLEFT JOIN cms_category as category ON cms_content.category_id=category.id\nWHERE cms_content.id=${pageTag.nextId}\n<#else>\nSELECT\n${select} as id,\n${select} as title,\n${select} as fulltitle,\n${select} as author, \n${select} as source, \n${select} as content,\n${select} as typename,\n${select} as typeid,\n${select} as typelink,\n${select} as litpic,\n${select} as \"link\",\n${select} as \"date\",\n${select} as descrip,\n${select} as hit,\n${select} as flag,\n${select} as keyword FROM cms_content\n', NULL, NULL, NULL, NULL, NULL, 0); +INSERT INTO `mdiy_tag_sql` VALUES (11, 10, '<#assign select=\"(SELECT \'\')\"/>\n<#if orderby?? >\n <#if orderby==\"date\">\n <#assign _orderby=\"content_datetime\">\n <#elseif orderby==\"updatedate\">\n <#assign _orderby=\"content_updatetime\">\n <#elseif orderby==\"hit\">\n <#assign _orderby=\"content_hit\">\n <#elseif orderby==\"sort\">\n <#assign _orderby=\"content_sort\">\n <#else><#assign _orderby=\"cms_content.id\">\n <#else>\n <#assign _orderby=\"cms_content.id\">\n \n<#if pageTag.nextId??>\nSELECT\ncms_content.id as id,\nleft(content_title,${titlelen?default(40)}) as title,\ncontent_title as fulltitle,\ncontent_author as author, \ncontent_source as source, \ncontent_details as content,\ncategory.category_title as typename,\ncategory.category_id as typeid,\n(SELECT \'index.html\') as typelink,\ncontent_img as litpic,\n<#--内容页动态链接-->\n <#if isDo?? && isDo>\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\n <#else>\n CONCAT(category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\n \ncontent_datetime as \"date\",\ncontent_description as descrip,\ncontent_hit as hit,\ncontent_type as flag,\ncontent_keyword as keyword \nFROM cms_content\nLEFT JOIN cms_category as category ON cms_content.category_id=category.id\nWHERE cms_content.id=${pageTag.nextId}\n<#else>\nSELECT\n${select} as id,\n${select} as title,\n${select} as fulltitle,\n${select} as author, \n${select} as source, \n${select} as content,\n${select} as typename,\n${select} as typeid,\n${select} as typelink,\n${select} as litpic,\n${select} as \"link\",\n${select} as \"date\",\n${select} as descrip,\n${select} as hit,\n${select} as flag,\n${select} as keyword \n', NULL, NULL, NULL, NULL, NULL, 0); COMMIT; -- ---------------------------- diff --git a/pom.xml b/pom.xml index d10e5dc3..529b7e04 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,6 @@ net.mingsoft ms-base 2.1.0 - net.mingsoft @@ -60,6 +59,7 @@ net.mingsoft store-client 2.1.0 + diff --git a/src/main/java/net/mingsoft/cms/action/web/ServerAction.java b/src/main/java/net/mingsoft/cms/action/web/ServerAction.java deleted file mode 100644 index 215d5228..00000000 --- a/src/main/java/net/mingsoft/cms/action/web/ServerAction.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.mingsoft.cms.action.web; - -import net.mingsoft.base.action.BaseAction; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@Controller() -@RequestMapping("/") -public class ServerAction extends BaseAction { - - @ResponseBody - @GetMapping("/server.do") - public String list(HttpServletRequest req, HttpServletResponse resp) { - LOG.debug("心跳"); - return ""; - } -} diff --git a/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java b/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java index cfb4b9c9..dd51e1fe 100755 --- a/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java +++ b/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java @@ -7,10 +7,10 @@ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: - + *

* The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. - + *

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR @@ -48,271 +48,273 @@ import java.util.List; * 创建日期:2019-11-28 15:12:32
* 历史修订:
*/ - @Service("cmscategoryBizImpl") - @Transactional(rollbackFor = RuntimeException.class) +@Service("cmscategoryBizImpl") +@Transactional(rollbackFor = RuntimeException.class) public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz { - @Autowired - private ICategoryDao categoryDao; + @Autowired + private ICategoryDao categoryDao; - @Autowired - private IContentDao contentDao; + @Autowired + private IContentDao contentDao; - @Override - protected IBaseDao getDao() { - // TODO Auto-generated method stub - return categoryDao; - } + @Override + protected IBaseDao getDao() { + // TODO Auto-generated method stub + return categoryDao; + } - @Override - public List queryChilds(CategoryEntity category) { - // TODO Auto-generated method stub - return categoryDao.queryChildren(category); - } - @Override - public void saveEntity(CategoryEntity categoryEntity) { - // TODO Auto-generated method stub - String pingYin = PinYinUtil.getPingYin(categoryEntity.getCategoryTitle()); - //如果用户自己填入了拼音则使用用户的 - if (StrUtil.isNotBlank(categoryEntity.getCategoryPinyin())) { - pingYin = categoryEntity.getCategoryPinyin(); - } - CategoryEntity category=new CategoryEntity(); - category.setCategoryPinyin(pingYin); - Object categoryBizEntity = getEntity(category); - setParentId(categoryEntity); - categoryEntity.setCategoryPinyin(pingYin); - //更新新的父级 - if(StrUtil.isNotBlank(categoryEntity.getCategoryId())&&!"0".equals(categoryEntity.getCategoryId())){ - CategoryEntity parent = getById(categoryEntity.getCategoryId()); - //如果之前是叶子节点就更新 - if(parent.getLeaf()){ - parent.setLeaf(false); - updateById(parent); - } - } - categoryEntity.setLeaf(false); - //如果是新增栏目一定是叶子节点 - if (StrUtil.isEmpty(categoryEntity.getId())) { - categoryEntity.setLeaf(true); - } - super.save(categoryEntity); - //拼音存在则拼接id - if(categoryBizEntity!=null){ - categoryEntity.setCategoryPinyin(pingYin+categoryEntity.getId()); - } - CategoryEntity parentCategory = null; - if (StringUtils.isNotBlank(categoryEntity.getCategoryId())) { - parentCategory = (CategoryEntity)getById(categoryEntity.getCategoryId()); - } - //保存链接地址 - String path=ObjectUtil.isNotNull(parentCategory)?parentCategory.getCategoryPath():""; - categoryEntity.setCategoryPath( path+"/" + categoryEntity.getCategoryPinyin()); - setTopId(categoryEntity); - super.updateById(categoryEntity); - } + @Override + public List queryChilds(CategoryEntity category) { + // TODO Auto-generated method stub + return categoryDao.queryChildren(category); + } - private void setParentId(CategoryEntity categoryEntity) { - String path = ""; - if(StringUtils.isNotEmpty(categoryEntity.getCategoryId())&&Long.parseLong(categoryEntity.getCategoryId())>0) { - CategoryEntity category = (CategoryEntity)getById(categoryEntity.getCategoryId()); - path = category.getCategoryPath(); - if(StringUtils.isEmpty(category.getCategoryParentIds())) { - categoryEntity.setCategoryParentIds(category.getId()); - } else { - categoryEntity.setCategoryParentIds(category.getCategoryParentIds()+","+category.getId()); - } - }else { - categoryEntity.setCategoryParentIds(null); - } - //保存时先保存再修改链接地址,修改时直接修改 - if(StringUtils.isNotBlank(categoryEntity.getId())) { - categoryEntity.setCategoryPath(path+ "/" + categoryEntity.getCategoryPinyin()); - } + @Override + public void saveEntity(CategoryEntity categoryEntity) { + // TODO Auto-generated method stub + String pingYin = PinYinUtil.getPingYin(categoryEntity.getCategoryTitle()); + //如果用户自己填入了拼音则使用用户的 + if (StrUtil.isNotBlank(categoryEntity.getCategoryPinyin())) { + pingYin = categoryEntity.getCategoryPinyin(); + } + CategoryEntity category = new CategoryEntity(); + category.setCategoryPinyin(pingYin); + Object categoryBizEntity = getEntity(category); + setParentId(categoryEntity); + categoryEntity.setCategoryPinyin(pingYin); + //更新新的父级 + if (StrUtil.isNotBlank(categoryEntity.getCategoryId()) && !"0".equals(categoryEntity.getCategoryId())) { + CategoryEntity parent = getById(categoryEntity.getCategoryId()); + //如果之前是叶子节点就更新 + if (parent.getLeaf()) { + parent.setLeaf(false); + updateById(parent); + } + } + categoryEntity.setLeaf(false); + //如果是新增栏目一定是叶子节点 + if (StrUtil.isEmpty(categoryEntity.getId())) { + categoryEntity.setLeaf(true); + } + super.save(categoryEntity); + //拼音存在则拼接id + if (categoryBizEntity != null) { + categoryEntity.setCategoryPinyin(pingYin + categoryEntity.getId()); + } + CategoryEntity parentCategory = null; + if (StringUtils.isNotBlank(categoryEntity.getCategoryId())) { + parentCategory = (CategoryEntity) getById(categoryEntity.getCategoryId()); + } + //保存链接地址 + String path = ObjectUtil.isNotNull(parentCategory) ? parentCategory.getCategoryPath() : ""; + categoryEntity.setCategoryPath(path + "/" + categoryEntity.getCategoryPinyin()); + setTopId(categoryEntity); + super.updateById(categoryEntity); + } - } - private void setChildParentId(CategoryEntity categoryEntity, String topId) { - CategoryEntity category=new CategoryEntity(); - category.setCategoryId(categoryEntity.getId()); - List list = categoryDao.query(category); - list.forEach(x->{ - if(StringUtils.isEmpty(categoryEntity.getCategoryParentIds())) { - x.setCategoryParentIds(categoryEntity.getId()); - } else { - x.setCategoryParentIds(categoryEntity.getCategoryParentIds()+","+categoryEntity.getId()); - } - //更新topid - x.setTopId(topId); - String path=categoryEntity.getCategoryPath(); - //判断是否有parentIds - x.setCategoryPath(path+"/"+x.getCategoryPinyin()); - //去除多余的/符号 - super.updateEntity(x); - setChildParentId(x, topId); - }); - } + private void setParentId(CategoryEntity categoryEntity) { + String path = ""; + if (StringUtils.isNotEmpty(categoryEntity.getCategoryId()) && Long.parseLong(categoryEntity.getCategoryId()) > 0) { + CategoryEntity category = (CategoryEntity) getById(categoryEntity.getCategoryId()); + path = category.getCategoryPath(); + if (StringUtils.isEmpty(category.getCategoryParentIds())) { + categoryEntity.setCategoryParentIds(category.getId()); + } else { + categoryEntity.setCategoryParentIds(category.getCategoryParentIds() + "," + category.getId()); + } + } else { + categoryEntity.setCategoryParentIds(null); + } + //保存时先保存再修改链接地址,修改时直接修改 + if (StringUtils.isNotBlank(categoryEntity.getId())) { + categoryEntity.setCategoryPath(path + "/" + categoryEntity.getCategoryPinyin()); + } - @Override - public void updateEntity(CategoryEntity entity) { - setParentId(entity); - String pingYin =entity.getCategoryPinyin(); - if(StrUtil.isNotBlank(pingYin)){ - CategoryEntity category=new CategoryEntity(); - category.setCategoryPinyin(pingYin); - CategoryEntity categoryBizEntity = (CategoryEntity)getEntity(category); - //拼音存在则拼接id - if(categoryBizEntity!=null&&!categoryBizEntity.getId().equals(entity.getId())){ - entity.setCategoryPinyin(pingYin+entity.getId()); - } - } - setParentLeaf(entity); - setTopId(entity); - //如果父级栏目和父级id为空字符串则转化成null - if (StringUtils.isEmpty(entity.getCategoryId())) { - entity.setCategoryId(null); - } - if (StringUtils.isEmpty(entity.getCategoryParentIds())) { - entity.setCategoryParentIds(null); - } - categoryDao.updateEntity(entity); - //更新子节点所有父节点id和topid - //如果本节点的topid为0(顶级栏目),则把自身的id作为子栏目的topid,非0所有的子栏目和本栏目使用同一个topid - String topId = entity.getTopId(); - if (topId.equals("0")) { - topId = entity.getId(); - } - setChildParentId(entity, topId); - } + } + + private void setChildParentId(CategoryEntity categoryEntity, String topId) { + CategoryEntity category = new CategoryEntity(); + category.setCategoryId(categoryEntity.getId()); + List list = categoryDao.query(category); + list.forEach(x -> { + if (StringUtils.isEmpty(categoryEntity.getCategoryParentIds())) { + x.setCategoryParentIds(categoryEntity.getId()); + } else { + x.setCategoryParentIds(categoryEntity.getCategoryParentIds() + "," + categoryEntity.getId()); + } + //更新topid + x.setTopId(topId); + String path = categoryEntity.getCategoryPath(); + //判断是否有parentIds + x.setCategoryPath(path + "/" + x.getCategoryPinyin()); + //去除多余的/符号 + super.updateEntity(x); + setChildParentId(x, topId); + }); + } + + @Override + public void updateEntity(CategoryEntity entity) { + setParentId(entity); + String pingYin = entity.getCategoryPinyin(); + if (StrUtil.isNotBlank(pingYin)) { + CategoryEntity category = new CategoryEntity(); + category.setCategoryPinyin(pingYin); + CategoryEntity categoryBizEntity = (CategoryEntity) getEntity(category); + //拼音存在则拼接id + if (categoryBizEntity != null && !categoryBizEntity.getId().equals(entity.getId())) { + entity.setCategoryPinyin(pingYin + entity.getId()); + } + } + setParentLeaf(entity); + setTopId(entity); + //如果父级栏目和父级id为空字符串则转化成null + if (StringUtils.isEmpty(entity.getCategoryId())) { + entity.setCategoryId(null); + } + if (StringUtils.isEmpty(entity.getCategoryParentIds())) { + entity.setCategoryParentIds(null); + } + categoryDao.updateEntity(entity); + //更新子节点所有父节点id和topid + //如果本节点的topid为0(顶级栏目),则把自身的id作为子栏目的topid,非0所有的子栏目和本栏目使用同一个topid + String topId = entity.getTopId(); + if (topId.equals("0")) { + topId = entity.getId(); + } + setChildParentId(entity, topId); + } - @Override - public void update(CategoryEntity entity) { - super.updateEntity(entity); - } + @Override + public void update(CategoryEntity entity) { + super.updateEntity(entity); + } - @Override - public void delete(String categoryId) { - // TODO Auto-generated method stub - CategoryEntity category = (CategoryEntity) categoryDao.selectById(categoryId); - //删除父类 - if(category != null){ - category.setCategoryParentIds(null); - List childrenList = categoryDao.queryChildren(category); - List ids = new ArrayList<>(); - for(int i = 0; i < childrenList.size(); i++){ - //删除子类 - ids.add(childrenList.get(i).getId()); - } - categoryDao.deleteBatchIds(ids); - // 删除文章 - contentDao.deleteEntityByCategoryIds(ids.toArray(new String[ids.size()])); + @Override + public void delete(String categoryId) { + // TODO Auto-generated method stub + CategoryEntity category = (CategoryEntity) categoryDao.selectById(categoryId); + //删除父类 + if (category != null) { + category.setCategoryParentIds(null); + List childrenList = categoryDao.queryChildren(category); + List ids = new ArrayList<>(); + for (int i = 0; i < childrenList.size(); i++) { + //删除子类 + ids.add(childrenList.get(i).getId()); + } + categoryDao.deleteBatchIds(ids); + // 删除文章 + contentDao.deleteEntityByCategoryIds(ids.toArray(new String[ids.size()])); - //获取被删节点的父节点 - CategoryEntity parentNode = categoryDao.selectById(category.getCategoryId()); - //获取被删节点的所属栏目的其他节点 - List childNode = categoryDao.queryChildren(parentNode); - //判断删除的是否为主节点 - if (parentNode != null) { - UpdateWrapper updateWrapper = new UpdateWrapper<>(); + //获取被删节点的父节点 + CategoryEntity parentNode = categoryDao.selectById(category.getCategoryId()); + //获取被删节点的所属栏目的其他节点 + List childNode = categoryDao.queryChildren(parentNode); + //判断删除的是否为主节点 + if (parentNode != null) { + //清空CategoryParentIds,避免查找不必要的数据,只需要当前的父级栏目 + parentNode.setCategoryParentIds(null); + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + //如果没有子节点进行更新代码 + if (childNode.size() == 1) { + updateWrapper.eq("id", parentNode.getId()).set("leaf", 1); + categoryDao.update(null, updateWrapper); + } - //是否还有子节点 - if (childNode.size() > 1) - updateWrapper.eq("id", parentNode.getId()).set("leaf", 0); - else - updateWrapper.eq("id", parentNode.getId()).set("leaf", 1); + } - categoryDao.update(null, updateWrapper); - } + } + } - } - } + /** + * 设置父级叶子节点 + * @param entity + */ + private void setParentLeaf(CategoryEntity entity) { + CategoryEntity categoryEntity = getById(entity.getId()); + //如果父级不为空并且修改了父级则需要更新父级 + if (entity.getCategoryId() != null && !entity.getCategoryId().equals(categoryEntity.getCategoryId())) { + //更新旧的父级 + if (StrUtil.isNotBlank(categoryEntity.getCategoryId()) && !"0".equals(categoryEntity.getCategoryId())) { + CategoryEntity parent = getById(categoryEntity.getCategoryId()); + //如果修改了父级则需要判断父级是否还有子节点 + boolean leaf = parent.getLeaf(); + //查找不等于当前更新的分类子集,有则不是叶子节点 + QueryWrapper queryWrapper = new QueryWrapper<>(); + parent.setLeaf(count(queryWrapper.eq("category_id", parent.getId()).ne("id", entity.getId())) == 0); + if (leaf != parent.getLeaf()) { + updateById(parent); + } - /** - * 设置父级叶子节点 - * @param entity - */ - private void setParentLeaf(CategoryEntity entity){ - CategoryEntity categoryEntity = getById(entity.getId()); - //如果父级不为空并且修改了父级则需要更新父级 - if(entity.getCategoryId() != null && !entity.getCategoryId().equals(categoryEntity.getCategoryId())){ - //更新旧的父级 - if(StrUtil.isNotBlank(categoryEntity.getCategoryId())&&!"0".equals(categoryEntity.getCategoryId())){ - CategoryEntity parent = getById(categoryEntity.getCategoryId()); - //如果修改了父级则需要判断父级是否还有子节点 - boolean leaf = parent.getLeaf(); - //查找不等于当前更新的分类子集,有则不是叶子节点 - QueryWrapper queryWrapper = new QueryWrapper<>(); - parent.setLeaf(count(queryWrapper.eq("category_id",parent.getId()).ne("id",entity.getId()))==0); - if(leaf!=parent.getLeaf()){ - updateById(parent); - } + } + //更新新的父级 + if (StrUtil.isNotBlank(entity.getCategoryId()) && !"0".equals(entity.getCategoryId())) { + CategoryEntity parent = getById(entity.getCategoryId()); + //如果之前是叶子节点就更新 + if (parent.getLeaf()) { + parent.setLeaf(false); + updateById(parent); + } + } + } + } - } - //更新新的父级 - if(StrUtil.isNotBlank(entity.getCategoryId())&&!"0".equals(entity.getCategoryId())){ - CategoryEntity parent = getById(entity.getCategoryId()); - //如果之前是叶子节点就更新 - if(parent.getLeaf()){ - parent.setLeaf(false); - updateById(parent); - } - } - } - } + /** + * 设置顶级id + * @param entity + */ + private void setTopId(CategoryEntity entity) { + String categoryParentId = entity.getCategoryParentIds(); + if (StrUtil.isNotBlank(categoryParentId)) { + String[] ids = categoryParentId.split(","); + //如果有ParentId就取第一个 + if (ids.length > 0) { + entity.setTopId(ids[0]); + return; + } + } + entity.setTopId("0"); + } - /** - * 设置顶级id - * @param entity - */ - private void setTopId(CategoryEntity entity){ - String categoryParentId = entity.getCategoryParentIds(); - if(StrUtil.isNotBlank(categoryParentId)){ - String[] ids = categoryParentId.split(","); - //如果有ParentId就取第一个 - if(ids.length>0){ - entity.setTopId(ids[0]); - return; - } - } - entity.setTopId("0"); - } + @Override + public void copyCategory(CategoryEntity category) { + String oldId = category.getId(); + //先保存被复制第一层栏目,因为第一层栏目不需要变更父级栏目 + category = getById(oldId); + //id、拼音和路径按照原来的业务逻辑生成 + category.setId(null); + category.setCategoryPinyin(null); + category.setCategoryPath(null); + saveEntity(category); + //传入简要被复制子栏目的id和复制后的生成的id,复制的子栏目全部使用 + recursionCopyChilds(oldId, category.getId()); + } - @Override - public void copyCategory(CategoryEntity category) { - String oldId = category.getId(); - //先保存被复制第一层栏目,因为第一层栏目不需要变更父级栏目 - category = getById(oldId); - //id、拼音和路径按照原来的业务逻辑生成 - category.setId(null); - category.setCategoryPinyin(null); - category.setCategoryPath(null); - saveEntity(category); - //传入简要被复制子栏目的id和复制后的生成的id,复制的子栏目全部使用 - recursionCopyChilds(oldId, category.getId()); - } - - /* - * 递归复制子栏目 - * @param oldParentId:被复制的父级栏目id(需要数据库原来存在该数据) - * @param newParentId:复制栏目后新父级的id(新插入数据的id) - * */ - private void recursionCopyChilds(String oldParentId, String newParentId) { - CategoryEntity _category = new CategoryEntity(); - _category.setCategoryId(oldParentId); - List childs = query(_category); - for (CategoryEntity child : childs) { - String childId = child.getId(); - //id、拼音和路径按照原来的业务逻辑生成 - child.setId(null); - child.setCategoryPinyin(null); - child.setCategoryPath(null); - child.setCategoryId(newParentId); - saveEntity(child); - //如果该栏目下还有子栏目则继续复制该栏目里的子栏目 - recursionCopyChilds(childId, child.getId()); - } - } + /* + * 递归复制子栏目 + * @param oldParentId:被复制的父级栏目id(需要数据库原来存在该数据) + * @param newParentId:复制栏目后新父级的id(新插入数据的id) + * */ + private void recursionCopyChilds(String oldParentId, String newParentId) { + CategoryEntity _category = new CategoryEntity(); + _category.setCategoryId(oldParentId); + List childs = query(_category); + for (CategoryEntity child : childs) { + String childId = child.getId(); + //id、拼音和路径按照原来的业务逻辑生成 + child.setId(null); + child.setCategoryPinyin(null); + child.setCategoryPath(null); + child.setCategoryId(newParentId); + saveEntity(child); + //如果该栏目下还有子栏目则继续复制该栏目里的子栏目 + recursionCopyChilds(childId, child.getId()); + } + } } diff --git a/src/main/java/net/mingsoft/cms/entity/CategoryEntity.java b/src/main/java/net/mingsoft/cms/entity/CategoryEntity.java index 91886cf7..b38e01e2 100755 --- a/src/main/java/net/mingsoft/cms/entity/CategoryEntity.java +++ b/src/main/java/net/mingsoft/cms/entity/CategoryEntity.java @@ -98,6 +98,8 @@ public class CategoryEntity extends BaseEntity { * 缩略图 */ private String categoryImg; + + /** * 自定义链接 */ @@ -452,4 +454,5 @@ public class CategoryEntity extends BaseEntity { public String getTypelitpic() { return categoryImg; } + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b7339855..7683608d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -12,6 +12,8 @@ logging: name: mcms.log #会在项目的根目录下生成对应的mcms.log文件,也可以根据实际情况写绝对路径,例如:d:/mcms.log path: log #会在项目的根目录下生成log目录,里面会生成对应的日期目录,日期目录下面生成日志压缩包备份文件,默认按每10M分割一个日志文件,例如:log/2020-01/app-2020-01-03-18.1.log.gz(表示2020年1月3号下午六点的第一个备份),也可以根据实际情况写绝对路径,例如:d:/log ms: + mstore-url: http://store.i.mingsoft.net + mstore-host: store.i.mingsoft.net diy: html-dir: html # scheme: https #解决使用代理服务器代理应用时标签解析域名依旧为http的问题