Browse Source

[Feature][JsonSplit] Add Project code (#4509)

* modify ProcessDefinition and add ProcessDefinitionLog

* processDefinitionJson

* code style

* code style

* code style

* Add Project code

* codeStyle

* conflicts

* conflicts
pull/3/MERGE
Simon 4 years ago committed by GitHub
parent
commit
0055ef4413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
  2. 42
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java
  3. 6
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml

8
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java

@ -24,6 +24,8 @@ import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils;
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils.SnowFlakeException;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.ProjectUser;
@ -85,15 +87,21 @@ public class ProjectServiceImpl extends BaseService implements ProjectService {
Date now = new Date(); Date now = new Date();
try {
project = Project project = Project
.newBuilder() .newBuilder()
.name(name) .name(name)
.code(SnowFlakeUtils.getInstance().nextId())
.description(desc) .description(desc)
.userId(loginUser.getId()) .userId(loginUser.getId())
.userName(loginUser.getUserName()) .userName(loginUser.getUserName())
.createTime(now) .createTime(now)
.updateTime(now) .updateTime(now)
.build(); .build();
} catch (SnowFlakeException e) {
putMsg(result, Status.CREATE_PROCESS_DEFINITION);
return result;
}
if (projectMapper.insert(project) > 0) { if (projectMapper.insert(project) > 0) {
Project insertedProject = projectMapper.queryByName(name); Project insertedProject = projectMapper.queryByName(name);

42
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java

@ -47,6 +47,11 @@ public class Project {
@TableField(exist = false) @TableField(exist = false)
private String userName; private String userName;
/**
* project code
*/
private Long code;
/** /**
* project name * project name
*/ */
@ -85,6 +90,14 @@ public class Project {
@TableField(exist = false) @TableField(exist = false)
private int instRunningCount; private int instRunningCount;
public Long getCode() {
return code;
}
public void setCode(Long code) {
this.code = code;
}
public int getDefCount() { public int getDefCount() {
return defCount; return defCount;
} }
@ -167,15 +180,19 @@ public class Project {
@Override @Override
public String toString() { public String toString() {
return "Project{" + return "Project{"
"id=" + id + + "id=" + id
", userId=" + userId + + ", userId=" + userId
", userName='" + userName + '\'' + + ", userName='" + userName + '\''
", name='" + name + '\'' + + ", code=" + code
", description='" + description + '\'' + + ", name='" + name + '\''
", createTime=" + createTime + + ", description='" + description + '\''
", updateTime=" + updateTime + + ", createTime=" + createTime
'}'; + ", updateTime=" + updateTime
+ ", perm=" + perm
+ ", defCount=" + defCount
+ ", instRunningCount=" + instRunningCount
+ '}';
} }
@Override @Override
@ -211,6 +228,7 @@ public class Project {
private int id; private int id;
private int userId; private int userId;
private String userName; private String userName;
private Long code;
private String name; private String name;
private String description; private String description;
private Date createTime; private Date createTime;
@ -222,6 +240,11 @@ public class Project {
private Builder() { private Builder() {
} }
public Builder code(Long code) {
this.code = code;
return this;
}
public Builder id(int id) { public Builder id(int id) {
this.id = id; this.id = id;
return this; return this;
@ -276,6 +299,7 @@ public class Project {
Project project = new Project(); Project project = new Project();
project.setId(id); project.setId(id);
project.setUserId(userId); project.setUserId(userId);
project.setCode(code);
project.setUserName(userName); project.setUserName(userName);
project.setName(name); project.setName(name);
project.setDescription(description); project.setDescription(description);

6
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml

@ -20,10 +20,10 @@
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectMapper">
<sql id="baseSql"> <sql id="baseSql">
id, name, description, user_id, flag, create_time, update_time id, name, code, description, user_id, flag, create_time, update_time
</sql> </sql>
<sql id="baseSqlV2"> <sql id="baseSqlV2">
${alias}.id, ${alias}.name, ${alias}.description, ${alias}.user_id, ${alias}.flag, ${alias}.create_time, ${alias}.update_time ${alias}.id, ${alias}.name, ${alias}.code, ${alias}.description, ${alias}.user_id, ${alias}.flag, ${alias}.create_time, ${alias}.update_time
</sql> </sql>
<select id="queryDetailById" resultType="org.apache.dolphinscheduler.dao.entity.Project"> <select id="queryDetailById" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select select
@ -109,4 +109,4 @@
join t_ds_user u on dp.user_id = u.id join t_ds_user u on dp.user_id = u.id
where di.id = #{processInstanceId}; where di.id = #{processInstanceId};
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save