use of com.albedo.java.common.core.cache.model.CacheKey in project albedo by somowhere.
the class ParameterServiceImpl method updateById.
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateById(ParameterDo model) {
long count = count(Wraps.<ParameterDo>lbQ().eq(ParameterDo::getKey, model.getKey()).ne(ParameterDo::getId, model.getId()));
ArgumentAssert.isFalse(count > 0, StrUtil.format("参数key[{}]已经存在,请勿重复创建", model.getKey()));
boolean bool = SqlHelper.retBool(getBaseMapper().updateById(model));
if (bool) {
CacheKey cacheKey = new ParameterKeyCacheKeyBuilder().key(model.getKey());
cacheOps.set(cacheKey, model.getValue());
SpringContextHolder.publishEvent(new ParameterUpdateEvent(new ParameterUpdate(model.getKey(), model.getValue(), null, ContextUtil.getTenant())));
}
return bool;
}
use of com.albedo.java.common.core.cache.model.CacheKey in project albedo by somowhere.
the class TenantServiceImpl method saveOrUpdate.
@Override
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdate(TenantDto tenantDto) {
// defaults 库
ArgumentAssert.isTrue(check(tenantDto.getCode()), "编码重复,请重新输入");
Tenant tenant = BeanUtil.toBean(tenantDto, Tenant.class);
if (tenantDto.getId() == null) {
// 1, 保存租户 (默认库)
tenant.setStatus(TenantStatusEnum.WAIT_INIT);
tenant.setType(TenantTypeEnum.CREATE);
// defaults 库
save(tenant);
} else {
updateById(tenant);
}
appendixService.save(tenant.getId(), tenantDto.getLogos());
CacheKey cacheKey = new TenantCodeCacheKeyBuilder().key(tenant.getCode());
super.cacheOps.set(cacheKey, tenant.getId());
}
use of com.albedo.java.common.core.cache.model.CacheKey in project albedo by somowhere.
the class LogLoginServiceImpl method save.
@Override
public boolean save(LogLoginDo logLoginDo) {
UserVo user;
Long userId = logLoginDo.getUserId();
String username = logLoginDo.getUsername();
if (userId != null) {
user = this.userService.findUserVoById(userId);
} else {
user = this.userService.findVoByUsername(username);
}
if (user != null) {
logLoginDo.setUsername(user.getUsername()).setUserId(user.getId()).setNickname(user.getNickname()).setCreatedBy(user.getId());
}
super.save(logLoginDo);
LocalDate now = LocalDate.now();
String tenDaysAgo = LocalDateTimeUtil.formatNormal(now.plusDays(-9));
CacheKey totalLoginPvKey = TotalLoginPvCacheKeyBuilder.build();
CacheKey todayLoginPvKey = TodayLoginPvCacheKeyBuilder.build(now);
// 登录IV
CacheKey totalLoginIvKey = TotalLoginIvCacheKeyBuilder.build();
CacheKey todayLoginIvKey = TodayLoginIvCacheKeyBuilder.build(now);
CacheKey logLoginTenDayKey = new LogLoginTenDayCacheKeyBuilder().key(tenDaysAgo);
CacheKey logLoginBrowserKey = new LogLoginBrowserCacheKeyBuilder().key();
CacheKey logLoginSystemKey = new LogLoginSystemCacheKeyBuilder().key();
cacheOps.del(totalLoginPvKey);
cacheOps.del(todayLoginPvKey);
cacheOps.del(todayLoginIvKey);
cacheOps.del(totalLoginIvKey);
cacheOps.del(logLoginTenDayKey);
cacheOps.del(logLoginBrowserKey);
cacheOps.del(logLoginSystemKey);
if (user != null) {
CacheKey logLoginTenDayUserKey = new LogLoginTenDayCacheKeyBuilder().key(tenDaysAgo, user.getUsername());
cacheOps.del(logLoginTenDayUserKey);
}
return true;
}
use of com.albedo.java.common.core.cache.model.CacheKey in project albedo by somowhere.
the class LogLoginServiceImpl method getTodayLoginPv.
@Override
public Long getTodayLoginPv() {
LocalDate now = LocalDate.now();
CacheKey logLoginTodayKey = TodayLoginPvCacheKeyBuilder.build(now);
return Convert.toLong(cacheOps.get(logLoginTodayKey, k -> repository.getTodayLoginPv(now)), 0L);
}
use of com.albedo.java.common.core.cache.model.CacheKey in project albedo by somowhere.
the class LogLoginServiceImpl method getTodayLoginIv.
@Override
public Long getTodayLoginIv() {
LocalDate now = LocalDate.now();
CacheKey logLoginTodayIpKey = TodayLoginIvCacheKeyBuilder.build(now);
return Convert.toLong(cacheOps.get(logLoginTodayIpKey, k -> repository.getTodayLoginIv(now)), 0L);
}
Aggregations