SbloodyS commented on code in PR #9536:
URL: https://github.com/apache/dolphinscheduler/pull/9536#discussion_r852019275


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java:
##########
@@ -557,20 +557,16 @@ public Map<String, Object> grantProject(User loginUser, 
int userId, String proje
         if (check(result, StringUtils.isEmpty(projectIds), Status.SUCCESS)) {
             return result;
         }
-
-        String[] projectIdArr = projectIds.split(",");
-
-        for (String projectId : projectIdArr) {
+        Arrays.stream(projectIds.split(",")).distinct().forEach(pId -> {
             Date now = new Date();
             ProjectUser projectUser = new ProjectUser();
             projectUser.setUserId(userId);
-            projectUser.setProjectId(Integer.parseInt(projectId));
+            projectUser.setProjectId(Integer.parseInt(pId));

Review Comment:
   It is recommended to use ```projectId``` instead of ```pId```.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java:
##########
@@ -557,20 +557,16 @@ public Map<String, Object> grantProject(User loginUser, 
int userId, String proje
         if (check(result, StringUtils.isEmpty(projectIds), Status.SUCCESS)) {
             return result;
         }
-
-        String[] projectIdArr = projectIds.split(",");
-
-        for (String projectId : projectIdArr) {
+        Arrays.stream(projectIds.split(",")).distinct().forEach(pId -> {
             Date now = new Date();
             ProjectUser projectUser = new ProjectUser();
             projectUser.setUserId(userId);
-            projectUser.setProjectId(Integer.parseInt(projectId));
+            projectUser.setProjectId(Integer.parseInt(pId));

Review Comment:
   It is recommended to use ```projectId``` instead of ```pId```.



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