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. 4
      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.common.Constants;
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.Project;
import org.apache.dolphinscheduler.dao.entity.ProjectUser;
@ -85,15 +87,21 @@ public class ProjectServiceImpl extends BaseService implements ProjectService {
Date now = new Date();
try {
project = Project
.newBuilder()
.name(name)
.code(SnowFlakeUtils.getInstance().nextId())
.description(desc)
.userId(loginUser.getId())
.userName(loginUser.getUserName())
.createTime(now)
.updateTime(now)
.build();
} catch (SnowFlakeException e) {
putMsg(result, Status.CREATE_PROCESS_DEFINITION);
return result;
}
if (projectMapper.insert(project) > 0) {
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)
private String userName;
/**
* project code
*/
private Long code;
/**
* project name
*/
@ -85,6 +90,14 @@ public class Project {
@TableField(exist = false)
private int instRunningCount;
public Long getCode() {
return code;
}
public void setCode(Long code) {
this.code = code;
}
public int getDefCount() {
return defCount;
}
@ -167,15 +180,19 @@ public class Project {
@Override
public String toString() {
return "Project{" +
"id=" + id +
", userId=" + userId +
", userName='" + userName + '\'' +
", name='" + name + '\'' +
", description='" + description + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
return "Project{"
+ "id=" + id
+ ", userId=" + userId
+ ", userName='" + userName + '\''
+ ", code=" + code
+ ", name='" + name + '\''
+ ", description='" + description + '\''
+ ", createTime=" + createTime
+ ", updateTime=" + updateTime
+ ", perm=" + perm
+ ", defCount=" + defCount
+ ", instRunningCount=" + instRunningCount
+ '}';
}
@Override
@ -211,6 +228,7 @@ public class Project {
private int id;
private int userId;
private String userName;
private Long code;
private String name;
private String description;
private Date createTime;
@ -222,6 +240,11 @@ public class Project {
private Builder() {
}
public Builder code(Long code) {
this.code = code;
return this;
}
public Builder id(int id) {
this.id = id;
return this;
@ -276,6 +299,7 @@ public class Project {
Project project = new Project();
project.setId(id);
project.setUserId(userId);
project.setCode(code);
project.setUserName(userName);
project.setName(name);
project.setDescription(description);

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

@ -20,10 +20,10 @@
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectMapper">
<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 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>
<select id="queryDetailById" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select

Loading…
Cancel
Save