|
@@ -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);
|