diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java index 575cf19afb..5679aa26b0 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java @@ -1505,6 +1505,8 @@ public class ProcessDefinitionServiceImpl extends BaseService implements return checkResult; } + // TODO: + // Project targetProject = projectMapper.queryDetailByCode(targetProjectCode); Project targetProject = projectMapper.queryDetailById(targetProjectId); if (targetProject == null) { putMsg(result, Status.PROJECT_NOT_FOUNT, targetProjectId); @@ -1553,6 +1555,8 @@ public class ProcessDefinitionServiceImpl extends BaseService implements return result; } + // TODO : + // Project targetProject = projectMapper.queryDetailByCode(targetProjectCode); Project targetProject = projectMapper.queryDetailById(targetProjectId); if (targetProject == null) { putMsg(result, Status.PROJECT_NOT_FOUNT, targetProjectId); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java index bca3b8d372..89d6787659 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java @@ -100,7 +100,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService { .updateTime(now) .build(); } catch (SnowFlakeException e) { - putMsg(result, Status.CREATE_PROCESS_DEFINITION); + putMsg(result, Status.CREATE_PROJECT_ERROR); return result; } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java index d54f209b5e..f7147c5757 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java @@ -37,6 +37,9 @@ public class ProjectUser { @TableField("project_id") private int projectId; + @TableField("project_code") + private int projectCode; + /** * project name */ @@ -60,6 +63,14 @@ public class ProjectUser { @TableField("update_time") private Date updateTime; + public int getProjectCode() { + return projectCode; + } + + public void setProjectCode(int projectCode) { + this.projectCode = projectCode; + } + public int getId() { return id; } @@ -123,17 +134,19 @@ public class ProjectUser { public void setPerm(int perm) { this.perm = perm; } + @Override public String toString() { - return "ProjectUser{" + - "id=" + id + - ", projectId=" + projectId + - ", projectName='" + projectName + '\'' + - ", userId=" + userId + - ", userName='" + userName + '\'' + - ", perm=" + perm + - ", createTime=" + createTime + - ", updateTime=" + updateTime + - '}'; + return "ProjectUser{" + + "id=" + id + + ", userId=" + userId + + ", projectId=" + projectId + + ", projectCode=" + projectCode + + ", projectName='" + projectName + '\'' + + ", userName='" + userName + '\'' + + ", perm=" + perm + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + '}'; } } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.java index 872d53fd92..ffc45a2eb3 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.java @@ -31,14 +31,28 @@ import com.baomidou.mybatisplus.core.metadata.IPage; * project mapper interface */ public interface ProjectMapper extends BaseMapper { + /** + * query project detail by code + * @param projectCode projectCode + * @return project + */ + Project queryByCode(@Param("projectCode") Long projectCode); /** + * TODO: delete * query project detail by id * @param projectId projectId * @return project */ Project queryDetailById(@Param("projectId") int projectId); + /** + * query project detail by code + * @param projectCode projectCode + * @return project + */ + Project queryDetailByCode(@Param("projectCode") Long projectCode); + /** * query project by name * @param projectName projectName @@ -91,5 +105,4 @@ public interface ProjectMapper extends BaseMapper { * @return projectName and userName */ ProjectUser queryProjectWithUserByProcessInstanceId(@Param("processInstanceId") int processInstanceId); - } diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml index 9def02d9af..53f073650a 100644 --- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml @@ -25,6 +25,26 @@ ${alias}.id, ${alias}.name, ${alias}.code, ${alias}.description, ${alias}.user_id, ${alias}.flag, ${alias}.create_time, ${alias}.update_time + + + + + select - dp.id projectId, + dp.code projectCode, dp.name projectName, u.user_name userName from t_ds_process_instance di - join t_ds_process_definition dpd on di.process_definition_id = dpd.id - join t_ds_project dp on dpd.project_id = dp.id + join t_ds_process_definition dpd on di.process_definition_code = dpd.code + join t_ds_project dp on dpd.project_code = dp.code join t_ds_user u on dp.user_id = u.id where di.id = #{processInstanceId}; diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.xml index de74d6480c..8c19ab38f1 100644 --- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.xml +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.xml @@ -19,7 +19,7 @@ - id, user_id, project_id, perm, create_time, update_time + id, user_id, project_code, perm, create_time, update_time delete from t_ds_relation_project_user diff --git a/sql/dolphinscheduler_mysql.sql b/sql/dolphinscheduler_mysql.sql index 640b55a866..d564241581 100644 --- a/sql/dolphinscheduler_mysql.sql +++ b/sql/dolphinscheduler_mysql.sql @@ -692,7 +692,7 @@ DROP TABLE IF EXISTS `t_ds_relation_project_user`; CREATE TABLE `t_ds_relation_project_user` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key', `user_id` int(11) NOT NULL COMMENT 'user id', - `project_id` int(11) DEFAULT NULL COMMENT 'project id', + `project_code` bigint(20) DEFAULT NULL COMMENT 'project code', `perm` int(11) DEFAULT '1' COMMENT 'limits of authority', `create_time` datetime DEFAULT NULL COMMENT 'create time', `update_time` datetime DEFAULT NULL COMMENT 'update time',