fuweng11 commented on code in PR #8100: URL: https://github.com/apache/inlong/pull/8100#discussion_r1209779574
########## inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/InlongRoleServiceImpl.java: ########## @@ -0,0 +1,89 @@ +/* + * 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.service.user; + +import org.apache.inlong.manager.common.consts.InlongConstants; +import org.apache.inlong.manager.common.enums.ErrorCodeEnum; +import org.apache.inlong.manager.common.exceptions.BusinessException; +import org.apache.inlong.manager.common.util.CommonBeanUtils; +import org.apache.inlong.manager.common.util.Preconditions; +import org.apache.inlong.manager.dao.entity.InlongUserRoleEntity; +import org.apache.inlong.manager.dao.mapper.InlongUserRoleEntityMapper; +import org.apache.inlong.manager.pojo.user.InlongRoleInfo; +import org.apache.inlong.manager.pojo.user.InlongRolePageRequest; +import org.apache.inlong.manager.pojo.user.InlongRoleRequest; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class InlongRoleServiceImpl implements InlongRoleService { + + @Autowired + private InlongUserRoleEntityMapper inlongUserMapper; + + @Override + public PageInfo<InlongRoleInfo> listByCondition(InlongRolePageRequest request) { + PageHelper.startPage(request.getPageNum(), request.getPageSize()); + Page<InlongUserRoleEntity> entityPage = inlongUserMapper.selectByCondition(request); + return entityPage.toPageInfo(entity -> CommonBeanUtils.copyProperties(entity, InlongRoleInfo::new)); + } + + @Override + public int save(InlongRoleRequest request) { + String username = request.getUsername(); + Preconditions.expectNotBlank(username, "Failed to save tenant user role, user should not be blank"); Review Comment: "Failed to save inlong user role, user should not be blank" ########## inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongRoleController.java: ########## @@ -0,0 +1,72 @@ +/* + * 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; + +import org.apache.inlong.manager.common.enums.OperationType; +import org.apache.inlong.manager.pojo.common.Response; +import org.apache.inlong.manager.pojo.user.InlongRoleInfo; +import org.apache.inlong.manager.pojo.user.InlongRolePageRequest; +import org.apache.inlong.manager.pojo.user.InlongRoleRequest; +import org.apache.inlong.manager.pojo.user.UserRoleCode; +import org.apache.inlong.manager.service.operationlog.OperationLog; +import org.apache.inlong.manager.service.user.InlongRoleService; + +import com.github.pagehelper.PageInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +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("/api") +@Api(tags = "INLONG-USER-API") +public class InlongRoleController { + + @Autowired + private InlongRoleService inlongRoleService; + + @RequestMapping(value = "/role/inlong/get/{id}", method = RequestMethod.GET) + @ApiOperation(value = "Get tenant role") + @RequiresRoles(value = UserRoleCode.INLONG_ADMIN) + @ApiImplicitParam(name = "id", dataTypeClass = Integer.class, required = true) + public Response<InlongRoleInfo> get(@PathVariable int id) { + return Response.success(inlongRoleService.get(id)); + } + + @RequestMapping(value = "/role/inlong/save", method = RequestMethod.POST) + @OperationLog(operation = OperationType.CREATE) + @RequiresRoles(value = UserRoleCode.INLONG_ADMIN) + @ApiOperation(value = "Save tenant role") + public Response<Integer> save(@Validated @RequestBody InlongRoleRequest request) { + return Response.success(inlongRoleService.save(request)); + } + + @RequestMapping(value = "/role/inlong/list", method = RequestMethod.POST) + @ApiOperation(value = "List tenant by paginating") Review Comment: "List inlong user role info by paginating" ########## inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/InlongRoleServiceImpl.java: ########## @@ -0,0 +1,89 @@ +/* + * 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.service.user; + +import org.apache.inlong.manager.common.consts.InlongConstants; +import org.apache.inlong.manager.common.enums.ErrorCodeEnum; +import org.apache.inlong.manager.common.exceptions.BusinessException; +import org.apache.inlong.manager.common.util.CommonBeanUtils; +import org.apache.inlong.manager.common.util.Preconditions; +import org.apache.inlong.manager.dao.entity.InlongUserRoleEntity; +import org.apache.inlong.manager.dao.mapper.InlongUserRoleEntityMapper; +import org.apache.inlong.manager.pojo.user.InlongRoleInfo; +import org.apache.inlong.manager.pojo.user.InlongRolePageRequest; +import org.apache.inlong.manager.pojo.user.InlongRoleRequest; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class InlongRoleServiceImpl implements InlongRoleService { + + @Autowired + private InlongUserRoleEntityMapper inlongUserMapper; + + @Override + public PageInfo<InlongRoleInfo> listByCondition(InlongRolePageRequest request) { + PageHelper.startPage(request.getPageNum(), request.getPageSize()); + Page<InlongUserRoleEntity> entityPage = inlongUserMapper.selectByCondition(request); + return entityPage.toPageInfo(entity -> CommonBeanUtils.copyProperties(entity, InlongRoleInfo::new)); + } + + @Override + public int save(InlongRoleRequest request) { + String username = request.getUsername(); + Preconditions.expectNotBlank(username, "Failed to save tenant user role, user should not be blank"); + Preconditions.expectNotBlank(request.getRoleCode(), Review Comment: "Failed to save inlong user role, role code should not be blank" ########## inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongRoleController.java: ########## @@ -0,0 +1,72 @@ +/* + * 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; + +import org.apache.inlong.manager.common.enums.OperationType; +import org.apache.inlong.manager.pojo.common.Response; +import org.apache.inlong.manager.pojo.user.InlongRoleInfo; +import org.apache.inlong.manager.pojo.user.InlongRolePageRequest; +import org.apache.inlong.manager.pojo.user.InlongRoleRequest; +import org.apache.inlong.manager.pojo.user.UserRoleCode; +import org.apache.inlong.manager.service.operationlog.OperationLog; +import org.apache.inlong.manager.service.user.InlongRoleService; + +import com.github.pagehelper.PageInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +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("/api") +@Api(tags = "INLONG-USER-API") +public class InlongRoleController { + + @Autowired + private InlongRoleService inlongRoleService; + + @RequestMapping(value = "/role/inlong/get/{id}", method = RequestMethod.GET) + @ApiOperation(value = "Get tenant role") + @RequiresRoles(value = UserRoleCode.INLONG_ADMIN) + @ApiImplicitParam(name = "id", dataTypeClass = Integer.class, required = true) + public Response<InlongRoleInfo> get(@PathVariable int id) { + return Response.success(inlongRoleService.get(id)); + } + + @RequestMapping(value = "/role/inlong/save", method = RequestMethod.POST) + @OperationLog(operation = OperationType.CREATE) + @RequiresRoles(value = UserRoleCode.INLONG_ADMIN) + @ApiOperation(value = "Save tenant role") Review Comment: "Save inlong user role" ########## inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongRoleController.java: ########## @@ -0,0 +1,72 @@ +/* + * 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; + +import org.apache.inlong.manager.common.enums.OperationType; +import org.apache.inlong.manager.pojo.common.Response; +import org.apache.inlong.manager.pojo.user.InlongRoleInfo; +import org.apache.inlong.manager.pojo.user.InlongRolePageRequest; +import org.apache.inlong.manager.pojo.user.InlongRoleRequest; +import org.apache.inlong.manager.pojo.user.UserRoleCode; +import org.apache.inlong.manager.service.operationlog.OperationLog; +import org.apache.inlong.manager.service.user.InlongRoleService; + +import com.github.pagehelper.PageInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +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("/api") +@Api(tags = "INLONG-USER-API") +public class InlongRoleController { + + @Autowired + private InlongRoleService inlongRoleService; + + @RequestMapping(value = "/role/inlong/get/{id}", method = RequestMethod.GET) + @ApiOperation(value = "Get tenant role") Review Comment: "Get inlong role" -- 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-unsubscr...@inlong.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org