|
|
@ -3,12 +3,18 @@ package com.thing.carbon.pub.service.impl; |
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
import com.mybatisflex.core.query.QueryWrapper; |
|
|
import com.mybatisflex.core.query.QueryWrapper; |
|
|
import com.thing.carbon.pub.dto.IotCarbonEnterpriseAuthDTO; |
|
|
import com.thing.carbon.pub.dto.IotCarbonEnterpriseAuthDTO; |
|
|
|
|
|
import com.thing.carbon.pub.entity.CarbonPubSupplierEntity; |
|
|
import com.thing.carbon.pub.entity.IotCarbonEnterpriseAuthEntity; |
|
|
import com.thing.carbon.pub.entity.IotCarbonEnterpriseAuthEntity; |
|
|
import com.thing.carbon.pub.mapper.IotCarbonEnterpriseAuthMapper; |
|
|
import com.thing.carbon.pub.mapper.IotCarbonEnterpriseAuthMapper; |
|
|
|
|
|
import com.thing.carbon.pub.service.CarbonPubSupplierService; |
|
|
import com.thing.carbon.pub.service.IotCarbonEnterpriseAuthService; |
|
|
import com.thing.carbon.pub.service.IotCarbonEnterpriseAuthService; |
|
|
|
|
|
import com.thing.carbontrack.share.dto.IotCarbonShareDTO; |
|
|
|
|
|
import com.thing.carbontrack.share.service.IotCarbonShareService; |
|
|
import com.thing.common.core.enumeration.TenantSaveType; |
|
|
import com.thing.common.core.enumeration.TenantSaveType; |
|
|
|
|
|
import com.thing.common.core.utils.RandomUtils; |
|
|
import com.thing.common.core.web.response.Result; |
|
|
import com.thing.common.core.web.response.Result; |
|
|
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|
|
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|
|
|
|
|
import com.thing.common.orm.utils.IdGenerator; |
|
|
import com.thing.sys.biz.service.SysRoleMenuService; |
|
|
import com.thing.sys.biz.service.SysRoleMenuService; |
|
|
import com.thing.sys.tenant.dto.SysTenantDetailDTO; |
|
|
import com.thing.sys.tenant.dto.SysTenantDetailDTO; |
|
|
import com.thing.sys.tenant.dto.TenantDetailForm; |
|
|
import com.thing.sys.tenant.dto.TenantDetailForm; |
|
|
@ -35,6 +41,12 @@ public class IotCarbonEnterpriseAuthServiceImpl extends BaseServiceImpl<IotCarbo |
|
|
@Autowired |
|
|
@Autowired |
|
|
private SysRoleMenuService sysRoleMenuService; |
|
|
private SysRoleMenuService sysRoleMenuService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private CarbonPubSupplierService supplierService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private IotCarbonShareService carbonShareService; |
|
|
|
|
|
|
|
|
Long roleId = 169210973415018496L; |
|
|
Long roleId = 169210973415018496L; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -49,7 +61,7 @@ public class IotCarbonEnterpriseAuthServiceImpl extends BaseServiceImpl<IotCarbo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void doSaveTenant(IotCarbonEnterpriseAuthDTO dto) { |
|
|
|
|
|
|
|
|
public void doSaveTenant(IotCarbonEnterpriseAuthDTO dto) throws InterruptedException { |
|
|
TenantDetailForm detailForm = new TenantDetailForm(); |
|
|
TenantDetailForm detailForm = new TenantDetailForm(); |
|
|
SysTenantDetailDTO tenantDetail = new SysTenantDetailDTO(); |
|
|
SysTenantDetailDTO tenantDetail = new SysTenantDetailDTO(); |
|
|
tenantDetail.setName(dto.getTenantName()); |
|
|
tenantDetail.setName(dto.getTenantName()); |
|
|
@ -63,6 +75,9 @@ public class IotCarbonEnterpriseAuthServiceImpl extends BaseServiceImpl<IotCarbo |
|
|
tenantDetail.setContact(dto.getContact()); |
|
|
tenantDetail.setContact(dto.getContact()); |
|
|
tenantDetail.setContactNumber(dto.getContactNumber()); |
|
|
tenantDetail.setContactNumber(dto.getContactNumber()); |
|
|
tenantDetail.setTenantType(0); |
|
|
tenantDetail.setTenantType(0); |
|
|
|
|
|
tenantDetail.setId(IdGenerator.nextId()); |
|
|
|
|
|
// 租户创建成功后,push租户存储完成事件 |
|
|
|
|
|
tenantDetail.setAccessToken(RandomUtils.getRandomString(10)); |
|
|
detailForm.setTenantDetail(tenantDetail); |
|
|
detailForm.setTenantDetail(tenantDetail); |
|
|
TenantDetailForm.TenantUser tenantUser = new TenantDetailForm.TenantUser(); |
|
|
TenantDetailForm.TenantUser tenantUser = new TenantDetailForm.TenantUser(); |
|
|
tenantUser.setUsername(dto.getUsername()); |
|
|
tenantUser.setUsername(dto.getUsername()); |
|
|
@ -78,6 +93,13 @@ public class IotCarbonEnterpriseAuthServiceImpl extends BaseServiceImpl<IotCarbo |
|
|
detailForm.setTenantRole(role); |
|
|
detailForm.setTenantRole(role); |
|
|
sysTenantDetailService.saveDetail(detailForm, |
|
|
sysTenantDetailService.saveDetail(detailForm, |
|
|
CollectionUtil.newArrayList(TenantSaveType.base, TenantSaveType.user, TenantSaveType.menu)); |
|
|
CollectionUtil.newArrayList(TenantSaveType.base, TenantSaveType.user, TenantSaveType.menu)); |
|
|
|
|
|
Long tenantId = tenantDetail.getId(); |
|
|
|
|
|
|
|
|
|
|
|
CarbonPubSupplierEntity entity =supplierService.getByCode(tenantId); |
|
|
|
|
|
if(ObjectUtils.isNotEmpty(entity)){ |
|
|
|
|
|
IotCarbonShareDTO shareDTO = IotCarbonShareDTO.init(tenantDetail.getId(),tenantDetail.getAccessToken()); |
|
|
|
|
|
carbonShareService.saveDto(shareDTO); |
|
|
|
|
|
} |
|
|
this.updateDto(dto); |
|
|
this.updateDto(dto); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|