2 changed files with 33 additions and 1 deletions
@ -1,20 +1,42 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import com.epmet.dao.CustomerThirdplatApiserviceDao; |
|||
import com.epmet.dto.result.ThirdplatApiserviceResultDTO; |
|||
import com.epmet.entity.CustomerThirdplatApiserviceEntity; |
|||
import com.epmet.service.CustomerThirdplatApiServiceService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class CustomerThirdplatApiServiceServiceImpl implements CustomerThirdplatApiServiceService { |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
@Autowired |
|||
private CustomerThirdplatApiserviceDao thirdplatApiserviceDao; |
|||
|
|||
@Override |
|||
public ThirdplatApiserviceResultDTO getByCustomerId(String customerId) { |
|||
return thirdplatApiserviceDao.getByCustomerId(customerId); |
|||
ThirdplatApiserviceResultDTO apiService = null; |
|||
|
|||
// 查redis,存redis
|
|||
Map<String, Object> apiServiceMap = redisUtils.hGetAll(RedisKeys.getCustomerApiServiceKey(customerId)); |
|||
if (!CollectionUtils.isEmpty(apiServiceMap)) { |
|||
apiService = BeanUtil.mapToBean(apiServiceMap, ThirdplatApiserviceResultDTO.class, true); |
|||
} |
|||
|
|||
if (apiService == null) { |
|||
apiService = thirdplatApiserviceDao.getByCustomerId(customerId); |
|||
redisUtils.hMSet(RedisKeys.getCustomerApiServiceKey(customerId), BeanUtil.beanToMap(apiService)); |
|||
} |
|||
|
|||
return apiService; |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue