This commit is contained in:
xuelijun
2026-01-23 11:56:21 +08:00
parent b357fb047e
commit 70f2a71df8
4 changed files with 60 additions and 8 deletions

BIN
bocai.db

Binary file not shown.

View File

@@ -20,26 +20,26 @@ public class LoginInfoResult {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_name", nullable = false)
@Column(name = "user_name")
private String username; //
@Column(name = "password", nullable = false)
@Column(name = "password")
private String password; //
@Column(name = "login_url", nullable = false)
@Column(name = "login_url")
private String loginUrl;
//限制赢多少
@Column(name = "win_num", nullable = false)
@Column(name = "win_num")
private Integer winNum;
//限制输多少
@Column(name = "lose_num", nullable = false)
@Column(name = "lose_num")
private Integer loseNum;
//1是开0是关
@Column(name = "on_off", nullable = false)
@Column(name = "on_off")
private Integer onOff;
/* @Column(name = "current_num", nullable = false)

View File

@@ -26,7 +26,7 @@ public class CrawlerSchedule {
// 每天凌晨2点执行爬取开奖结果
//@Scheduled(cron = "0 0 2 * * ?")
// 每7秒执行一次爬取开奖结果
@Scheduled(cron = "*/9 * * * * ?")
//@Scheduled(cron = "*/9 * * * * ?")
public void executeLotteryDraw() {
System.out.println("开始爬取开奖结果...");
int retryCount = 0;

View File

@@ -153,12 +153,64 @@ public class LoginServiceImpl implements LoginService {
return success ? "success" : "";
}
@Override
public String saveUserInfo(LoginInfoResult loginInfoResult) {
try {
Optional<LoginInfoResult> existingUser = loginInfoRepository.findFirstByOrderByCreateTimeDesc();
Date now = new Date();
if (existingUser.isPresent()) {
// 获取数据库中已有的用户
LoginInfoResult dbUser = existingUser.get();
// 只更新传入的非空字段
if (loginInfoResult.getUsername() != null) {
dbUser.setUsername(loginInfoResult.getUsername());
}
if (loginInfoResult.getPassword() != null) {
dbUser.setPassword(loginInfoResult.getPassword());
}
if (loginInfoResult.getLoginUrl() != null) {
dbUser.setLoginUrl(loginInfoResult.getLoginUrl());
}
if (loginInfoResult.getWinNum() != null) {
dbUser.setWinNum(loginInfoResult.getWinNum());
}
if (loginInfoResult.getLoseNum() != null) {
dbUser.setLoseNum(loginInfoResult.getLoseNum());
}
if (loginInfoResult.getOnOff() != null) {
dbUser.setOnOff(loginInfoResult.getOnOff());
}
// 更新修改时间
dbUser.setUpdateTime(now);
// 保存更新后的实体
loginInfoRepository.save(dbUser);
} else {
// 新增逻辑
loginInfoResult.setCreateTime(now);
loginInfoResult.setUpdateTime(now);
loginInfoRepository.save(loginInfoResult);
}
return "success";
} catch (Exception e) {
System.err.println("保存用户信息失败: " + e.getMessage());
return "error: " + e.getMessage();
}
}
/*@Override
public String saveUserInfo(LoginInfoResult loginInfoResult) {
try {
Optional<LoginInfoResult> existingUser = loginInfoRepository.findFirstByOrderByCreateTimeDesc();
Date now = new Date();
if (existingUser.isPresent()) {
// 如果是更新,保留原有创建时间
LoginInfoResult dbUser = existingUser.get();
@@ -178,7 +230,7 @@ public class LoginServiceImpl implements LoginService {
System.err.println("保存用户信息失败: " + e.getMessage());
return "error: " + e.getMessage();
}
}
}*/
/**