Commit ccfedef9 authored by sunxin's avatar sunxin

搜索修改

parent 96b43ef8
This diff is collapsed.
This diff is collapsed.
...@@ -160,10 +160,11 @@ public class SearchAction extends BaseAction { ...@@ -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 { ...@@ -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 { ...@@ -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,20 +255,19 @@ public class SearchAction extends BaseAction { ...@@ -252,20 +255,19 @@ 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);
...@@ -274,6 +276,8 @@ public class SearchAction extends BaseAction { ...@@ -274,6 +276,8 @@ public class SearchAction extends BaseAction {
Map<Object, Object> searchMap = new HashMap<>(); Map<Object, Object> searchMap = new HashMap<>();
searchMap.put(BASIC_TITLE, BasicUtil.getString(BASIC_TITLE)); searchMap.put(BASIC_TITLE, BasicUtil.getString(BASIC_TITLE));
searchMap.put(ParserUtil.PAGE_NO, pageNo); searchMap.put(ParserUtil.PAGE_NO, pageNo);
//设置栏目集合
searchMap.put("categoryIds", categoryIds);
map.put(SEARCH, searchMap); map.put(SEARCH, searchMap);
map.put(ParserUtil.PAGE, page); map.put(ParserUtil.PAGE, page);
//动态解析 //动态解析
......
...@@ -114,8 +114,7 @@ public interface IArticleBiz extends IBasicBiz { ...@@ -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);
/** /**
* 文章查询 * 文章查询
......
...@@ -28,10 +28,12 @@ import java.util.Map; ...@@ -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; ...@@ -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 { ...@@ -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);
} }
......
...@@ -103,9 +103,8 @@ public interface IArticleDao extends IBaseDao { ...@@ -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);
/** /**
* 文章查询 * 文章查询
......
...@@ -461,16 +461,9 @@ ...@@ -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">
......
...@@ -42,8 +42,11 @@ public class CmsParserUtil extends ParserUtil { ...@@ -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);
// 生成移动页面 // 生成移动页面
......
...@@ -8,11 +8,12 @@ import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; ...@@ -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; ...@@ -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 {
...@@ -51,7 +51,6 @@ public class WebConfig implements WebMvcConfigurer { ...@@ -51,7 +51,6 @@ public class WebConfig implements WebMvcConfigurer {
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/html/**").addResourceLocations("/html/"); registry.addResourceHandler("/html/**").addResourceLocations("/html/");
registry.addResourceHandler("/html/**").addResourceLocations("classpath:/html/");
registry.addResourceHandler("/app/**").addResourceLocations("classpath:/app/"); registry.addResourceHandler("/app/**").addResourceLocations("classpath:/app/");
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
registry.addResourceHandler("/api/**").addResourceLocations("classpath:/api/"); registry.addResourceHandler("/api/**").addResourceLocations("classpath:/api/");
...@@ -141,4 +140,13 @@ public class WebConfig implements WebMvcConfigurer { ...@@ -141,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);
}
} }
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