Authored by peuei

fix 公共库将文章表改为逻辑删除

1 package com.yoho.datasync.consumer.handler.listener; 1 package com.yoho.datasync.consumer.handler.listener;
2 2
3 -import com.yoho.datasync.consumer.common.ContentConvertUtil;  
4 import com.yoho.datasync.consumer.common.EventEnum; 3 import com.yoho.datasync.consumer.common.EventEnum;
5 import com.yoho.datasync.consumer.handler.helper.AnnotationClassFactory; 4 import com.yoho.datasync.consumer.handler.helper.AnnotationClassFactory;
6 import com.yoho.datasync.consumer.handler.mqcomponent.AbstractMqListener; 5 import com.yoho.datasync.consumer.handler.mqcomponent.AbstractMqListener;
@@ -16,7 +15,6 @@ import org.slf4j.LoggerFactory; @@ -16,7 +15,6 @@ import org.slf4j.LoggerFactory;
16 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
17 16
18 import javax.annotation.Resource; 17 import javax.annotation.Resource;
19 -import java.util.Map;  
20 18
21 /*** 19 /***
22 * @author peuei 20 * @author peuei
1 package com.yoho.datasync.consumer.service; 1 package com.yoho.datasync.consumer.service;
2 2
3 import com.yoho.datasync.consumer.common.BeanCopyUtils; 3 import com.yoho.datasync.consumer.common.BeanCopyUtils;
4 -import com.yoho.datasync.consumer.common.ContentConvertUtil;  
5 import com.yoho.datasync.consumer.common.ServiceConstant; 4 import com.yoho.datasync.consumer.common.ServiceConstant;
6 import com.yoho.datasync.consumer.dal.repository.PublicArticleBlockRepository; 5 import com.yoho.datasync.consumer.dal.repository.PublicArticleBlockRepository;
7 import com.yoho.datasync.consumer.dal.repository.PublicArticleRepository; 6 import com.yoho.datasync.consumer.dal.repository.PublicArticleRepository;
@@ -11,7 +10,6 @@ import org.slf4j.LoggerFactory; @@ -11,7 +10,6 @@ import org.slf4j.LoggerFactory;
11 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
12 11
13 import javax.annotation.Resource; 12 import javax.annotation.Resource;
14 -import java.util.Map;  
15 13
16 @Service 14 @Service
17 public class PublicArticleBlockService { 15 public class PublicArticleBlockService {
@@ -64,7 +62,7 @@ public class PublicArticleBlockService { @@ -64,7 +62,7 @@ public class PublicArticleBlockService {
64 findByArticleIdAndCreateTimeAndOrderBy(targetObject.getArticleId(), targetObject.getCreateTime(), targetObject.getOrderBy()); 62 findByArticleIdAndCreateTimeAndOrderBy(targetObject.getArticleId(), targetObject.getCreateTime(), targetObject.getOrderBy());
65 if (flag) { 63 if (flag) {
66 if (existObject == null) { 64 if (existObject == null) {
67 - log.error("something goes wrong ... data is null..."); 65 + log.error("something goes wrong ... data is null... with param {}", targetObject.toString());
68 return; 66 return;
69 } 67 }
70 publicArticleBlockRepository.deleteById(existObject.getId()); 68 publicArticleBlockRepository.deleteById(existObject.getId());
@@ -48,7 +48,7 @@ public class PublicArticleLabelService { @@ -48,7 +48,7 @@ public class PublicArticleLabelService {
48 public void updateData(PublicArticleLabel targetObject) { 48 public void updateData(PublicArticleLabel targetObject) {
49 final PublicArticleLabel existObject = publicArticleLabelRepository.findByLabelIdAndArticleId(targetObject.getLabelId(), targetObject.getArticleId()); 49 final PublicArticleLabel existObject = publicArticleLabelRepository.findByLabelIdAndArticleId(targetObject.getLabelId(), targetObject.getArticleId());
50 if (existObject != null) { 50 if (existObject != null) {
51 - log.error("something goes wrong, in this operation, there's no update , just only insert , with param {}", targetObject); 51 + log.error("something goes wrong, in this operation, there's no update , just only insert , with param {}", targetObject.toString());
52 return; 52 return;
53 } 53 }
54 publicArticleLabelRepository.save(targetObject); 54 publicArticleLabelRepository.save(targetObject);
@@ -55,7 +55,7 @@ public class PublicArticleProductService { @@ -55,7 +55,7 @@ public class PublicArticleProductService {
55 final PublicArticleProduct existObject = publicArticleProductRepository. 55 final PublicArticleProduct existObject = publicArticleProductRepository.
56 findByArticleIdAndProductSknAndCreateTimeAndOrderBy(targetObject.getArticleId(), targetObject.getProductSkn(), targetObject.getCreateTime(), targetObject.getOrderBy()); 56 findByArticleIdAndProductSknAndCreateTimeAndOrderBy(targetObject.getArticleId(), targetObject.getProductSkn(), targetObject.getCreateTime(), targetObject.getOrderBy());
57 if (existObject == null) { 57 if (existObject == null) {
58 - log.error("something goes wrong ... data is null"); 58 + log.error("something goes wrong ... data is null , with param {}", targetObject.toString());
59 return; 59 return;
60 } 60 }
61 publicArticleProductRepository.deleteById(existObject.getId()); 61 publicArticleProductRepository.deleteById(existObject.getId());
@@ -25,6 +25,8 @@ public class PublicArticleService { @@ -25,6 +25,8 @@ public class PublicArticleService {
25 @Resource 25 @Resource
26 private PublicArticleAuditRepository publicArticleAuditRepository; 26 private PublicArticleAuditRepository publicArticleAuditRepository;
27 27
  28 + private static final Integer DELETE = 2;
  29 +
28 /** 30 /**
29 * 删除数据 31 * 删除数据
30 * 32 *
@@ -36,7 +38,12 @@ public class PublicArticleService { @@ -36,7 +38,12 @@ public class PublicArticleService {
36 log.info("get nothing from database by condition relateId and articleType with targetObject {}", targetObject.toString()); 38 log.info("get nothing from database by condition relateId and articleType with targetObject {}", targetObject.toString());
37 return; 39 return;
38 } 40 }
39 - publicArticleRepository.deleteById(existObject.getId()); 41 + existObject.setStatus(DELETE);
  42 + /**
  43 + * 2019.4.4 将文章表改为逻辑删除
  44 + */
  45 + publicArticleRepository.save(existObject);
  46 + // publicArticleRepository.deleteById(existObject.getId());
40 } 47 }
41 48
42 49
@@ -54,6 +61,7 @@ public class PublicArticleService { @@ -54,6 +61,7 @@ public class PublicArticleService {
54 boolean mark = true; 61 boolean mark = true;
55 PublicArticle saveObject; 62 PublicArticle saveObject;
56 if (existObject != null) { 63 if (existObject != null) {
  64 + // update
57 mark = false; 65 mark = false;
58 targetObject.setCoverImg((String) checkResult); 66 targetObject.setCoverImg((String) checkResult);
59 if (targetObject.getId() != null) { 67 if (targetObject.getId() != null) {
@@ -71,6 +79,7 @@ public class PublicArticleService { @@ -71,6 +79,7 @@ public class PublicArticleService {
71 publicArticleAuditHandler(publicArticleAudit, existObject); 79 publicArticleAuditHandler(publicArticleAudit, existObject);
72 saveObject = publicArticleRepository.save(existObject); 80 saveObject = publicArticleRepository.save(existObject);
73 } else { 81 } else {
  82 + // insert
74 saveObject = publicArticleRepository.save(targetObject); 83 saveObject = publicArticleRepository.save(targetObject);
75 } 84 }
76 if (mark) { 85 if (mark) {