|
|
@@ -1,35 +1,40 @@
|
|
|
- package org.sky.system.service.impl;
|
|
|
-
|
|
|
- import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
- import lombok.AllArgsConstructor;
|
|
|
- import org.sky.core.cache.utils.CacheUtil;
|
|
|
- import org.sky.core.literule.engine.RuleEngineExecutor;
|
|
|
- import org.sky.core.literule.provider.LiteRuleResponse;
|
|
|
- import org.sky.core.log.exception.ServiceException;
|
|
|
- import org.sky.core.mp.base.BaseServiceImpl;
|
|
|
- import org.sky.core.mp.enums.StatusType;
|
|
|
- import org.sky.core.tenant.TenantId;
|
|
|
- import org.sky.core.tool.constant.KdConstant;
|
|
|
- import org.sky.core.tool.jackson.JsonUtil;
|
|
|
- import org.sky.core.tool.support.Kv;
|
|
|
- import org.sky.core.tool.utils.DesUtil;
|
|
|
- import org.sky.core.tool.utils.Func;
|
|
|
- import org.sky.system.mapper.TenantMapper;
|
|
|
- import org.sky.system.pojo.entity.*;
|
|
|
- import org.sky.system.rule.context.TenantContext;
|
|
|
- import org.sky.system.service.*;
|
|
|
- import org.springframework.stereotype.Service;
|
|
|
- import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
- import java.util.Date;
|
|
|
- import java.util.List;
|
|
|
- import java.util.stream.Collectors;
|
|
|
-
|
|
|
- import static org.sky.common.constant.TenantConstant.DES_KEY;
|
|
|
- import static org.sky.core.cache.constant.CacheConstant.SYS_CACHE;
|
|
|
- import static org.sky.system.cache.SysCache.TENANT_TENANT_ID;
|
|
|
- import static org.sky.system.rule.constant.TenantRuleConstant.TENANT_CHAIN_ID;
|
|
|
+package org.sky.system.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.sky.core.cache.utils.CacheUtil;
|
|
|
+import org.sky.core.literule.engine.RuleEngineExecutor;
|
|
|
+import org.sky.core.literule.provider.LiteRuleResponse;
|
|
|
+import org.sky.core.log.exception.ServiceException;
|
|
|
+import org.sky.core.mp.base.BaseServiceImpl;
|
|
|
+import org.sky.core.mp.enums.StatusType;
|
|
|
+import org.sky.core.redis.cache.KdRedis;
|
|
|
+import org.sky.core.secure.utils.SecureUtil;
|
|
|
+import org.sky.core.tenant.TenantId;
|
|
|
+import org.sky.core.tool.constant.KdConstant;
|
|
|
+import org.sky.core.tool.jackson.JsonUtil;
|
|
|
+import org.sky.core.tool.support.Kv;
|
|
|
+import org.sky.core.tool.utils.DesUtil;
|
|
|
+import org.sky.core.tool.utils.Func;
|
|
|
+import org.sky.system.cache.RegionCache;
|
|
|
+import org.sky.system.mapper.RegionMapper;
|
|
|
+import org.sky.system.mapper.TenantMapper;
|
|
|
+import org.sky.system.pojo.entity.*;
|
|
|
+import org.sky.system.rule.context.TenantContext;
|
|
|
+import org.sky.system.service.*;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static org.sky.common.constant.TenantConstant.DES_KEY;
|
|
|
+import static org.sky.core.cache.constant.CacheConstant.SYS_CACHE;
|
|
|
+import static org.sky.system.cache.SysCache.TENANT_TENANT_ID;
|
|
|
+import static org.sky.system.rule.constant.TenantRuleConstant.TENANT_CHAIN_ID;
|
|
|
|
|
|
/**
|
|
|
* 服务实现类
|
|
|
@@ -38,7 +43,7 @@
|
|
|
*/
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
-public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> implements ITenantService {
|
|
|
+public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> implements ITenantService {
|
|
|
|
|
|
private final TenantId tenantIdGenerator;
|
|
|
private final IRoleService roleService;
|
|
|
@@ -46,14 +51,26 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
|
|
|
private final IDeptService deptService;
|
|
|
private final IPostService postService;
|
|
|
private final IRoleMenuService roleMenuService;
|
|
|
- private final IDictBizService dictBizService;
|
|
|
+ private final IDictBizService dictBizService;
|
|
|
private final IUserService userService;
|
|
|
- private final IUserDeptService userDeptService;
|
|
|
+ private final IUserDeptService userDeptService;
|
|
|
private final RuleEngineExecutor ruleExecutor;
|
|
|
+ private final RegionMapper regionMapper;
|
|
|
+ private final KdRedis redis;
|
|
|
|
|
|
@Override
|
|
|
public IPage<Tenant> selectTenantPage(IPage<Tenant> page, Tenant tenant) {
|
|
|
- return page.setRecords(baseMapper.selectTenantPage(page, tenant));
|
|
|
+ List<Tenant> tenants = baseMapper.selectTenantPage(page, tenant);
|
|
|
+ for (Tenant t : tenants) {
|
|
|
+ if (Func.isNotEmpty(t.getRegionCode())) {
|
|
|
+ Region region = RegionCache.getByCode(t.getRegionCode());
|
|
|
+// Region region = regionMapper.selectOne(Wrappers.<Region>lambdaQuery().eq(Region::getCode, t.getRegionCode()));
|
|
|
+ if (region != null) {
|
|
|
+ t.setRegionName(region.getProvinceName() + "-" + region.getCityName() + "-" + region.getDistrictName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return page.setRecords(tenants);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -105,6 +122,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
|
|
|
}
|
|
|
CacheUtil.clear(SYS_CACHE, tenant.getTenantId());
|
|
|
CacheUtil.evict(SYS_CACHE, TENANT_TENANT_ID, tenant.getTenantId(), Boolean.FALSE);
|
|
|
+ CacheUtil.clear("kd:vip:years");
|
|
|
return super.saveOrUpdate(tenant);
|
|
|
}
|
|
|
|
|
|
@@ -239,4 +257,15 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<String> getVipYears() {
|
|
|
+ return CacheUtil.get("kd:vip:years", "vip:years:", SecureUtil.getTenantId(), () -> {
|
|
|
+ Tenant tenant = this.baseMapper.selectOne(Wrappers.<Tenant>lambdaQuery().eq(Tenant::getTenantId, SecureUtil.getTenantId()));
|
|
|
+ if (Func.notNull(tenant) && Func.isNotBlank(tenant.getVipYears())) {
|
|
|
+ return JSON.parseArray(tenant.getVipYears(), String.class);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|