dijiekstra commented on code in PR #2510:
URL: 
https://github.com/apache/incubator-seatunnel/pull/2510#discussion_r956718137


##########
seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/controller/AuthController.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.seatunnel.app.controller;
+
+import org.apache.seatunnel.app.common.Result;
+import org.apache.seatunnel.app.service.IRoleService;
+
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.validation.constraints.NotNull;
+
+@RequestMapping("/api/v1/auth")
+@RestController
+public class AuthController {
+
+    @Resource
+    private IRoleService roleServiceImpl;
+
+    @GetMapping("/userRole")
+    @ApiOperation(value = "check relation between user and role", httpMethod = 
"GET")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userName", value = "user name", dataType 
= "String"),

Review Comment:
   make `userName` lowercase



##########
seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/service/impl/RoleServiceImpl.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.seatunnel.app.service.impl;
+
+import static 
org.apache.seatunnel.server.common.SeatunnelErrorEnum.NO_SUCH_USER;
+import static com.google.common.base.Preconditions.checkState;
+
+import org.apache.seatunnel.app.common.RoleTypeEnum;
+import org.apache.seatunnel.app.common.UserTypeEnum;
+import org.apache.seatunnel.app.dal.dao.IRoleDao;
+import org.apache.seatunnel.app.dal.dao.IRoleUserRelationDao;
+import org.apache.seatunnel.app.dal.dao.IUserDao;
+import org.apache.seatunnel.app.dal.entity.Role;
+import org.apache.seatunnel.app.dal.entity.RoleUserRelation;
+import org.apache.seatunnel.app.dal.entity.User;
+import org.apache.seatunnel.app.service.IRoleService;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+import java.util.Objects;
+
+@Service
+@Slf4j
+public class RoleServiceImpl implements IRoleService {
+
+    @Resource
+    private IRoleDao roleDaoImpl;
+
+    @Resource
+    private IRoleUserRelationDao roleUserRelationDaoImpl;
+
+    @Resource
+    private IUserDao userDaoImpl;
+
+    @Override
+    public boolean addUserToRole(Integer userId, Integer type){
+
+        String roleName = type == UserTypeEnum.ADMIN.getCode() ? 
RoleTypeEnum.ADMIN.getDescription() : RoleTypeEnum.NORMAL.getDescription();

Review Comment:
   add parse(int code) to enum instead of ternary expression



##########
seatunnel-server/seatunnel-app/src/main/resources/org/apache/seatunnel/app/dal/mapper/RoleMapper.xml:
##########
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper namespace="org.apache.seatunnel.app.dal.mapper.RoleMapper">
+  <resultMap id="BaseResultMap" 
type="org.apache.seatunnel.app.dal.entity.Role">
+    <[email protected]>

Review Comment:
   remove useless comment



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