添加乡镇或别名查询
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
value="${district!}"></input>
|
||||
<label for="name">乡镇:</label>
|
||||
<input type="text" name="street" id="street" class="input-medium" style="margin-top:9px;"
|
||||
placeholder="乡镇或其别名"
|
||||
value="${street!}"></input>
|
||||
<input id="queryBtn" class="btn btn-primary" type="submit" value="查询"/>
|
||||
</div>
|
||||
@@ -38,6 +39,7 @@
|
||||
<th>城市</th>
|
||||
<th>区域</th>
|
||||
<th>乡镇</th>
|
||||
<th>乡镇别名</th>
|
||||
<th>修改日期</th>
|
||||
<th>操作人</th>
|
||||
</tr>
|
||||
@@ -47,6 +49,12 @@
|
||||
<td>${it.city1!}</td>
|
||||
<td>${it.district!}</td>
|
||||
<td><a href="../township/edit?id=${it.id!}"> ${it.street!}</a></td>
|
||||
<td> <#if it.alias??>
|
||||
<#list it.alias as item>
|
||||
${item?string}<#if item_has_next>, </#if>
|
||||
</#list>
|
||||
</#if>
|
||||
</td>
|
||||
<td>${it.updateTime!?string("yyyy-MM-dd HH:mm:ss")}</td>
|
||||
<td>${it.operator!}</td>
|
||||
</tr>
|
||||
|
||||
+11
-2
@@ -4,6 +4,8 @@ import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.mongo.dao.AdministrativeMappingDao;
|
||||
import com.fangjia.dal.mongo.dao.TownshipDao;
|
||||
import com.fangjia.dal.mongo.model.Township;
|
||||
import com.mongodb.BasicDBList;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.sothis.core.util.Pager;
|
||||
|
||||
@@ -42,7 +44,10 @@ public class TownshipServiceImpl implements TownshipService {
|
||||
}
|
||||
if (StringUtils.isNotBlank(street)) {
|
||||
Pattern pattern = Pattern.compile(".*" + street + ".*");
|
||||
params.add(new QueryParam("street", pattern));
|
||||
BasicDBList orList = new BasicDBList();
|
||||
orList.add(new BasicDBObject("alias", pattern));
|
||||
orList.add(new BasicDBObject("street", pattern));
|
||||
params.add(new QueryParam("$or",orList));
|
||||
}
|
||||
params.add(new QueryParam("type","乡镇街道"));
|
||||
|
||||
@@ -67,7 +72,11 @@ public class TownshipServiceImpl implements TownshipService {
|
||||
}
|
||||
if (StringUtils.isNotBlank(street)) {
|
||||
Pattern pattern = Pattern.compile(".*" + street + ".*");
|
||||
params.add(new QueryParam("street", pattern));
|
||||
//mongo or查询方法
|
||||
BasicDBList orList = new BasicDBList();
|
||||
orList.add(new BasicDBObject("alias", pattern));
|
||||
orList.add(new BasicDBObject("street", pattern));
|
||||
params.add(new QueryParam("$or",orList));
|
||||
}
|
||||
params.add(new QueryParam("type","乡镇街道"));
|
||||
return townshipDao.findCountByParams(params);
|
||||
|
||||
Reference in New Issue
Block a user