fix: can creating a job with the wrong parameters #312

This commit is contained in:
tjq 2021-11-03 21:26:25 +08:00
parent e094c22952
commit 4c0e5f348b
2 changed files with 18 additions and 1 deletions

View File

@ -173,4 +173,11 @@ public class CommonUtils {
} catch (InterruptedException ignore) { } catch (InterruptedException ignore) {
} }
} }
/**
* ignore compile warning of 'Result of 'Long.valueOf()' is ignored '
* @param obj anything
*/
public static void ignoreIgnoredResultWarning(Object obj) {
}
} }

View File

@ -6,6 +6,7 @@ import tech.powerjob.common.PowerQuery;
import tech.powerjob.common.enums.TimeExpressionType; import tech.powerjob.common.enums.TimeExpressionType;
import tech.powerjob.common.request.http.SaveJobInfoRequest; import tech.powerjob.common.request.http.SaveJobInfoRequest;
import tech.powerjob.common.response.JobInfoDTO; import tech.powerjob.common.response.JobInfoDTO;
import tech.powerjob.common.utils.CommonUtils;
import tech.powerjob.server.common.SJ; import tech.powerjob.server.common.SJ;
import tech.powerjob.server.common.constants.SwitchableStatus; import tech.powerjob.server.common.constants.SwitchableStatus;
import tech.powerjob.server.common.utils.CronExpression; import tech.powerjob.server.common.utils.CronExpression;
@ -61,7 +62,7 @@ public class JobService {
*/ */
public Long saveJob(SaveJobInfoRequest request) throws ParseException { public Long saveJob(SaveJobInfoRequest request) throws ParseException {
request.valid(); checkValid(request);
JobInfoDO jobInfoDO; JobInfoDO jobInfoDO;
if (request.getId() != null) { if (request.getId() != null) {
@ -278,4 +279,13 @@ public class JobService {
return jobInfoDTO; return jobInfoDTO;
} }
private static void checkValid(SaveJobInfoRequest request) {
request.valid();
if (TimeExpressionType.frequentTypes.contains(request.getTimeExpressionType().getV())) {
CommonUtils.ignoreIgnoredResultWarning(Long.valueOf(request.getTimeExpression()));
}
}
} }