mingsoft преди 4 години
родител
ревизия
0dc93a9376

Файловите разлики са ограничени, защото са твърде много
+ 138 - 0
doc/mcms-5.2.4.sql


+ 1 - 1
src/main/java/net/mingsoft/cms/action/BaseAction.java

@@ -26,7 +26,7 @@ import java.util.MissingResourceException;
  * @Author: 铭飞开源团队--huise
  * @Date: 2019/8/9 20:47
  */
-public class BaseAction extends net.mingsoft.mdiy.action.BaseAction{
+public class BaseAction extends net.mingsoft.basic.action.BaseAction{
     @Override
     protected String getResString(String key) {
         // TODO Auto-generated method stub

+ 9 - 3
src/main/java/net/mingsoft/cms/action/CategoryAction.java

@@ -290,11 +290,17 @@ public class CategoryAction extends BaseAction {
 		 CategoryEntity _category = new CategoryEntity();
 		 _category.setCategoryParentIds(category.getId());
 		 List<CategoryEntity> categoryList = categoryBiz.queryChilds(_category);
-		 for(CategoryEntity item:categoryList){
-			 if(item.getId().equals(category.getCategoryId())){
-				 return ResultData.build().error(getResString("cannot.select.child"));
+		 if(categoryList.size()>0) {
+			 for(CategoryEntity item:categoryList){
+				 if(item.getId().equals(category.getCategoryId())){
+					 return ResultData.build().error(getResString("cannot.select.child"));
+				 }
 			 }
+			 category.setLeaf(true);
+		 } else {
+			 category.setLeaf(false);
 		 }
+
 		 // 这里不能使用mybitsplus 存在业务
 		 categoryBiz.updateEntity(category);
 		return ResultData.build().success(category);

+ 28 - 0
src/main/java/net/mingsoft/cms/action/ContentAction.java

@@ -32,8 +32,12 @@ import net.mingsoft.basic.constant.e.BusinessTypeEnum;
 import net.mingsoft.basic.util.BasicUtil;
 import net.mingsoft.basic.util.StringUtil;
 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 net.mingsoft.cms.entity.ContentEntity;
+import net.mingsoft.mdiy.biz.IModelBiz;
+import net.mingsoft.mdiy.entity.ModelEntity;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -42,10 +46,13 @@ import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 import springfox.documentation.annotations.ApiIgnore;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 文章管理控制层
@@ -65,6 +72,14 @@ public class ContentAction extends BaseAction {
 	@Autowired
 	private IContentBiz contentBiz;
 
+
+	@Autowired
+	private ICategoryBiz categoryBiz;
+
+
+	@Resource(name="mdiyModelBizImpl")
+	private IModelBiz modelBiz;
+
 	/**
 	 * 返回主界面index
 	 */
@@ -227,7 +242,20 @@ public class ContentAction extends BaseAction {
 		List<String> ids = new ArrayList<>();
 		for(int i = 0;i<contents.size();i++){
 			ids.add(contents.get(i).getId());
+			//获取栏目实体
+			CategoryEntity categoryEntity = categoryBiz.getById(contents.get(i).getCategoryId());
+			//如果栏目绑定的模型ID为空
+			if (categoryEntity.getMdiyModelId() == null){
+				break;
+			}
+			//获取到配置模型实体
+			ModelEntity modelEntity = modelBiz.getById(categoryEntity.getMdiyModelId());
+			//删除模型表的数据
+			Map<String, String> map = new HashMap<>();
+			map.put("link_id", contents.get(i).getId());
+			modelBiz.deleteBySQL(modelEntity.getModelTableName(), map);
 		}
+
 		contentBiz.removeByIds(ids);
 		return ResultData.build().success();
 	}

+ 27 - 9
src/main/java/net/mingsoft/cms/action/GeneraterAction.java

@@ -173,7 +173,10 @@ public class GeneraterAction extends BaseAction {
 
         // 获取栏目列表模版
         for (CategoryEntity column : columns) {
-
+            //如果是链接就跳过生成
+            if(column.getCategoryType().equals(CategoryTypeEnum.LINK.toString())) {
+                continue;
+            }
             ContentBean contentBean = new ContentBean();
             contentBean.setCategoryId(column.getId());
             contentBean.setCategoryType(column.getCategoryType());
@@ -184,7 +187,7 @@ public class GeneraterAction extends BaseAction {
                 case LIST: // 列表
 
                     // 判断模板文件是否存在
-                    if (!FileUtil.exist(ParserUtil.buildTemplatePath(column.getCategoryListUrl()))) {
+                    if (StringUtils.isEmpty(column.getCategoryListUrl()) || !FileUtil.exist(ParserUtil.buildTemplatePath(column.getCategoryListUrl()))) {
                         LOG.error("模板不存在:{}", column.getCategoryUrl());
                         continue;
                     }
@@ -192,6 +195,13 @@ public class GeneraterAction extends BaseAction {
                     CmsParserUtil.generateList(column, articleIdList.size(),htmlDir);
                     break;
                 case COVER:// 单页
+
+                    // 判断模板文件是否存在
+                    if (StringUtils.isEmpty(column.getCategoryUrl()) || !FileUtil.exist(ParserUtil.buildTemplatePath(column.getCategoryUrl()))) {
+                        LOG.error("模板不存在:{}", column.getCategoryUrl());
+                        continue;
+                    }
+
                     if (articleIdList.size() == 0) {
                         CategoryBean columnArticleIdBean = new CategoryBean();
                         CopyOptions copyOptions = CopyOptions.create();
@@ -226,16 +236,19 @@ public class GeneraterAction extends BaseAction {
         ContentBean contentBean = new ContentBean();
         contentBean.setBeginTime(dateTime);
 
-        // 生成所有栏目的文章
         if ("0".equals(columnId)) {
-            categoryList = categoryBiz.list(Wrappers.<CategoryEntity>lambdaQuery()
-                    .isNull(CategoryEntity::getCategoryParentIds));
-        } else {
-            CategoryEntity category = (CategoryEntity) categoryBiz.getById(columnId);
-            categoryList.add(category);
+            categoryList = categoryBiz.list();
+        } else { //选择栏目更新
+            CategoryEntity categoryEntity = new CategoryEntity();
+            categoryEntity.setId(columnId);
+            categoryList = categoryBiz.queryChilds(categoryEntity);
         }
 
         for (CategoryEntity category : categoryList) {
+            //如果是链接就跳过生成
+            if(category.getCategoryType().equals(CategoryTypeEnum.LINK.toString())) {
+                continue;
+            }
             contentBean.setCategoryId(category.getId());
             contentBean.setCategoryType(category.getCategoryType());
             //将文章列表标签中的中的参数
@@ -248,6 +261,11 @@ public class GeneraterAction extends BaseAction {
                     continue;
                 }
             } else if (category.getCategoryType().equals(CategoryTypeEnum.COVER.toString())) {
+                // 判断模板文件是否存在
+                if (!FileUtil.exist(ParserUtil.buildTemplatePath(category.getCategoryListUrl())) || StringUtils.isEmpty(category.getCategoryListUrl())) {
+                    LOG.error("模板不存在:{}", category.getCategoryUrl());
+                    continue;
+                }
                 CategoryBean columnArticleIdBean = new CategoryBean();
                 CopyOptions copyOptions = CopyOptions.create();
                 copyOptions.setIgnoreError(true);
@@ -275,7 +293,7 @@ public class GeneraterAction extends BaseAction {
     public String viewIndex(HttpServletRequest request, @PathVariable String position, HttpServletResponse response) {
         AppEntity app = BasicUtil.getApp();
         // 组织主页预览地址
-        String indexPosition = app.getAppHostUrl() + File.separator + htmlDir+ File.separator + app.getAppDir()
+        String indexPosition = app.getAppHostUrl() + htmlDir+ File.separator + app.getAppDir()
                 + File.separator + position + ParserUtil.HTML_SUFFIX;
         return "redirect:" + indexPosition;
     }

+ 6 - 20
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java

@@ -74,6 +74,7 @@ import java.util.Map;
  *
  * @author 铭飞开源团队
  * @date 2018年12月17日
+ * @date 2021年8月26日取消默认search.htm
  */
 @Controller("dynamicPageAction")
 @RequestMapping("/mcms")
@@ -99,11 +100,6 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
 
 
     /**
-     * 搜索标签;
-     */
-    public static final String SEARCH = "search";
-
-    /**
      * 自定义模型
      */
     @Autowired
@@ -320,9 +316,10 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
     @RequestMapping(value = "search",method = {RequestMethod.GET, RequestMethod.POST})
     @ResponseBody
     public String search(HttpServletRequest request, HttpServletResponse response) {
+        String search = BasicUtil.getString("tmpl", "search.htm");
         //设置分页类
         PageBean page = new PageBean();
-        page.setSize(ParserUtil.getPageSize(SEARCH + ParserUtil.HTM_SUFFIX, 20));
+        page.setSize(ParserUtil.getPageSize(search, 20));
 
         //参数集合,提供给解析使用
         Map<String, Object> params = new HashMap<>();
@@ -461,7 +458,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
         //查询数量
         int count = contentBiz.getSearchCount(contentModel, fieldValueList, searchMap, BasicUtil.getApp().getAppId(), categoryIds);
         page.setRcount(count);
-        params.put(SEARCH, searchMap);
+        params.put("search", searchMap);
 
         //站点编号
         if (BasicUtil.getWebsiteApp() != null) {
@@ -473,15 +470,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
             params.put(ParserUtil.APP_DIR, BasicUtil.getApp().getAppDir());
         }
 
-        params.put(ParserUtil.PAGE, page);
-        params.put(ParserUtil.HTML, htmlDir);
-        //动态解析
-        params.put(ParserUtil.IS_DO, false);
-        //设置动态请求的模块路径
-        params.put(ParserUtil.MODEL_NAME, "mcms");
-
         searchMap.put("pageNo", 0);
-//        ParserUtil.read(SEARCH + ParserUtil.HTM_SUFFIX, map, page);
+//        ParserUtil.read(search, map, page);
         int total = PageUtil.totalPage(count, page.getSize());
 
 
@@ -512,10 +502,6 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
         page.setPreUrl(preUrl);
         page.setLastUrl(lastUrl);
 
-        params.put(SEARCH, searchMap);
-        if (BasicUtil.getWebsiteApp() != null) {
-            params.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
-        }
         params.put(ParserUtil.PAGE, page);
         params.put(ParserUtil.HTML, htmlDir);
         //动态解析
@@ -527,7 +513,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
         String content = "";
         try {
             //根据模板路径,参数生成
-            content = ParserUtil.rendering(SEARCH + ParserUtil.HTM_SUFFIX, params);
+            content = ParserUtil.rendering(search, params);
         } catch (TemplateNotFoundException e) {
             e.printStackTrace();
         } catch (MalformedTemplateNameException e) {

+ 1 - 1
src/main/java/net/mingsoft/cms/biz/ICategoryBiz.java

@@ -35,7 +35,7 @@ import java.util.List;
 public interface ICategoryBiz extends IBaseBiz<CategoryEntity> {
 
     /**
-     * 查询当前分类下的所有子分类
+     * 查询当前分类下的所有子分类,包含自身
      * @param category
      * @return
      */

+ 0 - 3
src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java

@@ -200,7 +200,6 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
         CategoryEntity category = (CategoryEntity) categoryDao.selectById(categoryId);
         //删除父类
         if (category != null) {
-            category.setCategoryParentIds(null);
             List<CategoryEntity> childrenList = categoryDao.queryChildren(category);
             List<String> ids = new ArrayList<>();
             for (int i = 0; i < childrenList.size(); i++) {
@@ -217,8 +216,6 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
             List<CategoryEntity> childNode = categoryDao.queryChildren(parentNode);
             //判断删除的是否为主节点
             if (parentNode != null) {
-                //清空CategoryParentIds,避免查找不必要的数据,只需要当前的父级栏目
-                parentNode.setCategoryParentIds(null);
                 UpdateWrapper<CategoryEntity> updateWrapper = new UpdateWrapper<>();
                 //如果没有子节点进行更新代码
                 if (childNode.size() == 1) {

+ 2 - 9
src/main/java/net/mingsoft/cms/dao/ICategoryDao.xml

@@ -43,8 +43,8 @@
 				category_parent_ids=#{categoryParentIds},
 				<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>
-				<if test="categoryUrl != null and categoryUrl != ''">category_url=#{categoryUrl},</if>
+				category_list_url=#{categoryListUrl},
+				category_url=#{categoryUrl},
 				<if test="categoryKeyword != null ">category_keyword=#{categoryKeyword},</if>
 				<if test="categoryDescrip != null ">category_descrip=#{categoryDescrip},</if>
 				<if test="categoryImg != null and categoryImg != ''">category_img=#{categoryImg},</if>
@@ -109,15 +109,8 @@
 			</if>
 			and
 			(
-			<if test="categoryParentIds != null and categoryParentIds!=''">
-				find_in_set(#{categoryParentIds},CATEGORY_PARENT_IDS)>0
-			</if>
-			<if test="categoryParentIds == null or  categoryParentIds ==''">
 				find_in_set('${id}',CATEGORY_PARENT_IDS)>0
-			</if>
-			<if test="id != null">
 				or id=#{id}
-			</if>
 			)
 			and del=0
 		</where>

+ 4 - 1
src/main/java/net/mingsoft/cms/util/CmsParserUtil.java

@@ -38,6 +38,8 @@ import net.mingsoft.mdiy.biz.impl.ModelBizImpl;
 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 javax.servlet.http.HttpServletRequest;
 import java.io.File;
@@ -46,7 +48,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ExecutorService;
 
 /**
  * 文章解析工具类
@@ -55,6 +56,7 @@ public class CmsParserUtil {
 
 
     private final static String FIELD = "field";
+    protected final static Logger LOG = LoggerFactory.getLogger(CmsParserUtil.class);
 
     /**
      * 指定模板,指定路径进行生成静态页面,会自定识别pc与移动端
@@ -226,6 +228,7 @@ public class CmsParserUtil {
             }
             // 文章的模板路径
             String columnUrl = categoryBean.getCategoryUrl();
+            LOG.debug("columnUrl {}",columnUrl);
             // 文章的栏目模型编号
             Integer columnContentModelId = null;
             if (articleIdList.get(artId).getMdiyModelId() != null && categoryBean.getMdiyModelId() > 0) {

Някои файлове не бяха показани, защото твърде много файлове са промени