Ver Fonte

列表排序

luoxj há 5 anos atrás
pai
commit
8a28ed1b62

+ 5 - 34
pom.xml

@@ -3,52 +3,23 @@
 		 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>org.springframework.boot</groupId>
-		<artifactId>spring-boot-starter-parent</artifactId>
-		<version>2.2.2.RELEASE</version>
+		<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>mcms</artifactId>
-	<version>5.0.0</version>
+	<version>5.1-SNAPSHOT</version>
 	<name>ms-mcms</name>
 	<properties>
 		<java.version>1.8</java.version>
 	</properties>
-	<repositories>
-		<repository>
-			<id>sonatype-nexus-snapshots</id>
-			<name>Sonatype Nexus Snapshots</name>
-			<url>http://repo1.maven.org/maven2/</url>
-			<releases>
-				<enabled>true</enabled>
-			</releases>
-			<snapshots>
-				<enabled>true</enabled>
-			</snapshots>
-		</repository>
-		<repository>
-			<id>sonatype</id>
-			<name>Sonatype Snapshots</name>
-			<url>https://oss.sonatype.org/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.24</version>
-		</dependency>
-		<dependency>
-			<groupId>net.mingsoft</groupId>
-			<artifactId>ms-basic</artifactId>
-			<version>1.0.30-SNAPSHOT</version>
 		</dependency>
 		<!-- 此部分是铭飞平台MStroe的客户端(MStore不在铭飞开源产品范围),如果不需要使用MStore可以删除掉 -->
 		<dependency>

+ 50 - 40
src/main/java/net/mingsoft/cms/action/GeneraterAction.java

@@ -36,6 +36,7 @@ import net.mingsoft.cms.util.CmsParserUtil;
 import net.mingsoft.mdiy.bean.AttributeBean;
 import net.mingsoft.mdiy.bean.PageBean;
 import net.mingsoft.mdiy.util.ParserUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -173,27 +174,30 @@ public class GeneraterAction extends BaseAction {
 			// 1、设置模板文件夹路径
 			// 获取栏目列表模版
 			for (CategoryEntity column : columns) {
-				// 判断模板文件是否存在
-				if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryUrl()))) {
-					LOG.error("模板不存在:{}",column.getCategoryUrl());
-					continue;
-				}
-				//获取模板中列表标签中的条件
-				Map<String, Object> map = new HashMap<>();
-				map.put(ParserUtil.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);
 				ContentBean contentBean = new ContentBean();
 				contentBean.setContentCategoryId(column.getId());
-				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());
+				// 分类是列表,链接
+				if(!column.getCategoryType().equals("2")) {
+					// 判断模板文件是否存在
+					if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryListUrl()))) {
+						LOG.error("模板不存在:{}", column.getCategoryUrl());
+						continue;
+					}
+					//获取模板中列表标签中的条件
+					Map<String, Object> map = new HashMap<>();
+					map.put(ParserUtil.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 = contentBiz.queryIdsByCategoryIdForParser(contentBean);
 				// 判断列表类型
 				switch (column.getCategoryType()) {
@@ -249,17 +253,20 @@ public class GeneraterAction extends BaseAction {
 			categoryList = categoryBiz.query(categoryEntity);
 			for(CategoryEntity category : categoryList){
 				contentBean.setContentCategoryId(category.getId());
-				// 判断模板文件是否存在
-				if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryUrl()))) {
-					LOG.error("模板不存在:{}",category.getCategoryUrl());
-					continue;
+				// 分类是列表,链接
+				if(!category.getCategoryType().equals("2")){
+					// 判断模板文件是否存在
+					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());
 				}
-				// 获取文章列表表属性
-				ParserUtil.read(category.getCategoryListUrl(),map, page,attributeBean);
-				contentBean.setFlag(attributeBean.getFlag());
-				contentBean.setNoflag(attributeBean.getNoflag());
-				contentBean.setOrder(attributeBean.getOrder());
-				contentBean.setOrderBy(attributeBean.getOrderby());
 				articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean);
 				// 有符合条件的就更新
 				if (articleIdList.size() > 0) {
@@ -268,18 +275,21 @@ public class GeneraterAction extends BaseAction {
 			}
 		}else {
 			CategoryEntity category = (CategoryEntity) categoryBiz.getEntity(Integer.parseInt(columnId));
-			// 获取文章列表表属性
-			// 判断模板文件是否存在
-			if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryUrl()))) {
-				LOG.error("模板不存在:{}",category.getCategoryUrl());
-				return;
-			}
-			ParserUtil.read(category.getCategoryListUrl(),map, page,attributeBean);
-			contentBean.setFlag(attributeBean.getFlag());
-			contentBean.setNoflag(attributeBean.getNoflag());
-			contentBean.setOrder(attributeBean.getOrder());
-			contentBean.setOrderBy(attributeBean.getOrderby());
 			contentBean.setContentCategoryId(columnId);
+			// 分类是列表,链接
+			if(!category.getCategoryType().equals("2")){
+				// 获取文章列表表属性
+				// 判断模板文件是否存在
+				if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryUrl()))) {
+					LOG.error("模板不存在:{}",category.getCategoryUrl());
+					return;
+				}
+				ParserUtil.read(category.getCategoryListUrl(),map, page,attributeBean);
+				contentBean.setFlag(attributeBean.getFlag());
+				contentBean.setNoflag(attributeBean.getNoflag());
+				contentBean.setOrder(attributeBean.getOrder());
+				contentBean.setOrderBy(attributeBean.getOrderby());
+			}
 			articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean);
 			// 有符合条件的就更新
 			if (articleIdList.size() > 0) {

+ 13 - 3
src/main/java/net/mingsoft/cms/dao/IContentDao.xml

@@ -276,10 +276,20 @@
 			and (cms_content.content_type not in ( #{noflag}  ) or cms_content.content_type is null)
 			</if>
 			<if test="orderBy!=null  and orderBy!='' ">
-				ORDER BY ${orderBy}
-				<if  test="order!=null and order!=''">
-				${order}
+				<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
 				</if>
+				<choose>
+					<when test="order!=null and order!=''">
+						${order}
+					</when>
+					<otherwise>
+						desc
+					</otherwise>
+				</choose>
 			</if>
 
 	</select>