Commit c1b81d0d authored by wujj's avatar wujj
Browse files

Merge remote-tracking branch 'origin/5.2'

# Conflicts:
#	doc/mcms-5.1.sql
#	pom.xml
parents c791bf40 1a95a697

ALTER TABLE `cms_category` ADD COLUMN `leaf` bigint(1) NULL DEFAULT NULL COMMENT '是否是叶子节点' AFTER `category_pinyin`;
ALTER TABLE `cms_category` ADD COLUMN `top_id` bigint(20) NULL DEFAULT NULL COMMENT '顶级id' AFTER `leaf`;
ALTER TABLE `cms_category` MODIFY COLUMN `id` bigint(20) UNSIGNED NOT NULL FIRST ;
ALTER TABLE `cms_content` MODIFY COLUMN `id` bigint(20) UNSIGNED NOT NULL FIRST ;
ALTER TABLE `manager` ADD COLUMN `create_date` datetime NULL DEFAULT NULL AFTER `manager_admin`;
ALTER TABLE `manager` ADD COLUMN `update_date` datetime NULL DEFAULT NULL AFTER `create_date`;
ALTER TABLE `manager` ADD COLUMN `update_by` int(11) NULL DEFAULT NULL AFTER `update_date`;
ALTER TABLE `manager` ADD COLUMN `create_by` int(11) NULL DEFAULT NULL AFTER `update_by`;
ALTER TABLE `manager` ADD COLUMN `del` int(11) NULL DEFAULT NULL AFTER `create_by`;
ALTER TABLE `manager` MODIFY COLUMN `manager_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '管理员id(主键)' FIRST ;
ALTER TABLE `mdiy_dict` ADD COLUMN `dict_enable` varchar(11) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT '1' COMMENT '启用状态' AFTER `is_child`;
ALTER TABLE `mdiy_model` ADD COLUMN `app_id` int(11) NULL DEFAULT NULL COMMENT '应用编号' AFTER `model_json`;
ALTER TABLE `mdiy_model` DROP COLUMN `model_app_id`;
ALTER TABLE `mdiy_page` DROP FOREIGN KEY `mdiy_page_ibfk_1`;
ALTER TABLE `mdiy_page` ADD COLUMN `app_id` int(11) NOT NULL COMMENT '应用id' AFTER `page_id`;
ALTER TABLE `mdiy_page` DROP COLUMN `page_app_id`;
ALTER TABLE `mdiy_page` ADD CONSTRAINT `mdiy_page_ibfk_1` FOREIGN KEY (`app_id`) REFERENCES `app` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
DROP INDEX `index_page_app_id` ON `mdiy_page`;
CREATE INDEX `index_page_app_id` ON `mdiy_page`(`app_id`) USING BTREE ;
ALTER TABLE `people` DROP FOREIGN KEY `people_ibfk_1`;
ALTER TABLE `people` ADD COLUMN `app_id` int(11) NOT NULL COMMENT '应用编号' AFTER `people_datetime`;
ALTER TABLE `people` DROP COLUMN `people_app_id`;
ALTER TABLE `people` ADD CONSTRAINT `people_ibfk_1` FOREIGN KEY (`app_id`) REFERENCES `app` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
DROP INDEX `fk_people` ON `people`;
CREATE INDEX `fk_people` ON `people`(`app_id`) USING BTREE ;
ALTER TABLE `people_address` ADD COLUMN `APP_ID` int(11) NOT NULL COMMENT '对应的站点id' AFTER `PA_DEFAULT`;
ALTER TABLE `people_address` DROP COLUMN `PA_APP_ID`;
DROP INDEX `PA_APP_ID` ON `people_address`;
CREATE INDEX `PA_APP_ID` ON `people_address`(`APP_ID`) USING BTREE ;
ALTER TABLE `system_log` MODIFY COLUMN `id` bigint(20) UNSIGNED NOT NULL FIRST ;
UPDATE `mdiy_tag_sql` SET `id`='5', `tag_id`='3', `tag_sql`='<#assign _typeid=\'\'/>\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 size??>\r\n <#assign _size=\'${size}\'>\r\n</#if>\r\n<#if orderby?? >\r\n <#if orderby==\'date\'> \r\n <#assign _orderby=\'content_datetime\'>\r\n <#elseif orderby==\'updatedate\'>\r\n <#assign _orderby=\'content_updatetime\'>\r\n <#elseif orderby==\'hit\'> \r\n <#assign _orderby=\'content_hit\'>\r\n <#elseif orderby==\'sort\'>\r\n <#assign _orderby=\'content_sort\'>\r\n <#else><#assign _orderby=\'cms_content.id\'></#if>\r\n <#else>\r\n <#assign _orderby=\'cms_content.id\'>\r\n </#if>\r\nSELECT\r\n cms_content.id AS id,\r\n content_title AS title,\r\n content_title AS fulltitle,\r\n content_author AS author,\r\n content_source AS source,\r\n content_details AS content,\r\n category.category_title AS typename,\r\n category.id AS typeid,\r\n category.category_img AS typelitpic,\r\n <#--列表页动态链接-->\r\n <#if isDo?? && isDo>\r\n CONCAT(\'/${modelName}/list.do?typeid=\', category.category_id) as typelink,\r\n <#else>\r\n (SELECT \'index.html\') AS typelink,\r\n </#if>\r\n content_img AS litpic,\r\n <#--内容页动态链接-->\r\n <#if isDo?? && isDo>\r\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\r\n <#else>\r\n\r\n CONCAT(category.category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\r\n </#if>\r\n content_datetime AS \"date\",<#if tableName??>${tableName}.*,</#if>\r\n content_description AS descrip,\r\n content_hit AS hit,\r\n content_type AS flag,\r\n category_title AS typetitle,\r\n cms_content.content_keyword AS keyword \r\nFROM\r\n cms_content\r\n LEFT JOIN cms_category as category ON content_category_id = category.id\r\n <#--判断是否有自定义模型表-->\r\n <#if tableName??>LEFT JOIN ${tableName} ON ${tableName}.link_id=cms_content.id </#if>\r\nWHERE \r\n content_display=0 \r\n and cms_content.del=0 \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 <#--判断是否有搜索分类集合-->\r\n <#if search??>\r\n <#if search.categoryIds??>and FIND_IN_SET(category.id,\'${search.categoryIds}\')</#if>\r\n <#--标题-->\r\n <#if search.content_title??> and content_title like CONCAT(\'%\',\'${search.content_title}\',\'%\')</#if>\r\n <#--作者-->\r\n <#if search.content_author??> and content_author like CONCAT(\'%\',\'${search.content_author}\',\'%\')</#if>\r\n <#--来源-->\r\n <#if search.content_source??> and content_source like CONCAT(\'%\',\'${search.content_source}\',\'%\')</#if>\r\n <#--属性-->\r\n <#if search.content_type??> and (\r\n <#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)\r\n </#list>)</#if>\r\n <#--描述-->\r\n <#if search.content_description??> and content_description like CONCAT(\'%\',\'${search.content_description}\',\'%\')</#if>\r\n <#--关键字-->\r\n <#if search.content_keyword??> and content_keyword like CONCAT(\'%\',\'${search.content_keyword}\',\'%\')</#if>\r\n <#--内容-->\r\n <#if search.content_details??> and content_details like CONCAT(\'%\',\'${search.content_details}\',\'%\')</#if>\r\n \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??> and content_datetime between \'${search.content_datetime_start}\' and \'${search.content_datetime_end}\'</#if>\r\n <#else><#--查询栏目-->\r\n <#if _typeid?has_content> and (content_category_id=${_typeid} or content_category_id in \r\n (select id FROM cms_category where cms_category.del=0 and FIND_IN_SET(${_typeid},CATEGORY_PARENT_ID))) </#if>\r\n </#if>\r\n <#--标题-->\r\n <#if content_title??> and content_title like CONCAT(\'%\',\'${content_title}\',\'%\')</#if>\r\n <#--作者-->\r\n <#if content_author??> and content_author like CONCAT(\'%\',\'${content_author}\',\'%\')</#if>\r\n <#--来源-->\r\n <#if content_source??> and content_source like CONCAT(\'%\',\'${content_source}\',\'%\')</#if>\r\n <#--属性-->\r\n <#if content_type??> and content_type like CONCAT(\'%\',\'${content_type}\',\'%\')</#if>\r\n <#--描述-->\r\n <#if content_description??> and content_description like CONCAT(\'%\',\'${content_description}\',\'%\')</#if>\r\n <#--关键字-->\r\n <#if content_keyword??> and content_keyword like CONCAT(\'%\',\'${content_keyword}\',\'%\')</#if>\r\n <#--内容-->\r\n <#if content_details??> and content_details like 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 and ${tableName}.${dm.key} like CONCAT(\'%\',\'${dm.value}\',\'%\') \r\n </#list>\r\n </#if>\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_content.content_type)\r\n </#list>)\r\n </#if>\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_content.content_type)=0\r\n </#list> or cms_content.content_type is null)\r\n </#if>\r\n <#--字段排序-->\r\n <#if orderby?? >\r\n ORDER BY \r\n <#if orderby==\'date\'> content_datetime\r\n <#elseif orderby==\'updatedate\'> content_updatetime\r\n <#elseif orderby==\'hit\'> content_hit\r\n <#elseif orderby==\'sort\'> content_sort\r\n <#else>cms_content.id</#if>\r\n <#else>\r\n ORDER BY cms_content.id\r\n </#if>\r\n <#if order?? >\r\n <#if order==\'desc\'> desc</#if>\r\n <#if order==\'asc\'> asc</#if>\r\n </#if>\r\n LIMIT \r\n <#--判断是否分页-->\r\n <#if ispaging?? && (pageTag.pageNo)??>${((pageTag.pageNo-1)*_size?eval)?c},${_size?default(20)}\r\n <#else>${_size?default(20)}</#if>', `sort`='1' WHERE (`id`='5');
UPDATE `mdiy_tag_sql` SET `id`='6', `tag_id`='4', `tag_sql`='<#assign _typeid=\'0\'/>\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<#if typeid??>\r\n <#assign _typeid=\'${typeid}\'>\r\n</#if>\r\nselect \r\n id,\r\n id as typeid,\r\n category_title as typetitle,\r\n <#--返回父id集合-->\r\n category_parent_id as pids,\r\n <#--动态链接-->\r\n <#if isDo?? && isDo>\r\n CONCAT(\'/${modelName}/list.do?typeid=\', id) as typelink,\r\n <#else>\r\n <#--栏目类型为链接-->\r\n CONCAT(category_path,\'/index.html\') as typelink,\r\n </#if>\r\n category_keyword as typekeyword,\r\n category_diy_url as typeurl,\r\n category_flag as flag,\r\n category_parent_id as parentid,\r\ncategory_descrip as typedescrip,\r\n category_img as typelitpic ,\r\n(select count(*) from cms_category c where c.category_id=id and c.del=0) as childsize\r\n from cms_category \r\n where \r\n cms_category.del=0 \r\n <#--根据站点编号查询-->\r\n <#if appId?? >\r\n and cms_category.app_id=${appId}\r\n </#if>\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}\',category_flag)\r\n </#list>)\r\n </#if>\r\n <#if noflag?? >\r\n and\r\n (\r\n <#list noflag?split(\',\') as item>\r\n <#if item?index gt 0> and</#if>\r\n FIND_IN_SET(\'${item}\',category_flag)=0\r\n </#list> or category_flag is null)\r\n </#if>\r\n <#--type默认son-->\r\n<#if !type??||!type?has_content>\r\n<#assign type=\'son\'/>\r\n</#if>\r\n<#if type?has_content>\r\n <#--顶级栏目(单个)-->\r\n <#if type==\'top\'>\r\n <#if _typeid != \'0\'>\r\n and (id = top_id or top_id = 0)\r\n </#if>\r\n <#elseif type==\'nav\'>\r\n and(category_id=0 or category_id is null)\r\n <#--同级栏目(多个)-->\r\n <#elseif type==\'level\'>\r\n and\r\n <#if _typeid?has_content>\r\n category_id=(select category_id from cms_category where id=${_typeid})\r\n <#else>\r\n 1=1\r\n </#if>\r\n <#--当前栏目(单个)-->\r\n <#elseif type==\'self\'>\r\n and \r\n <#if _typeid?has_content>\r\n id=${_typeid}\r\n <#else>\r\n 1=1\r\n </#if>\r\n <#--当前栏目的所属栏目(多个)-->\r\n <#elseif type==\'path\'>\r\n and \r\n <#if _typeid?has_content>\r\n id in (<#if column?? && column.categoryParentId??>${column.categoryParentId},</#if>${_typeid})\r\n <#else>\r\n 1=1\r\n </#if>\r\n <#--子栏目(多个)-->\r\n <#elseif type==\'son\'>\r\n and \r\n <#if _typeid?has_content>\r\n category_id=${_typeid}\r\n <#else>\r\n 1=1\r\n </#if>\r\n <#--上一级栏目没有则取当前栏目(单个)-->\r\n <#elseif type==\'parent\'>\r\n and \r\n <#if _typeid?has_content>\r\n <#if column?? && column.categoryId??>\r\n id=${column.categoryId}\r\n <#else>\r\n id=${_typeid}\r\n </#if>\r\n <#else>\r\n 1=1\r\n </#if>\r\n </#if>\r\n<#else> <#--默认顶级栏目-->\r\n and\r\n <#if _typeid?has_content>\r\n id=${_typeid}\r\n <#else>\r\n (category_id=0 or category_id is null)\r\n </#if>\r\n</#if>\r\n<#--字段排序-->\r\n <#if orderby?? >\r\n ORDER BY \r\n <#if orderby==\'date\'> category_datetime\r\n <#elseif orderby==\'sort\'> category_sort\r\n <#else>cms_content.id</#if>\r\n\r\n </#if>\r\n <#if order?? >\r\n <#if order==\'desc\'> desc</#if>\r\n <#if order==\'asc\'> asc</#if>\r\n </#if>', `sort`='1' WHERE (`id`='6');
UPDATE `mdiy_tag_sql` SET `id`='7', `tag_id`='5', `tag_sql`='select \r\nAPP_NAME as name,\r\napp_logo as logo ,\r\napp_keyword as keyword,\r\napp_description as descrip,\r\napp_copyright as copyright,\r\n<#--动态解析 -->\r\n<#if isDo?? && isDo>\r\nCONCAT(\'${url}\',\'/${html}/\',id) as url,\r\n\'${url}\' as host,\r\n<#--使用地址栏的域名 -->\r\n<#elseif url??>\r\nCONCAT(\'${url}\',\'/${html}/\',id,\'/<#if m??>${m}</#if>\') as url,\r\n\'${url}\' as host,\r\n<#else>\r\nCONCAT(REPLACE(REPLACE(TRIM(substring_index(app_url,\'\\n\',1)), CHAR(10),\'\'), CHAR(13),\'\'),\'/html/\',id,\'/<#if m??>${m}</#if>\') as url,\r\nREPLACE(REPLACE(TRIM(substring_index(app_url,\'\\n\',1)), CHAR(10),\'\'), CHAR(13),\'\') as host,\r\n</#if>\r\nCONCAT(\'templets/\',id,\'/\',<#if m??>CONCAT(app_style,\'/${m}\')<#else>app_style</#if>) as \"style\" <#-- 判断是否为手机端 -->\r\nfrom app where id = ${appId} limit 1', `sort`='1' WHERE (`id`='7');
UPDATE `mdiy_tag_sql` SET `id`='8', `tag_id`='7', `tag_sql`='SELECT \r\ncms_content.id as id,\r\nleft(content_title,${titlelen?default(40)}) as title,\r\ncontent_title as fulltitle,\r\ncontent_author as author, \r\ncontent_source as source, \r\ncontent_details as content,\r\ncategory_title as typetitle,\r\ncms_category.id as typeid,\r\n cms_category.category_img AS typelitpic,\r\n<#--动态链接-->\r\n<#if isDo?? && isDo>\r\nCONCAT(\'/${modelName}/list.do?typeid=\', cms_category.id) as typelink,\r\n<#else>\r\n(SELECT \'index.html\') as typelink,\r\n</#if>\r\ncms_content.content_img AS litpic,\r\n<#--内容页动态链接-->\r\n<#if isDo?? && isDo>\r\nCONCAT(\'/mcms/view.do?id=\', cms_content.id) as \"link\",\r\n<#else>\r\ncontent_url AS \"link\",\r\n</#if>\r\ncontent_datetime as \"date\",\r\ncontent_description as descrip,\r\nCONCAT(\'<script type=\"text/javascript\" src=\"${url}/cms/content/\',cms_content.id,\'/hit.do\"></script>\') as hit,\r\ncontent_type as flag,\r\ncategory_title as typetitle,\r\n<#if tableName??>${tableName}.*,</#if>\r\ncontent_keyword as keyword\r\nFROM cms_content\r\nLEFT JOIN cms_category ON \r\n<#--如果是栏目列表页没有文章id所以只取栏目id-->\r\n<#if column??&&column.id??&&!id??> \r\n cms_category.id=${column.id}\r\n<#else>\r\ncms_category.id = content_category_id\r\n</#if>\r\n<#--判断是否有自定义模型表-->\r\n<#if tableName??>left join ${tableName} on ${tableName}.link_id=cms_content.id</#if>\r\nWHERE \r\n cms_content.del=0\r\n<#if id??> and cms_content.id=${id}</#if>', `sort`='1' WHERE (`id`='8');
UPDATE `mdiy_tag_sql` SET `id`='9', `tag_id`='8', `tag_sql`='<#assign select=\"(SELECT \'\')\"/>\r\n<#if orderby?? >\r\n <#if orderby==\"date\"> \r\n <#assign _orderby=\"content_datetime\">\r\n <#elseif orderby==\"updatedate\">\r\n <#assign _orderby=\"content_updatetime\">\r\n <#elseif orderby==\"hit\"> \r\n <#assign _orderby=\"content_hit\">\r\n <#elseif orderby==\"sort\">\r\n <#assign _orderby=\"content_sort\">\r\n <#else><#assign _orderby=\"cms_content.id\"></#if>\r\n <#else>\r\n <#assign _orderby=\"cms_content.id\">\r\n </#if>\r\n<#if pageTag.preId??>\r\nSELECT \r\ncms_content.id as id,\r\nleft(content_title,${titlelen?default(40)}) as title,\r\ncontent_title as fulltitle,\r\ncontent_author as author, \r\ncontent_source as source, \r\ncontent_details as content,\r\ncategory.category_title as typename,\r\ncategory.category_id as typeid,\r\n(SELECT \'index.html\') as typelink,\r\ncontent_img as litpic,\r\n<#--内容页动态链接-->\r\n <#if isDo?? && isDo>\r\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\r\n <#else>\r\n CONCAT(category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\r\n </#if>\r\ncontent_datetime as \"date\",\r\ncontent_description as descrip,\r\ncontent_hit as hit,\r\ncontent_type as flag,\r\ncontent_keyword as keyword \r\nFROM cms_content \r\nLEFT JOIN cms_category as category ON content_category_id=category.id \r\nWHERE cms_content.id=${pageTag.preId}\r\n<#else>\r\nSELECT \r\n${select} as id,\r\n${select} as title,\r\n${select} as fulltitle,\r\n${select} as author, \r\n${select} as source, \r\n${select} as content,\r\n${select} as typename,\r\n${select} as typeid,\r\n${select} as typelink,\r\n${select} as litpic,\r\n${select} as \"link\",\r\n${select} as \"date\",\r\n${select} as descrip,\r\n${select} as hit,\r\n${select} as flag,\r\n${select} as keyword FROM cms_content\r\n</#if>', `sort`=NULL WHERE (`id`='9');
UPDATE `mdiy_tag_sql` SET `id`='10', `tag_id`='9', `tag_sql`=' select\r\n <#if !(pageTag.indexUrl??)>\r\n <#--判断是否有栏目对象,用于搜索不传栏目-->\r\n <#if column??>\r\n <#assign path=column.categoryPath/>\r\n <#else>\r\n <#assign path=\"\"/>\r\n </#if>\r\n <#--总记录数、总页数-->\r\n (SELECT ${pageTag.total}) as \"total\",\r\n <#--记录总数-->\r\n (SELECT ${pageTag.size}) as \"rcount\",\r\n <#--当前页码-->\r\n (SELECT ${pageTag.pageNo}) as \"cur\",\r\n <#--首页-->\r\n CONCAT(\'${path}\', \'/index.html\') as \"index\",\r\n <#--上一页-->\r\n <#if (pageTag.pageNo?eval-1) gt 1>\r\n CONCAT(\'${path}\',\'/list-${pageTag.pageNo?eval-1}.html\') as \"pre\",\r\n <#else>\r\n CONCAT(\'${path}\',\'/index.html\') as \"pre\",\r\n </#if>\r\n <#--下一页-->\r\n <#if pageTag.total==1>\r\n CONCAT(\'${path}\', \'/index.html\') as \"next\",\r\n CONCAT(\'${path}\', \'/index.html\') as \"last\"\r\n <#else>\r\n <#if pageTag.pageNo?eval gte pageTag.total>\r\n CONCAT(\'${path}\',\'/list-${pageTag.total}.html\') as \"next\",\r\n <#else>\r\n CONCAT(\'${path}\',\'/list-${pageTag.pageNo?eval+1}.html\') as \"next\",\r\n </#if>\r\n <#--最后一页-->\r\n CONCAT(\'${path}\',\'/list-${pageTag.total}.html\') as \"last\"\r\n </#if>\r\n<#else><#--判断是否是搜索页面-->\r\n \'${pageTag.indexUrl}\' as \"index\",\'${pageTag.lastUrl}\' as \"last\",\'${pageTag.preUrl}\' as \"pre\",\'${pageTag.nextUrl}\' as \"next\",\'${pageTag.total}\' as \"total\",\'${pageTag.size}\' as \"rcount\",\'${pageTag.pageNo}\' as \"cur\"\r\n</#if>', `sort`=NULL WHERE (`id`='10');
UPDATE `mdiy_tag_sql` SET `id`='11', `tag_id`='10', `tag_sql`='<#assign select=\"(SELECT \'\')\"/>\r\n<#if orderby?? >\r\n <#if orderby==\"date\"> \r\n <#assign _orderby=\"content_datetime\">\r\n <#elseif orderby==\"updatedate\">\r\n <#assign _orderby=\"content_updatetime\">\r\n <#elseif orderby==\"hit\"> \r\n <#assign _orderby=\"content_hit\">\r\n <#elseif orderby==\"sort\">\r\n <#assign _orderby=\"content_sort\">\r\n <#else><#assign _orderby=\"cms_content.id\"></#if>\r\n <#else>\r\n <#assign _orderby=\"cms_content.id\">\r\n </#if>\r\n<#if pageTag.nextId??>\r\nSELECT \r\ncms_content.id as id,\r\nleft(content_title,${titlelen?default(40)}) as title,\r\ncontent_title as fulltitle,\r\ncontent_author as author, \r\ncontent_source as source, \r\ncontent_details as content,\r\ncategory.category_title as typename,\r\ncategory.category_id as typeid,\r\n(SELECT \'index.html\') as typelink,\r\ncontent_img as litpic,\r\n<#--内容页动态链接-->\r\n <#if isDo?? && isDo>\r\n CONCAT(\'/${modelName}/view.do?id=\', cms_content.id,\'&orderby=${_orderby}\',\'&order=${order!\'ASC\'}\',\'&typeid=${typeid}\') as \"link\",\r\n <#else>\r\n CONCAT(category_path,\'/\',cms_content.id,\'.html\') AS \"link\",\r\n </#if>\r\ncontent_datetime as \"date\",\r\ncontent_description as descrip,\r\ncontent_hit as hit,\r\ncontent_type as flag,\r\ncontent_keyword as keyword \r\nFROM cms_content \r\nLEFT JOIN cms_category as category ON content_category_id=category.id \r\nWHERE cms_content.id=${pageTag.nextId}\r\n<#else>\r\nSELECT \r\n${select} as id,\r\n${select} as title,\r\n${select} as fulltitle,\r\n${select} as author, \r\n${select} as source, \r\n${select} as content,\r\n${select} as typename,\r\n${select} as typeid,\r\n${select} as typelink,\r\n${select} as litpic,\r\n${select} as \"link\",\r\n${select} as \"date\",\r\n${select} as descrip,\r\n${select} as hit,\r\n${select} as flag,\r\n${select} as keyword FROM cms_content\r\n</#if>', `sort`=NULL WHERE (`id`='11');
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>net.mingsoft</groupId>
<artifactId>ms-pom</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>net.mingsoft</groupId>
<artifactId>ms-mcms</artifactId>
<version>5.2-SNAPSHOT</version>
<name>ms-mcms</name>
<!-- 打包jar包 -->
<packaging>jar</packaging>
<!-- 打包war包 -->
<!-- <packaging>war</packaging> -->
<properties>
<java.version>1.8</java.version>
</properties>
<modelVersion>4.0.0</modelVersion>
<groupId>net.mingsoft</groupId>
<artifactId>ms-mcms</artifactId>
<version>5.1</version>
<name>ms-mcms</name>
<!-- 打包jar包 -->
<packaging>jar</packaging>
<!-- 打包war包 -->
<!-- <packaging>war</packaging> -->
<properties>
<java.version>1.8</java.version>
</properties>
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>ms-mpeople</artifactId>
<version>1.0.28</version>
</dependency>
<dependencies>
<!-- 此部分是铭飞平台MStroe的客户端(MStore不在铭飞开源产品范围),如果不需要使用MStore可以删除掉 -->
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>store-client</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.2.2.RELEASE</version>
<dependency>
<groupId>dm</groupId>
<artifactId>dm.jdbc.driver</artifactId>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>ms-mpeople</artifactId>
</dependency>
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>ms-db</artifactId>
</dependency>
<!-- 此部分是铭飞平台MStroe的客户端(MStore不在铭飞开源产品范围),如果不需要使用MStore可以删除掉 -->
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>store-client</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.2.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>ms-mcms</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<fork>true</fork>
<build>
<finalName>ms-mcms</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<excludes>
<exclude>**/static/plugins/</exclude>
<exclude>**/static/skin/</exclude>
<exclude>**/*.yml</exclude>
<exclude>**/Dockerfile</exclude>
<exclude>**/ehcache.xml</exclude>
<exclude>**/upgrade/</exclude>
<exclude>**/MSApplication.*</exclude>
<exclude>**/MSServletInitializer.*</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<excludes>
<exclude>**/static/plugins/</exclude>
<exclude>**/static/skin/</exclude>
<exclude>**/*.yml</exclude>
<exclude>**/Dockerfile</exclude>
<exclude>**/ehcache.xml</exclude>
<exclude>**/upgrade/</exclude>
<exclude>**/config/</exclude>
<exclude>**/MSApplication.java</exclude>
<exclude>**/MSServletInitializer.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArguments>
<verbose />
<bootclasspath>${java.home}/lib/rt.jar${path.separator}${java.home}/lib/jce.jar</bootclasspath>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
</configuration>
</plugin>
......@@ -95,7 +169,7 @@
</plugins>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<excludes>
<!--打包生产 -->
......@@ -104,14 +178,24 @@
<!-- <exclude>upload/</exclude> -->
<!-- <exclude>templets/</exclude> -->
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
<defaultGoal>compile</defaultGoal>
</build>
<excludes>
<!--打包生产 -->
<exclude>static/</exclude>
<exclude>html/</exclude>
<exclude>upload/</exclude>
<exclude>template/</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<defaultGoal>compile</defaultGoal>
</build>
</project>
\ No newline at end of file
......@@ -13,7 +13,7 @@ import java.util.Locale;
@SpringBootApplication
@ComponentScan(basePackages = {"net.mingsoft"})
@MapperScan(basePackages={"**.dao"})
@MapperScan(basePackages={"**.dao","**.mapper"})
@ServletComponentScan(basePackages = {"net.mingsoft"})
public class MSApplication {
public static void main(String[] args) {
......
package net.mingsoft.cms.action;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.constant.e.BusinessTypeEnum;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.PinYinUtil;
import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.basic.util.PinYinUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -25,6 +25,7 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 分类管理控制层
* @author 铭飞开发团队
......@@ -34,7 +35,7 @@ import java.util.List;
@Api(value = "分类接口")
@Controller("cmsCategoryAction")
@RequestMapping("/${ms.manager.path}/cms/category")
public class CategoryAction extends BaseAction{
public class CategoryAction extends BaseAction {
/**
......@@ -84,23 +85,18 @@ public class CategoryAction extends BaseAction{
})
@RequestMapping("/list")
@ResponseBody
public ResultData list(@ModelAttribute @ApiIgnore CategoryEntity category,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) {
category.setAppId(BasicUtil.getAppId());
public ResultData list(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model, BindingResult result) {
BasicUtil.startPage();
List categoryList = categoryBiz.query(category);
return ResultData.build().success(new EUListBean(categoryList,(int)BasicUtil.endPage(categoryList).getTotal()));
return ResultData.build().success(new EUListBean(categoryList,(int) BasicUtil.endPage(categoryList).getTotal()));
}
/**
* 返回编辑界面category_form
*/
@GetMapping("/form")
public String form(@ModelAttribute CategoryEntity category,HttpServletResponse response,HttpServletRequest request,ModelMap model){
if(category.getId()!=null){
BaseEntity categoryEntity = categoryBiz.getEntity(Integer.parseInt(category.getId()));
model.addAttribute("categoryEntity",categoryEntity);
}
model.addAttribute("appId",BasicUtil.getAppId());
public String form(@ModelAttribute CategoryEntity category, HttpServletResponse response, HttpServletRequest request, ModelMap model){
model.addAttribute("appId", BasicUtil.getAppId());
return "/cms/category/form";
}
......@@ -112,12 +108,11 @@ public class CategoryAction extends BaseAction{
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query")
@GetMapping("/get")
@ResponseBody
public ResultData get(@ModelAttribute @ApiIgnore CategoryEntity category,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){
public ResultData get(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model){
if(category.getId()==null) {
return ResultData.build().error();
}
category.setAppId(BasicUtil.getAppId());
CategoryEntity _category = (CategoryEntity)categoryBiz.getEntity(Integer.parseInt(category.getId()));
CategoryEntity _category = (CategoryEntity)categoryBiz.getById(category.getId());
return ResultData.build().success(_category);
}
......@@ -172,9 +167,16 @@ public class CategoryAction extends BaseAction{
if(!StringUtil.checkLength(category.getCategoryParentId()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
}
//获取拼音
//判断拼音是否重复
if(StrUtil.isNotBlank(category.getCategoryPinyin())) {
CategoryEntity _category = new CategoryEntity();
_category.setCategoryPinyin(category.getCategoryPinyin());
List<CategoryEntity> query = categoryBiz.query(_category);
if (query.size() > 0) {
return ResultData.build().error(getResString("err.exist", this.getResString("category.pinyin")));
}
}
category.setAppId(BasicUtil.getAppId());
categoryBiz.saveEntity(category);
return ResultData.build().success(category);
}
......@@ -187,9 +189,9 @@ public class CategoryAction extends BaseAction{
@ResponseBody
@LogAnn(title = "删除分类", businessType = BusinessTypeEnum.DELETE)
@RequiresPermissions("cms:category:del")
public ResultData delete(@RequestBody List<CategoryEntity> categorys,HttpServletResponse response, HttpServletRequest request) {
public ResultData delete(@RequestBody List<CategoryEntity> categorys, HttpServletResponse response, HttpServletRequest request) {
for(int i = 0;i<categorys.size();i++){
categoryBiz.delete(Integer.parseInt(categorys.get(i).getId()));
categoryBiz.delete(categorys.get(i).getId());
}
return ResultData.build().success();
}
......@@ -230,7 +232,7 @@ public class CategoryAction extends BaseAction{
@LogAnn(title = "更新分类", businessType = BusinessTypeEnum.UPDATE)
@RequiresPermissions("cms:category:update")
public ResultData update(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response,
HttpServletRequest request) {
HttpServletRequest request) {
//验证栏目管理名称的值是否合法
if(StringUtil.isBlank(category.getCategoryTitle())){
return ResultData.build().error(getResString("err.empty", this.getResString("category.title")));
......@@ -245,10 +247,22 @@ public class CategoryAction extends BaseAction{
if(!StringUtil.checkLength(category.getCategoryParentId()+"", 0, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
}
//判断拼音是否重复并且是否和原拼音相同
if(StrUtil.isNotBlank(category.getCategoryPinyin()) && !categoryBiz.getById(category.getId()).getCategoryPinyin().equals(category.getCategoryPinyin())) {
CategoryEntity _category = new CategoryEntity();
_category.setCategoryPinyin(category.getCategoryPinyin());
List<CategoryEntity> query = categoryBiz.query(_category);
if (query.size() > 0) {
return ResultData.build().error(getResString("err.exist", this.getResString("category.pinyin")));
}
}
String pingYin = PinYinUtil.getPingYin(category.getCategoryTitle());
//如果用户填写了拼音则使用用户填写的
if (StrUtil.isNotBlank(category.getCategoryPinyin())) {
pingYin = category.getCategoryPinyin();
}
CategoryEntity categoryEntity=new CategoryEntity();
categoryEntity.setCategoryPinyin(pingYin);
categoryEntity.setAppId(BasicUtil.getAppId());
CategoryEntity categoryBizEntity = (CategoryEntity)categoryBiz.getEntity(categoryEntity);
category.setCategoryPinyin(pingYin);
//如果存在此拼音栏目则拼接上id
......@@ -258,14 +272,12 @@ public class CategoryAction extends BaseAction{
//判断是否选择子级为所属栏目
CategoryEntity _category = new CategoryEntity();
_category.setCategoryParentId(category.getId());
_category.setAppId(BasicUtil.getAppId());
List<CategoryEntity> categoryList = categoryBiz.queryChilds(_category);
for(CategoryEntity item:categoryList){
if(item.getId().equals(category.getCategoryId())){
return ResultData.build().error(getResString("cannot.select.child"));
}
}
category.setAppId(BasicUtil.getAppId());
categoryBiz.updateEntity(category);
return ResultData.build().success(category);
}
......
......@@ -4,7 +4,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.bean.EUListBean;
......@@ -23,7 +22,9 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
* 文章管理控制层
* @author 铭飞开发团队
......@@ -33,7 +34,7 @@ import java.util.List;
@Api(value = "文章接口")
@Controller("cmsContentAction")
@RequestMapping("/${ms.manager.path}/cms/content")
public class ContentAction extends BaseAction{
public class ContentAction extends BaseAction {
/**
......@@ -86,23 +87,18 @@ public class ContentAction extends BaseAction{
})
@RequestMapping("/list")
@ResponseBody
public ResultData list(@ModelAttribute @ApiIgnore ContentEntity content,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) {
content.setAppId(BasicUtil.getAppId());
public ResultData list(@ModelAttribute @ApiIgnore ContentEntity content, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model, BindingResult result) {
BasicUtil.startPage();
List contentList = contentBiz.query(content);
return ResultData.build().success(new EUListBean(contentList,(int)BasicUtil.endPage(contentList).getTotal()));
return ResultData.build().success(new EUListBean(contentList,(int) BasicUtil.endPage(contentList).getTotal()));
}
/**
* 返回编辑界面content_form
*/
@GetMapping("/form")
public String form(@ModelAttribute ContentEntity content,HttpServletResponse response,HttpServletRequest request,ModelMap model){
if(content.getId()!=null){
BaseEntity contentEntity = contentBiz.getEntity(Integer.parseInt(content.getId()));
model.addAttribute("contentEntity",contentEntity);
}
model.addAttribute("appId",BasicUtil.getAppId());
public String form(@ModelAttribute ContentEntity content, HttpServletResponse response, HttpServletRequest request, ModelMap model){
model.addAttribute("appId", BasicUtil.getAppId());
return "/cms/content/form";
}
......@@ -114,12 +110,11 @@ public class ContentAction extends BaseAction{
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query")
@GetMapping("/get")
@ResponseBody
public ResultData get(@ModelAttribute @ApiIgnore ContentEntity content,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){
public ResultData get(@ModelAttribute @ApiIgnore ContentEntity content, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model){
if(content.getId()==null) {
return ResultData.build().error();
}
content.setAppId(BasicUtil.getAppId());
ContentEntity _content = (ContentEntity)contentBiz.getEntity(Integer.parseInt(content.getId()));
ContentEntity _content = contentBiz.getById(content.getId());
return ResultData.build().success(_content);
}
......@@ -176,8 +171,7 @@ public class ContentAction extends BaseAction{
if(!StringUtil.checkLength(content.getContentUrl()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200"));
}
content.setAppId(BasicUtil.getAppId());
contentBiz.saveEntity(content);
contentBiz.save(content);
return ResultData.build().success(content);
}
......@@ -189,12 +183,12 @@ public class ContentAction extends BaseAction{
@ResponseBody
@LogAnn(title = "删除文章", businessType = BusinessTypeEnum.DELETE)
@RequiresPermissions("cms:content:del")
public ResultData delete(@RequestBody List<ContentEntity> contents,HttpServletResponse response, HttpServletRequest request) {
int[] ids = new int[contents.size()];
public ResultData delete(@RequestBody List<ContentEntity> contents, HttpServletResponse response, HttpServletRequest request) {
List<String> ids = new ArrayList<>();
for(int i = 0;i<contents.size();i++){
ids[i] =Integer.parseInt(contents.get(i).getId()) ;
ids.add(contents.get(i).getId());
}
contentBiz.delete(ids);
contentBiz.removeByIds(ids);
return ResultData.build().success();
}
/**
......@@ -230,7 +224,7 @@ public class ContentAction extends BaseAction{
@LogAnn(title = "更新文章", businessType = BusinessTypeEnum.UPDATE)
@RequiresPermissions("cms:content:update")
public ResultData update(@ModelAttribute @ApiIgnore ContentEntity content, HttpServletResponse response,
HttpServletRequest request) {
HttpServletRequest request) {
//验证文章标题的值是否合法
if(StringUtil.isBlank(content.getContentTitle())){
return ResultData.build().error(getResString("err.empty", this.getResString("content.title")));
......@@ -251,7 +245,6 @@ public class ContentAction extends BaseAction{
if(!StringUtil.checkLength(content.getContentUrl()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200"));
}
content.setAppId(BasicUtil.getAppId());
contentBiz.updateEntity(content);
return ResultData.build().success(content);
}
......
......@@ -161,12 +161,10 @@ public class GeneraterAction extends BaseAction {
if (CategoryId>0) {
CategoryEntity categoryEntity = new CategoryEntity();
categoryEntity.setId(CategoryId+"");
categoryEntity.setAppId(app.getAppId());
columns = categoryBiz.queryChilds(categoryEntity);
} else {
// 获取所有的内容管理栏目
CategoryEntity categoryEntity=new CategoryEntity();
categoryEntity.setAppId(app.getAppId());
columns = categoryBiz.query(categoryEntity);
}
List<CategoryBean> articleIdList = null;
......
package net.mingsoft.cms.action.web;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -103,10 +104,9 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
@ApiImplicitParam(name = "contentId", value = "文章编号", required = true,paramType="path")
@GetMapping(value = "/{contentId}/hit")
@ResponseBody
public void hit(@PathVariable @ApiIgnore int contentId, HttpServletRequest request, HttpServletResponse response){
public String hit(@PathVariable @ApiIgnore int contentId, HttpServletRequest request, HttpServletResponse response){
if(contentId<=0){
this.outString(response, "document.write(0)");
return;
return "document.write(0)";
}
//获取ip
String ip = BasicUtil.getIp();
......@@ -114,11 +114,17 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
boolean isMobileDevice = BasicUtil.isMobileDevice();
ContentEntity content = (ContentEntity)contentBiz.getEntity(contentId);
if(content == null){
return "document.write(0)";
}
//浏览数+1
content.setContentHit(content.getContentHit()+1);
if(ObjectUtil.isNotEmpty(content.getContentHit())){
content.setContentHit(content.getContentHit()+1);
}else {
content.setContentHit(1);
}
contentBiz.updateEntity(content);
// cms_history 增加相应记录
HistoryLogEntity entity = new HistoryLogEntity();
entity.setHlIsMobile(isMobileDevice);
......@@ -126,17 +132,10 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
entity.setContentId(content.getId());
entity.setCreateDate(new Date());
historyLogBiz.saveEntity(entity);
if(content == null){
this.outString(response, "document.write(0)");
return;
}
if(content.getAppId() == null || content.getAppId() != BasicUtil.getAppId()){
this.outString(response, "document.write(0)");
return;
return "document.write(0)";
}
this.outString(response, "document.write(" + content.getContentHit() + ")");
return;
return "document.write(" + content.getContentHit() + ")";
}
}
......@@ -26,7 +26,9 @@ import cn.hutool.core.util.PageUtil;
import freemarker.core.ParseException;
import freemarker.template.MalformedTemplateNameException;
import freemarker.template.TemplateNotFoundException;
import net.bytebuddy.implementation.bytecode.Throw;
import net.mingsoft.base.constant.Const;
import net.mingsoft.basic.exception.BusinessException;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.cms.bean.CategoryBean;
......@@ -105,7 +107,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
* 动态列表页
*/
@GetMapping("/index.do")
public void index(HttpServletRequest req, HttpServletResponse resp) {
@ResponseBody
public String index(HttpServletRequest req, HttpServletResponse resp) {
Map map = BasicUtil.assemblyRequestMap();
map.forEach((k,v)->{
map.put(k,v.toString().replaceAll("('|\"|\\\\)","\\\\$1"));
......@@ -129,7 +132,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
} catch (IOException e) {
e.printStackTrace();
}
this.outString(resp, content);
return content;
}
/**
......@@ -137,8 +140,9 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
* @param req
* @param resp
*/
@ResponseBody
@GetMapping("/list.do")
public void list(HttpServletRequest req, HttpServletResponse resp) {
public String list(HttpServletRequest req, HttpServletResponse resp) {
Map map = BasicUtil.assemblyRequestMap();
map.forEach((k,v)->{
map.put(k,v.toString().replaceAll("('|\"|\\\\)","\\\\$1"));
......@@ -152,7 +156,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
List<CategoryBean> columnArticles = contentBiz.queryIdsByCategoryIdForParser(contentBean);
//判断栏目下是否有文章
if(columnArticles.size()==0){
this.outJson(resp, false);
return "";
}
//设置分页类
PageBean page = new PageBean();
......@@ -185,7 +189,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
} catch (IOException e) {
e.printStackTrace();
}
this.outString(resp, content);
return content;
}
/**
......@@ -193,18 +197,17 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
* @param id 文章编号
*/
@GetMapping("/view.do")
public void view(String orderby,String order,HttpServletRequest req, HttpServletResponse resp) {
@ResponseBody
public String view(String orderby,String order,HttpServletRequest req, HttpServletResponse resp) {
//参数文章编号
ContentEntity article = (ContentEntity) contentBiz.getEntity(BasicUtil.getInt(ParserUtil.ID));
if(ObjectUtil.isNull(article)){
this.outJson(resp, null,false,getResString("err.empty", this.getResString("id")));
return;
throw new BusinessException(this.getResString("err.empty", this.getResString("id"))) ;
}
if(StringUtils.isNotBlank(order)){
//防注入
if(!order.toLowerCase().equals("asc")&&!order.toLowerCase().equals("desc")){
this.outJson(resp, null,false,getResString("err.error", this.getResString("order")));
return;
throw new BusinessException(this.getResString("err.error", this.getResString("order")));
}
}
......@@ -239,7 +242,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
ModelEntity contentModel = null;
for (int artId = 0; artId < articleIdList.size();) {
//如果不是当前文章则跳过
if(articleIdList.get(artId).getArticleId() != Integer.parseInt(article.getId())){
if(articleIdList.get(artId).getArticleId().equals(article.getId())){
artId++;
continue;
}
......@@ -289,7 +292,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
} catch (IOException e) {
e.printStackTrace();
}
this.outString(resp, content);
return content;
}
......@@ -303,7 +306,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
*/
@RequestMapping(value = "search")
@ResponseBody
public void search(HttpServletRequest request, HttpServletResponse response) throws IOException {
public String search(HttpServletRequest request, HttpServletResponse response) throws IOException {
Map<String, Object> map = new HashMap<>();
// 读取请求字段
......@@ -447,7 +450,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
} catch (IOException e) {
e.printStackTrace();
}
this.outString(response, content);
return content;
}
// 清除路径中的转义字符
......
......@@ -13,16 +13,16 @@ public class CategoryBean extends CategoryEntity {
/**
* 文章编号
*/
private int articleId;
private String articleId;
public int getArticleId() {
public String getArticleId() {
return articleId;
}
public void setArticleId(int articleId) {
public void setArticleId(String articleId) {
this.articleId = articleId;
}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ import java.util.List;
* 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/>
*/
public interface ICategoryBiz extends IBaseBiz {
public interface ICategoryBiz extends IBaseBiz<CategoryEntity> {
/**
* 查询当前分类下的所有子分类
......@@ -33,5 +33,5 @@ public interface ICategoryBiz extends IBaseBiz {
*/
void update(CategoryEntity entity);
void delete(int categoryId);
void delete(String categoryId);
}
......@@ -3,6 +3,7 @@ package net.mingsoft.cms.biz;
import net.mingsoft.base.biz.IBaseBiz;
import net.mingsoft.cms.bean.CategoryBean;
import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.entity.ContentEntity;
import net.mingsoft.mdiy.entity.ModelEntity;
import java.util.List;
......@@ -15,7 +16,7 @@ import java.util.Map;
* 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/>
*/
public interface IContentBiz extends IBaseBiz {
public interface IContentBiz extends IBaseBiz<ContentEntity> {
/**
* 根据文章属性查询
......
......@@ -21,19 +21,23 @@ The MIT License (MIT) * Copyright (c) 2019 铭飞科技
package net.mingsoft.cms.biz.impl;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import net.mingsoft.base.biz.impl.BaseBizImpl;
import net.mingsoft.base.dao.IBaseDao;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.PinYinUtil;
import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.dao.ICategoryDao;
import net.mingsoft.cms.dao.IContentDao;
import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.basic.util.PinYinUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -43,7 +47,8 @@ import java.util.List;
* 历史修订:<br/>
*/
@Service("cmscategoryBizImpl")
public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
@Transactional(rollbackFor = RuntimeException.class)
public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> implements ICategoryBiz {
@Autowired
......@@ -68,31 +73,49 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
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);
category.setAppId(BasicUtil.getAppId());
Object categoryBizEntity = getEntity(category);
setParentId(categoryEntity);
categoryEntity.setCategoryPinyin(pingYin);
super.saveEntity(categoryEntity);
//更新新的父级
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)categoryDao.getEntity(Integer.parseInt(categoryEntity.getCategoryId()));
parentCategory = (CategoryEntity)getById(categoryEntity.getCategoryId());
}
//保存链接地址
String path=ObjectUtil.isNotNull(parentCategory)?parentCategory.getCategoryPath():"";
categoryEntity.setCategoryPath( path+"/" + categoryEntity.getCategoryPinyin());
super.updateEntity(categoryEntity);
setTopId(categoryEntity);
super.updateById(categoryEntity);
}
private void setParentId(CategoryEntity categoryEntity) {
String path = "";
if(StringUtils.isNotEmpty(categoryEntity.getCategoryId())&&Integer.parseInt(categoryEntity.getCategoryId())>0) {
CategoryEntity category = (CategoryEntity)categoryDao.getEntity(Integer.parseInt(categoryEntity.getCategoryId()));
if(StringUtils.isNotEmpty(categoryEntity.getCategoryId())&&Long.parseLong(categoryEntity.getCategoryId())>0) {
CategoryEntity category = (CategoryEntity)getById(categoryEntity.getCategoryId());
path = category.getCategoryPath();
if(StringUtils.isEmpty(category.getCategoryParentId())) {
categoryEntity.setCategoryParentId(category.getId());
......@@ -132,13 +155,14 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
String pingYin = PinYinUtil.getPingYin(entity.getCategoryTitle());
CategoryEntity category=new CategoryEntity();
category.setCategoryPinyin(pingYin);
category.setAppId(BasicUtil.getAppId());
CategoryEntity categoryBizEntity = (CategoryEntity)getEntity(category);
//拼音存在则拼接id
if(categoryBizEntity!=null&&!categoryBizEntity.getId().equals(entity.getId())){
entity.setCategoryPinyin(pingYin+entity.getId());
}
super.updateEntity(entity);
setParentLeaf(entity);
setTopId(entity);
super.updateById(entity);
setChildParentId(entity);
}
......@@ -148,21 +172,72 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
}
@Override
public void delete(int categoryId) {
public void delete(String categoryId) {
// TODO Auto-generated method stub
CategoryEntity category = (CategoryEntity) categoryDao.getEntity(categoryId);
CategoryEntity category = (CategoryEntity) categoryDao.selectById(categoryId);
//删除父类
if(category != null){
category.setCategoryParentId(null);
List<CategoryEntity> childrenList = categoryDao.queryChildren(category);
int[] ids = new int[childrenList.size()];
List<String> ids = new ArrayList<>();
for(int i = 0; i < childrenList.size(); i++){
//删除子类
ids[i] = Integer.parseInt(childrenList.get(i).getId());
ids.add(childrenList.get(i).getId());
}
categoryDao.delete(ids);
categoryDao.deleteBatchIds(ids);
// 删除文章
contentDao.deleteEntityByCategoryIds(ids);
contentDao.deleteEntityByCategoryIds(ids.toArray(new String[ids.size()]));
}
}
/**
* 设置父级叶子节点
* @param entity
*/
private void setParentLeaf(CategoryEntity entity){
Assert.notNull(entity);
CategoryEntity categoryEntity = getById(entity.getId());
//如果父级不为空并且修改了父级则需要更新父级
if(!entity.getCategoryId().equals(categoryEntity.getCategoryId())){
//更新旧的父级
if(StrUtil.isNotBlank(categoryEntity.getCategoryId())&&!"0".equals(categoryEntity.getCategoryId())){
CategoryEntity parent = getById(categoryEntity.getCategoryId());
//如果修改了父级则需要判断父级是否还有子节点
boolean leaf = parent.getLeaf();
//查找不等于当前更新的分类子集,有则不是叶子节点
QueryWrapper<CategoryEntity> 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);
}
}
}
}
/**
* 设置顶级id
* @param entity
*/
private void setTopId(CategoryEntity entity){
String categoryParentId = entity.getCategoryParentId();
if(StrUtil.isNotBlank(categoryParentId)){
String[] ids = categoryParentId.split(",");
//如果有ParentId就取第一个
if(ids.length>0){
entity.setTopId(ids[0]);
return;
}
}
entity.setTopId("0");
}
}
......@@ -21,14 +21,32 @@ The MIT License (MIT) * Copyright (c) 2019 铭飞科技
package net.mingsoft.cms.biz.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import net.mingsoft.basic.constant.Const;
import net.mingsoft.basic.holder.DataHolder;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.cms.bean.CategoryBean;
import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.dao.ICategoryDao;
import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.cms.entity.ContentEntity;
import net.mingsoft.cms.util.CmsParserUtil;
import net.mingsoft.mdiy.bean.AttributeBean;
import net.mingsoft.mdiy.bean.PageBean;
import net.mingsoft.mdiy.entity.ModelEntity;
import net.mingsoft.mdiy.util.ParserUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import net.mingsoft.base.biz.impl.BaseBizImpl;
import net.mingsoft.base.dao.IBaseDao;
import java.io.IOException;
import java.util.*;
import net.mingsoft.cms.biz.IContentBiz;
......@@ -41,13 +59,22 @@ import net.mingsoft.cms.dao.IContentDao;
* 历史修订:<br/>
*/
@Service("cmscontentBizImpl")
public class ContentBizImpl extends BaseBizImpl implements IContentBiz {
public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> implements IContentBiz {
/*
* log4j日志记录
*/
protected final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Autowired
private IContentDao contentDao;
/**
* 栏目管理业务层
*/
@Autowired
private ICategoryDao categoryDao;
@Override
protected IBaseDao getDao() {
// TODO Auto-generated method stub
......@@ -67,4 +94,152 @@ public class ContentBizImpl extends BaseBizImpl implements IContentBiz {
}
return contentDao.getSearchCount(null,null,whereMap, appId,categoryIds);
}
/*
* 任务调度静态化任务
*/
public void staticizeTask(Integer appId, String tmpFileName, String generateFileName) {
LOG.info("定时静态化任务", new Date());
try {
//将任务采集传过来的appId导入到线程变量中
//当前线程使用appId时优先使用此数据
DataHolder.set(net.mingsoft.basic.constant.Const.APP_ID, appId);
//调用三种静态化
genernateColumn();
generaterIndex(tmpFileName, generateFileName);
//生成文章日期默认为执行日期的上一天
generateArticle(DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd"));
LOG.info("静态化完成", new Date());
} catch (IOException e) {
LOG.info("静态化失败", new Date());
e.printStackTrace();
}
}
/*
* 生成文章逻辑
*/
private void generateArticle(String dateTime) throws IOException {
// 网站风格物理路径
List<CategoryBean> articleIdList = null;
List<CategoryEntity> categoryList = null;
AttributeBean attributeBean = new AttributeBean();
ContentBean contentBean = new ContentBean();
contentBean.setBeginTime(dateTime);
Map<String, Object> map = new HashMap<>();
map.put(net.mingsoft.basic.constant.Const.APP_ID, BasicUtil.getAppId());
PageBean page = new PageBean();
map.put(ParserUtil.HTML, ParserUtil.HTML);
map.put(ParserUtil.URL, BasicUtil.getUrl());
map.put(ParserUtil.PAGE, page);
CategoryEntity categoryEntity = new CategoryEntity();
categoryList = categoryDao.query(categoryEntity);
for(CategoryEntity category : categoryList){
contentBean.setContentCategoryId(category.getId());
// 分类是列表
if(category.getCategoryType().equals("1")){
// 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryListUrl())) || StringUtils.isEmpty(category.getCategoryListUrl())) {
LOG.error("模板不存在:{}",category.getCategoryUrl());
continue;
}
// 获取文章列表表属性
ParserUtil.read(category.getCategoryListUrl(),map, page,attributeBean);
contentBean.setFlag(attributeBean.getFlag());
contentBean.setNoflag(attributeBean.getNoflag());
contentBean.setOrder(attributeBean.getOrder());
contentBean.setOrderBy(attributeBean.getOrderby());
}
articleIdList = queryIdsByCategoryIdForParser(contentBean);
// 有符合条件的就更新
if (articleIdList.size() > 0) {
CmsParserUtil.generateBasic(articleIdList);
}
}
}
/*
* 生成栏目逻辑
*/
private void genernateColumn() throws IOException {
List<CategoryEntity> columns = new ArrayList<>();
// 获取所有的内容管理栏目
CategoryEntity categoryEntity=new CategoryEntity();
categoryEntity.setAppId(BasicUtil.getAppId());
columns = categoryDao.query(categoryEntity);
List<CategoryBean> articleIdList = null;
// 1、设置模板文件夹路径
// 获取栏目列表模版
for (CategoryEntity column : columns) {
ContentBean contentBean = new ContentBean();
contentBean.setContentCategoryId(column.getId());
// 分类是列表
if(column.getCategoryType().equals("1")) {
// 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryListUrl()))) {
LOG.error("模板不存在:{}", column.getCategoryUrl());
continue;
}
//获取模板中列表标签中的条件
Map<String, Object> map = new HashMap<>();
map.put(net.mingsoft.basic.constant.Const.APP_ID, BasicUtil.getAppId());
PageBean page = new PageBean();
map.put(ParserUtil.HTML, ParserUtil.HTML);
map.put(ParserUtil.URL, BasicUtil.getUrl());
map.put(ParserUtil.PAGE, page);
AttributeBean attributeBean = new AttributeBean();
// 获取文章列表模板标签属性
ParserUtil.read(column.getCategoryListUrl(), map, page, attributeBean);
contentBean.setFlag(attributeBean.getFlag());
contentBean.setNoflag(attributeBean.getNoflag());
contentBean.setOrder(attributeBean.getOrder());
contentBean.setOrderBy(attributeBean.getOrderby());
}
articleIdList = contentDao.queryIdsByCategoryIdForParser(contentBean);
// 判断列表类型
switch (column.getCategoryType()) {
//TODO 暂时先用字符串代替
case "1": // 列表
CmsParserUtil.generateList(column, articleIdList.size());
break;
case "2":// 单页
if(articleIdList.size()==0){
CategoryBean columnArticleIdBean=new CategoryBean();
CopyOptions copyOptions=CopyOptions.create();
copyOptions.setIgnoreError(true);
BeanUtil.copyProperties(column,columnArticleIdBean,copyOptions);
articleIdList.add(columnArticleIdBean);
}
CmsParserUtil.generateBasic(articleIdList);
break;
}
}
}
/*
* 生成主页逻辑
*/
private void generaterIndex(String templatePath, String targetPath) throws IOException {
if (!FileUtil.exist(ParserUtil.buildTempletPath())) {
LOG.info("模板文件不存在");
return;
}
Map<String, Object> map = new HashMap<String, Object>();
map.put(ParserUtil.IS_DO, false);
CategoryEntity column = new CategoryEntity();
//内容管理栏目编码
map.put(ParserUtil.COLUMN, column);
//如果单站点,就废弃站点地址
if (ParserUtil.IS_SINGLE) {
map.put(ParserUtil.URL, BasicUtil.getUrl());
}
//设置生成的路径
map.put(ParserUtil.HTML, ParserUtil.HTML);
//设置站点编号
map.put(Const.APP_ID, BasicUtil.getAppId());
String read = ParserUtil.read(templatePath, map);
FileUtil.writeString(read, ParserUtil.buildHtmlPath(targetPath), net.mingsoft.base.constant.Const.UTF8);
}
}
\ No newline at end of file
package net.mingsoft.cms.dao;
import net.mingsoft.base.dao.IBaseDao;
import java.util.*;
import net.mingsoft.cms.entity.CategoryEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 分类持久层
* @author 铭飞开发团队
......@@ -14,13 +13,13 @@ import org.springframework.stereotype.Component;
* 历史修订:<br/>
*/
@Component("cmsCategoryDao")
public interface ICategoryDao extends IBaseDao {
public interface ICategoryDao extends IBaseDao<CategoryEntity> {
/**
* 查询当前分类下面的所有子分类
* @param category 必须存在categoryId categoryParentId
* @return
*/
public List<net.mingsoft.cms.entity.CategoryEntity> queryChildren(CategoryEntity category);
public List<CategoryEntity> queryChildren(CategoryEntity category);
}
\ No newline at end of file
......@@ -49,7 +49,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''">mdiy_model_id,</if>
<if test="categoryDatetime != null">category_datetime,</if>
<if test="categoryManagerId != null">category_manager_id,</if>
<if test="appId != null">app_id,</if>
<if test="dictId != null">dict_id,</if>
<if test="categoryFlag != null">category_flag,</if>
<if test="categoryPath != null and categoryPath != ''">category_path,</if>
......@@ -75,7 +74,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''">#{mdiyModelId},</if>
<if test="categoryDatetime != null">#{categoryDatetime},</if>
<if test="categoryManagerId != null">#{categoryManagerId},</if>
<if test="appId != null">#{appId},</if>
<if test="dictId != null">#{dictId},</if>
<if test="categoryFlag != null ">#{categoryFlag},</if>
<if test="categoryPath != null and categoryPath != ''">#{categoryPath},</if>
......@@ -107,7 +105,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''">mdiy_model_id=#{mdiyModelId},</if>
<if test="categoryDatetime != null">category_datetime=#{categoryDatetime},</if>
<if test="categoryManagerId != null">category_manager_id=#{categoryManagerId},</if>
<if test="appId != null">app_id=#{appId},</if>
<if test="dictId != null">dict_id=#{dictId},</if>
<if test="categoryFlag != null ">category_flag=#{categoryFlag},</if>
<if test="categoryPath != null and categoryPath != ''">category_path=#{categoryPath},</if>
......@@ -143,7 +140,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''">and mdiy_model_id=#{mdiyModelId}</if>
<if test="categoryDatetime != null"> and category_datetime=#{categoryDatetime} </if>
<if test="categoryManagerId != null"> and category_manager_id=#{categoryManagerId} </if>
<if test="appId != null"> and app_id=#{appId} </if>
<if test="dictId != null"> and dict_id=#{dictId} </if>
<if test="categoryFlag != null and categoryFlag != ''">and category_flag=#{categoryFlag}</if>
<if test="categoryPath != null and categoryPath != ''">and category_path=#{categoryPath}</if>
......@@ -170,9 +166,7 @@
<select id="queryChildren" resultMap="resultMap">
select * from cms_category
<where>
<if test="appId &gt; 0">
and app_id=#{appId}
</if>
<if test="dictId &gt; 0">
and dict_id=#{dictId}
</if>
......@@ -228,7 +222,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''"> and mdiy_model_id=#{mdiyModelId}</if>
<if test="categoryDatetime != null"> and category_datetime=#{categoryDatetime} </if>
<if test="categoryManagerId != null"> and category_manager_id=#{categoryManagerId} </if>
<if test="appId != null"> and app_id=#{appId} </if>
<if test="dictId != null"> and dict_id=#{dictId} </if>
<if test="categoryFlag != null and categoryFlag != ''"> and category_flag=#{categoryFlag}</if>
<if test="categoryPath != null and categoryPath != ''"> and category_path=#{categoryPath}</if>
......@@ -240,7 +233,6 @@
<if test="del != null"> and del=#{del} </if>
<include refid="net.mingsoft.base.dao.IBaseDao.sqlWhere"></include>
</where>
order by id desc
</select>
</mapper>
package net.mingsoft.cms.dao;
import net.mingsoft.base.dao.IBaseDao;
import java.util.*;
import net.mingsoft.cms.bean.CategoryBean;
import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.entity.ContentEntity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 文章持久层
* @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/>
*/
public interface IContentDao extends IBaseDao {
public interface IContentDao extends IBaseDao<ContentEntity> {
/**
* 查询文章编号集合
......@@ -32,12 +34,12 @@ public interface IContentDao extends IBaseDao {
* list[2]:是否是等值查询 list[3]:字段的值
* @return 文章实体总数
*/
int getSearchCount(@Param("tableName") String tableName, @Param("diyList") List diyList,@Param("map") Map<String, Object> map,
int getSearchCount(@Param("tableName") String tableName, @Param("diyList") List diyList, @Param("map") Map<String, Object> map,
@Param("websiteId") int websiteId, @Param("ids") String ids);
/**
* 分类编号删除文章
* @param ids
*/
void deleteEntityByCategoryIds(@Param("ids") int[] ids);
void deleteEntityByCategoryIds(@Param("ids") String[] ids);
}
\ No newline at end of file
......@@ -43,7 +43,6 @@
<result column="content_url" property="contentUrl" /><!--文章跳转链接地址 -->
<result column="static_url" property="staticUrl" /><!--静态地址 -->
<result column="content_hit" property="contentHit" /><!--点击次数 -->
<result column="app_id" property="appId" /><!--文章管理的应用id -->
<result column="create_by" property="createBy" /><!--创建人 -->
<result column="create_date" property="createDate" /><!--创建时间 -->
<result column="update_by" property="updateBy" /><!--修改人 -->
......@@ -67,7 +66,6 @@
<result column="mdiy_model_id" property="mdiyModelId" /><!--栏目管理的内容模型id -->
<result column="category_datetime" property="categoryDatetime" /><!--类别发布时间 -->
<result column="category_manager_id" property="categoryManagerId" /><!--发布用户id -->
<result column="app_id" property="appId" /><!--应用编号 -->
<result column="dict_id" property="dictId" /><!--字典对应编号 -->
<result column="category_flag" property="categoryFlag" /><!--栏目属性 -->
<result column="category_path" property="categoryPath" /><!--栏目路径 -->
......@@ -98,7 +96,6 @@
<if test="contentDetails != null and contentDetails != ''">content_details,</if>
<if test="contentUrl != null and contentUrl != ''">content_url,</if>
<if test="contentHit != null">content_hit,</if>
<if test="appId != null">app_id,</if>
<if test="createBy &gt; 0">create_by,</if>
<if test="createDate != null">create_date,</if>
<if test="updateBy &gt; 0">update_by,</if>
......@@ -120,7 +117,6 @@
<if test="contentDetails != null and contentDetails != ''">#{contentDetails},</if>
<if test="contentUrl != null and contentUrl != ''">#{contentUrl},</if>
<if test="contentHit != null">#{contentHit},</if>
<if test="appId != null">#{appId},</if>
<if test="createBy &gt; 0">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="updateBy &gt; 0">#{updateBy},</if>
......@@ -147,7 +143,6 @@
<if test="contentDetails != null ">content_details=#{contentDetails},</if>
<if test="contentUrl != null and contentUrl != ''">content_url=#{contentUrl},</if>
<if test="contentHit != null">content_hit=#{contentHit},</if>
<if test="appId != null">app_id=#{appId},</if>
<if test="createBy &gt; 0">create_by=#{createBy},</if>
<if test="createDate != null">create_date=#{createDate},</if>
<if test="updateBy &gt; 0">update_by=#{updateBy},</if>
......@@ -181,7 +176,6 @@
<if test="contentDetails != null and contentDetails != ''">and content_details=#{contentDetails}</if>
<if test="contentUrl != null and contentUrl != ''">and content_url=#{contentUrl}</if>
<if test="contentHit != null">and content_hit=#{contentHit}</if>
<if test="appId != null"> and app_id=#{appId} </if>
<if test="createBy &gt; 0"> and create_by=#{createBy} </if>
<if test="createDate != null"> and create_date=#{createDate} </if>
<if test="updateBy &gt; 0"> and update_by=#{updateBy} </if>
......@@ -219,7 +213,7 @@
</select>
<!--条件查询-->
<select id="query" resultMap="resultContentMap">
select ct.*,CONCAT("/html/",ct.app_id,category_path,"/",ct.id,".html") AS static_url from (
select ct.*,CONCAT('/html/',ct.app_id,category_path,'/',ct.id,'.html') AS static_url from (
select ct.*,cc.category_path from cms_content ct
join cms_category cc on ct.content_category_id=cc.id
<where>
......@@ -239,13 +233,12 @@
<if test="contentDetails != null and contentDetails != ''"> and content_details=#{contentDetails}</if>
<if test="contentUrl != null and contentUrl != ''"> and content_url=#{contentUrl}</if>
<if test="contentHit != null"> and content_hit=#{contentHit}</if>
<if test="appId != null"> and ct.app_id=#{appId} </if>
<if test="createBy &gt; 0"> and ct.create_by=#{createBy} </if>
<if test="createDate != null"> and ct.create_date=#{createDate} </if>
<if test="updateBy &gt; 0"> and ct.update_by=#{updateBy} </if>
<if test="updateDate != null"> and update_date=#{updateDate} </if>
</where>
)ct ORDER BY date_format(ct.content_datetime,'%Y-%m-%d') desc,content_sort desc
)ct ORDER BY ct.content_datetime desc,content_sort desc
</select>
<sql id="queryWhereCategoryId" databaseId="mysql">
......@@ -261,13 +254,11 @@
<!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 -->
<select id="queryIdsByCategoryIdForParser" resultMap="resultBean" >
select
cms_content.id article_id,c.*
FROM cms_content
ct.id article_id,c.*
FROM cms_content ct
LEFT JOIN cms_category c ON content_category_id = c.id
where cms_content.del=0
<if test="appId &gt; 0">
and cms_content.app_id = #{appId}
</if>
where ct.del=0
<!-- 查询子栏目数据 -->
<if test="contentCategoryId &gt; 0">
and (content_category_id=#{contentCategoryId} or content_category_id in
......@@ -280,17 +271,17 @@
and content_datetime &gt;= #{endTime}
</if>
<if test="flag!=null and flag!=''">
and cms_content.content_type in ( #{flag})
and ct.content_type in ( #{flag})
</if>
<if test="noflag!=null and noflag!=''">
and (cms_content.content_type not in ( #{noflag} ) or cms_content.content_type is null)
and (ct.content_type not in ( #{noflag} ) or ct.content_type is null)
</if>
<if test="orderBy!=null and orderBy!='' ">
<if test="orderBy=='date'">ORDER BY content_datetime</if>
<if test="orderBy=='hit'">ORDER BY content_hit</if>
<if test="orderBy=='sort'">ORDER BY content_sort</if>
<if test="orderBy!='date' and orderBy!='hit' and orderBy!='sort'">
ORDER BY cms_content.id
ORDER BY ct.id
</if>
<choose>
<when test="order!=null and order!=''">
......@@ -312,7 +303,7 @@
<if test="tableName!=null and tableName!='' and diyMap!=null">left join ${tableName} d on d.link_id=a.id
</if>
<where>
a.del=0 and a.app_id = #{websiteId}
a.del=0
<if test="ids!=null and ids!=''">
and FIND_IN_SET(content_category_id,#{ids})
</if>
......
......@@ -4,16 +4,21 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.format.annotation.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import net.mingsoft.base.entity.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 分类实体
* @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/>
*/
@TableName("cms_category")
public class CategoryEntity extends BaseEntity {
private static final long serialVersionUID = 1574925152750L;
......@@ -80,6 +85,7 @@ private static final long serialVersionUID = 1574925152750L;
/**
* 应用编号
*/
@TableField(exist = false)
private Integer appId;
/**
* 字典对应编号
......@@ -98,6 +104,31 @@ private static final long serialVersionUID = 1574925152750L;
*/
private String categoryParentId;
/**
* 叶子节点
*/
private Boolean leaf;
/**
* 顶级id
*/
private String topId;
public Boolean getLeaf() {
return leaf;
}
public void setLeaf(Boolean leaf) {
this.leaf = leaf;
}
public String getTopId() {
return topId;
}
public void setTopId(String topId) {
this.topId = topId;
}
/**
* 设置栏目管理名称
......
package net.mingsoft.cms.entity;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.format.annotation.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import net.mingsoft.base.entity.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 文章实体
* @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/>
*/
@TableName("cms_content")
public class ContentEntity extends BaseEntity {
private static final long serialVersionUID = 1574925152617L;
......@@ -73,6 +78,7 @@ private static final long serialVersionUID = 1574925152617L;
/**
* 文章管理的应用id
*/
@TableField(exist = false)
private Integer appId;
/**
* 点击次数
......
......@@ -34,3 +34,4 @@ content.sort=\u81EA\u5B9A\u4E49\u987A\u5E8F
category.diy.url=\u81EA\u5B9A\u4E49\u94FE\u63A5
content.keyword=\u5173\u952E\u5B57
templet.file=\u672A\u627E\u5230\u6A21\u677F\u6587\u4EF6
category.pinyin=\u62FC\u97F3
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment