当前位置:   article > 正文

redis缓存hset, hget, hPutAll_redis hput

redis hput

redis缓存hset, hget, hPutAll 在业务场景中使用

package com.miniso.pintea.core.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.miniso.pintea.common.constant.redis.CoreRedisConstant;
import com.miniso.pintea.common.util.JsonUtil;
import com.miniso.pintea.core.constant.StoreDailyStatus;
import com.miniso.pintea.core.constant.StoreStatus;
import com.miniso.pintea.core.dto.*;
import com.miniso.pintea.core.entity.StoreInformation;
import com.miniso.pintea.core.mapper.StoreInformationMapper;
import com.miniso.pintea.core.service.StoreInformationService;
import com.miniso.pintea.core.third.service.AMapWebApiCallService;
import com.miniso.pintea.core.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.text.Collator;
import java.text.MessageFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 门店信息 服务实现类
 * </p>
 *
 * @author chenqixuan
 * @since 2021-02-24
 */
@Slf4j
@Service
public class StoreInformationServiceImpl implements StoreInformationService {
   

    @Autowired
    private RedisUtil redisUtil;

    @Autowired
    private StoreInformationMapper storeInformationMapper;

    @Autowired
    private AMapWebApiCallService aMapWebApiCallService;

    @Value("${store.location.distance}")
    private Integer storeDistance;


    @Override
    public List<StoreLocationInfo> getNearbyStoreList4Sf(NearbyStoreRequestDTO nearbyStoreRequestDto, String city,String district, int pageNum, int pageSize) {
   
        List<StoreLocationInfo> storeLocationInfos = new ArrayList<>();
        Integer limitDistance = 10000;
        if(null != storeDistance){
   
            limitDistance = storeDistance;//查附近多少公里的默认设置为10公里(单位米)
        }
        try {
   
            city = city.endsWith("市") || city.endsWith("州") || city.endsWith("区") ? city.substring(0, city.length() - 1) : city;
            Double longitudeN = nearbyStoreRequestDto.getReceiverLng();
            Double latitudeN = nearbyStoreRequestDto.getReceiverLat();

            List<StoreInformation> storeInfoList = getAllStoreInfoRedis();//从缓存取数据

            if(null != storeInfoList && storeInfoList.size() > 0){
   
                if(StringUtils.isNotBlank(city)){
   //城市
                    String finalCity = city;
                    storeInfoList = storeInfoList.stream().filter(s-> s.getStoreCity() == null ? false : s.getStoreCity().contains(finalCity)).collect(Collectors.toList());
                }
                if(StringUtils.isNotBlank(district)){
   //区域
                    storeInfoList = storeInfoList.stream().filter(s-> s.getStoreDistrict() == null ? false : s.getStoreDistrict().contains(district)).collect(Collectors.toList());
                }

                for (StoreInformation storeInfo : storeInfoList) {
   
                    StoreLocationInfo storeLocationInfo = new Store
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/800911
推荐阅读
相关标签
  

闽ICP备14008679号