You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/04/21 07:11:52 UTC

[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #9536: bugfix:relation_project_user duplicate

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


##########
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/mysql/dolphinscheduler_ddl.sql:
##########
@@ -57,3 +57,8 @@ d//
 delimiter ;
 CALL uc_dolphin_T_t_ds_alert_R_sign;
 DROP PROCEDURE uc_dolphin_T_t_ds_alert_R_sign;
+
+-- add unique key to t_ds_relation_project_user
+ALTER TABLE t_ds_relation_project_user ADD UNIQUE KEY uniq_uid_pid(user_id,project_id);

Review Comment:
   i think we should add to new SQL directory named `3.0.0`?



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java:
##########
@@ -610,14 +606,18 @@ public Map<String, Object> grantProjectByCode(final User loginUser, final int us
         }
 
         // 4. maintain the relationship between project and user
-        final Date today = new Date();
-        ProjectUser projectUser = new ProjectUser();
-        projectUser.setUserId(userId);
-        projectUser.setProjectId(project.getId());
-        projectUser.setPerm(7);
-        projectUser.setCreateTime(today);
-        projectUser.setUpdateTime(today);
-        this.projectUserMapper.insert(projectUser);
+        // check if already existed
+        ProjectUser pu = projectUserMapper.queryProjectRelation(project.getId(), userId);

Review Comment:
   but this `getId` is object `project`'s function



-- 
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-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org