Ver código fonte

优化接口

xiewenjie 3 anos atrás
pai
commit
7bca5c5cbf

+ 6 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IRenovationPartsBrandService.java

@@ -7,4 +7,10 @@ import com.fdkk.sxz.entity.RenovationPartsBrandEntity;
  * Created by Hb_zzZ on 2020/12/24.
  */
 public interface IRenovationPartsBrandService extends IBaseService<RenovationPartsBrandEntity> {
+    RenovationPartsBrandEntity findById(Long id);
+
+    @Override
+    boolean updateById(RenovationPartsBrandEntity entity);
+
+    boolean removeById(Long id);
 }

+ 7 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IRenovationPartsService.java

@@ -13,4 +13,11 @@ import java.util.List;
 public interface IRenovationPartsService extends IBaseService<RenovationPartsEntity> {
 
     List<ResponseRenovationParts> getRenovationPartsList();
+    
+    RenovationPartsEntity findById(Long id);
+
+    @Override
+    boolean updateById(RenovationPartsEntity entity);
+
+    boolean removeById(Long id);
 }

+ 7 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IRenovationPartsSizeService.java

@@ -10,4 +10,11 @@ import com.fdkk.sxz.vo.response.ResponseRenovationPartsSize;
 public interface IRenovationPartsSizeService extends IBaseService<RenovationPartsSizeEntity> {
 
     ResponseRenovationPartsSize findSizeByDetailId(Long id);
+
+    RenovationPartsSizeEntity findById(Long id);
+
+    @Override
+    boolean updateById(RenovationPartsSizeEntity entity);
+
+    boolean removeById(Long id);
 }

+ 7 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IRenovationPartsTypeService.java

@@ -12,4 +12,11 @@ import java.util.List;
 public interface IRenovationPartsTypeService extends IBaseService<RenovationPartsTypeEntity> {
 
     List<ResponseRenovationPartsType> findTypeByPartsId(Long id);
+
+    RenovationPartsTypeEntity findById(Long id);
+
+    @Override
+    boolean updateById(RenovationPartsTypeEntity entity);
+
+    boolean removeById(Long id);
 }

+ 4 - 7
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/RenovationPartsAttachingServiceImpl.java

@@ -17,24 +17,21 @@ import org.springframework.transaction.annotation.Transactional;
 @Service
 @Transactional
 public class RenovationPartsAttachingServiceImpl extends BaseServiceImpl<IRenovationPartsAttachingMapper, RenovationPartsAttachingEntity> implements IRenovationPartsAttachingService {
-
-    @Autowired
-    private IRenovationPartsAttachingMapper mapper;
     @Autowired
     private CacheChannel cacheChannel;
 
     @Override
     public ResponseRenovationPartsAttaching findAttachinByDetailId(Long id) {
-        ResponseRenovationPartsAttaching entity = mapper.findAttachinByDetailId(id);
+        ResponseRenovationPartsAttaching entity = getBaseMapper().findAttachinByDetailId(id);
         if (ObjectUtil.isNotNull(entity)) {
-            cacheChannel.set("PartsAttachingResponse", "id::" + entity.getId(), entity, 60 * 30);
+            cacheChannel.set("ResponseRenovationPartsAttaching", "id::" + entity.getId(), entity, 60 * 30);
         }
         return entity;
     }
 
     @Override
     public RenovationPartsAttachingEntity findByDetailId(Long id) {
-        RenovationPartsAttachingEntity entity = mapper.findByDetailId(id);
+        RenovationPartsAttachingEntity entity = getBaseMapper().findByDetailId(id);
         if (ObjectUtil.isNotNull(id)) {
             cacheChannel.set("PartsAttachingEntity", "id::" + entity.getId(), entity, 60 * 30);
         }
@@ -54,7 +51,7 @@ public class RenovationPartsAttachingServiceImpl extends BaseServiceImpl<IRenova
     public boolean removeById(Long id) {
         boolean removeById = super.removeById(id);
         if (removeById) {
-            cacheChannel.evict("PartsAttachingResponse", "id::" + id);
+            cacheChannel.evict("ResponseRenovationPartsAttaching", "id::" + id);
             cacheChannel.evict("PartsAttachingEntity", "id::" + id);
         }
         return removeById;

+ 31 - 3
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/RenovationPartsBrandServiceImpl.java

@@ -1,9 +1,11 @@
 package com.fdkk.sxz.webApi.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
 import com.fdkk.sxz.entity.RenovationPartsBrandEntity;
 import com.fdkk.sxz.webApi.mapper.IRenovationPartsBrandMapper;
 import com.fdkk.sxz.webApi.service.IRenovationPartsBrandService;
+import net.oschina.j2cache.CacheChannel;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -11,9 +13,35 @@ import org.springframework.stereotype.Service;
  * Created by Hb_zzZ on 2020/12/24.
  */
 @Service
-public class RenovationPartsBrandServiceImpl extends BaseServiceImpl<IRenovationPartsBrandMapper , RenovationPartsBrandEntity> implements IRenovationPartsBrandService {
-
+public class RenovationPartsBrandServiceImpl extends BaseServiceImpl<IRenovationPartsBrandMapper, RenovationPartsBrandEntity> implements IRenovationPartsBrandService {
     @Autowired
-    private IRenovationPartsBrandMapper renovationPartsBrandMapper;
+    private CacheChannel cacheChannel;
+    
+    @Override
+    public RenovationPartsBrandEntity findById(Long id) {
+        RenovationPartsBrandEntity entity = super.findById(id);
+        if (ObjectUtil.isNotNull(entity)) {
+            cacheChannel.set("RenovationPartsBrandEntity", "id::" + entity.getId(), entity, 60 * 30);
+        }
+        return entity;
+    }
+
+    @Override
+    public boolean updateById(RenovationPartsBrandEntity entity) {
+        boolean updateById = super.updateById(entity);
+        if (updateById) {
+            cacheChannel.set("RenovationPartsBrandEntity", "id::" + entity.getId(), entity, 60 * 30);
+        }
+        return updateById;
+    }
+
+    @Override
+    public boolean removeById(Long id) {
+        boolean removeById = super.removeById(id);
+        if (removeById) {
+            cacheChannel.evict("RenovationPartsBrandEntity", "id::" + id);
+        }
+        return removeById;
+    }
 
 }

+ 33 - 5
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/RenovationPartsServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fdkk.sxz.webApi.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
 import com.fdkk.sxz.entity.RenovationPartsEntity;
 import com.fdkk.sxz.vo.response.ResponseRenovationParts;
@@ -8,6 +9,7 @@ import com.fdkk.sxz.vo.response.ResponseRenovationPartsType;
 import com.fdkk.sxz.webApi.mapper.*;
 import com.fdkk.sxz.webApi.service.IRenovationPartsService;
 import lombok.extern.slf4j.Slf4j;
+import net.oschina.j2cache.CacheChannel;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -22,9 +24,9 @@ import java.util.List;
 @Slf4j
 @Transactional
 public class RenovationPartsServiceImpl extends BaseServiceImpl<IRenovationPartsMapper, RenovationPartsEntity> implements IRenovationPartsService {
-
     @Autowired
-    private IRenovationPartsMapper mapper;
+    private CacheChannel cacheChannel;
+
 
     @Autowired
     private IRenovationPartsDetailMapper renovationPartsDetailMapper;
@@ -38,21 +40,47 @@ public class RenovationPartsServiceImpl extends BaseServiceImpl<IRenovationParts
     @Autowired
     private IRenovationPartsSizeMapper renovationPartsSizeMapper;
 
+    @Override
+    public RenovationPartsEntity findById(Long id) {
+        RenovationPartsEntity entity = super.findById(id);
+        if (ObjectUtil.isNotNull(entity)) {
+            cacheChannel.set("RenovationPartsEntity", "id::" + entity.getId(), entity, 60 * 30);
+        }
+        return entity;
+    }
+
+    @Override
+    public boolean updateById(RenovationPartsEntity entity) {
+        boolean updateById = super.updateById(entity);
+        if (updateById) {
+            cacheChannel.set("RenovationPartsEntity", "id::" + entity.getId(), entity, 60 * 30);
+        }
+        return updateById;
+    }
+
+    @Override
+    public boolean removeById(Long id) {
+        boolean removeById = super.removeById(id);
+        if (removeById) {
+            cacheChannel.evict("RenovationPartsEntity", "id::" + id);
+        }
+        return removeById;
+    }
 
     @Override
     public List<ResponseRenovationParts> getRenovationPartsList() {
-        List<ResponseRenovationParts> result = mapper.findParts();
+        List<ResponseRenovationParts> result = getBaseMapper().findParts();
 
         List<ResponseRenovationPartsType> typeList = null;
 
         List<String> keys = null;
-        for(ResponseRenovationParts parts : result){
+        for (ResponseRenovationParts parts : result) {
 
             typeList = renovationPartsTypeMapper.findTypeByPartsId(parts.getId());
             parts.setChildrens(typeList);
 
             keys = new ArrayList<>();
-            for(ResponseRenovationPartsType type : typeList){
+            for (ResponseRenovationPartsType type : typeList) {
                 keys.add(type.getKeyWord());
                 List<ResponseRenovationPartsDetail> detailList = renovationPartsDetailMapper.findDetailByTypeId(type.getId(), null, null);
                 type.setChildrens(detailList);

+ 39 - 6
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/RenovationPartsSizeServiceImpl.java

@@ -1,12 +1,13 @@
 package com.fdkk.sxz.webApi.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
 import com.fdkk.sxz.entity.RenovationPartsSizeEntity;
+import com.fdkk.sxz.vo.response.ResponseRenovationPartsSize;
 import com.fdkk.sxz.webApi.mapper.IRenovationPartsSizeMapper;
 import com.fdkk.sxz.webApi.service.IRenovationPartsSizeService;
-import com.fdkk.sxz.vo.response.ResponseRenovationPartsSize;
+import net.oschina.j2cache.CacheChannel;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -15,14 +16,46 @@ import org.springframework.transaction.annotation.Transactional;
  */
 @Service
 @Transactional
-public class RenovationPartsSizeServiceImpl extends BaseServiceImpl<IRenovationPartsSizeMapper , RenovationPartsSizeEntity> implements IRenovationPartsSizeService{
-
+public class RenovationPartsSizeServiceImpl extends BaseServiceImpl<IRenovationPartsSizeMapper, RenovationPartsSizeEntity> implements IRenovationPartsSizeService {
     @Autowired
-    private IRenovationPartsSizeMapper mapper;
+    private CacheChannel cacheChannel;
 
 
     @Override
     public ResponseRenovationPartsSize findSizeByDetailId(Long id) {
-        return mapper.findSizeByDetailId(id);
+        ResponseRenovationPartsSize entity = getBaseMapper().findSizeByDetailId(id);
+        if (ObjectUtil.isNotNull(entity)) {
+            cacheChannel.set("ResponseRenovationPartsSize", "id::" + entity.getId(), entity, 60 * 30);
+        }
+        return entity;
+    }
+
+    @Override
+    public RenovationPartsSizeEntity findById(Long id) {
+        RenovationPartsSizeEntity entity = super.findById(id);
+        if (ObjectUtil.isNotNull(entity)) {
+            cacheChannel.set("RenovationPartsSizeEntity", "id::" + entity.getId(), entity, 60 * 30);
+        }
+        return entity;
+    }
+
+    @Override
+    public boolean updateById(RenovationPartsSizeEntity entity) {
+        boolean updateById = super.updateById(entity);
+        if (updateById) {
+            cacheChannel.evict("ResponseRenovationPartsSize", "id::" + entity.getId());
+            cacheChannel.set("RenovationPartsSizeEntity", "id::" + entity.getId(), entity, 60 * 30);
+        }
+        return updateById;
+    }
+
+    @Override
+    public boolean removeById(Long id) {
+        boolean removeById = super.removeById(id);
+        if (removeById) {
+            cacheChannel.evict("ResponseRenovationPartsSize", "id::" + id);
+            cacheChannel.evict("RenovationPartsSizeEntity", "id::" + id);
+        }
+        return removeById;
     }
 }

+ 33 - 5
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/RenovationPartsTypeServiceImpl.java

@@ -1,10 +1,12 @@
 package com.fdkk.sxz.webApi.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
 import com.fdkk.sxz.entity.RenovationPartsTypeEntity;
+import com.fdkk.sxz.vo.response.ResponseRenovationPartsType;
 import com.fdkk.sxz.webApi.mapper.IRenovationPartsTypeMapper;
 import com.fdkk.sxz.webApi.service.IRenovationPartsTypeService;
-import com.fdkk.sxz.vo.response.ResponseRenovationPartsType;
+import net.oschina.j2cache.CacheChannel;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -16,14 +18,40 @@ import java.util.List;
  */
 @Service
 @Transactional
-public class RenovationPartsTypeServiceImpl extends BaseServiceImpl<IRenovationPartsTypeMapper , RenovationPartsTypeEntity> implements IRenovationPartsTypeService {
+public class RenovationPartsTypeServiceImpl extends BaseServiceImpl<IRenovationPartsTypeMapper, RenovationPartsTypeEntity> implements IRenovationPartsTypeService {
 
     @Autowired
-    private IRenovationPartsTypeMapper mapper;
-
+    private CacheChannel cacheChannel;
 
     @Override
     public List<ResponseRenovationPartsType> findTypeByPartsId(Long id) {
-        return mapper.findTypeByPartsId(id);
+        return getBaseMapper().findTypeByPartsId(id);
+    }
+
+    @Override
+    public RenovationPartsTypeEntity findById(Long id) {
+        RenovationPartsTypeEntity entity = super.findById(id);
+        if (ObjectUtil.isNotNull(entity)) {
+            cacheChannel.set("RenovationPartsTypeEntity", "id::" + entity.getId(), entity, 60 * 30);
+        }
+        return entity;
+    }
+
+    @Override
+    public boolean updateById(RenovationPartsTypeEntity entity) {
+        boolean updateById = super.updateById(entity);
+        if (updateById) {
+            cacheChannel.set("RenovationPartsTypeEntity", "id::" + entity.getId(), entity, 60 * 30);
+        }
+        return updateById;
+    }
+
+    @Override
+    public boolean removeById(Long id) {
+        boolean removeById = super.removeById(id);
+        if (removeById) {
+            cacheChannel.evict("RenovationPartsTypeEntity", "id::" + id);
+        }
+        return removeById;
     }
 }