use of com.github.liuweijw.business.wechat.domain.UrlInfo in project fw-cloud-framework by liuweijw.
the class UrlInfoServiceImpl method findByUuid.
@Override
public UrlInfo findByUuid(String uuid) {
if (StringHelper.isBlank(uuid))
return null;
QUrlInfo qUrlInfo = QUrlInfo.urlInfo;
UrlInfo dbUrlInfo = this.queryFactory.selectFrom(qUrlInfo).where(qUrlInfo.uuid.eq(uuid)).fetchFirst();
return dbUrlInfo;
}
use of com.github.liuweijw.business.wechat.domain.UrlInfo in project fw-cloud-framework by liuweijw.
the class UrlInfoServiceImpl method cacheUrlInfo.
@Override
public void cacheUrlInfo(UrlInfoBean urlInfoBean) {
try {
log.info("设置缓存微信UrlInfo[uuid]:" + urlInfoBean.getUuid());
cacheManager.getCache(WECHAT_URL_INFO).put(urlInfoBean.getUuid(), urlInfoBean);
} catch (Exception e) {
log.info("设置缓存微信UrlInfo[uuid]:" + urlInfoBean.getUuid() + "失败,入库保障");
UrlInfo urlInfo = new UrlInfo();
urlInfo.setTime(System.currentTimeMillis());
urlInfo.setUrl(urlInfoBean.getUrl());
urlInfo.setUuid(urlInfoBean.getUuid());
this.saveOrUpdate(urlInfo);
}
}
use of com.github.liuweijw.business.wechat.domain.UrlInfo in project fw-cloud-framework by liuweijw.
the class UrlInfoServiceImpl method findFromCacheByUuid.
@Override
public UrlInfoBean findFromCacheByUuid(String uuid) {
log.info("从缓存查询微信UrlInfo[uuid]:" + uuid);
Cache cache = cacheManager.getCache(WECHAT_URL_INFO);
Optional<UrlInfoBean> optional = Optional.ofNullable(cache.get(uuid, UrlInfoBean.class));
if (optional.isPresent()) {
log.info("从缓存查询微信UrlInfo[uuid]:" + uuid + "查询成功");
cache.evict(uuid);
return optional.get();
}
log.error("从缓存查询微信UrlInfo[uuid]:" + uuid + "未查询到");
UrlInfo dbUserinfo = findByUuid(uuid);
if (null == dbUserinfo) {
log.error("从db查询微信UrlInfo[uuid]:" + uuid + "未查询到");
return new UrlInfoBean();
}
log.info("从db查询微信UrlInfo[uuid]:" + uuid + "查询成功");
return new UrlInfoBean(dbUserinfo.getUuid(), dbUserinfo.getUrl());
}
Aggregations