|
|
|
@ -29,7 +29,6 @@ import org.apache.dolphinscheduler.api.utils.PageInfo;
|
|
|
|
|
import org.apache.dolphinscheduler.api.utils.RegexUtils; |
|
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType; |
|
|
|
|
import org.apache.dolphinscheduler.common.storage.StorageOperate; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils; |
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
@ -47,16 +46,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.*; |
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.TENANT_FULL_NAME_MAX_LENGTH; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -143,8 +137,8 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
|
|
|
|
|
String desc) throws Exception { |
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
result.put(Constants.STATUS, false); |
|
|
|
|
if (!canOperatorPermissions(loginUser,null, AuthorizationType.TENANT, TENANT_CREATE)) { |
|
|
|
|
throw new ServiceException(Status.USER_NO_OPERATION_PERM); |
|
|
|
|
if (isNotAdmin(loginUser, result)) { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Tenant tenant = new Tenant(tenantCode, desc, queueId); |
|
|
|
@ -155,7 +149,6 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
|
|
|
|
|
if (PropertyUtils.getResUploadStartupState()) { |
|
|
|
|
storageOperate.createTenantDirIfNotExists(tenantCode); |
|
|
|
|
} |
|
|
|
|
permissionPostHandle(AuthorizationType.TENANT, loginUser.getId(), Collections.singletonList(tenant.getId()), logger); |
|
|
|
|
result.put(Constants.DATA_LIST, tenant); |
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
return result; |
|
|
|
@ -174,18 +167,15 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
|
|
|
|
|
public Result<Object> queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { |
|
|
|
|
|
|
|
|
|
Result<Object> result = new Result<>(); |
|
|
|
|
PageInfo<Tenant> pageInfo = new PageInfo<>(pageNo, pageSize); |
|
|
|
|
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.TENANT, loginUser.getId(), logger); |
|
|
|
|
if (ids.isEmpty()) { |
|
|
|
|
result.setData(pageInfo); |
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
return result; |
|
|
|
|
if (!isAdmin(loginUser)) { |
|
|
|
|
putMsg(result, Status.USER_NO_OPERATION_PERM); |
|
|
|
|
} |
|
|
|
|
Page<Tenant> page = new Page<>(pageNo, pageSize); |
|
|
|
|
IPage<Tenant> tenantPage = tenantMapper.queryTenantPaging(page, new ArrayList<>(ids), searchVal); |
|
|
|
|
IPage<Tenant> tenantIPage = tenantMapper.queryTenantPaging(page, searchVal); |
|
|
|
|
PageInfo<Tenant> pageInfo = new PageInfo<>(pageNo, pageSize); |
|
|
|
|
pageInfo.setTotal((int) tenantIPage.getTotal()); |
|
|
|
|
pageInfo.setTotalList(tenantIPage.getRecords()); |
|
|
|
|
|
|
|
|
|
pageInfo.setTotal((int) tenantPage.getTotal()); |
|
|
|
|
pageInfo.setTotalList(tenantPage.getRecords()); |
|
|
|
|
result.setData(pageInfo); |
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
return result; |
|
|
|
@ -207,9 +197,10 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
|
|
|
|
|
String desc) throws Exception { |
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
result.put(Constants.STATUS, false); |
|
|
|
|
|
|
|
|
|
if (!canOperatorPermissions(loginUser,null, AuthorizationType.TENANT,TENANT_UPDATE)) { |
|
|
|
|
throw new ServiceException(Status.USER_NO_OPERATION_PERM); |
|
|
|
|
if (isNotAdmin(loginUser, result)) { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Tenant updateTenant = new Tenant(id, tenantCode, desc, queueId); |
|
|
|
@ -242,8 +233,8 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
|
|
|
|
|
public Map<String, Object> deleteTenantById(User loginUser, int id) throws Exception { |
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
if (!canOperatorPermissions(loginUser,null, AuthorizationType.TENANT,TENANT_DELETE)) { |
|
|
|
|
throw new ServiceException(Status.USER_NO_OPERATION_PERM); |
|
|
|
|
if (isNotAdmin(loginUser, result)) { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Tenant tenant = tenantMapper.queryById(id); |
|
|
|
@ -293,13 +284,7 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
|
|
|
|
|
public Map<String, Object> queryTenantList(User loginUser) { |
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.TENANT, loginUser.getId(), logger); |
|
|
|
|
if (ids.isEmpty()) { |
|
|
|
|
result.put(Constants.DATA_LIST, Collections.emptyList()); |
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
List<Tenant> resourceList = tenantMapper.selectBatchIds(ids); |
|
|
|
|
List<Tenant> resourceList = tenantMapper.selectList(null); |
|
|
|
|
result.put(Constants.DATA_LIST, resourceList); |
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
return result; |
|
|
|
|