-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from Dapp-Learning-DAO/dev
replace op graph redpacket url
- Loading branch information
Showing
18 changed files
with
366 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/com/dl/officialsite/bounty/job/BountyXxlJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.dl.officialsite.bounty.job; | ||
|
||
import com.dl.officialsite.bounty.BountyService; | ||
import com.xxl.job.core.context.XxlJobHelper; | ||
import com.xxl.job.core.handler.annotation.XxlJob; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* @Description | ||
* @Author xiaoming | ||
* @Date 2024/7/6 7:45 PM | ||
**/ | ||
@Component | ||
public class BountyXxlJob { | ||
|
||
@Autowired | ||
private BountyService bountyService; | ||
|
||
/** | ||
* 更新bounty数据 | ||
*/ | ||
@XxlJob("updateBountyDataJobHandler") | ||
public void updateBountyStatus() { | ||
XxlJobHelper.log("updateBountyData start"); | ||
bountyService.updateBountyData(); | ||
XxlJobHelper.log("updateBountyData end"); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/dl/officialsite/config/XxlJobConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.dl.officialsite.config; | ||
|
||
import com.xxl.job.core.executor.XxlJobExecutor; | ||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @Description | ||
* @Author xiaoming | ||
* @Date 2024/7/5 10:07 PM | ||
**/ | ||
@Configuration | ||
@Slf4j | ||
@EnableConfigurationProperties({XxlJobProperties.class}) | ||
public class XxlJobConfig { | ||
|
||
@Bean | ||
public XxlJobExecutor xxlJobExecutor(XxlJobProperties properties) { | ||
log.info("[xxlJobExecutor][初始化 XXL-Job 执行器的配置]"); | ||
XxlJobProperties.AdminProperties admin = properties.getAdmin(); | ||
XxlJobProperties.ExecutorProperties executor = properties.getExecutor(); | ||
|
||
// 初始化执行器 | ||
XxlJobExecutor xxlJobExecutor = new XxlJobSpringExecutor(); | ||
xxlJobExecutor.setIp(executor.getIp()); | ||
xxlJobExecutor.setPort(executor.getPort()); | ||
xxlJobExecutor.setAppname(executor.getAppName()); | ||
xxlJobExecutor.setLogPath(executor.getLogPath()); | ||
xxlJobExecutor.setLogRetentionDays(executor.getLogRetentionDays()); | ||
xxlJobExecutor.setAdminAddresses(admin.getAddresses()); | ||
xxlJobExecutor.setAccessToken(properties.getAccessToken()); | ||
return xxlJobExecutor; | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
src/main/java/com/dl/officialsite/config/XxlJobProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.dl.officialsite.config; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.validation.annotation.Validated; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotEmpty; | ||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* XXL-Job 配置类 | ||
*/ | ||
@ConfigurationProperties("xxl.job") | ||
@Validated | ||
@Data | ||
public class XxlJobProperties { | ||
|
||
/** | ||
* 访问令牌 | ||
*/ | ||
private String accessToken; | ||
/** | ||
* 控制器配置 | ||
*/ | ||
@NotNull(message = "控制器配置不能为空") | ||
private AdminProperties admin; | ||
/** | ||
* 执行器配置 | ||
*/ | ||
@NotNull(message = "执行器配置不能为空") | ||
private ExecutorProperties executor; | ||
|
||
/** | ||
* XXL-Job 调度器配置类 | ||
*/ | ||
@Data | ||
@Valid | ||
public static class AdminProperties { | ||
|
||
/** | ||
* 调度器地址 | ||
*/ | ||
@NotEmpty(message = "调度器地址不能为空") | ||
private String addresses; | ||
|
||
} | ||
|
||
/** | ||
* XXL-Job 执行器配置类 | ||
*/ | ||
@Data | ||
@Valid | ||
public static class ExecutorProperties { | ||
|
||
/** | ||
* 默认端口 | ||
* | ||
* 这里使用 -1 表示随机 | ||
*/ | ||
private static final Integer PORT_DEFAULT = -1; | ||
|
||
/** | ||
* 默认日志保留天数 | ||
* | ||
* 如果想永久保留,则设置为 -1 | ||
*/ | ||
private static final Integer LOG_RETENTION_DAYS_DEFAULT = 30; | ||
|
||
/** | ||
* 应用名 | ||
*/ | ||
@NotEmpty(message = "应用名不能为空") | ||
private String appName; | ||
/** | ||
* 执行器的 IP | ||
*/ | ||
private String ip; | ||
/** | ||
* 执行器的 Port | ||
*/ | ||
private Integer port = PORT_DEFAULT; | ||
/** | ||
* 日志地址 | ||
*/ | ||
@NotEmpty(message = "日志地址不能为空") | ||
private String logPath; | ||
/** | ||
* 日志保留天数 | ||
*/ | ||
private Integer logRetentionDays = LOG_RETENTION_DAYS_DEFAULT; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/main/java/com/dl/officialsite/defi/job/DefiXxlJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.dl.officialsite.defi.job; | ||
|
||
import com.dl.officialsite.defi.Schedule; | ||
import com.dl.officialsite.defi.TokenInfoList; | ||
import com.dl.officialsite.defi.service.AaveService; | ||
import com.dl.officialsite.defi.service.AaveTokenAPYService; | ||
import com.dl.officialsite.defi.service.WhaleService; | ||
import com.dl.officialsite.defi.vo.HealthInfoVo; | ||
import com.dl.officialsite.mail.EmailService; | ||
import com.dl.officialsite.member.Member; | ||
import com.dl.officialsite.team.TeamService; | ||
import com.dl.officialsite.team.vo.TeamQueryVo; | ||
import com.dl.officialsite.team.vo.TeamsWithMembers; | ||
import com.xxl.job.core.context.XxlJobHelper; | ||
import com.xxl.job.core.handler.annotation.XxlJob; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.List; | ||
|
||
/** | ||
* @Description | ||
* @Author xiaoming | ||
* @Date 2024/7/6 7:02 PM | ||
**/ | ||
@Component | ||
@Slf4j | ||
public class DefiXxlJob { | ||
|
||
@Autowired | ||
private Schedule schedule; | ||
|
||
@Autowired | ||
private AaveTokenAPYService aaveTokenAPYService; | ||
|
||
@Autowired | ||
private WhaleService whaleService; | ||
|
||
|
||
/** | ||
* 监控价格一天发送一次 | ||
*/ | ||
@XxlJob("monitorPriceJobHandler") | ||
public void monitorPrice() throws Exception { | ||
XxlJobHelper.log("monitorPrice start"); | ||
schedule.monitorPrice(); | ||
XxlJobHelper.log("monitorPrice end"); | ||
} | ||
|
||
/** | ||
* 监控健康系数,如果小于1.2,立即发送邮件 | ||
*/ | ||
@XxlJob("monitorHealthJobHandler") | ||
public void monitorHealth() { | ||
XxlJobHelper.log("monitorHealth start"); | ||
schedule.monitorHealth(); | ||
XxlJobHelper.log("monitorHealth end"); | ||
} | ||
|
||
|
||
/** | ||
* 定期更新 Token 的 APY(年化收益率)信息 | ||
*/ | ||
@XxlJob("updateTokenAPYInfoJobHandler") | ||
public void updateTokenAPYInfo() { | ||
XxlJobHelper.log("update token info task begin --------------------- "); | ||
aaveTokenAPYService.updateTokenAPYInfo(); | ||
XxlJobHelper.log("update token info task end --------------------- "); | ||
} | ||
|
||
/** | ||
* 更新Whale和WhaleTxRow数据 | ||
*/ | ||
@XxlJob("aaveListenerJobHandler") | ||
public void aaveListener() { | ||
XxlJobHelper.log("aaveListenerJobHandler start"); | ||
whaleService.aaveListener(); | ||
XxlJobHelper.log("aaveListenerJobHandler end"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.