|
|
@@ -77,10 +77,6 @@ public class QueueMessageParser {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- if (object == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
parsedQueueMessage.setObject(object);
|
|
|
return parsedQueueMessage;
|
|
|
}
|
|
|
@@ -94,14 +90,19 @@ public class QueueMessageParser {
|
|
|
*/
|
|
|
// {"method":"value1","table":"product$kind","ki_id":5}
|
|
|
private KindSimpleInfo parseKind(JSONObject jsonObject) throws JSONException {
|
|
|
- KindSimpleInfo kind = new KindSimpleInfo();
|
|
|
Long kindid = jsonObject.getLong("ki_id");
|
|
|
- kind.setId(kindid);
|
|
|
-
|
|
|
- KindSimpleInfo temp = kindDao.findById(kindid);
|
|
|
- // 如果更改是删除的话,根据id获取到的对象为null
|
|
|
- if (temp != null) {
|
|
|
- kind = temp;
|
|
|
+ KindSimpleInfo kind = kindDao.findById(kindid);
|
|
|
+ // 对删除操作的事务回退进行处理
|
|
|
+ // (新增操作回退的话,返回的是null,并不影响索引;
|
|
|
+ // 更新回退的话,数据与先前一样,这时更新索引,索引数据并不变)
|
|
|
+ if (jsonObject.getString("method").equals("delete")) {
|
|
|
+ // 数据库中该类目仍存在,认为事务回退,不删除索引
|
|
|
+ if (kind != null) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ kind = new KindSimpleInfo();
|
|
|
+ kind.setId(kindid);
|
|
|
+ }
|
|
|
}
|
|
|
return kind;
|
|
|
}
|
|
|
@@ -115,13 +116,15 @@ public class QueueMessageParser {
|
|
|
*/
|
|
|
// {"method":"value1","table":"product$brand","br_id":60}
|
|
|
private BrandSimpleInfo parseBrand(JSONObject jsonObject) throws JSONException {
|
|
|
- BrandSimpleInfo brand = new BrandSimpleInfo();
|
|
|
Long brandid = jsonObject.getLong("br_id");
|
|
|
- brand.setId(brandid);
|
|
|
-
|
|
|
- BrandSimpleInfo temp = brandDao.findById(brandid);
|
|
|
- if (temp != null) {
|
|
|
- brand = temp;
|
|
|
+ BrandSimpleInfo brand = brandDao.findById(brandid);
|
|
|
+ if (jsonObject.getString("method").equals("delete")) {
|
|
|
+ if (brand != null) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ brand = new BrandSimpleInfo();
|
|
|
+ brand.setId(brandid);
|
|
|
+ }
|
|
|
}
|
|
|
return brand;
|
|
|
}
|
|
|
@@ -135,13 +138,15 @@ public class QueueMessageParser {
|
|
|
*/
|
|
|
// {"method":"value1","table":"product$component","cmp_id":2029}
|
|
|
private ComponentSimpleInfo parseComponent(JSONObject jsonObject) throws JSONException {
|
|
|
- ComponentSimpleInfo component = new ComponentSimpleInfo();
|
|
|
Long componentid = jsonObject.getLong("cmp_id");
|
|
|
- component.setId(componentid);
|
|
|
-
|
|
|
- ComponentSimpleInfo temp = componentDao.findById(componentid);
|
|
|
- if (temp != null) {
|
|
|
- component = temp;
|
|
|
+ ComponentSimpleInfo component = componentDao.findById(componentid);
|
|
|
+ if (jsonObject.getString("method").equals("delete")) {
|
|
|
+ if (component != null) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ component = new ComponentSimpleInfo();
|
|
|
+ component.setId(componentid);
|
|
|
+ }
|
|
|
}
|
|
|
return component;
|
|
|
}
|