| | |
| | | import com.boying.mapper.ParkMapper; |
| | | import com.boying.service.BarrierService; |
| | | import com.boying.service.EnterParkService; |
| | | import com.boying.util.RedisJsonUtil; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.ZoneId; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | private OutParkMapper outParkMapper; |
| | | private StringRedisTemplate redisTemplate; |
| | | private ParkMapper parkMapper; |
| | | private RedisJsonUtil redisJsonUtil; |
| | | @Override |
| | | public Barrier findByCode(String code) { |
| | | QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Barrier::getCode,code); |
| | | List<Barrier> list = list(wrapper); |
| | | if(list.size()>0){ |
| | | return list.get(0); |
| | | }else { |
| | | Barrier barrier = null; |
| | | try { |
| | | barrier = redisJsonUtil.get("barrier-"+code,Barrier.class); |
| | | if(barrier != null){ |
| | | return barrier; |
| | | }else { |
| | | QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Barrier::getCode,code); |
| | | List<Barrier> list = list(wrapper); |
| | | if(list.size()>0){ |
| | | redisJsonUtil.set("barrier-"+code,list.get(0)); |
| | | return list.get(0); |
| | | } |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |