s7monk commented on code in PR #8:
URL: 
https://github.com/apache/incubator-paimon-webui/pull/8#discussion_r1276120527


##########
paimon-web-server/src/main/resources/db/migration/V1__add_user.sql:
##########


Review Comment:
   Would it be better to merge them into one  sql file?



##########
paimon-web-server/src/main/java/org/apache/paimon/web/server/controller/SysRoleController.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.paimon.web.server.controller;
+
+import org.apache.paimon.web.server.data.model.SysRole;
+import org.apache.paimon.web.server.data.model.User;
+import org.apache.paimon.web.server.data.model.UserRole;
+import org.apache.paimon.web.server.data.result.PageR;
+import org.apache.paimon.web.server.data.result.R;
+import org.apache.paimon.web.server.data.result.enums.Status;
+import org.apache.paimon.web.server.service.SysRoleService;
+import org.apache.paimon.web.server.service.UserService;
+import org.apache.paimon.web.server.util.PageSupport;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/** role controller. */
+@RestController
+@RequestMapping("/api/role")
+public class SysRoleController {
+    @Autowired private SysRoleService roleService;
+
+    @Autowired private UserService userService;
+
+    @SaCheckPermission("system:role:list")
+    @GetMapping("/list")
+    public PageR<SysRole> list(SysRole role) {
+        IPage<SysRole> page = PageSupport.startPage();
+        List<SysRole> list = roleService.selectRoleList(page, role);
+        return 
PageR.<SysRole>builder().success(true).total(page.getTotal()).data(list).build();
+    }
+
+    /** Obtain detailed information based on role number. */
+    @SaCheckPermission("system:role:query")
+    @GetMapping(value = "/{roleId}")
+    public R<SysRole> getInfo(@PathVariable Integer roleId) {
+        return R.succeed(roleService.selectRoleById(roleId));
+    }
+
+    /** Add new role. */
+    @SaCheckPermission("system:role:add")
+    @PostMapping
+    public R<Void> add(@Validated @RequestBody SysRole role) {
+        if (!roleService.checkRoleNameUnique(role)) {
+            return R.failed(Status.ROLE_NAME_IS_EXIST, role.getRoleName());
+        } else if (!roleService.checkRoleKeyUnique(role)) {
+            return R.failed(Status.ROLE_KEY_IS_EXIST, role.getRoleKey());
+        }
+
+        return roleService.insertRole(role) > 0 ? R.succeed() : R.failed();
+    }
+
+    /** Update role info. */
+    @SaCheckPermission("system:role:edit")
+    @PutMapping
+    public R<Void> edit(@Validated @RequestBody SysRole role) {
+        roleService.checkRoleAllowed(role);
+        if (!roleService.checkRoleNameUnique(role)) {
+            return R.failed(Status.ROLE_NAME_IS_EXIST, role.getRoleName());
+        } else if (!roleService.checkRoleKeyUnique(role)) {
+            return R.failed(Status.ROLE_KEY_IS_EXIST, role.getRoleKey());
+        }
+
+        if (roleService.updateRole(role) > 0) {
+            // TODO 更新缓存用户权限

Review Comment:
   we can change to english



-- 
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