xiewenjie 3 vuotta sitten
vanhempi
commit
769accfc47

+ 1 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IRenovationPartsAttachingService.java

@@ -9,6 +9,7 @@ import com.fdkk.sxz.vo.response.ResponseRenovationPartsAttaching;
  * Created by Hb_zzZ on 2020/8/11.
  */
 public interface IRenovationPartsAttachingService extends IBaseService<RenovationPartsAttachingEntity> {
+    RenovationPartsAttachingEntity findById(Long id);
 
     ResponseRenovationPartsAttaching findAttachinByDetailId(Long id);
 

+ 25 - 6
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/RenovationPartsAttachingServiceImpl.java

@@ -25,6 +25,21 @@ public class RenovationPartsAttachingServiceImpl extends BaseServiceImpl<IRenova
     private String region = "PartsAttachingEntity";
 
     @Override
+    public RenovationPartsAttachingEntity findById(Long id) {
+        RenovationPartsAttachingEntity entity = null;
+        if (cacheChannel.exists(region, "id::" + id)) {
+            CacheObject cache = cacheChannel.get(region, "id::" + id);
+            entity = BeanUtil.toBean(cache.getValue(), RenovationPartsAttachingEntity.class);
+        } else {
+            entity = super.findById(id);
+            if (ObjectUtil.isNotNull(entity)) {
+                cacheChannel.set(region, "id::" + entity.getId(), entity, 60 * 30);
+            }
+        }
+        return entity;
+    }
+
+    @Override
     public ResponseRenovationPartsAttaching findAttachinByDetailId(Long id) {
         ResponseRenovationPartsAttaching entity = null;
         if (cacheChannel.exists(region, "responseId::" + id)) {
@@ -33,7 +48,7 @@ public class RenovationPartsAttachingServiceImpl extends BaseServiceImpl<IRenova
         } else {
             entity = getBaseMapper().findAttachinByDetailId(id);
             if (ObjectUtil.isNotNull(entity)) {
-                cacheChannel.set(region, "responseId::" + entity.getId(), entity, 60 * 30);
+                cacheChannel.set(region, "responseId::" + id, entity, 60 * 30);
             }
         }
         return entity;
@@ -48,7 +63,7 @@ public class RenovationPartsAttachingServiceImpl extends BaseServiceImpl<IRenova
         } else {
             entity = getBaseMapper().findByDetailId(id);
             if (ObjectUtil.isNotNull(entity)) {
-                cacheChannel.set(region, "detailId::" + entity.getId(), entity, 60 * 30);
+                cacheChannel.set(region, "detailId::" + id, entity, 60 * 30);
             }
         }
         return entity;
@@ -58,17 +73,21 @@ public class RenovationPartsAttachingServiceImpl extends BaseServiceImpl<IRenova
     public boolean updateById(RenovationPartsAttachingEntity entity) {
         boolean updateById = super.updateById(entity);
         if (updateById) {
-            cacheChannel.set(region, "detailId::" + entity.getId(), entity, 60 * 30);
+            cacheChannel.evict(region, "responseId::" + entity.getPartsDetailId());
+            cacheChannel.set(region, "detailId::" + entity.getPartsDetailId(), entity, 60 * 30);
+            cacheChannel.set(region, "id::" + entity.getId(), entity, 60 * 30);
         }
         return updateById;
     }
 
     @Override
     public boolean removeById(Long id) {
+        RenovationPartsAttachingEntity entity = super.findById(id);
         boolean removeById = super.removeById(id);
-        if (removeById) {
-            cacheChannel.evict(region, "responseId::" + id);
-            cacheChannel.evict(region, "detailId::" + id);
+        if (ObjectUtil.isNotNull(entity) && removeById) {
+            cacheChannel.evict(region, "responseId::" + entity.getPartsDetailId());
+            cacheChannel.evict(region, "detailId::" + entity.getPartsDetailId());
+            cacheChannel.evict(region, "id::" + entity.getPartsDetailId());
         }
         return removeById;
     }

+ 5 - 4
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/RenovationPartsSizeServiceImpl.java

@@ -28,7 +28,7 @@ public class RenovationPartsSizeServiceImpl extends BaseServiceImpl<IRenovationP
     public ResponseRenovationPartsSize findSizeByDetailId(Long id) {
         ResponseRenovationPartsSize entity = getBaseMapper().findSizeByDetailId(id);
         if (ObjectUtil.isNotNull(entity)) {
-            cacheChannel.set("ResponseRenovationPartsSize", "id::" + entity.getId(), entity, 60 * 30);
+            cacheChannel.set(region, "responseId::" + entity.getId(), entity, 60 * 30);
         }
         return entity;
     }
@@ -52,7 +52,7 @@ public class RenovationPartsSizeServiceImpl extends BaseServiceImpl<IRenovationP
     public boolean updateById(RenovationPartsSizeEntity entity) {
         boolean updateById = super.updateById(entity);
         if (updateById) {
-            cacheChannel.evict(region, "responseId::" + entity.getId());
+            cacheChannel.evict(region, "responseId::" + entity.getPartsDetailId());
             cacheChannel.set(region, "id::" + entity.getId(), entity, 60 * 30);
         }
         return updateById;
@@ -60,9 +60,10 @@ public class RenovationPartsSizeServiceImpl extends BaseServiceImpl<IRenovationP
 
     @Override
     public boolean removeById(Long id) {
+        RenovationPartsSizeEntity byId = findById(id);
         boolean removeById = super.removeById(id);
-        if (removeById) {
-            cacheChannel.evict(region, "responseId::" + id);
+        if (ObjectUtil.isNotNull(byId) && removeById) {
+            cacheChannel.evict(region, "responseId::" + byId.getPartsDetailId());
             cacheChannel.evict(region, "id::" + id);
         }
         return removeById;