列表排序

This commit is contained in:
luoxj 2020-09-02 16:42:17 +08:00
parent 588d0791eb
commit 8a28ed1b62
3 changed files with 68 additions and 77 deletions

39
pom.xml
View File

@ -3,52 +3,23 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>net.mingsoft</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>ms-pom</artifactId>
<version>2.2.2.RELEASE</version> <version>2.0.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.mingsoft</groupId> <groupId>net.mingsoft</groupId>
<artifactId>mcms</artifactId> <artifactId>mcms</artifactId>
<version>5.0.0</version> <version>5.1-SNAPSHOT</version>
<name>ms-mcms</name> <name>ms-mcms</name>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
</properties> </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> <dependencies>
<dependency> <dependency>
<groupId>net.mingsoft</groupId> <groupId>net.mingsoft</groupId>
<artifactId>ms-mpeople</artifactId> <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> </dependency>
<!-- 此部分是铭飞平台MStroe的客户端MStore不在铭飞开源产品范围如果不需要使用MStore可以删除掉 --> <!-- 此部分是铭飞平台MStroe的客户端MStore不在铭飞开源产品范围如果不需要使用MStore可以删除掉 -->
<dependency> <dependency>

View File

@ -36,6 +36,7 @@ import net.mingsoft.cms.util.CmsParserUtil;
import net.mingsoft.mdiy.bean.AttributeBean; import net.mingsoft.mdiy.bean.AttributeBean;
import net.mingsoft.mdiy.bean.PageBean; import net.mingsoft.mdiy.bean.PageBean;
import net.mingsoft.mdiy.util.ParserUtil; import net.mingsoft.mdiy.util.ParserUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -173,8 +174,12 @@ public class GeneraterAction extends BaseAction {
// 1设置模板文件夹路径 // 1设置模板文件夹路径
// 获取栏目列表模版 // 获取栏目列表模版
for (CategoryEntity column : columns) { for (CategoryEntity column : columns) {
ContentBean contentBean = new ContentBean();
contentBean.setContentCategoryId(column.getId());
// 分类是列表链接
if(!column.getCategoryType().equals("2")) {
// 判断模板文件是否存在 // 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryUrl()))) { if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryListUrl()))) {
LOG.error("模板不存在:{}", column.getCategoryUrl()); LOG.error("模板不存在:{}", column.getCategoryUrl());
continue; continue;
} }
@ -185,8 +190,6 @@ public class GeneraterAction extends BaseAction {
map.put(ParserUtil.HTML, ParserUtil.HTML); map.put(ParserUtil.HTML, ParserUtil.HTML);
map.put(ParserUtil.URL, BasicUtil.getUrl()); map.put(ParserUtil.URL, BasicUtil.getUrl());
map.put(ParserUtil.PAGE, page); map.put(ParserUtil.PAGE, page);
ContentBean contentBean = new ContentBean();
contentBean.setContentCategoryId(column.getId());
AttributeBean attributeBean = new AttributeBean(); AttributeBean attributeBean = new AttributeBean();
// 获取文章列表模板标签属性 // 获取文章列表模板标签属性
ParserUtil.read(column.getCategoryListUrl(), map, page, attributeBean); ParserUtil.read(column.getCategoryListUrl(), map, page, attributeBean);
@ -194,6 +197,7 @@ public class GeneraterAction extends BaseAction {
contentBean.setNoflag(attributeBean.getNoflag()); contentBean.setNoflag(attributeBean.getNoflag());
contentBean.setOrder(attributeBean.getOrder()); contentBean.setOrder(attributeBean.getOrder());
contentBean.setOrderBy(attributeBean.getOrderby()); contentBean.setOrderBy(attributeBean.getOrderby());
}
articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean); articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean);
// 判断列表类型 // 判断列表类型
switch (column.getCategoryType()) { switch (column.getCategoryType()) {
@ -249,8 +253,10 @@ public class GeneraterAction extends BaseAction {
categoryList = categoryBiz.query(categoryEntity); categoryList = categoryBiz.query(categoryEntity);
for(CategoryEntity category : categoryList){ for(CategoryEntity category : categoryList){
contentBean.setContentCategoryId(category.getId()); contentBean.setContentCategoryId(category.getId());
// 分类是列表链接
if(!category.getCategoryType().equals("2")){
// 判断模板文件是否存在 // 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryUrl()))) { if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryListUrl())) || StringUtils.isEmpty(category.getCategoryListUrl())) {
LOG.error("模板不存在:{}",category.getCategoryUrl()); LOG.error("模板不存在:{}",category.getCategoryUrl());
continue; continue;
} }
@ -260,6 +266,7 @@ public class GeneraterAction extends BaseAction {
contentBean.setNoflag(attributeBean.getNoflag()); contentBean.setNoflag(attributeBean.getNoflag());
contentBean.setOrder(attributeBean.getOrder()); contentBean.setOrder(attributeBean.getOrder());
contentBean.setOrderBy(attributeBean.getOrderby()); contentBean.setOrderBy(attributeBean.getOrderby());
}
articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean); articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean);
// 有符合条件的就更新 // 有符合条件的就更新
if (articleIdList.size() > 0) { if (articleIdList.size() > 0) {
@ -268,6 +275,9 @@ public class GeneraterAction extends BaseAction {
} }
}else { }else {
CategoryEntity category = (CategoryEntity) categoryBiz.getEntity(Integer.parseInt(columnId)); CategoryEntity category = (CategoryEntity) categoryBiz.getEntity(Integer.parseInt(columnId));
contentBean.setContentCategoryId(columnId);
// 分类是列表链接
if(!category.getCategoryType().equals("2")){
// 获取文章列表表属性 // 获取文章列表表属性
// 判断模板文件是否存在 // 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryUrl()))) { if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryUrl()))) {
@ -279,7 +289,7 @@ public class GeneraterAction extends BaseAction {
contentBean.setNoflag(attributeBean.getNoflag()); contentBean.setNoflag(attributeBean.getNoflag());
contentBean.setOrder(attributeBean.getOrder()); contentBean.setOrder(attributeBean.getOrder());
contentBean.setOrderBy(attributeBean.getOrderby()); contentBean.setOrderBy(attributeBean.getOrderby());
contentBean.setContentCategoryId(columnId); }
articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean); articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean);
// 有符合条件的就更新 // 有符合条件的就更新
if (articleIdList.size() > 0) { if (articleIdList.size() > 0) {

View File

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