!159 搜索参数修改

Merge pull request !159 from 他是超人他会飞/4.7.0
This commit is contained in:
铭飞 2019-03-19 11:48:52 +08:00
commit 016fc54903
10 changed files with 63 additions and 49 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

11
pom.xml
View File

@ -60,6 +60,17 @@
<version>1.0.7-SNAPSHOT</version> <version>1.0.7-SNAPSHOT</version>
<classifier>classes</classifier> <classifier>classes</classifier>
</dependency> </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>9.0.16</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>ms-mcms</finalName> <finalName>ms-mcms</finalName>

View File

@ -148,7 +148,7 @@ public class SearchAction extends BaseAction {
if (ObjectUtil.isNull(search)) { if (ObjectUtil.isNull(search)) {
this.outJson(response, false); this.outJson(response, false);
} }
Map<String, Object> map = BasicUtil.assemblyRequestMap(); Map<String, Object> map = new HashMap<>();
// 读取请求字段 // 读取请求字段
Map<String, String[]> field = request.getParameterMap(); Map<String, String[]> field = request.getParameterMap();
Map<String, String> basicField = getMapByProperties(net.mingsoft.mdiy.constant.Const.BASIC_FIELD); Map<String, String> basicField = getMapByProperties(net.mingsoft.mdiy.constant.Const.BASIC_FIELD);
@ -160,10 +160,11 @@ public class SearchAction extends BaseAction {
ContentModelEntity contentModel = null; // 栏目对应模型 ContentModelEntity contentModel = null; // 栏目对应模型
List<ContentModelFieldEntity> fieldList = new ArrayList<ContentModelFieldEntity>(); // 栏目对应字段 List<ContentModelFieldEntity> fieldList = new ArrayList<ContentModelFieldEntity>(); // 栏目对应字段
List<DiyModelMap> fieldValueList = new ArrayList<DiyModelMap>(); // 栏目对应字段的值 List<DiyModelMap> fieldValueList = new ArrayList<DiyModelMap>(); // 栏目对应字段的值
int typeId = BasicUtil.getInt("categoryId",0); int typeId = BasicUtil.getInt("typeid",0);
String categoryIds = BasicUtil.getString("categoryId");
//记录自定义模型字段名 //记录自定义模型字段名
List filedStr = new ArrayList<>(); List filedStr = new ArrayList<>();
//根据栏目确定模版 //根据栏目确定自定义模型
if(typeId>0){ if(typeId>0){
column = (ColumnEntity) columnBiz.getEntity(Integer.parseInt(typeId+"")); column = (ColumnEntity) columnBiz.getEntity(Integer.parseInt(typeId+""));
// 获取表单类型的id // 获取表单类型的id
@ -222,8 +223,9 @@ public class SearchAction extends BaseAction {
} }
//组织where查询条件 //组织where查询条件
Map whereMap = this.searchMap(articleFieldName, diyFieldName, fieldList); Map whereMap = this.searchMap(articleFieldName, diyFieldName, fieldList);
// 获取符合条件的文章总数 // 获取符合条件的文章总数
int count = articleBiz.getSearchCount(contentModel, whereMap, BasicUtil.getAppId(), null); int count = articleBiz.getSearchCount(contentModel, whereMap, BasicUtil.getAppId(), categoryIds);
//设置分页类 //设置分页类
PageBean page = new PageBean(); PageBean page = new PageBean();
//读取模板的分页数量 //读取模板的分页数量
@ -240,8 +242,9 @@ public class SearchAction extends BaseAction {
e1.printStackTrace(); e1.printStackTrace();
} }
int total = PageUtil.totalPage(count, size); int total = PageUtil.totalPage(count, size);
int pageNo = BasicUtil.getInt(ParserUtil.PAGE_NO,1);
if(pageNo >= total) { int pageNo = BasicUtil.getInt(ParserUtil.PAGE_NO, 1);
if(pageNo >= total && total!=0) {
pageNo = total; pageNo = total;
} }
//获取总数 //获取总数
@ -252,27 +255,25 @@ public class SearchAction extends BaseAction {
page.setPageNo(pageNo); page.setPageNo(pageNo);
String str = ParserUtil.PAGE_NO+","+ParserUtil.SIZE; String str = ParserUtil.PAGE_NO+","+ParserUtil.SIZE;
//设置分页的统一链接 //设置分页的统一链接
String url = request.getServletPath() +"?" + BasicUtil.assemblyRequestUrlParams(str.split(",")); String url = BasicUtil.getUrl()+request.getServletPath() +"?" + BasicUtil.assemblyRequestUrlParams(str.split(","));
String pageNoStr = "&"+ParserUtil.SIZE+"="+size+"&"+ParserUtil.PAGE_NO+"="; String pageNoStr = "&"+ParserUtil.SIZE+"="+size+"&"+ParserUtil.PAGE_NO+"=";
//下一页 //下一页
String nextUrl = url + pageNoStr+((pageNo+1 > total)?total:++pageNo); String nextUrl = url + pageNoStr+((pageNo+1 > total)?total:pageNo+1);
//首页 //首页
String indexUrl = url + pageNoStr + 1; String indexUrl = url + pageNoStr + 1;
//尾页 //尾页
String lastUrl = url + pageNoStr + total; String lastUrl = url + pageNoStr + total;
//上一页 //上一页 当前页为1时上一页就是1
String preUrl = url + pageNoStr + (--pageNo); String preUrl = url + pageNoStr + ((pageNo==1) ? 1:pageNo-1);
page.setIndexUrl(indexUrl); page.setIndexUrl(indexUrl);
page.setNextUrl(nextUrl); page.setNextUrl(nextUrl);
page.setPreUrl(preUrl); page.setPreUrl(preUrl);
page.setLastUrl(lastUrl); page.setLastUrl(lastUrl);
map.put(ParserUtil.URL, BasicUtil.getUrl()); map.put(ParserUtil.URL, BasicUtil.getUrl());
Map<Object, Object> searchMap = new HashMap<>(); Map<String, Object> searchMap = BasicUtil.assemblyRequestMap();
searchMap.put(BASIC_TITLE, BasicUtil.getString(BASIC_TITLE));
searchMap.put(ParserUtil.PAGE_NO, pageNo); searchMap.put(ParserUtil.PAGE_NO, pageNo);
map.put(SEARCH, searchMap); map.put(SEARCH, searchMap);
map.put(ParserUtil.PAGE, page); map.put(ParserUtil.PAGE, page);

View File

@ -114,8 +114,7 @@ public interface IArticleBiz extends IBasicBiz {
* @return 记录数量 * @return 记录数量
* @see IArticleBiz.count * @see IArticleBiz.count
*/ */
@Deprecated public int getSearchCount(ContentModelEntity contentModel, Map whereMap, int appId, String ids);
public int getSearchCount(ContentModelEntity contentModel, Map whereMap, int appId, List ids);
/** /**
* 文章查询 * 文章查询

View File

@ -28,10 +28,12 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import net.mingsoft.base.dao.IBaseDao;
import net.mingsoft.basic.biz.ICategoryBiz; import net.mingsoft.basic.biz.ICategoryBiz;
import net.mingsoft.basic.biz.IColumnBiz; import net.mingsoft.basic.biz.IColumnBiz;
import net.mingsoft.basic.biz.IModelBiz; import net.mingsoft.basic.biz.IModelBiz;
import net.mingsoft.basic.biz.impl.BasicBizImpl; import net.mingsoft.basic.biz.impl.BasicBizImpl;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.cms.bean.ColumnArticleIdBean; import net.mingsoft.cms.bean.ColumnArticleIdBean;
import net.mingsoft.cms.biz.IArticleBiz; import net.mingsoft.cms.biz.IArticleBiz;
import net.mingsoft.cms.dao.IArticleDao; import net.mingsoft.cms.dao.IArticleDao;
@ -39,9 +41,6 @@ import net.mingsoft.cms.entity.ArticleEntity;
import net.mingsoft.mdiy.biz.IContentModelBiz; import net.mingsoft.mdiy.biz.IContentModelBiz;
import net.mingsoft.mdiy.entity.ContentModelEntity; import net.mingsoft.mdiy.entity.ContentModelEntity;
import net.mingsoft.base.dao.IBaseDao;
import net.mingsoft.basic.util.BasicUtil;
/** /**
* *
* @ClassName: ArticleBizImpl * @ClassName: ArticleBizImpl
@ -157,8 +156,7 @@ public class ArticleBizImpl extends BasicBizImpl implements IArticleBiz {
return articleDao.getNextOrPrevious(appId, basicId, false,categoryId); return articleDao.getNextOrPrevious(appId, basicId, false,categoryId);
} }
@Override @Override
@Deprecated public int getSearchCount(ContentModelEntity contentModel,Map wherMap, int websiteId,String ids) {
public int getSearchCount(ContentModelEntity contentModel,Map wherMap, int websiteId,List ids) {
if (contentModel!=null) { if (contentModel!=null) {
return articleDao.getSearchCount(contentModel.getCmTableName(),wherMap, websiteId,ids); return articleDao.getSearchCount(contentModel.getCmTableName(),wherMap, websiteId,ids);
} }

View File

@ -103,9 +103,8 @@ public interface IArticleDao extends IBaseDao {
* list[2]:是否是等值查询 list[3]:字段的值 * list[2]:是否是等值查询 list[3]:字段的值
* @return 文章实体总数 * @return 文章实体总数
*/ */
@Deprecated
int getSearchCount(@Param("tableName") String tableName, @Param("map") Map<String, List> map, int getSearchCount(@Param("tableName") String tableName, @Param("map") Map<String, List> map,
@Param("websiteId") int websiteId, @Param("ids") List ids); @Param("websiteId") int websiteId, @Param("ids") String ids);
/** /**
* 文章查询 * 文章查询

View File

@ -461,16 +461,9 @@
<if test="tableName!=null">left join ${tableName} d on d.basicId=a.ARTICLE_BASICID <if test="tableName!=null">left join ${tableName} d on d.basicId=a.ARTICLE_BASICID
</if> </if>
where a.ARTICLE_WEBID = #{websiteId} where a.ARTICLE_WEBID = #{websiteId}
<if test="ids!=null"> <if test="ids!=null">
and and FIND_IN_SET(category_categoryid,'${ids}')
b.BASIC_CATEGORYID in
<foreach item="id" index="key" collection="ids" open="("
separator="," close=")">
#{id.categoryId}
</foreach>
</if> </if>
<foreach item="item" index="key" collection="map" open="" <foreach item="item" index="key" collection="map" open=""
separator="" close=""> separator="" close="">
<if test=" item[0] == false"> <if test=" item[0] == false">

View File

@ -42,8 +42,11 @@ public class CmsParserUtil extends ParserUtil {
public static void generate(String templatePath, String targetPath) throws IOException { public static void generate(String templatePath, String targetPath) throws IOException {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put(IS_DO, false); map.put(IS_DO, false);
ColumnEntity column = new ColumnEntity();
//内容管理栏目编码
column.setCategoryModelId(BasicUtil.getModelCodeId("02990000"));
map.put(COLUMN, column);
String content = CmsParserUtil.generate(templatePath, map, false); String content = CmsParserUtil.generate(templatePath, map, false);
FileUtil.writeString(content, ParserUtil.buildHtmlPath(targetPath), Const.UTF8); FileUtil.writeString(content, ParserUtil.buildHtmlPath(targetPath), Const.UTF8);
// 生成移动页面 // 生成移动页面
@ -101,11 +104,12 @@ public class CmsParserUtil extends ParserUtil {
PageBean page = new PageBean(); PageBean page = new PageBean();
page.setSize(pageSize); page.setSize(pageSize);
//全局参数设置 //全局参数设置
Map parserParams = new HashMap(); Map<String, Object> parserParams = new HashMap<String, Object>();
parserParams.put(COLUMN, column); parserParams.put(COLUMN, column);
page.setTotal(totalPageSize); page.setTotal(totalPageSize);
parserParams.put(IS_DO, false); parserParams.put(IS_DO, false);
parserParams.put(HTML, HTML); parserParams.put(HTML, HTML);
parserParams.put(APP_ID, BasicUtil.getAppId());
if (contentModel!=null) { if (contentModel!=null) {
// 将自定义模型编号设置为key值 // 将自定义模型编号设置为key值
parserParams.put(TABLE_NAME, contentModel.getCmTableName()); parserParams.put(TABLE_NAME, contentModel.getCmTableName());

View File

@ -8,11 +8,12 @@ import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.context.request.RequestContextListener; import org.springframework.web.context.request.RequestContextListener;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
@ -22,7 +23,6 @@ import com.alibaba.druid.support.spring.stat.BeanTypeAutoProxyCreator;
import com.alibaba.druid.support.spring.stat.DruidStatInterceptor; import com.alibaba.druid.support.spring.stat.DruidStatInterceptor;
import net.mingsoft.basic.interceptor.ActionInterceptor; import net.mingsoft.basic.interceptor.ActionInterceptor;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration @Configuration
public class WebConfig implements WebMvcConfigurer { public class WebConfig implements WebMvcConfigurer {
@ -140,4 +140,13 @@ public class WebConfig implements WebMvcConfigurer {
public ServletListenerRegistrationBean<RequestContextListener> requestContextListenerRegistration() { public ServletListenerRegistrationBean<RequestContextListener> requestContextListenerRegistration() {
return new ServletListenerRegistrationBean<>(new RequestContextListener()); return new ServletListenerRegistrationBean<>(new RequestContextListener());
} }
/**
* 设置默认首页
*/
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/html/1/index.html");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
WebMvcConfigurer.super.addViewControllers(registry);
}
} }