You've already forked FrameTour-BE
修改
This commit is contained in:
@ -9,6 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
public class DeviceRepository {
|
||||
@Autowired
|
||||
@ -35,8 +38,13 @@ public class DeviceRepository {
|
||||
return JSONObject.parseObject(redisTemplate.opsForValue().get(String.format(DEVICE_CACHE_KEY, deviceNo)), DeviceEntity.class);
|
||||
}
|
||||
DeviceEntity device = deviceMapper.getByDeviceNo(deviceNo);
|
||||
if (null == device) {
|
||||
device = deviceMapper.getByDeviceNo2(deviceNo);
|
||||
}
|
||||
if (null != device) {
|
||||
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, deviceNo), JSONObject.toJSONString(device));
|
||||
} else {
|
||||
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, deviceNo), "null", 60 * 60L, TimeUnit.SECONDS);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
@ -66,4 +74,28 @@ public class DeviceRepository {
|
||||
redisTemplate.delete(String.format(DEVICE_CONFIG_CACHE_KEY, deviceId));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateOnlineStatus(String deviceNo, int online, Date keepaliveAt) {
|
||||
DeviceEntity device = getDeviceByDeviceNo(deviceNo);
|
||||
if (null == device) {
|
||||
return;
|
||||
}
|
||||
updateOnlineStatus(device.getId(), null, online, keepaliveAt);
|
||||
}
|
||||
|
||||
public void updateOnlineStatus(Long deviceId, String ipAddr, int online, Date keepaliveAt) {
|
||||
DeviceEntity device = getDevice(deviceId);
|
||||
if (null == device) {
|
||||
return;
|
||||
}
|
||||
device.setOnline(online);
|
||||
device.setKeepaliveAt(keepaliveAt);
|
||||
deviceMapper.updateOnlineStatus(deviceId, ipAddr, online, keepaliveAt);
|
||||
updateDeviceCache(device);
|
||||
}
|
||||
|
||||
private void updateDeviceCache(DeviceEntity device) {
|
||||
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, device.getId()), JSONObject.toJSONString(device));
|
||||
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, device.getNo()), JSONObject.toJSONString(device));
|
||||
}
|
||||
}
|
||||
|
@ -72,11 +72,20 @@ public class OrderRepository {
|
||||
redisTemplate.opsForValue().set(String.format(ORDER_USER_TYPE_BUY_ITEM_CACHE_KEY, userId, goodsType, goodsId), "0", 60, TimeUnit.SECONDS);
|
||||
return false;
|
||||
}
|
||||
redisTemplate.opsForValue().set(String.format(ORDER_USER_TYPE_BUY_ITEM_CACHE_KEY, userId, goodsType, goodsId), "1");
|
||||
return true;
|
||||
if (Integer.valueOf(1).equals(orderEntity.getStatus())) {
|
||||
redisTemplate.opsForValue().set(String.format(ORDER_USER_TYPE_BUY_ITEM_CACHE_KEY, userId, goodsType, goodsId), "1");
|
||||
return true;
|
||||
} else {
|
||||
redisTemplate.opsForValue().set(String.format(ORDER_USER_TYPE_BUY_ITEM_CACHE_KEY, userId, goodsType, goodsId), "0", 60, TimeUnit.SECONDS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public OrderEntity getUserBuyItem(Long userId, int goodsType, Long goodsId) {
|
||||
return orderMapper.getUserBuyItem(userId, goodsType, goodsId);
|
||||
}
|
||||
|
||||
public boolean checkUserBuyFaceSourceImage(Long userId, Long faceId) {
|
||||
return checkUserBuyItem(userId, 2, faceId);
|
||||
}
|
||||
|
Reference in New Issue
Block a user