Skip to content

Commit cc1640b

Browse files
authored
Merge pull request #114 from stelin/main
1.0.4
2 parents 0c84d17 + cbe86a4 commit cc1640b

File tree

120 files changed

+4333
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+4333
-307
lines changed

openjob-common/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,10 @@
3131
<artifactId>junit-jupiter-api</artifactId>
3232
<scope>test</scope>
3333
</dependency>
34+
35+
<dependency>
36+
<groupId>com.fasterxml.jackson.core</groupId>
37+
<artifactId>jackson-databind</artifactId>
38+
</dependency>
3439
</dependencies>
3540
</project>

openjob-common/src/main/java/io/openjob/common/constant/ExecuteTypeEnum.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public enum ExecuteTypeEnum {
2828
/**
2929
* Sharding.
3030
*/
31-
Sharding("sharding"),
31+
SHARDING("sharding"),
3232
;
3333

3434
private final String type;
@@ -42,4 +42,35 @@ public enum ExecuteTypeEnum {
4242
public static Boolean isStandalone(String type) {
4343
return STANDALONE.getType().equals(type);
4444
}
45+
46+
/**
47+
* Whether is broadcast
48+
*
49+
* @param type type
50+
* @return Boolean
51+
*/
52+
public static Boolean isBroadcast(String type) {
53+
return BROADCAST.getType().equals(type);
54+
}
55+
56+
57+
/**
58+
* Whether is map reduce
59+
*
60+
* @param type type
61+
* @return Boolean
62+
*/
63+
public static Boolean isMapReduce(String type) {
64+
return MAP_REDUCE.getType().equals(type);
65+
}
66+
67+
/**
68+
* Whether is sharding
69+
*
70+
* @param type type
71+
* @return Boolean
72+
*/
73+
public static Boolean isSharding(String type) {
74+
return SHARDING.getType().equals(type);
75+
}
4576
}

openjob-common/src/main/java/io/openjob/common/constant/ProcessorTypeEnum.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,32 @@ public enum ProcessorTypeEnum {
2020
*/
2121
SHELL("shell"),
2222

23+
/**
24+
* Kettle.
25+
*/
26+
KETTLE("kettle"),
27+
2328
/**
2429
* Http.
2530
*/
2631
HTTP("http"),
2732
;
2833

2934
private final String type;
35+
36+
public static Boolean isProcessor(String type) {
37+
return ProcessorTypeEnum.PROCESSOR.getType().equals(type);
38+
}
39+
40+
public static Boolean isShell(String type) {
41+
return ProcessorTypeEnum.SHELL.getType().equals(type);
42+
}
43+
44+
public static Boolean isKettle(String type) {
45+
return ProcessorTypeEnum.KETTLE.getType().equals(type);
46+
}
47+
48+
public static Boolean isHttp(String type) {
49+
return ProcessorTypeEnum.HTTP.getType().equals(type);
50+
}
3051
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.openjob.common.constant;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
6+
/**
7+
* @author stelin swoft@qq.com
8+
* @since 1.0.4
9+
*/
10+
@Getter
11+
@AllArgsConstructor
12+
public enum ShellTypeEnum {
13+
14+
/**
15+
* unix
16+
*/
17+
UNIX("unix"),
18+
19+
/**
20+
* windows
21+
*/
22+
WINDOWS("windows"),
23+
;
24+
25+
/**
26+
* Type
27+
*/
28+
private final String type;
29+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.openjob.common.dto;
2+
3+
import lombok.Data;
4+
import io.openjob.common.constant.ShellTypeEnum;
5+
6+
/**
7+
* @author stelin swoft@qq.com
8+
* @since 1.0.4
9+
*/
10+
@Data
11+
public class ShellProcessorDTO {
12+
/**
13+
* Content
14+
*/
15+
private String content;
16+
17+
/**
18+
* Type
19+
*
20+
* @see ShellTypeEnum
21+
*/
22+
private String type;
23+
}

openjob-server/openjob-server-common/src/main/java/io/openjob/server/common/util/JsonUtil.java renamed to openjob-common/src/main/java/io/openjob/common/util/JsonUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.openjob.server.common.util;
1+
package io.openjob.common.util;
22

33
import com.fasterxml.jackson.core.JsonProcessingException;
44
import com.fasterxml.jackson.core.type.TypeReference;

openjob-server/openjob-server-admin/src/main/java/io/openjob/server/admin/constant/CodeEnum.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
public enum CodeEnum implements CodeExceptionAssert {
2020
// Code list
2121
USER_EXIST(100, "User is exist!"),
22+
USER_NOT_FOUND(101, "User not found"),
23+
USER_DELETED(102, "User deleted"),
24+
USER_PWD_INVALID(103, "User password invalid"),
25+
USER_ROLE_EMPTY(104, "User role empty"),
26+
USER_VERIFY_CODE_INVALID(105, "Verification code invalid"),
2227

2328
// Namespace
2429
NAMESPACE_DELETE_INVALID(200, "Namespace can not be delete!"),
@@ -30,6 +35,11 @@ public enum CodeEnum implements CodeExceptionAssert {
3035
// Job
3136
TIME_EXPRESSION_INVALID(400, "Time expression is invalid"),
3237
JOB_DELETE_INVALID(401, "Job can not be deleted!"),
38+
SHELL_PROCESSOR_INFO_INVALID(402, "Shell content can not be empty!"),
39+
SHELL_PROCESSOR_TYPE_INVALID(403, "Shell type type can not be empty!"),
40+
KETTLE_PROCESSOR_INFO_INVALID(404, "Kettle command can not be empty!"),
41+
KETTLE_PROCESSOR_TYPE_INVALID(405, "Kettle command type can not be empty!"),
42+
SHARDING_PARAMS_INVALID(406, "Sharding params can not be empty!"),
3343

3444
// Delay
3545
DELAY_TOPIC_EXIST(500, "Topic is exist!"),

openjob-server/openjob-server-admin/src/main/java/io/openjob/server/admin/request/delay/UpdateDelayRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class UpdateDelayRequest {
3838
@ApiModelProperty(value = "Description", required = true)
3939
private String description;
4040

41-
@ApiModelProperty(value = "", required = true)
41+
@ApiModelProperty(value = "Processor info", required = true)
4242
private String processorInfo;
4343

4444
@ApiModelProperty(value = "Fail retry times", required = true)

openjob-server/openjob-server-admin/src/main/java/io/openjob/server/admin/request/job/AddJobRequest.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,34 @@ public class AddJobRequest {
3434
@ApiModelProperty(value = "Job process type: bean/shell/python, default(bean)", required = true)
3535
private String processorType;
3636

37-
@NotBlank
38-
@ApiModelProperty(value = "Job process info", required = true)
37+
@ApiModelProperty(value = "Job process info")
3938
private String processorInfo;
4039

40+
@ApiModelProperty(value = "Shell processor info")
41+
private String shellProcessorInfo;
42+
43+
@ApiModelProperty(value = "Shell processor type")
44+
private String shellProcessorType;
45+
46+
@ApiModelProperty(value = "Kettle processor type")
47+
private String kettleProcessorType;
48+
49+
@ApiModelProperty(value = "Kettle processor info")
50+
private String kettleProcessorInfo;
51+
52+
@ApiModelProperty(value = "Sharding params")
53+
private String shardingParams;
54+
4155
@NotBlank
4256
@ApiModelProperty(value = "Execute type: standalone, broadcast, MR", required = true)
4357
private String executeType;
4458

45-
@NotBlank
46-
@ApiModelProperty(value = "Job params type", required = true)
59+
@ApiModelProperty(value = "Job params type")
4760
private String paramsType;
4861

4962
@ApiModelProperty(value = "Job params")
5063
private String params;
5164

52-
@NotBlank
5365
@ApiModelProperty(value = "Job extend params type")
5466
private String extendParamsType;
5567

openjob-server/openjob-server-admin/src/main/java/io/openjob/server/admin/service/impl/AdminLoginServiceImpl.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.openjob.common.util.DateUtil;
55
import io.openjob.server.admin.autoconfigure.AdminUserProperties;
66
import io.openjob.server.admin.constant.AdminHttpStatusEnum;
7+
import io.openjob.server.admin.constant.CodeEnum;
78
import io.openjob.server.admin.request.admin.AdminUserLoginRequest;
89
import io.openjob.server.admin.request.admin.AdminUserLogoutRequest;
910
import io.openjob.server.admin.request.admin.LoginUserInfoRequest;
@@ -73,19 +74,19 @@ public LoginUserInfoVO loginUserInfo(LoginUserInfoRequest request, String sessKe
7374

7475
private void checkLoginUser(AdminUser user, String passwd) {
7576
if (Objects.isNull(user)) {
76-
AdminHttpStatusEnum.NOT_FOUND.throwException();
77+
CodeEnum.USER_NOT_FOUND.throwException();
7778
}
7879

7980
if (CommonUtil.isTrue(user.getDeleted())) {
80-
AdminHttpStatusEnum.NOT_FOUND.throwException();
81+
CodeEnum.USER_DELETED.throwException();
8182
}
8283

8384
if (!HmacUtil.verifyPasswd(user.getPasswd(), passwd, userProperties.getPasswdSalt())) {
84-
AdminHttpStatusEnum.FORBIDDEN.throwException();
85+
CodeEnum.USER_PWD_INVALID.throwException();
8586
}
8687

87-
if (CollectionUtils.isEmpty(user.getRoleIds())) {
88-
AdminHttpStatusEnum.FORBIDDEN.throwException();
88+
if (CollectionUtils.isEmpty(user.getRoleIdsByJson())) {
89+
CodeEnum.USER_ROLE_EMPTY.throwException();
8990
}
9091
}
9192

@@ -105,7 +106,7 @@ private AdminUserLoginVO buildUserLoginVO(AdminUser user) {
105106
.build();
106107

107108
// Query user role and perms
108-
List<AdminRole> roles = this.adminRoleDAO.getByIds(user.getRoleIds());
109+
List<AdminRole> roles = this.adminRoleDAO.getByIds(user.getRoleIdsByJson());
109110
if (CollectionUtils.isEmpty(roles)) {
110111
AdminHttpStatusEnum.NOT_FOUND.throwException();
111112
}
@@ -118,7 +119,7 @@ private AdminUserLoginVO buildUserLoginVO(AdminUser user) {
118119
isAdmin.set(true);
119120
return;
120121
}
121-
permIds.addAll(r.getPermIds());
122+
permIds.addAll(r.getPermIdsByJson());
122123
});
123124
loginVO.setSupperAdmin(isAdmin.get());
124125

0 commit comments

Comments
 (0)