Sun Xin 6 lat temu
rodzic
commit
b033abee65

+ 60 - 56
src/main/java/net/mingsoft/cms/action/web/SearchAction.java

@@ -45,6 +45,7 @@ import net.mingsoft.basic.biz.IColumnBiz;
 import net.mingsoft.basic.entity.ColumnEntity;
 import net.mingsoft.cms.biz.IArticleBiz;
 import net.mingsoft.cms.util.CmsParserUtil;
+import net.mingsoft.mdiy.biz.IContentModelFieldBiz;
 import net.mingsoft.mdiy.biz.ISearchBiz;
 import net.mingsoft.mdiy.entity.ContentModelFieldEntity;
 import net.mingsoft.mdiy.entity.SearchEntity;
@@ -123,6 +124,8 @@ public class SearchAction extends BaseAction {
 		Map<String, String> basicField = getMapByProperties(net.mingsoft.mdiy.constant.Const.BASIC_FIELD);
 		// 文章字段集合
 		Map<String, Object> articleFieldName = new HashMap<String, Object>();
+		// 自定义字段集合
+		Map<String, String> diyFieldName = new HashMap<String, String>();
 		// 遍历取字段集合
 		if (field != null) {
 			for (Entry<String, String[]> entry : field.entrySet()) {
@@ -141,11 +144,15 @@ public class SearchAction extends BaseAction {
 					// 若为文章字段,则保存至文章字段集合;否则保存至自定义字段集合
 					if (ObjectUtil.isNotNull(basicField.get(entry.getKey())) && ObjectUtil.isNotNull(value)) {
 						articleFieldName.put(entry.getKey(), value);
-					} 
+					} else {
+						if (!StringUtil.isBlank(value)) {
+							diyFieldName.put(entry.getKey(), value);
+						}
+					}
 				}
 			}
 		}
-		Map whereMap = this.searchMap(articleFieldName, null, null);
+		Map whereMap = this.searchMap(articleFieldName, diyFieldName, null);
 		// 获取符合条件的文章总数
 		int count = articleBiz.getSearchCount(null, whereMap, BasicUtil.getAppId(), null);
 		int typeId = BasicUtil.getInt("categoryId",0);
@@ -175,25 +182,22 @@ public class SearchAction extends BaseAction {
 			next = pageNo+1;
 			pre = pageNo ==1 ? 1 : pageNo+1;
 		}
-		String url = BasicUtil.getUrl() + request.getServletPath() +"?";
+		String url = BasicUtil.getUrl() + request.getServletPath() +"?" + BasicUtil.assemblyRequestUrlParams(ParserUtil.PAGE_NO.split(""));
 		String pageNoStr = "&"+ParserUtil.PAGE_NO+"=";
-		BasicUtil.removeUrlParams(ParserUtil.PAGE_NO.split(""));
 		//下一页
-		String nextUrl = url + BasicUtil.assemblyRequestUrlParams()+pageNoStr+next;
+		String nextUrl = url + pageNoStr+next;
 		//首页
-		String indexUrl = url + BasicUtil.assemblyRequestUrlParams() + pageNoStr + 1;
+		String indexUrl = url + pageNoStr + 1;
 		//尾页
-		String lastUrl = url + BasicUtil.assemblyRequestUrlParams() + pageNoStr + total;
+		String lastUrl = url + pageNoStr + total;
 		//上一页
-		String preUrl = url + BasicUtil.assemblyRequestUrlParams() + pageNoStr + pre;
+		String preUrl = url + pageNoStr + pre;
 		
-		Map<String, Object> pageMap = new HashMap<String, Object>();
-		pageMap.put(ParserUtil.INDEX_URL, indexUrl);
-		pageMap.put(ParserUtil.NEXT_URL, nextUrl);
-		pageMap.put(ParserUtil.PRE_URL, preUrl);
-		pageMap.put(ParserUtil.LAST_URL, lastUrl);
+		map.put(ParserUtil.INDEX_URL, indexUrl);
+		map.put(ParserUtil.NEXT_URL, nextUrl);
+		map.put(ParserUtil.PRE_URL, preUrl);
+		map.put(ParserUtil.LAST_URL, lastUrl);
 		map.put(ParserUtil.URL, BasicUtil.getUrl());
-		map.put(ParserUtil.PAGE, pageMap);
 		Map<Object, Object> searchMap = new HashMap<>();
 		searchMap.put(BASIC_TITLE, BasicUtil.getString(BASIC_TITLE));
 		searchMap.put(ParserUtil.PAGE_NO, BasicUtil.getInt(ParserUtil.PAGE_NO,1));
@@ -256,48 +260,48 @@ public class SearchAction extends BaseAction {
 		}
 
 		// 遍历字段自定义字段
-//		for (Iterator iter = diyFieldName.keySet().iterator(); iter.hasNext();) {
-//			String key = iter.next().toString();
-//			String fieldValue = diyFieldName.get(key);
-//			// 获取字段实体
-//			ContentModelFieldEntity field = this.get(key, fields);
-//			if (field != null) {
-//				List list = new ArrayList();
-//				// 是否为自定义字段0
-//				list.add(0, true);
-//				List listValue = new ArrayList();
-//				// 字段的值
-//				if (field.getFieldType() == IContentModelFieldBiz.INT || field.getFieldType() == IContentModelFieldBiz.FLOAT) {
-//					// 判断是否为区间查询
-//
-//					if (diyFieldName.get(key).toString().indexOf("-") > 0) {
-//						String[] values = fieldValue.toString().split("-");
-//						// 是否是数字类型,false:是
-//						list.add(false);
-//						// 是否是区间比较 false:是
-//						list.add(false);
-//						// 字段值1
-//						listValue.add(values[0]);
-//						listValue.add(values[1]);
-//					} else {
-//						// 是否是数字类型,false:是2
-//						list.add(false);
-//						// 是否是区间比较 true:不是3
-//						list.add(true);
-//						// 字段值 1
-//						listValue.add(fieldValue);
-//					}
-//				} else {
-//					// 是否是数字类型,true:不是2
-//					list.add(true);
-//					list.add(false);
-//					// 字段值 1
-//					listValue.add(fieldValue);
-//				}
-//				list.add(listValue);
-//				map.put(key, list);
-//			}
-//		}
+		for (Iterator iter = diyFieldName.keySet().iterator(); iter.hasNext();) {
+			String key = iter.next().toString();
+			String fieldValue = diyFieldName.get(key);
+			// 获取字段实体
+			ContentModelFieldEntity field = this.get(key, fields);
+			if (field != null) {
+				List list = new ArrayList();
+				// 是否为自定义字段0
+				list.add(0, true);
+				List listValue = new ArrayList();
+				// 字段的值
+				if (field.getFieldType() == IContentModelFieldBiz.INT || field.getFieldType() == IContentModelFieldBiz.FLOAT) {
+					// 判断是否为区间查询
+
+					if (diyFieldName.get(key).toString().indexOf("-") > 0) {
+						String[] values = fieldValue.toString().split("-");
+						// 是否是数字类型,false:是
+						list.add(false);
+						// 是否是区间比较 false:是
+						list.add(false);
+						// 字段值1
+						listValue.add(values[0]);
+						listValue.add(values[1]);
+					} else {
+						// 是否是数字类型,false:是2
+						list.add(false);
+						// 是否是区间比较 true:不是3
+						list.add(true);
+						// 字段值 1
+						listValue.add(fieldValue);
+					}
+				} else {
+					// 是否是数字类型,true:不是2
+					list.add(true);
+					list.add(false);
+					// 字段值 1
+					listValue.add(fieldValue);
+				}
+				list.add(listValue);
+				map.put(key, list);
+			}
+		}
 		return map;
 	}
 

+ 4 - 4
src/main/webapp/templets/1/default/search.htm

@@ -27,10 +27,10 @@
                     </ul>
                 </div>
                 <div class="ms-content-main-page">
-	              	 <a class="ms-content-main-page-first" href="{ms:global.url/}{ms:page.index/}">首页</a>
-		             <a class="ms-content-main-page-upper" href="{ms:global.url/}{ms:page.pre/}">上一页</a>
-		             <a class="ms-content-main-page-next" href="{ms:global.url/}{ms:page.next/}">下一页</a>
-		             <a class="ms-content-main-page-last" href="{ms:global.url/}{ms:page.last/}">末页</a>
+	              	 <a class="ms-content-main-page-first" href="{ms:page.index/}">首页</a>
+		             <a class="ms-content-main-page-upper" href="{ms:page.pre/}">上一页</a>
+		             <a class="ms-content-main-page-next" href="{ms:page.next/}">下一页</a>
+		             <a class="ms-content-main-page-last" href="{ms:page.last/}">末页</a>
 	            </div>
             </div>
         </div>