Commit ac217e7c authored by sgjj's avatar sgjj

标签升级

parent b03361cd
......@@ -31,7 +31,9 @@ import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.biz.IContentBiz;
import net.mingsoft.cms.entity.CategoryEntity;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -48,8 +50,6 @@ import net.mingsoft.basic.action.BaseAction;
import net.mingsoft.basic.biz.IModelBiz;
import net.mingsoft.basic.entity.AppEntity;
import net.mingsoft.cms.bean.ColumnArticleIdBean;
import net.mingsoft.cms.biz.IArticleBiz;
import net.mingsoft.cms.constant.ModelCode;
import net.mingsoft.cms.util.CmsParserUtil;
import net.mingsoft.mdiy.biz.IContentModelBiz;
import net.mingsoft.mdiy.biz.IContentModelFieldBiz;
......@@ -76,7 +76,7 @@ public class GeneraterAction extends BaseAction {
* 文章管理业务层
*/
@Autowired
private IArticleBiz articleBiz;
private IContentBiz contentBiz;
/**
* 栏目管理业务层
......@@ -99,11 +99,6 @@ public class GeneraterAction extends BaseAction {
@Autowired
protected IContentModelFieldBiz fieldBiz;
/**
* 自定义模型业务层
*/
@Autowired
protected IContentModelBiz contentBiz;
/**
* 更新主页
......@@ -151,7 +146,7 @@ public class GeneraterAction extends BaseAction {
*
* @param request
* @param response
* @param columnId
* @param CategoryId
*/
@RequestMapping("/{CategoryId}/genernateColumn")
@RequiresPermissions("cms:generate:column")
......@@ -172,7 +167,7 @@ public class GeneraterAction extends BaseAction {
categoryEntity.setAppId(app.getAppId());
columns = categoryBiz.query(categoryEntity);
}
List<ColumnArticleIdBean> articleIdList = null;
List<ContentBean> articleIdList = null;
try {
// 1、设置模板文件夹路径
// 获取栏目列表模版
......@@ -181,7 +176,7 @@ public class GeneraterAction extends BaseAction {
if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryUrl()))) {
continue;
}
articleIdList = articleBiz.queryIdsByCategoryIdForParser(Integer.parseInt(column.getCategoryId()), null, null);
articleIdList = contentBiz.queryIdsByCategoryIdForParser(column.getId(), null, null);
// 判断列表类型
switch (column.getCategoryType()) {
//TODO 暂时先用字符串代替
......@@ -190,7 +185,7 @@ public class GeneraterAction extends BaseAction {
break;
case "2":// 单页
if(articleIdList.size()==0){
ColumnArticleIdBean columnArticleIdBean=new ColumnArticleIdBean();
ContentBean columnArticleIdBean=new ContentBean();
CopyOptions copyOptions=CopyOptions.create();
copyOptions.setIgnoreError(true);
BeanUtil.copyProperties(column,columnArticleIdBean,copyOptions);
......@@ -217,13 +212,13 @@ public class GeneraterAction extends BaseAction {
@RequestMapping("/{columnId}/generateArticle")
@RequiresPermissions("cms:generate:article")
@ResponseBody
public void generateArticle(HttpServletRequest request, HttpServletResponse response, @PathVariable int columnId) {
public void generateArticle(HttpServletRequest request, HttpServletResponse response, @PathVariable String columnId) {
String dateTime = request.getParameter("dateTime");
// 网站风格物理路径
List<ColumnArticleIdBean> articleIdList = null;
List<ContentBean> articleIdList = null;
try {
// 查出所有文章(根据选择栏目)包括子栏目
articleIdList = articleBiz.queryIdsByCategoryIdForParser(columnId, dateTime, null);
articleIdList = contentBiz.queryIdsByCategoryIdForParser(columnId, dateTime, null);
// 有符合条件的新闻就更新
if (articleIdList.size() > 0) {
CmsParserUtil.generateBasic(articleIdList);
......
package net.mingsoft.cms.bean;
import net.mingsoft.cms.entity.CategoryEntity;
/**
* 文章实体
* @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/>
*/
public class ContentBean extends CategoryEntity {
/**
* 文章编号
*/
private int articleId;
public int getArticleId() {
return articleId;
}
public void setArticleId(int articleId) {
this.articleId = articleId;
}
}
\ No newline at end of file
package net.mingsoft.cms.biz;
import net.mingsoft.base.biz.IBaseBiz;
import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.mdiy.entity.ModelEntity;
import java.util.List;
import java.util.Map;
/**
......@@ -11,4 +16,9 @@ import net.mingsoft.base.biz.IBaseBiz;
*/
public interface IContentBiz extends IBaseBiz {
List<ContentBean> queryIdsByCategoryIdForParser(String categoryId, String beginTime, String endTime);
List<ContentBean> queryIdsByCategoryIdForParser(String categoryId, String beginTime, String endTime, String orderBy, String order);
int getSearchCount(ModelEntity contentModel, Map whereMap, int appId, String categoryIds);
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ The MIT License (MIT) * Copyright (c) 2019 铭飞科技
package net.mingsoft.cms.biz.impl;
import cn.hutool.core.util.ObjectUtil;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.cms.entity.CategoryEntity;
import org.apache.commons.lang3.StringUtils;
......@@ -28,6 +29,8 @@ 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.File;
import java.util.*;
import net.mingsoft.cms.biz.ICategoryBiz;
......@@ -69,24 +72,38 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
if(StringUtils.isNotEmpty(categoryEntity.getCategoryId())&&Integer.parseInt(categoryEntity.getCategoryId())>0) {
CategoryEntity category = (CategoryEntity)categoryDao.getEntity(Integer.parseInt(categoryEntity.getCategoryId()));
if(StringUtils.isEmpty(category.getCategoryParentId())) {
categoryEntity.setCategoryParentId(categoryEntity.getCategoryId());
categoryEntity.setCategoryParentId(category.getId());
} else {
categoryEntity.setCategoryParentId(category.getCategoryParentId()+","+categoryEntity.getCategoryParentId());
categoryEntity.setCategoryParentId(category.getCategoryParentId()+","+category.getId());
}
}else {
categoryEntity.setCategoryParentId(null);
}
String path=ObjectUtil.isNotNull(categoryEntity.getCategoryParentId())?categoryEntity.getCategoryParentId():"";
categoryEntity.setCategoryPath("/"+path.replaceAll(",","/")+"/"+categoryEntity.getId());
}
private void setChildParentId(CategoryEntity categoryEntity) {
CategoryEntity category=new CategoryEntity();
category.setCategoryId(categoryEntity.getId());
List<CategoryEntity> list = categoryDao.query(category);
list.forEach(x->{
if(StringUtils.isEmpty(categoryEntity.getCategoryParentId())) {
x.setCategoryParentId(categoryEntity.getId());
} else {
x.setCategoryParentId(categoryEntity.getCategoryParentId()+","+categoryEntity.getId());
}
String path=ObjectUtil.isNotNull(x.getCategoryParentId())?x.getCategoryParentId():"";
x.setCategoryPath("/"+path.replaceAll(",","/")+"/"+x.getId());
super.updateEntity(x);
setChildParentId(x);
});
}
@Override
public void updateEntity(CategoryEntity entity) {
List<CategoryEntity> categoryEntities = queryChilds(entity);
setParentId(entity);
super.updateEntity(entity);
categoryEntities.forEach(x->{
setParentId(x);
if(!x.getId().equals(entity.getId())){
super.updateEntity(x);
}
});
setChildParentId(entity);
}
}
\ No newline at end of file
......@@ -21,6 +21,9 @@ The MIT License (MIT) * Copyright (c) 2019 铭飞科技
package net.mingsoft.cms.biz.impl;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.mdiy.entity.ModelEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import net.mingsoft.base.biz.impl.BaseBizImpl;
......@@ -48,5 +51,22 @@ public class ContentBizImpl extends BaseBizImpl implements IContentBiz {
protected IBaseDao getDao() {
// TODO Auto-generated method stub
return contentDao;
}
}
@Override
public List<ContentBean> queryIdsByCategoryIdForParser(String categoryId, String beginTime, String endTime) {
return this.contentDao.queryIdsByCategoryIdForParser(categoryId,BasicUtil.getAppId(), beginTime, endTime,null,null);
}
@Override
public List<ContentBean> queryIdsByCategoryIdForParser(String categoryId, String beginTime, String endTime, String orderBy, String order) {
return this.contentDao.queryIdsByCategoryIdForParser(categoryId, BasicUtil.getAppId(), beginTime, endTime,orderBy,order);
}
@Override
public int getSearchCount(ModelEntity contentModel, Map whereMap, int appId, String categoryIds) {
if (contentModel!=null) {
return contentDao.getSearchCount(contentModel.getModelTableName(),whereMap, appId,categoryIds);
}
return contentDao.getSearchCount(null,whereMap, appId,categoryIds);
}
}
\ No newline at end of file
......@@ -91,6 +91,7 @@
<set>
<if test="categoryTitle != null and categoryTitle != ''">category_title=#{categoryTitle},</if>
category_id=#{categoryId},
category_parent_id=#{categoryParentId},
<if test="categoryType != null and categoryType != ''">category_type=#{categoryType},</if>
<if test="categorySort != null">category_sort=#{categorySort},</if>
<if test="categoryListUrl != null and categoryListUrl != ''">category_list_url=#{categoryListUrl},</if>
......@@ -106,7 +107,6 @@
<if test="dictId != null">dict_id=#{dictId},</if>
<if test="categoryFlag != null and categoryFlag != ''">category_flag=#{categoryFlag},</if>
<if test="categoryPath != null and categoryPath != ''">category_path=#{categoryPath},</if>
<if test="categoryParentId != null and categoryParentId != ''">category_parent_id=#{categoryParentId},</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>
......
......@@ -2,7 +2,9 @@ package net.mingsoft.cms.dao;
import net.mingsoft.base.dao.IBaseDao;
import java.util.*;
import net.mingsoft.cms.entity.ContentEntity;
import net.mingsoft.cms.bean.ContentBean;
import org.apache.ibatis.annotations.Param;
/**
* 文章持久层
......@@ -11,4 +13,27 @@ import net.mingsoft.cms.entity.ContentEntity;
* 历史修订:<br/>
*/
public interface IContentDao extends IBaseDao {
/**
* 查询文章编号集合
* @param categoryId 栏目编号
* @param appId 站点编号
* @param beginTime 开始时间
* @param endTime 结束时间
* @return
*/
public List<ContentBean> queryIdsByCategoryIdForParser(@Param("categoryId")String categoryId, @Param("appId")int appId , @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("orderBy")String orderBy, @Param("order")String order);
/**
* 根据查询文章实体总数
*
* @param tableName
* :自定义生成的表名
* @param map
* key:字段名 value:List 字段的各种判断值 list[0]:是否为自定义字段 list[1]:是否为整形
* list[2]:是否是等值查询 list[3]:字段的值
* @return 文章实体总数
*/
int getSearchCount(@Param("tableName") String tableName, @Param("map") Map<String, List> map,
@Param("websiteId") int websiteId, @Param("ids") String ids);
}
\ No newline at end of file
......@@ -26,6 +26,34 @@
<result column="del" property="del" /><!--删除标记 -->
</resultMap>
<resultMap id="resultBean" type="net.mingsoft.cms.bean.ContentBean">
<id column="id" property="id" /><!--编号 -->
<id column="article_Id" property="articleId" /><!--编号 -->
<result column="category_title" property="categoryTitle" /><!--栏目管理名称 -->
<result column="category_id" property="categoryId" /><!--所属栏目 -->
<result column="category_type" property="categoryType" /><!--栏目管理属性 -->
<result column="category_sort" property="categorySort" /><!--自定义顺序 -->
<result column="category_list_url" property="categoryListUrl" /><!--列表模板 -->
<result column="category_url" property="categoryUrl" /><!--内容模板 -->
<result column="category_keyword" property="categoryKeyword" /><!--栏目管理关键字 -->
<result column="category_descrip" property="categoryDescrip" /><!--栏目管理描述 -->
<result column="category_img" property="categoryImg" /><!--缩略图 -->
<result column="category_diy_url" property="categoryDiyUrl" /><!--自定义链接 -->
<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" /><!--栏目路径 -->
<result column="category_parent_id" property="categoryParentId" /><!--父类型编号 -->
<result column="create_by" property="createBy" /><!--创建人 -->
<result column="create_date" property="createDate" /><!--创建时间 -->
<result column="update_by" property="updateBy" /><!--修改人 -->
<result column="update_date" property="updateDate" /><!--修改时间 -->
<result column="del" property="del" /><!--删除标记 -->
</resultMap>
<!--保存-->
<insert id="saveEntity" useGeneratedKeys="true" keyProperty="id"
parameterType="net.mingsoft.cms.entity.ContentEntity" >
......@@ -184,4 +212,113 @@
order by id desc
</select>
<sql id="queryWhereCategoryId" databaseId="mysql">
find_in_set('${categoryId}',CATEGORY_PARENT_ID)
</sql>
<sql id="queryWhereCategoryId" databaseId="oracle" >
instr(','||'${categoryId}'||',', ','||CATEGORY_PARENT_ID||',')>0
</sql>
<sql id="queryWhereCategoryId" databaseId="sqlServer">
CHARINDEX(','+'${categoryId}'+',' , ','+CATEGORY_PARENT_ID +',')>0
</sql>
<!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 -->
<select id="queryIdsByCategoryIdForParser" resultMap="resultBean">
select
cms_content.id article_id,c.*
FROM cms_content
LEFT JOIN cms_category c ON content_category_id = c.id
where
<if test="appId &gt; 0">
cms_content.app_id = #{appId}
</if>
<!-- 查询子栏目数据 -->
<if test="categoryId &gt; 0">
and (content_category_id=#{categoryId} or content_category_id in
(select id FROM cms_category where <include refid="queryWhereCategoryId"></include>))
</if>
<if test="beginTime!=null and beginTime!=''">
and content_updatetime &gt;= #{beginTime}
</if>
<if test="endTime!=null and endTime!=''">
and content_updatetime &gt;= #{endTime}
</if>
<if test="orderBy!=null and order!=null and orderBy!='' and order!=''">
ORDER BY `${orderBy}` ${order}
</if>
</select>
<select id="getSearchCount" resultType="int">
select count(*) from
cms_content a
left join cms_category c
ON a.content_category_id
= c.id
<if test="tableName!=null and tableName!=''">left join ${tableName} d on d.link_id=a.id
</if>
where a.app_id = #{websiteId}
<if test="ids!=null and ids!=''">
and FIND_IN_SET(content_category_id,'${ids}')
</if>
<foreach item="item" index="key" collection="map" open=""
separator="" close="">
<if test=" item[0] == false">
and ${key}
</if>
<if test="item[0]== true">
and d.${key}
</if>
<!-- 数字类型的查找 item[1]:字段是否为数字类型false:数字 -->
<if test="item[1] == false">
<!--item[2]: 是采用等值还是区间查询。false:区间 itme[3][0]第一个值item[3][1]的二个值 -->
<if test="item[2] == true">
=
<foreach item="val" index="index" collection="item[3]">#{val}
</foreach>
</if>
<if test="item[2] == false">
between
<foreach item="val" index="index" collection="item[3]"
separator="and">
#{val}
</foreach>
</if>
</if>
<!-- 字符型数据的查找 item[1]:字段是否为数字类型true:字符串 -->
<if test="item[1] == true">
<!--item[2]: 是采用模糊查询。false:不采用模糊 -->
<if test="item[2] == true">
<include refid="queryLike"></include>
</if>
<if test="item[2] == false">
=
<foreach item="val" index="index" collection="item[3]">#{val}
</foreach>
</if>
</if>
</foreach>
</select>
<!-- 根据字段条件查找文章实体开始 -->
<sql id="queryLike" databaseId="mysql">
like CONCAT("%",
<foreach item="val" index="index" collection="item[3]">
<if test="index==0">#{val}</if>
</foreach>
,"%")
</sql>
<sql id="queryLike" databaseId="oracle">
like '%'||
<foreach item="val" index="index" collection="item[3]">
<if test="index==0">#{val}</if>
</foreach>
||'%'
</sql>
<sql id="queryLike" databaseId="sqlServer">
like '%'+
<foreach item="val" index="index" collection="item[3]">
<if test="index==0">#{val}</if>
</foreach>
+'%'
</sql>
</mapper>
\ No newline at end of file
......@@ -21,10 +21,12 @@ import net.mingsoft.basic.entity.ColumnEntity;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.SpringUtil;
import net.mingsoft.cms.bean.ColumnArticleIdBean;
import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.constant.e.ColumnTypeEnum;
import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.mdiy.bean.PageBean;
import net.mingsoft.mdiy.biz.IContentModelBiz;
import net.mingsoft.mdiy.biz.IModelBiz;
import net.mingsoft.mdiy.biz.impl.ModelBizImpl;
import net.mingsoft.mdiy.entity.ContentModelEntity;
import net.mingsoft.mdiy.entity.ModelEntity;
......@@ -192,11 +194,11 @@ public class CmsParserUtil extends ParserUtil {
* @throws MalformedTemplateNameException
* @throws TemplateNotFoundException
*/
public static void generateBasic(List<ColumnArticleIdBean> articleIdList)
public static void generateBasic(List<ContentBean> articleIdList)
throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException {
Map<Object, Object> contentModelMap = new HashMap<Object, Object>();
ContentModelEntity contentModel = null;
ModelEntity contentModel = null;
String writePath = null;
// 记录已经生成了文章编号
List<Integer> generateIds = new ArrayList<>();
......@@ -237,29 +239,29 @@ public class CmsParserUtil extends ParserUtil {
if (StringUtils.isNotBlank(columnContentModelId)) {
// 通过当前栏目的模型编号获取,自定义模型表名
if (contentModelMap.containsKey(columnContentModelId)) {
parserParams.put(TABLE_NAME, contentModel.getCmTableName());
parserParams.put(TABLE_NAME, contentModel.getModelTableName());
} else {
// 通过栏目模型编号获取自定义模型实体
contentModel = (ContentModelEntity) SpringUtil.getBean(IContentModelBiz.class)
contentModel = (ModelEntity) SpringUtil.getBean(IModelBiz.class)
.getEntity(Integer.parseInt(columnContentModelId));
// 将自定义模型编号设置为key值
contentModelMap.put(columnContentModelId, contentModel.getCmTableName());
parserParams.put(TABLE_NAME, contentModel.getCmTableName());
contentModelMap.put(columnContentModelId, contentModel.getModelTableName());
parserParams.put(TABLE_NAME, contentModel.getModelTableName());
}
}
parserParams.put(ID, articleId);
// 第一篇文章没有上一篇
if (artId > 0) {
ColumnArticleIdBean preCaBean = articleIdList.get(artId - 1);
ContentBean preCaBean = articleIdList.get(artId - 1);
//判断当前文档是否与上一页文章在同一栏目下,并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
if(articleColumnPath.contains(preCaBean.getCategoryId()+"")){
if( articleColumnPath.contains(preCaBean.getCategoryId()+"")){
page.setPreId(preCaBean.getArticleId());
}
}
// 最后一篇文章没有下一篇
if (artId + 1 < articleIdList.size()) {
ColumnArticleIdBean nextCaBean = articleIdList.get(artId + 1);
ContentBean nextCaBean = articleIdList.get(artId + 1);
//判断当前文档是否与下一页文章在同一栏目下并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
if(articleColumnPath.contains(nextCaBean.getCategoryId()+"")){
page.setNextId(nextCaBean.getArticleId());
......
Markdown is supported
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