Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.4 #114

Merged
merged 34 commits into from
Jul 3, 2023
Merged

1.0.4 #114

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions openjob-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum ExecuteTypeEnum {
/**
* Sharding.
*/
Sharding("sharding"),
SHARDING("sharding"),
;

private final String type;
Expand All @@ -42,4 +42,35 @@ public enum ExecuteTypeEnum {
public static Boolean isStandalone(String type) {
return STANDALONE.getType().equals(type);
}

/**
* Whether is broadcast
*
* @param type type
* @return Boolean
*/
public static Boolean isBroadcast(String type) {
return BROADCAST.getType().equals(type);
}


/**
* Whether is map reduce
*
* @param type type
* @return Boolean
*/
public static Boolean isMapReduce(String type) {
return MAP_REDUCE.getType().equals(type);
}

/**
* Whether is sharding
*
* @param type type
* @return Boolean
*/
public static Boolean isSharding(String type) {
return SHARDING.getType().equals(type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,32 @@ public enum ProcessorTypeEnum {
*/
SHELL("shell"),

/**
* Kettle.
*/
KETTLE("kettle"),

/**
* Http.
*/
HTTP("http"),
;

private final String type;

public static Boolean isProcessor(String type) {
return ProcessorTypeEnum.PROCESSOR.getType().equals(type);
}

public static Boolean isShell(String type) {
return ProcessorTypeEnum.SHELL.getType().equals(type);
}

public static Boolean isKettle(String type) {
return ProcessorTypeEnum.KETTLE.getType().equals(type);
}

public static Boolean isHttp(String type) {
return ProcessorTypeEnum.HTTP.getType().equals(type);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.openjob.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* @author stelin [email protected]
* @since 1.0.4
*/
@Getter
@AllArgsConstructor
public enum ShellTypeEnum {

/**
* unix
*/
UNIX("unix"),

/**
* windows
*/
WINDOWS("windows"),
;

/**
* Type
*/
private final String type;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.openjob.common.dto;

import lombok.Data;
import io.openjob.common.constant.ShellTypeEnum;

/**
* @author stelin [email protected]
* @since 1.0.4
*/
@Data
public class ShellProcessorDTO {
/**
* Content
*/
private String content;

/**
* Type
*
* @see ShellTypeEnum
*/
private String type;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.openjob.server.common.util;
package io.openjob.common.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
public enum CodeEnum implements CodeExceptionAssert {
// Code list
USER_EXIST(100, "User is exist!"),
USER_NOT_FOUND(101, "User not found"),
USER_DELETED(102, "User deleted"),
USER_PWD_INVALID(103, "User password invalid"),
USER_ROLE_EMPTY(104, "User role empty"),
USER_VERIFY_CODE_INVALID(105, "Verification code invalid"),

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

// Delay
DELAY_TOPIC_EXIST(500, "Topic is exist!"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class UpdateDelayRequest {
@ApiModelProperty(value = "Description", required = true)
private String description;

@ApiModelProperty(value = "", required = true)
@ApiModelProperty(value = "Processor info", required = true)
private String processorInfo;

@ApiModelProperty(value = "Fail retry times", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,34 @@ public class AddJobRequest {
@ApiModelProperty(value = "Job process type: bean/shell/python, default(bean)", required = true)
private String processorType;

@NotBlank
@ApiModelProperty(value = "Job process info", required = true)
@ApiModelProperty(value = "Job process info")
private String processorInfo;

@ApiModelProperty(value = "Shell processor info")
private String shellProcessorInfo;

@ApiModelProperty(value = "Shell processor type")
private String shellProcessorType;

@ApiModelProperty(value = "Kettle processor type")
private String kettleProcessorType;

@ApiModelProperty(value = "Kettle processor info")
private String kettleProcessorInfo;

@ApiModelProperty(value = "Sharding params")
private String shardingParams;

@NotBlank
@ApiModelProperty(value = "Execute type: standalone, broadcast, MR", required = true)
private String executeType;

@NotBlank
@ApiModelProperty(value = "Job params type", required = true)
@ApiModelProperty(value = "Job params type")
private String paramsType;

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

@NotBlank
@ApiModelProperty(value = "Job extend params type")
private String extendParamsType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.openjob.common.util.DateUtil;
import io.openjob.server.admin.autoconfigure.AdminUserProperties;
import io.openjob.server.admin.constant.AdminHttpStatusEnum;
import io.openjob.server.admin.constant.CodeEnum;
import io.openjob.server.admin.request.admin.AdminUserLoginRequest;
import io.openjob.server.admin.request.admin.AdminUserLogoutRequest;
import io.openjob.server.admin.request.admin.LoginUserInfoRequest;
Expand Down Expand Up @@ -73,19 +74,19 @@ public LoginUserInfoVO loginUserInfo(LoginUserInfoRequest request, String sessKe

private void checkLoginUser(AdminUser user, String passwd) {
if (Objects.isNull(user)) {
AdminHttpStatusEnum.NOT_FOUND.throwException();
CodeEnum.USER_NOT_FOUND.throwException();
}

if (CommonUtil.isTrue(user.getDeleted())) {
AdminHttpStatusEnum.NOT_FOUND.throwException();
CodeEnum.USER_DELETED.throwException();
}

if (!HmacUtil.verifyPasswd(user.getPasswd(), passwd, userProperties.getPasswdSalt())) {
AdminHttpStatusEnum.FORBIDDEN.throwException();
CodeEnum.USER_PWD_INVALID.throwException();
}

if (CollectionUtils.isEmpty(user.getRoleIds())) {
AdminHttpStatusEnum.FORBIDDEN.throwException();
if (CollectionUtils.isEmpty(user.getRoleIdsByJson())) {
CodeEnum.USER_ROLE_EMPTY.throwException();
}
}

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

// Query user role and perms
List<AdminRole> roles = this.adminRoleDAO.getByIds(user.getRoleIds());
List<AdminRole> roles = this.adminRoleDAO.getByIds(user.getRoleIdsByJson());
if (CollectionUtils.isEmpty(roles)) {
AdminHttpStatusEnum.NOT_FOUND.throwException();
}
Expand All @@ -118,7 +119,7 @@ private AdminUserLoginVO buildUserLoginVO(AdminUser user) {
isAdmin.set(true);
return;
}
permIds.addAll(r.getPermIds());
permIds.addAll(r.getPermIdsByJson());
});
loginVO.setSupperAdmin(isAdmin.get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public AdminPermServiceImpl(AdminPermissionDAO adminPermissionDAO, AdminRoleDAO
@Override
public AdminPermissionMenusVO getMenus(AdminPermissionMenusRequest request) {
AdminUser user = this.adminUserDAO.getById(request.getUid());
List<AdminRole> roles = this.adminRoleDAO.getByIds(user.getRoleIds());
List<AdminRole> roles = this.adminRoleDAO.getByIds(user.getRoleIdsByJson());

// Menu ids.
AtomicBoolean isAdmin = new AtomicBoolean(false);
Expand All @@ -59,7 +59,7 @@ public AdminPermissionMenusVO getMenus(AdminPermissionMenusRequest request) {
isAdmin.set(true);
return;
}
menuIds.addAll(r.getMenuIds());
menuIds.addAll(r.getMenuIdsByJson());
});

//Menu list
Expand All @@ -86,9 +86,9 @@ private List<MenuItemVO> formatTreeMenus(List<AdminPermission> dtoList) {
node.setId(dataRecord.getId());
node.setName(dataRecord.getName());
node.setPath(dataRecord.getPath());
node.setComponent(dataRecord.getMeta().getComponent());
node.setComponent(dataRecord.getMetaByJson().getComponent());

MenuMetaVO menuMetaVO = BeanMapperUtil.map(dataRecord.getMeta(), MenuMetaVO.class);
MenuMetaVO menuMetaVO = BeanMapperUtil.map(dataRecord.getMetaByJson(), MenuMetaVO.class);
menuMetaVO.setIsHide(CommonUtil.isTrue(dataRecord.getHidden()));
node.setMeta(menuMetaVO);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ public StopJobInstanceVO stopInstance(StopJobInstanceRequest killRequest) {
jobInstanceStopRequestDTO.setJobInstanceId(killRequest.getId());
JobInstanceStopResponseDTO stop = this.jobInstanceScheduler.stop(jobInstanceStopRequestDTO);

// Update status.
this.jobInstanceDAO.updateStatusById(killRequest.getId(), InstanceStatusEnum.STOP.getStatus());
// Stop success to update status.
if (CommonConstant.INT_ZERO.equals(stop.getType())) {
this.jobInstanceDAO.updateStatusById(killRequest.getId(), InstanceStatusEnum.STOP.getStatus());
}

// Response
StopJobInstanceVO stopJobInstanceVO = new StopJobInstanceVO();
Expand Down
Loading