新增样本批量删除
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.sothis</groupId>
|
<groupId>org.sothis</groupId>
|
||||||
<artifactId>sothis-core</artifactId>
|
<artifactId>sothis-core</artifactId>
|
||||||
<version>0.2.0-SNAPSHOT</version>
|
<version>0.2.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.poseidon</groupId>
|
<groupId>com.poseidon</groupId>
|
||||||
<artifactId>poseidon-message</artifactId>
|
<artifactId>poseidon-message</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.sothis</groupId>
|
<groupId>org.sothis</groupId>
|
||||||
<artifactId>sothis-web</artifactId>
|
<artifactId>sothis-web</artifactId>
|
||||||
<version>0.2.0-SNAPSHOT</version>
|
<version>0.2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
|||||||
+9
@@ -12,6 +12,7 @@ import com.fangjia.service.mongo.fangjia.SeawaterService;
|
|||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.sothis.core.util.Pager;
|
import org.sothis.core.util.Pager;
|
||||||
|
import org.sothis.web.mvc.annotation.Param;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -116,6 +117,14 @@ public class SeawaterController {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object batchDeleteAction(@Param(name="ids") String ids) throws UnsupportedEncodingException {
|
||||||
|
JsonModel ret = new JsonModel();
|
||||||
|
if (StringUtils.isNotBlank(ids)){
|
||||||
|
seawaterService.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSeawaterService(SeawaterService seawaterService) {
|
public void setSeawaterService(SeawaterService seawaterService) {
|
||||||
this.seawaterService = seawaterService;
|
this.seawaterService = seawaterService;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,9 +118,13 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<span style="font-size:12px;">查询到<b style="color:red;">${pager.totalRows!}</b>条记录</span>
|
<div>
|
||||||
|
<span style="font-size:12px;">查询到<b style="color:red;">${pager.totalRows!}</b>条记录</span>
|
||||||
|
<input class ="btn btn-primary" id="batchDelete" type="submit" value="批量删除" style="float: right" />
|
||||||
|
</div>
|
||||||
<table id="dataSheet" class="table table-hover table-condensed" name="reginTable">
|
<table id="dataSheet" class="table table-hover table-condensed" name="reginTable">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th style="width:30px;"><input type="checkbox" id="checkAll"/>全选</th>
|
||||||
<th style="width:60px;">类型</th>
|
<th style="width:60px;">类型</th>
|
||||||
<th style="width:50px;">区域</th>
|
<th style="width:50px;">区域</th>
|
||||||
<th style="width:130px;">小区名</th>
|
<th style="width:130px;">小区名</th>
|
||||||
@@ -142,6 +146,7 @@
|
|||||||
<#if seawaterList??>
|
<#if seawaterList??>
|
||||||
<#list seawaterList as it>
|
<#list seawaterList as it>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><input type="checkbox" name="houseCheck" value="${it.id}"/></td>
|
||||||
<td>
|
<td>
|
||||||
<#if it.category! == 'sell'>
|
<#if it.category! == 'sell'>
|
||||||
二手房
|
二手房
|
||||||
@@ -249,7 +254,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
changeCity('${cityDisplay!}');
|
changeCity('${cityDisplay!}');
|
||||||
|
|
||||||
$(".hrefClick").click(function(){
|
$(".hrefClick").click(function(){
|
||||||
@@ -336,8 +341,48 @@
|
|||||||
$("#roomSpan").hide();
|
$("#roomSpan").hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 全选
|
||||||
|
$("#checkAll").click(function(){
|
||||||
|
$('input[name="houseCheck"]').each(function() {
|
||||||
|
var _this = this
|
||||||
|
if (_this.checked == true) {
|
||||||
|
_this.checked = false
|
||||||
|
} else {
|
||||||
|
_this.checked = true
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
$("#batchDelete").click(function(){
|
||||||
|
if(confirm('确认要删除所选的数据吗?')) {
|
||||||
|
var ids = "";
|
||||||
|
$('input:checkbox[name=houseCheck]:checked').each(function() {
|
||||||
|
var _this = $(this);
|
||||||
|
ids += _this.val() + ","
|
||||||
|
});
|
||||||
|
if (ids == "") {
|
||||||
|
alert("请选择数据")
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
jQuery.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '../seawater/batchDelete',
|
||||||
|
data:{ids:ids},
|
||||||
|
dataType: 'json',
|
||||||
|
timeout: 100000,
|
||||||
|
success: function(model) {
|
||||||
|
alert("批量删除操作成功");
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
error : function() {
|
||||||
|
//alert("操作失败");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
</#compress>
|
</#compress>
|
||||||
@@ -205,7 +205,6 @@ public abstract class ElasticDaoImpl<E extends MongoEntity> extends AbstractJpaC
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteByIds(List<String> idList) {
|
public void deleteByIds(List<String> idList) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ public interface SeawaterDao extends com.fangjia.dal.SeawaterDao<Seawater> {
|
|||||||
|
|
||||||
Seawater findByIdFromEs(String id,String table);
|
Seawater findByIdFromEs(String id,String table);
|
||||||
|
|
||||||
|
|
||||||
List<Seawater> findSeawatersFromEs(String category, String city, String region, String name, List<String> alias, List<String> regionAlias, Integer startDate, Integer endDate,
|
List<Seawater> findSeawatersFromEs(String category, String city, String region, String name, List<String> alias, List<String> regionAlias, Integer startDate, Integer endDate,
|
||||||
Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit , String table);
|
Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit , String table);
|
||||||
|
|
||||||
List<Seawater> findHouses(String city, String region, List<String> alias, Integer minPrice, Integer maxPrice, Integer limit);
|
List<Seawater> findHouses(String city, String region, List<String> alias, Integer minPrice, Integer maxPrice, Integer limit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,44 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
|||||||
return new ArrayList<Seawater>();
|
return new ArrayList<Seawater>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteById(String id) {
|
||||||
|
deleteByIds(Arrays.asList(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> buildHeader() {
|
||||||
|
Base64 token = new Base64();
|
||||||
|
String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes());
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("Content-Type", "application/json");
|
||||||
|
headers.put("Authorization", "Basic " + authenticationEncoding + "");
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByIds(List<String> idList) {
|
||||||
|
HttpRequest request = new HttpRequest();
|
||||||
|
|
||||||
|
JSONObject reqBody = new JSONObject();
|
||||||
|
JSONObject query = new JSONObject();
|
||||||
|
JSONObject bool = new JSONObject();
|
||||||
|
JSONArray must = new JSONArray();
|
||||||
|
must.add(addTerms("_id", idList));
|
||||||
|
bool.put("must", must);
|
||||||
|
query.put("bool", bool);
|
||||||
|
reqBody.put("query", query);
|
||||||
|
|
||||||
|
JSONObject script = new JSONObject();
|
||||||
|
script.put("source", "ctx._source.status=1");
|
||||||
|
reqBody.put("script", script);
|
||||||
|
|
||||||
|
try {
|
||||||
|
request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query", reqBody, this.buildHeader(), "UTF-8");
|
||||||
|
} catch (HttpRequestException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private JSONObject addMatch(String name, String value){
|
private JSONObject addMatch(String name, String value){
|
||||||
JSONObject term = new JSONObject();
|
JSONObject term = new JSONObject();
|
||||||
JSONObject match = new JSONObject();
|
JSONObject match = new JSONObject();
|
||||||
@@ -338,6 +376,14 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
|||||||
if(limit >= 0){
|
if(limit >= 0){
|
||||||
reqBody.put("size", limit);
|
reqBody.put("size", limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ²»Õ¹Ê¾É¾³ý
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
param.put("status", 0);
|
||||||
|
JSONObject temp = new JSONObject();
|
||||||
|
temp.put("term", param);
|
||||||
|
jsonList.add(temp);
|
||||||
|
|
||||||
query.put("must", jsonList);
|
query.put("must", jsonList);
|
||||||
q.put("bool", query);
|
q.put("bool", query);
|
||||||
reqBody.put("query", q);
|
reqBody.put("query", q);
|
||||||
|
|||||||
+6
-1
@@ -31,10 +31,15 @@ public interface SeawaterService {
|
|||||||
|
|
||||||
void deleteById(String id);
|
void deleteById(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除,英文逗号分割,如1,2,3
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
void deleteByIds(String ids);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
List<Seawater> findAllSeawater(String category, String city, String name, String region, Integer room, String root, String sort, Integer startDate, Integer endDate, int start, int limit, boolean order, String[] fields);
|
List<Seawater> findAllSeawater(String category, String city, String name, String region, Integer room, String root, String sort, Integer startDate, Integer endDate, int start, int limit, boolean order, String[] fields);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
int findAllSeawaterCount(String category, String city, String name, String region, Integer room, String root, Integer startDate, Integer endDate);
|
int findAllSeawaterCount(String category, String city, String name, String region, Integer room, String root, Integer startDate, Integer endDate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-4
@@ -12,10 +12,7 @@ import org.apache.lucene.search.BooleanQuery;
|
|||||||
import org.apache.lucene.search.TermQuery;
|
import org.apache.lucene.search.TermQuery;
|
||||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
import org.apache.solr.client.solrj.util.ClientUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SeawaterServiceImpl implements SeawaterService {
|
public class SeawaterServiceImpl implements SeawaterService {
|
||||||
private SeawaterDao seawaterDao;
|
private SeawaterDao seawaterDao;
|
||||||
@@ -188,6 +185,12 @@ public class SeawaterServiceImpl implements SeawaterService {
|
|||||||
seawaterDao.deleteById(id);
|
seawaterDao.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByIds(String ids) {
|
||||||
|
String[] idArr = ids.split(",");
|
||||||
|
seawaterDao.deleteByIds(Arrays.asList(idArr));
|
||||||
|
}
|
||||||
|
|
||||||
public void setSeawaterDao(SeawaterDao seawaterDao) {
|
public void setSeawaterDao(SeawaterDao seawaterDao) {
|
||||||
this.seawaterDao = seawaterDao;
|
this.seawaterDao = seawaterDao;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.sothis</groupId>
|
<groupId>org.sothis</groupId>
|
||||||
<artifactId>sothis-core</artifactId>
|
<artifactId>sothis-core</artifactId>
|
||||||
<version>0.2.0-SNAPSHOT</version>
|
<version>0.2.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.poseidon</groupId>
|
<groupId>com.poseidon</groupId>
|
||||||
<artifactId>poseidon-message</artifactId>
|
<artifactId>poseidon-message</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
|
|||||||
Reference in New Issue
Block a user