You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "castorqin (via GitHub)" <gi...@apache.org> on 2023/07/07 06:23:48 UTC

[GitHub] [inlong] castorqin opened a new pull request, #8463: [INLONG-8442][Manager]Manager support delete tenant and delete tenant role

castorqin opened a new pull request, #8463:
URL: https://github.com/apache/inlong/pull/8463

   ### Prepare a Pull Request
   *(Change the title refer to the following example)*
   
   - Title Example: [INLONG-XYZ][Component] Title of the pull request
   
   *(The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)*
   
   - Fixes #8442   
   
   ### Motivation
   inlong manager support  delete tenant and delete tenant role
   
   ### Modifications
   The details can be found at [#8442   ](https://github.com/apache/inlong/issues/8442).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] castorqin commented on a diff in pull request #8463: [INLONG-8442][Manager]Manager support delete tenant and delete tenant role

Posted by "castorqin (via GitHub)" <gi...@apache.org>.
castorqin commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255331436


##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongTenantRoleController.java:
##########
@@ -81,4 +81,11 @@ public Response<PageInfo<TenantRoleInfo>> listByCondition(@RequestBody TenantRol
         return Response.success(tenantRoleService.listByCondition(request));
     }
 
+    @RequestMapping(value = "/role/tenant/delete/{id}", method = RequestMethod.DELETE)
+    @ApiOperation(value = "Delete tenant role by ID")
+    @ApiImplicitParam(name = "id", dataTypeClass = Integer.class, required = true)
+    @RequiresRoles(logical = Logical.OR, value = {UserRoleCode.TENANT_ADMIN, UserRoleCode.TENANT_OPERATOR})

Review Comment:
   done



##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongTenantController.java:
##########
@@ -82,4 +83,13 @@ public Response<Boolean> update(@Validated(UpdateByIdValidation.class) @RequestB
         return Response.success(tenantService.update(request));
     }
 
+    @RequestMapping(value = "/tenant/delete/{name}", method = RequestMethod.GET)
+    @ApiOperation(value = "Delete inlong tenant by name")
+    @ApiImplicitParam(name = "name", dataTypeClass = String.class, required = true)
+    @RequiresRoles(logical = Logical.OR, value = {INLONG_ADMIN, INLONG_OPERATOR})

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] castorqin commented on a diff in pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "castorqin (via GitHub)" <gi...@apache.org>.
castorqin commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255852777


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java:
##########
@@ -121,6 +122,14 @@ public Boolean update(InlongTenantRequest request) {
         return true;
     }
 
+    @Override
+    public Boolean delete(String name) {
+        InlongTenantEntity inlongTenantEntity = inlongTenantEntityMapper.selectByName(name);

Review Comment:
   done



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java:
##########
@@ -121,6 +122,14 @@ public Boolean update(InlongTenantRequest request) {
         return true;
     }
 
+    @Override
+    public Boolean delete(String name) {
+        InlongTenantEntity inlongTenantEntity = inlongTenantEntityMapper.selectByName(name);
+        int success = inlongTenantEntityMapper.deleteById(inlongTenantEntity.getId());
+        Preconditions.expectTrue(success == 1, "delete failed");
+        return true;

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] vernedeng commented on a diff in pull request #8463: [INLONG-8442][Manager]Manager support delete tenant and delete tenant role

Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255321317


##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongTenantController.java:
##########
@@ -82,4 +83,13 @@ public Response<Boolean> update(@Validated(UpdateByIdValidation.class) @RequestB
         return Response.success(tenantService.update(request));
     }
 
+    @RequestMapping(value = "/tenant/delete/{name}", method = RequestMethod.GET)
+    @ApiOperation(value = "Delete inlong tenant by name")
+    @ApiImplicitParam(name = "name", dataTypeClass = String.class, required = true)
+    @RequiresRoles(logical = Logical.OR, value = {INLONG_ADMIN, INLONG_OPERATOR})

Review Comment:
   INLONG_OPERATOR has no permission to do this.



##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongTenantRoleController.java:
##########
@@ -81,4 +81,11 @@ public Response<PageInfo<TenantRoleInfo>> listByCondition(@RequestBody TenantRol
         return Response.success(tenantRoleService.listByCondition(request));
     }
 
+    @RequestMapping(value = "/role/tenant/delete/{id}", method = RequestMethod.DELETE)
+    @ApiOperation(value = "Delete tenant role by ID")
+    @ApiImplicitParam(name = "id", dataTypeClass = Integer.class, required = true)
+    @RequiresRoles(logical = Logical.OR, value = {UserRoleCode.TENANT_ADMIN, UserRoleCode.TENANT_OPERATOR})

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] castorqin commented on a diff in pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "castorqin (via GitHub)" <gi...@apache.org>.
castorqin commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255607323


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java:
##########
@@ -107,4 +107,11 @@ public Boolean update(InlongTenantRequest request) {
         }
         return true;
     }
+
+    @Override
+    public Boolean delete(String name, String operator) {
+        InlongTenantEntity inlongTenantEntity = inlongTenantEntityMapper.selectByName(name);
+        return inlongTenantEntityMapper.deleteById(inlongTenantEntity.getId()) > 0;

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] castorqin commented on a diff in pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "castorqin (via GitHub)" <gi...@apache.org>.
castorqin commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255853541


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java:
##########
@@ -121,6 +122,14 @@ public Boolean update(InlongTenantRequest request) {
         return true;
     }
 
+    @Override
+    public Boolean delete(String name) {

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] vernedeng commented on a diff in pull request #8463: [INLONG-8442][Manager]Manager support delete tenant and delete tenant role

Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255320759


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java:
##########
@@ -116,4 +116,9 @@ public TenantRoleInfo getByUsernameAndTenant(String name, String tenant) {
         return CommonBeanUtils.copyProperties(entity, TenantRoleInfo::new);
     }
 
+    @Override
+    public boolean delete(Integer id) {
+        return tenantUserRoleEntityMapper.deleteById(id) > 0;

Review Comment:
   No need to check if the delete result bigger than 0, just return it directly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow commented on a diff in pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "healchow (via GitHub)" <gi...@apache.org>.
healchow commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255573013


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleService.java:
##########
@@ -52,4 +52,11 @@ public interface TenantRoleService {
      * Get one tenant role by name and tenant
      */
     TenantRoleInfo getByUsernameAndTenant(String name, String tenant);
+
+    /**
+     * Delete tenant role by id
+     * @param id tenant role

Review Comment:
   Add one blank between doc description and param tag, thanks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] castorqin commented on a diff in pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "castorqin (via GitHub)" <gi...@apache.org>.
castorqin commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255606075


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java:
##########
@@ -116,4 +116,16 @@ public TenantRoleInfo getByUsernameAndTenant(String name, String tenant) {
         return CommonBeanUtils.copyProperties(entity, TenantRoleInfo::new);
     }
 
+    @Override
+    public boolean delete(Integer id) {
+        int rowCount = tenantUserRoleEntityMapper.deleteById(id);
+        if (rowCount != InlongConstants.AFFECTED_ONE_ROW) {

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] castorqin commented on a diff in pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "castorqin (via GitHub)" <gi...@apache.org>.
castorqin commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255853159


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java:
##########
@@ -126,4 +126,11 @@ public List<String> listTenantByUsername(String username) {
         return tenantUserRoleEntityMapper.listByUsername(username);
     }
 
+    @Override
+    public Boolean delete(Integer id) {
+        int success = tenantUserRoleEntityMapper.deleteById(id);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow commented on a diff in pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "healchow (via GitHub)" <gi...@apache.org>.
healchow commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255573517


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleService.java:
##########
@@ -52,4 +52,11 @@ public interface TenantRoleService {
      * Get one tenant role by name and tenant
      */
     TenantRoleInfo getByUsernameAndTenant(String name, String tenant);
+
+    /**
+     * Delete tenant role by id
+     * @param id tenant role
+     * @return true = delete success/ false = delete fail
+     */
+    boolean delete(Integer id);

Review Comment:
   Change the return type to `Boolean` please.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] castorqin commented on a diff in pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "castorqin (via GitHub)" <gi...@apache.org>.
castorqin commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255606384


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleService.java:
##########
@@ -52,4 +52,11 @@ public interface TenantRoleService {
      * Get one tenant role by name and tenant
      */
     TenantRoleInfo getByUsernameAndTenant(String name, String tenant);
+
+    /**
+     * Delete tenant role by id
+     * @param id tenant role

Review Comment:
   done



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleService.java:
##########
@@ -52,4 +52,11 @@ public interface TenantRoleService {
      * Get one tenant role by name and tenant
      */
     TenantRoleInfo getByUsernameAndTenant(String name, String tenant);
+
+    /**
+     * Delete tenant role by id
+     * @param id tenant role
+     * @return true = delete success/ false = delete fail
+     */
+    boolean delete(Integer id);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] fuweng11 commented on a diff in pull request #8463: [INLONG-8442][Manager]Manager support delete tenant and delete tenant role

Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255382292


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java:
##########
@@ -116,4 +116,16 @@ public TenantRoleInfo getByUsernameAndTenant(String name, String tenant) {
         return CommonBeanUtils.copyProperties(entity, TenantRoleInfo::new);
     }
 
+    @Override
+    public boolean delete(Integer id) {
+        int rowCount = tenantUserRoleEntityMapper.deleteById(id);
+        if (rowCount != InlongConstants.AFFECTED_ONE_ROW) {

Review Comment:
   `Preconditions.expectTrue(success == 1, "delete failed");`



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java:
##########
@@ -107,4 +107,11 @@ public Boolean update(InlongTenantRequest request) {
         }
         return true;
     }
+
+    @Override
+    public Boolean delete(String name, String operator) {
+        InlongTenantEntity inlongTenantEntity = inlongTenantEntityMapper.selectByName(name);
+        return inlongTenantEntityMapper.deleteById(inlongTenantEntity.getId()) > 0;

Review Comment:
   Preconditions.expectTrue(success == 1, "delete failed");



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] dockerzhang merged pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "dockerzhang (via GitHub)" <gi...@apache.org>.
dockerzhang merged PR #8463:
URL: https://github.com/apache/inlong/pull/8463


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] castorqin commented on a diff in pull request #8463: [INLONG-8442][Manager]Manager support delete tenant and delete tenant role

Posted by "castorqin (via GitHub)" <gi...@apache.org>.
castorqin commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255331655


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java:
##########
@@ -116,4 +116,9 @@ public TenantRoleInfo getByUsernameAndTenant(String name, String tenant) {
         return CommonBeanUtils.copyProperties(entity, TenantRoleInfo::new);
     }
 
+    @Override
+    public boolean delete(Integer id) {
+        return tenantUserRoleEntityMapper.deleteById(id) > 0;

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] fuweng11 commented on a diff in pull request #8463: [INLONG-8442][Manager] Support delete tenant and tenant role

Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #8463:
URL: https://github.com/apache/inlong/pull/8463#discussion_r1255774930


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java:
##########
@@ -121,6 +122,14 @@ public Boolean update(InlongTenantRequest request) {
         return true;
     }
 
+    @Override
+    public Boolean delete(String name) {

Review Comment:
   ```suggestion
       public Boolean delete(String name, String operator) {
   ```



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java:
##########
@@ -121,6 +122,14 @@ public Boolean update(InlongTenantRequest request) {
         return true;
     }
 
+    @Override
+    public Boolean delete(String name) {
+        InlongTenantEntity inlongTenantEntity = inlongTenantEntityMapper.selectByName(name);

Review Comment:
   Add some log. like `LOGGER.info("begin to delete inlong tenant name={} by user={}", name, operator);`



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java:
##########
@@ -121,6 +122,14 @@ public Boolean update(InlongTenantRequest request) {
         return true;
     }
 
+    @Override
+    public Boolean delete(String name) {
+        InlongTenantEntity inlongTenantEntity = inlongTenantEntityMapper.selectByName(name);
+        int success = inlongTenantEntityMapper.deleteById(inlongTenantEntity.getId());
+        Preconditions.expectTrue(success == 1, "delete failed");
+        return true;

Review Comment:
   Add some log. like LOGGER.info("success to delete inlong tenant name={} by user={}", name, operator);



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java:
##########
@@ -126,4 +126,11 @@ public List<String> listTenantByUsername(String username) {
         return tenantUserRoleEntityMapper.listByUsername(username);
     }
 
+    @Override
+    public Boolean delete(Integer id) {
+        int success = tenantUserRoleEntityMapper.deleteById(id);

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org