vernedeng commented on code in PR #8665:
URL: https://github.com/apache/inlong/pull/8665#discussion_r1287882732


##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/OpenInLongClusterController.java:
##########
@@ -80,6 +87,8 @@ public Response<ClusterTagResponse> getTag(@PathVariable 
Integer id) {
     public Response<List<ClusterTagResponse>> listTag(@RequestBody 
ClusterTagPageRequest request) {
         Preconditions.expectNotNull(request, ErrorCodeEnum.INVALID_PARAMETER, 
"request cannot be null");
         Preconditions.expectNotNull(LoginUserUtils.getLoginUser(), 
ErrorCodeEnum.LOGIN_USER_EMPTY);
+        request.setIsAdminRole(
+                
LoginUserUtils.getLoginUser().getRoles().contains(TenantUserTypeEnum.TENANT_ADMIN.name()));

Review Comment:
   Both INLONG_ADMIN and TENANT_ADMIN are admin role for this interface 



##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/OpenInLongClusterController.java:
##########
@@ -125,6 +134,8 @@ public Response<ClusterInfo> get(@PathVariable Integer id) {
     public Response<List<ClusterInfo>> list(@RequestBody ClusterPageRequest 
request) {
         Preconditions.expectNotNull(request, ErrorCodeEnum.INVALID_PARAMETER, 
"request cannot be null");
         Preconditions.expectNotNull(LoginUserUtils.getLoginUser(), 
ErrorCodeEnum.LOGIN_USER_EMPTY);
+        request.setIsAdminRole(
+                
LoginUserUtils.getLoginUser().getRoles().contains(TenantUserTypeEnum.TENANT_ADMIN.name()));

Review Comment:
   ditto



##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/OpenInlongTenantRoleController.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.web.controller.openapi;
+
+import org.apache.inlong.manager.common.enums.OperationType;
+import org.apache.inlong.manager.pojo.common.PageResult;
+import org.apache.inlong.manager.pojo.common.Response;
+import org.apache.inlong.manager.pojo.user.LoginUserUtils;
+import org.apache.inlong.manager.pojo.user.TenantRoleInfo;
+import org.apache.inlong.manager.pojo.user.TenantRolePageRequest;
+import org.apache.inlong.manager.pojo.user.TenantRoleRequest;
+import org.apache.inlong.manager.pojo.user.UserRoleCode;
+import org.apache.inlong.manager.service.operationlog.OperationLog;
+import org.apache.inlong.manager.service.user.TenantRoleService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/openapi")
+@Api(tags = "Open-InlongTenantRole-API")
+public class OpenInlongTenantRoleController {
+
+    @Autowired
+    private TenantRoleService tenantRoleService;
+
+    @RequestMapping(value = "/role/tenant/get/{id}", method = 
RequestMethod.GET)
+    @ApiOperation(value = "Get tenant role by ID")
+    @ApiImplicitParam(name = "id", dataTypeClass = Integer.class, required = 
true)
+    @RequiresRoles(logical = Logical.OR, value = {UserRoleCode.TENANT_ADMIN, 
UserRoleCode.TENANT_OPERATOR,
+            UserRoleCode.INLONG_ADMIN})
+    public Response<TenantRoleInfo> get(@PathVariable int id) {
+        return Response.success(tenantRoleService.get(id));
+    }
+
+    @RequestMapping(value = "/role/tenant/save", method = RequestMethod.POST)
+    @OperationLog(operation = OperationType.CREATE)
+    @ApiOperation(value = "Save tenant role")
+    @RequiresRoles(logical = Logical.OR, value = {UserRoleCode.TENANT_ADMIN, 
UserRoleCode.INLONG_ADMIN})
+    public Response<Integer> save(@Validated @RequestBody TenantRoleRequest 
request) {
+        String operator = LoginUserUtils.getLoginUser().getName();
+        return Response.success(tenantRoleService.save(request, operator));
+    }
+
+    @RequestMapping(value = "/role/tenant/update", method = RequestMethod.POST)
+    @OperationLog(operation = OperationType.CREATE)
+    @ApiOperation(value = "Update tenant role")
+    public Response<Boolean> update(@Validated @RequestBody TenantRoleRequest 
request) {
+        String operator = LoginUserUtils.getLoginUser().getName();
+        return Response.success(tenantRoleService.update(request, operator));
+    }
+
+    @RequestMapping(value = "/role/tenant/list", method = RequestMethod.POST)
+    @ApiOperation(value = "List tenant roles by paginating")
+    public Response<PageResult<TenantRoleInfo>> listByCondition(@RequestBody 
TenantRolePageRequest request) {
+        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.INLONG_ADMIN})

Review Comment:
   Only INLONG ADMIN can delete tenants



##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/OpenInlongTenantRoleController.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.web.controller.openapi;
+
+import org.apache.inlong.manager.common.enums.OperationType;
+import org.apache.inlong.manager.pojo.common.PageResult;
+import org.apache.inlong.manager.pojo.common.Response;
+import org.apache.inlong.manager.pojo.user.LoginUserUtils;
+import org.apache.inlong.manager.pojo.user.TenantRoleInfo;
+import org.apache.inlong.manager.pojo.user.TenantRolePageRequest;
+import org.apache.inlong.manager.pojo.user.TenantRoleRequest;
+import org.apache.inlong.manager.pojo.user.UserRoleCode;
+import org.apache.inlong.manager.service.operationlog.OperationLog;
+import org.apache.inlong.manager.service.user.TenantRoleService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/openapi")
+@Api(tags = "Open-InlongTenantRole-API")
+public class OpenInlongTenantRoleController {
+
+    @Autowired
+    private TenantRoleService tenantRoleService;
+
+    @RequestMapping(value = "/role/tenant/get/{id}", method = 
RequestMethod.GET)
+    @ApiOperation(value = "Get tenant role by ID")
+    @ApiImplicitParam(name = "id", dataTypeClass = Integer.class, required = 
true)
+    @RequiresRoles(logical = Logical.OR, value = {UserRoleCode.TENANT_ADMIN, 
UserRoleCode.TENANT_OPERATOR,
+            UserRoleCode.INLONG_ADMIN})
+    public Response<TenantRoleInfo> get(@PathVariable int id) {
+        return Response.success(tenantRoleService.get(id));
+    }
+
+    @RequestMapping(value = "/role/tenant/save", method = RequestMethod.POST)
+    @OperationLog(operation = OperationType.CREATE)
+    @ApiOperation(value = "Save tenant role")
+    @RequiresRoles(logical = Logical.OR, value = {UserRoleCode.TENANT_ADMIN, 
UserRoleCode.INLONG_ADMIN})
+    public Response<Integer> save(@Validated @RequestBody TenantRoleRequest 
request) {
+        String operator = LoginUserUtils.getLoginUser().getName();
+        return Response.success(tenantRoleService.save(request, operator));
+    }
+
+    @RequestMapping(value = "/role/tenant/update", method = RequestMethod.POST)
+    @OperationLog(operation = OperationType.CREATE)
+    @ApiOperation(value = "Update tenant role")
+    public Response<Boolean> update(@Validated @RequestBody TenantRoleRequest 
request) {

Review Comment:
   Only INLONG_ADMIN or TENANT_ADMIN can update tenant info



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to