|
@@ -16,14 +16,20 @@
|
|
|
*/
|
|
|
package com.fjhx.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fjhx.base.Condition;
|
|
|
import com.fjhx.mapper.TenantMapper;
|
|
|
import com.fjhx.service.*;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.core.cache.utils.CacheUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.base.BaseEntity;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
@@ -36,10 +42,7 @@ import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static org.springblade.common.constant.TenantConstant.*;
|
|
|
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
|
@@ -61,9 +64,11 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
|
|
|
private final IUserClient userClient;
|
|
|
private final IMenuService menuService;
|
|
|
|
|
|
+ private final ExRegionService exRegionService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public synchronized boolean submitTenant(Tenant tenant) {
|
|
|
+ public synchronized void submitTenant(Tenant tenant) {
|
|
|
if (Func.isEmpty(tenant.getId())) {
|
|
|
|
|
|
String tenantId = tenant.getTenantId();
|
|
@@ -72,8 +77,8 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
|
|
|
tenant.setTenantId(tenantId);
|
|
|
|
|
|
// 获取参数配置的账号额度
|
|
|
- int accountNumber = Func.toInt(ParamCache.getValue(ACCOUNT_NUMBER_KEY), DEFAULT_ACCOUNT_NUMBER);
|
|
|
- tenant.setAccountNumber(accountNumber);
|
|
|
+ // int accountNumber = Func.toInt(ParamCache.getValue(ACCOUNT_NUMBER_KEY), DEFAULT_ACCOUNT_NUMBER);
|
|
|
+ // tenant.setAccountNumber(accountNumber);
|
|
|
|
|
|
// 新建租户对应的默认角色
|
|
|
Role role = new Role();
|
|
@@ -141,17 +146,72 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
|
|
|
user.setSex(1);
|
|
|
user.setUserType(UserEnum.WEB.getCategory());
|
|
|
user.setIsDeleted(BladeConstant.DB_NOT_DELETED);
|
|
|
- boolean temp = super.saveOrUpdate(tenant);
|
|
|
+
|
|
|
+ saveOrUpdate(tenant);
|
|
|
+
|
|
|
R<Boolean> result = userClient.saveUser(user);
|
|
|
if (!result.isSuccess()) {
|
|
|
throw new ServiceException(result.getMsg());
|
|
|
}
|
|
|
- return temp;
|
|
|
|
|
|
} else {
|
|
|
CacheUtil.clear(SYS_CACHE, tenant.getTenantId());
|
|
|
- return super.saveOrUpdate(tenant);
|
|
|
+ saveOrUpdate(tenant);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Map<String, Object>> getPage(Condition condition) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<Tenant> wrapper = Wrappers.lambdaQuery();
|
|
|
+
|
|
|
+ String tenantId = condition.getStr("tenantId");
|
|
|
+ String tenantName = condition.getStr("tenantName");
|
|
|
+ String linkman = condition.getStr("linkman");
|
|
|
+ String contactNumber = condition.getStr("contactNumber");
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+ Date expireBeginTime = condition.getBeginTime("expireBeginTime");
|
|
|
+ Date expireEndTime = condition.getBeginTime("expireEndTime");
|
|
|
+ String countryId = condition.getStr("countryId");
|
|
|
+ String provinceId = condition.getStr("provinceId");
|
|
|
+ String cityId = condition.getStr("cityId");
|
|
|
+
|
|
|
+ wrapper.like(ObjectUtil.isNotEmpty(tenantId), Tenant::getTenantId, tenantId)
|
|
|
+ .like(ObjectUtil.isNotEmpty(tenantName), Tenant::getTenantName, tenantName)
|
|
|
+ .like(ObjectUtil.isNotEmpty(linkman), Tenant::getLinkman, linkman)
|
|
|
+ .like(ObjectUtil.isNotEmpty(contactNumber), Tenant::getContactNumber, contactNumber)
|
|
|
+ .between(ObjectUtil.isNotEmpty(beginTime), BaseEntity::getCreateTime, beginTime, endTime)
|
|
|
+ .between(ObjectUtil.isNotEmpty(expireBeginTime), Tenant::getExpireTime, expireBeginTime, expireEndTime)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(countryId), Tenant::getCountryId, countryId)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(provinceId), Tenant::getProvinceId, provinceId)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(cityId), Tenant::getCityId, cityId)
|
|
|
+ ;
|
|
|
+
|
|
|
+
|
|
|
+ Page<Map<String, Object>> page = pageMaps(condition.getPage(), wrapper);
|
|
|
+ List<Map<String, Object>> records = page.getRecords();
|
|
|
+
|
|
|
+ // 省市县id集合
|
|
|
+ Set<String> regionSet = new HashSet<>();
|
|
|
+
|
|
|
+ for (Map<String, Object> record : records) {
|
|
|
+ // 查询国省市
|
|
|
+ regionSet.add(Convert.toStr(record.get("countryId")));
|
|
|
+ regionSet.add(Convert.toStr(record.get("provinceId")));
|
|
|
+ regionSet.add(Convert.toStr(record.get("cityId")));
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, String> regionMap = exRegionService.getChineseNameById(regionSet);
|
|
|
+
|
|
|
+ for (Map<String, Object> record : records) {
|
|
|
+ // 赋值国省市
|
|
|
+ record.put("countryName", regionMap.get(Convert.toStr(record.get("countryId"))));
|
|
|
+ record.put("provinceName", regionMap.get(Convert.toStr(record.get("provinceId"))));
|
|
|
+ record.put("cityName", regionMap.get(Convert.toStr(record.get("cityId"))));
|
|
|
+ }
|
|
|
+
|
|
|
+ return page;
|
|
|
}
|
|
|
|
|
|
private List<Menu> getMenus(List<String> codes, LinkedList<Menu> menus) {
|