diff --git a/bonus-common-biz/job/pom.xml b/bonus-common-biz/job/pom.xml new file mode 100644 index 00000000..75557d66 --- /dev/null +++ b/bonus-common-biz/job/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + com.bonus + bonus-common-biz + 24.12.0-SNAPSHOT + + + org.example + job + + + 21 + 21 + UTF-8 + + + \ No newline at end of file diff --git a/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/XxlJobConfig.java b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/XxlJobConfig.java new file mode 100644 index 00000000..4c9a1729 --- /dev/null +++ b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/XxlJobConfig.java @@ -0,0 +1,40 @@ +package net.xnzn.framework.job; + +import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; +import net.xnzn.framework.job.api.XxlJobApi; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.cloud.commons.util.InetUtils; +import org.springframework.cloud.commons.util.UtilAutoConfiguration; +import org.springframework.context.annotation.Bean; + +@AutoConfiguration( + after = {UtilAutoConfiguration.class} +) +@EnableConfigurationProperties({XxlJobProperties.class}) +@ConditionalOnProperty( + name = {"xxl.job.enabled"}, + havingValue = "true", + matchIfMissing = true +) +public class XxlJobConfig { + @Bean + public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties, InetUtils inetUtils) { + XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); + xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdmin().getAddresses()); + xxlJobSpringExecutor.setAppname(xxlJobProperties.getExecutor().getAppName()); + xxlJobSpringExecutor.setAddress(xxlJobProperties.getExecutor().getAddress()); + xxlJobSpringExecutor.setIp(inetUtils.findFirstNonLoopbackHostInfo().getIpAddress()); + xxlJobSpringExecutor.setPort(xxlJobProperties.getExecutor().getPort()); + xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getAdmin().getAccessToken()); + xxlJobSpringExecutor.setLogPath(xxlJobProperties.getExecutor().getLogPath()); + xxlJobSpringExecutor.setLogRetentionDays(xxlJobProperties.getExecutor().getLogRetentionDays()); + return xxlJobSpringExecutor; + } + + @Bean + public XxlJobApi xxlJobApi(XxlJobProperties xxlJobProperties) { + return new XxlJobApi(xxlJobProperties); + } +} diff --git a/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/XxlJobProperties.java b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/XxlJobProperties.java new file mode 100644 index 00000000..43a2f5e9 --- /dev/null +++ b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/XxlJobProperties.java @@ -0,0 +1,353 @@ +package net.xnzn.framework.job; + +import lombok.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties( + prefix = "xxl.job" +) +public class XxlJobProperties { + public static final String PREFIX = "xxl.job"; + private boolean enabled = true; + private AdminProperties admin = new AdminProperties(); + private ExecutorProperties executor = new ExecutorProperties(); + + @Generated + public boolean isEnabled() { + return this.enabled; + } + + @Generated + public AdminProperties getAdmin() { + return this.admin; + } + + @Generated + public ExecutorProperties getExecutor() { + return this.executor; + } + + @Generated + public void setEnabled(final boolean enabled) { + this.enabled = enabled; + } + + @Generated + public void setAdmin(final AdminProperties admin) { + this.admin = admin; + } + + @Generated + public void setExecutor(final ExecutorProperties executor) { + this.executor = executor; + } + + @Generated + public boolean equals(final Object o) { + if (o == this) { + return true; + } else if (!(o instanceof XxlJobProperties)) { + return false; + } else { + XxlJobProperties other = (XxlJobProperties)o; + if (!other.canEqual(this)) { + return false; + } else if (this.isEnabled() != other.isEnabled()) { + return false; + } else { + Object this$admin = this.getAdmin(); + Object other$admin = other.getAdmin(); + if (this$admin == null) { + if (other$admin != null) { + return false; + } + } else if (!this$admin.equals(other$admin)) { + return false; + } + + Object this$executor = this.getExecutor(); + Object other$executor = other.getExecutor(); + if (this$executor == null) { + if (other$executor != null) { + return false; + } + } else if (!this$executor.equals(other$executor)) { + return false; + } + + return true; + } + } + } + + @Generated + protected boolean canEqual(final Object other) { + return other instanceof XxlJobProperties; + } + + @Generated + public int hashCode() { + int PRIME = true; + int result = 1; + result = result * 59 + (this.isEnabled() ? 79 : 97); + Object $admin = this.getAdmin(); + result = result * 59 + ($admin == null ? 43 : $admin.hashCode()); + Object $executor = this.getExecutor(); + result = result * 59 + ($executor == null ? 43 : $executor.hashCode()); + return result; + } + + @Generated + public String toString() { + boolean var10000 = this.isEnabled(); + return "XxlJobProperties(enabled=" + var10000 + ", admin=" + String.valueOf(this.getAdmin()) + ", executor=" + String.valueOf(this.getExecutor()) + ")"; + } + + public static class AdminProperties { + private String addresses = "http://127.0.0.1:8080/xxl-job-admin"; + private String accessToken; + + @Generated + public String getAddresses() { + return this.addresses; + } + + @Generated + public String getAccessToken() { + return this.accessToken; + } + + @Generated + public void setAddresses(final String addresses) { + this.addresses = addresses; + } + + @Generated + public void setAccessToken(final String accessToken) { + this.accessToken = accessToken; + } + + @Generated + public boolean equals(final Object o) { + if (o == this) { + return true; + } else if (!(o instanceof AdminProperties)) { + return false; + } else { + AdminProperties other = (AdminProperties)o; + if (!other.canEqual(this)) { + return false; + } else { + Object this$addresses = this.getAddresses(); + Object other$addresses = other.getAddresses(); + if (this$addresses == null) { + if (other$addresses != null) { + return false; + } + } else if (!this$addresses.equals(other$addresses)) { + return false; + } + + Object this$accessToken = this.getAccessToken(); + Object other$accessToken = other.getAccessToken(); + if (this$accessToken == null) { + if (other$accessToken != null) { + return false; + } + } else if (!this$accessToken.equals(other$accessToken)) { + return false; + } + + return true; + } + } + } + + @Generated + protected boolean canEqual(final Object other) { + return other instanceof AdminProperties; + } + + @Generated + public int hashCode() { + int PRIME = true; + int result = 1; + Object $addresses = this.getAddresses(); + result = result * 59 + ($addresses == null ? 43 : $addresses.hashCode()); + Object $accessToken = this.getAccessToken(); + result = result * 59 + ($accessToken == null ? 43 : $accessToken.hashCode()); + return result; + } + + @Generated + public String toString() { + String var10000 = this.getAddresses(); + return "XxlJobProperties.AdminProperties(addresses=" + var10000 + ", accessToken=" + this.getAccessToken() + ")"; + } + } + + public static class ExecutorProperties { + private String appName = "xxl-job-executor"; + private String address; + private String ip; + private int port = 0; + private String logPath = "/var/log/xxl-job"; + private int logRetentionDays = 7; + + @Generated + public String getAppName() { + return this.appName; + } + + @Generated + public String getAddress() { + return this.address; + } + + @Generated + public String getIp() { + return this.ip; + } + + @Generated + public int getPort() { + return this.port; + } + + @Generated + public String getLogPath() { + return this.logPath; + } + + @Generated + public int getLogRetentionDays() { + return this.logRetentionDays; + } + + @Generated + public void setAppName(final String appName) { + this.appName = appName; + } + + @Generated + public void setAddress(final String address) { + this.address = address; + } + + @Generated + public void setIp(final String ip) { + this.ip = ip; + } + + @Generated + public void setPort(final int port) { + this.port = port; + } + + @Generated + public void setLogPath(final String logPath) { + this.logPath = logPath; + } + + @Generated + public void setLogRetentionDays(final int logRetentionDays) { + this.logRetentionDays = logRetentionDays; + } + + @Generated + public boolean equals(final Object o) { + if (o == this) { + return true; + } else if (!(o instanceof ExecutorProperties)) { + return false; + } else { + ExecutorProperties other = (ExecutorProperties)o; + if (!other.canEqual(this)) { + return false; + } else if (this.getPort() != other.getPort()) { + return false; + } else if (this.getLogRetentionDays() != other.getLogRetentionDays()) { + return false; + } else { + label64: { + Object this$appName = this.getAppName(); + Object other$appName = other.getAppName(); + if (this$appName == null) { + if (other$appName == null) { + break label64; + } + } else if (this$appName.equals(other$appName)) { + break label64; + } + + return false; + } + + label57: { + Object this$address = this.getAddress(); + Object other$address = other.getAddress(); + if (this$address == null) { + if (other$address == null) { + break label57; + } + } else if (this$address.equals(other$address)) { + break label57; + } + + return false; + } + + Object this$ip = this.getIp(); + Object other$ip = other.getIp(); + if (this$ip == null) { + if (other$ip != null) { + return false; + } + } else if (!this$ip.equals(other$ip)) { + return false; + } + + Object this$logPath = this.getLogPath(); + Object other$logPath = other.getLogPath(); + if (this$logPath == null) { + if (other$logPath != null) { + return false; + } + } else if (!this$logPath.equals(other$logPath)) { + return false; + } + + return true; + } + } + } + + @Generated + protected boolean canEqual(final Object other) { + return other instanceof ExecutorProperties; + } + + @Generated + public int hashCode() { + int PRIME = true; + int result = 1; + result = result * 59 + this.getPort(); + result = result * 59 + this.getLogRetentionDays(); + Object $appName = this.getAppName(); + result = result * 59 + ($appName == null ? 43 : $appName.hashCode()); + Object $address = this.getAddress(); + result = result * 59 + ($address == null ? 43 : $address.hashCode()); + Object $ip = this.getIp(); + result = result * 59 + ($ip == null ? 43 : $ip.hashCode()); + Object $logPath = this.getLogPath(); + result = result * 59 + ($logPath == null ? 43 : $logPath.hashCode()); + return result; + } + + @Generated + public String toString() { + String var10000 = this.getAppName(); + return "XxlJobProperties.ExecutorProperties(appName=" + var10000 + ", address=" + this.getAddress() + ", ip=" + this.getIp() + ", port=" + this.getPort() + ", logPath=" + this.getLogPath() + ", logRetentionDays=" + this.getLogRetentionDays() + ")"; + } + } +} diff --git a/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobApi.java b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobApi.java new file mode 100644 index 00000000..125de546 --- /dev/null +++ b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobApi.java @@ -0,0 +1,72 @@ +package net.xnzn.framework.job.api; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.lang.TypeReference; +import com.google.common.collect.Maps; +import java.util.List; +import java.util.Map; +import net.xnzn.framework.job.XxlJobProperties; + +public class XxlJobApi { + private final XxlJobRemoteHelper remoteHelper; + + public XxlJobApi(XxlJobProperties properties) { + this.remoteHelper = new XxlJobRemoteHelper(properties); + } + + public Map pageList(XxlJobInfo xxlJobInfo) { + Map params = BeanUtil.beanToMap(xxlJobInfo, false, false); + return (Map)this.remoteHelper.sendPost("/jobinfo/pageList", params, new TypeReference>(this) { + }); + } + + public XxlJobReturn add(XxlJobInfo xxlJobInfo) { + Map params = BeanUtil.beanToMap(xxlJobInfo, false, false); + return (XxlJobReturn)this.remoteHelper.sendPost("/jobinfo/add", params, new TypeReference>(this) { + }); + } + + public XxlJobReturn update(XxlJobInfo xxlJobInfo) { + Map params = BeanUtil.beanToMap(xxlJobInfo, false, false); + return (XxlJobReturn)this.remoteHelper.sendPost("/jobinfo/update", params, new TypeReference>(this) { + }); + } + + public XxlJobReturn remove(int id) { + Map params = Maps.newHashMap(); + params.put("id", id); + return (XxlJobReturn)this.remoteHelper.sendPost("/jobinfo/remove", params, new TypeReference>(this) { + }); + } + + public XxlJobReturn stop(int id) { + Map params = Maps.newHashMap(); + params.put("id", id); + return (XxlJobReturn)this.remoteHelper.sendPost("/jobinfo/stop", params, new TypeReference>(this) { + }); + } + + public XxlJobReturn start(int id) { + Map params = Maps.newHashMap(); + params.put("id", id); + return (XxlJobReturn)this.remoteHelper.sendPost("/jobinfo/start", params, new TypeReference>(this) { + }); + } + + public XxlJobReturn triggerJob(int id, String executorParam, String addressList) { + Map params = Maps.newHashMap(); + params.put("id", id); + params.put("executorParam", executorParam); + params.put("addressList", addressList); + return (XxlJobReturn)this.remoteHelper.sendPost("/jobinfo/trigger", params, new TypeReference>(this) { + }); + } + + public XxlJobReturn> nextTriggerTime(String scheduleType, String scheduleConf) { + Map params = Maps.newHashMap(); + params.put("scheduleType", scheduleType); + params.put("scheduleConf", scheduleConf); + return (XxlJobReturn)this.remoteHelper.sendPost("/jobinfo/nextTriggerTime", params, new TypeReference>>(this) { + }); + } +} diff --git a/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobInfo.java b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobInfo.java new file mode 100644 index 00000000..d8eb0f01 --- /dev/null +++ b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobInfo.java @@ -0,0 +1,271 @@ +package net.xnzn.framework.job.api; + +import java.util.Date; +import lombok.Generated; + +public class XxlJobInfo { + private int id; + private int jobGroup; + private String jobDesc; + private Date addTime; + private Date updateTime; + private String author; + private String alarmEmail; + private String scheduleType; + private String scheduleConf; + private String misfireStrategy; + private String executorRouteStrategy; + private String executorHandler; + private String executorParam; + private String executorBlockStrategy; + private int executorTimeout; + private int executorFailRetryCount; + private String glueType; + private String glueSource; + private String glueRemark; + private Date glueUpdatetime; + private String childJobId; + private int triggerStatus; + private long triggerLastTime; + private long triggerNextTime; + + @Generated + public void setId(final int id) { + this.id = id; + } + + @Generated + public void setJobGroup(final int jobGroup) { + this.jobGroup = jobGroup; + } + + @Generated + public void setJobDesc(final String jobDesc) { + this.jobDesc = jobDesc; + } + + @Generated + public void setAddTime(final Date addTime) { + this.addTime = addTime; + } + + @Generated + public void setUpdateTime(final Date updateTime) { + this.updateTime = updateTime; + } + + @Generated + public void setAuthor(final String author) { + this.author = author; + } + + @Generated + public void setAlarmEmail(final String alarmEmail) { + this.alarmEmail = alarmEmail; + } + + @Generated + public void setScheduleType(final String scheduleType) { + this.scheduleType = scheduleType; + } + + @Generated + public void setScheduleConf(final String scheduleConf) { + this.scheduleConf = scheduleConf; + } + + @Generated + public void setMisfireStrategy(final String misfireStrategy) { + this.misfireStrategy = misfireStrategy; + } + + @Generated + public void setExecutorRouteStrategy(final String executorRouteStrategy) { + this.executorRouteStrategy = executorRouteStrategy; + } + + @Generated + public void setExecutorHandler(final String executorHandler) { + this.executorHandler = executorHandler; + } + + @Generated + public void setExecutorParam(final String executorParam) { + this.executorParam = executorParam; + } + + @Generated + public void setExecutorBlockStrategy(final String executorBlockStrategy) { + this.executorBlockStrategy = executorBlockStrategy; + } + + @Generated + public void setExecutorTimeout(final int executorTimeout) { + this.executorTimeout = executorTimeout; + } + + @Generated + public void setExecutorFailRetryCount(final int executorFailRetryCount) { + this.executorFailRetryCount = executorFailRetryCount; + } + + @Generated + public void setGlueType(final String glueType) { + this.glueType = glueType; + } + + @Generated + public void setGlueSource(final String glueSource) { + this.glueSource = glueSource; + } + + @Generated + public void setGlueRemark(final String glueRemark) { + this.glueRemark = glueRemark; + } + + @Generated + public void setGlueUpdatetime(final Date glueUpdatetime) { + this.glueUpdatetime = glueUpdatetime; + } + + @Generated + public void setChildJobId(final String childJobId) { + this.childJobId = childJobId; + } + + @Generated + public void setTriggerStatus(final int triggerStatus) { + this.triggerStatus = triggerStatus; + } + + @Generated + public void setTriggerLastTime(final long triggerLastTime) { + this.triggerLastTime = triggerLastTime; + } + + @Generated + public void setTriggerNextTime(final long triggerNextTime) { + this.triggerNextTime = triggerNextTime; + } + + @Generated + public int getId() { + return this.id; + } + + @Generated + public int getJobGroup() { + return this.jobGroup; + } + + @Generated + public String getJobDesc() { + return this.jobDesc; + } + + @Generated + public Date getAddTime() { + return this.addTime; + } + + @Generated + public Date getUpdateTime() { + return this.updateTime; + } + + @Generated + public String getAuthor() { + return this.author; + } + + @Generated + public String getAlarmEmail() { + return this.alarmEmail; + } + + @Generated + public String getScheduleType() { + return this.scheduleType; + } + + @Generated + public String getScheduleConf() { + return this.scheduleConf; + } + + @Generated + public String getMisfireStrategy() { + return this.misfireStrategy; + } + + @Generated + public String getExecutorRouteStrategy() { + return this.executorRouteStrategy; + } + + @Generated + public String getExecutorHandler() { + return this.executorHandler; + } + + @Generated + public String getExecutorParam() { + return this.executorParam; + } + + @Generated + public String getExecutorBlockStrategy() { + return this.executorBlockStrategy; + } + + @Generated + public int getExecutorTimeout() { + return this.executorTimeout; + } + + @Generated + public int getExecutorFailRetryCount() { + return this.executorFailRetryCount; + } + + @Generated + public String getGlueType() { + return this.glueType; + } + + @Generated + public String getGlueSource() { + return this.glueSource; + } + + @Generated + public String getGlueRemark() { + return this.glueRemark; + } + + @Generated + public Date getGlueUpdatetime() { + return this.glueUpdatetime; + } + + @Generated + public String getChildJobId() { + return this.childJobId; + } + + @Generated + public int getTriggerStatus() { + return this.triggerStatus; + } + + @Generated + public long getTriggerLastTime() { + return this.triggerLastTime; + } + + @Generated + public long getTriggerNextTime() { + return this.triggerNextTime; + } +} diff --git a/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobRemoteHelper.java b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobRemoteHelper.java new file mode 100644 index 00000000..df607c9b --- /dev/null +++ b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobRemoteHelper.java @@ -0,0 +1,63 @@ +package net.xnzn.framework.job.api; + +import cn.hutool.core.lang.TypeReference; +import cn.hutool.http.Header; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import java.math.BigInteger; +import java.util.Map; +import lombok.Generated; +import net.xnzn.framework.job.XxlJobProperties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.DigestUtils; + +public class XxlJobRemoteHelper { + @Generated + private static final Logger log = LoggerFactory.getLogger(XxlJobRemoteHelper.class); + private static final String LOGIN_IDENTITY_KEY = "XXL_JOB_LOGIN_IDENTITY"; + private final XxlJobProperties properties; + + public XxlJobRemoteHelper(XxlJobProperties properties) { + this.properties = properties; + } + + public T sendPost(String path, Map param, TypeReference clz, Object... uriVariables) { + String var10000 = this.properties.getAdmin().getAddresses(); + HttpRequest req = ((HttpRequest)HttpRequest.post(var10000 + path).header(Header.COOKIE, "XXL_JOB_LOGIN_IDENTITY=" + this.getLoginIdentity())).form(param).timeout(10000); + log.info("【xxl-job】发送:{}Form Param:\n{}", req, param); + HttpResponse res = req.execute(); + log.info("【xxl-job】返回:{}", res); + return JSONUtil.toBean(res.body(), clz, true); + } + + private String getLoginIdentity() { + XxlJobUser adminUser = new XxlJobUser(); + adminUser.setId(1); + adminUser.setUsername("admin"); + String password = this.properties.getAdmin().getAccessToken(); + String passwordMd5 = DigestUtils.md5DigestAsHex(password.getBytes()); + adminUser.setPassword(passwordMd5); + adminUser.setRole(1); + adminUser.setPermission((String)null); + return this.makeToken(adminUser); + } + + private String makeToken(XxlJobUser xxlJobUser) { + String tokenJson = JSONUtil.toJsonStr(xxlJobUser); + return (new BigInteger(tokenJson.getBytes())).toString(16); + } + + private XxlJobUser parseToken(String tokenHex) { + new JSONObject(); + XxlJobUser xxlJobUser = null; + if (tokenHex != null) { + String tokenJson = new String((new BigInteger(tokenHex, 16)).toByteArray()); + xxlJobUser = (XxlJobUser)JSONUtil.toBean(tokenJson, XxlJobUser.class); + } + + return xxlJobUser; + } +} diff --git a/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobReturn.java b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobReturn.java new file mode 100644 index 00000000..a79c64e8 --- /dev/null +++ b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobReturn.java @@ -0,0 +1,66 @@ +package net.xnzn.framework.job.api; + +import com.xxl.job.core.biz.model.ReturnT; +import lombok.Generated; + +public class XxlJobReturn { + public static final int SUCCESS_CODE = 200; + public static final int FAIL_CODE = 500; + public static final ReturnT SUCCESS = new ReturnT((Object)null); + public static final ReturnT FAIL = new ReturnT(500, (String)null); + private int code; + private String msg; + private T content; + + public XxlJobReturn() { + } + + public XxlJobReturn(int code, String msg) { + this.code = code; + this.msg = msg; + } + + public XxlJobReturn(T content) { + this.code = 200; + this.content = content; + } + + public boolean isSuccess() { + return 200 == this.code; + } + + public String toString() { + int var10000 = this.code; + return "ReturnT [code=" + var10000 + ", msg=" + this.msg + ", content=" + String.valueOf(this.content) + "]"; + } + + @Generated + public void setCode(final int code) { + this.code = code; + } + + @Generated + public void setMsg(final String msg) { + this.msg = msg; + } + + @Generated + public void setContent(final T content) { + this.content = content; + } + + @Generated + public int getCode() { + return this.code; + } + + @Generated + public String getMsg() { + return this.msg; + } + + @Generated + public T getContent() { + return this.content; + } +} diff --git a/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobUser.java b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobUser.java new file mode 100644 index 00000000..6c21e333 --- /dev/null +++ b/bonus-common-biz/job/src/main/java/net/xnzn/framework/job/api/XxlJobUser.java @@ -0,0 +1,82 @@ +package net.xnzn.framework.job.api; + +import lombok.Generated; +import org.springframework.util.StringUtils; + +public class XxlJobUser { + private int id; + private String username; + private String password; + private int role; + private String permission; + + public boolean validPermission(int jobGroup) { + if (this.role == 1) { + return true; + } else { + if (StringUtils.hasText(this.permission)) { + String[] var2 = this.permission.split(","); + int var3 = var2.length; + + for(int var4 = 0; var4 < var3; ++var4) { + String permissionItem = var2[var4]; + if (String.valueOf(jobGroup).equals(permissionItem)) { + return true; + } + } + } + + return false; + } + } + + @Generated + public void setId(final int id) { + this.id = id; + } + + @Generated + public void setUsername(final String username) { + this.username = username; + } + + @Generated + public void setPassword(final String password) { + this.password = password; + } + + @Generated + public void setRole(final int role) { + this.role = role; + } + + @Generated + public void setPermission(final String permission) { + this.permission = permission; + } + + @Generated + public int getId() { + return this.id; + } + + @Generated + public String getUsername() { + return this.username; + } + + @Generated + public String getPassword() { + return this.password; + } + + @Generated + public int getRole() { + return this.role; + } + + @Generated + public String getPermission() { + return this.permission; + } +} diff --git a/bonus-common-biz/pom.xml b/bonus-common-biz/pom.xml index 816ed8e0..62ece42b 100644 --- a/bonus-common-biz/pom.xml +++ b/bonus-common-biz/pom.xml @@ -19,6 +19,7 @@ pigx-common-log pigx-common-oss pigx-common-security + job bonus-common-biz