存储数据
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.tem.bocai;
|
||||
|
||||
import com.tem.bocai.util.SQLiteUtil;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
|
||||
@@ -9,59 +9,50 @@ import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Table(name = "lottery_results")
|
||||
@Data
|
||||
public class LotteryResult {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
/*@Column(name = "id", nullable = false, unique = true)
|
||||
private String id; // 期号*/
|
||||
|
||||
@Column(name = "issue", nullable = false, unique = true)
|
||||
private String issue; // 期号
|
||||
|
||||
@Column(name = "date", nullable = false)
|
||||
private String date; // 日期
|
||||
|
||||
@Column(name = "time", nullable = false)
|
||||
private String time; // 开奖时间
|
||||
|
||||
@ElementCollection
|
||||
@JoinColumn(name = "result_id")
|
||||
@Column(name = "number")
|
||||
private List<String> numbers; // 开奖号码
|
||||
@Column(name = "result")
|
||||
private List<String> result; // 开奖号码
|
||||
|
||||
@Column(name = "sum", nullable = false)
|
||||
private String sum; // 总和值
|
||||
@Column(name = "winner", nullable = false)
|
||||
private String winner; //
|
||||
|
||||
@Column(name = "first_second_sum", nullable = false)
|
||||
private String firstSecondSum; // 冠亚和
|
||||
|
||||
@Column(name = "two_series", nullable = false)
|
||||
private String twoSeries; // 2串
|
||||
@Column(name = "sum1", nullable = false)
|
||||
private String sum1; // 总和值
|
||||
|
||||
@Column(name = "four_series", nullable = false)
|
||||
private String fourSeries; // 4串
|
||||
@Column(name = "sum2", nullable = false)
|
||||
private String sum2; // 冠亚和
|
||||
|
||||
@Column(name = "size", nullable = false)
|
||||
private String size; // 大小
|
||||
|
||||
@Column(name = "dragon_tiger", nullable = false)
|
||||
private String dragonTiger; // 龙虎
|
||||
|
||||
@ElementCollection
|
||||
@JoinColumn(name = "result_id")
|
||||
@Column(name = "tail")
|
||||
private List<String> tails; // 1~5尾
|
||||
@Column(name = "gd1", nullable = false)
|
||||
private String gd1; // 冠亚单
|
||||
|
||||
// getter和setter方法
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@Column(name = "gd2", nullable = false)
|
||||
private String gd2; // 冠亚大
|
||||
|
||||
|
||||
@Column(name = "glh_result", nullable = false)
|
||||
private String glh_result; //[ "龙", "龙", "龙", "虎", "虎" ] 龙虎
|
||||
|
||||
public String getIssue() {
|
||||
return issue;
|
||||
@@ -71,12 +62,12 @@ public class LotteryResult {
|
||||
this.issue = issue;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
@@ -87,67 +78,59 @@ public class LotteryResult {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public List<String> getNumbers() {
|
||||
return numbers;
|
||||
public List<String> getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setNumbers(List<String> numbers) {
|
||||
this.numbers = numbers;
|
||||
public void setResult(List<String> result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getSum() {
|
||||
return sum;
|
||||
public String getWinner() {
|
||||
return winner;
|
||||
}
|
||||
|
||||
public void setSum(String sum) {
|
||||
this.sum = sum;
|
||||
public void setWinner(String winner) {
|
||||
this.winner = winner;
|
||||
}
|
||||
|
||||
public String getFirstSecondSum() {
|
||||
return firstSecondSum;
|
||||
public String getSum1() {
|
||||
return sum1;
|
||||
}
|
||||
|
||||
public void setFirstSecondSum(String firstSecondSum) {
|
||||
this.firstSecondSum = firstSecondSum;
|
||||
public void setSum1(String sum1) {
|
||||
this.sum1 = sum1;
|
||||
}
|
||||
|
||||
public String getTwoSeries() {
|
||||
return twoSeries;
|
||||
public String getSum2() {
|
||||
return sum2;
|
||||
}
|
||||
|
||||
public void setTwoSeries(String twoSeries) {
|
||||
this.twoSeries = twoSeries;
|
||||
public void setSum2(String sum2) {
|
||||
this.sum2 = sum2;
|
||||
}
|
||||
|
||||
public String getFourSeries() {
|
||||
return fourSeries;
|
||||
public String getGd2() {
|
||||
return gd2;
|
||||
}
|
||||
|
||||
public void setFourSeries(String fourSeries) {
|
||||
this.fourSeries = fourSeries;
|
||||
public void setGd2(String gd2) {
|
||||
this.gd2 = gd2;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
public String getGd1() {
|
||||
return gd1;
|
||||
}
|
||||
|
||||
public void setSize(String size) {
|
||||
this.size = size;
|
||||
public void setGd1(String gd1) {
|
||||
this.gd1 = gd1;
|
||||
}
|
||||
|
||||
public String getDragonTiger() {
|
||||
return dragonTiger;
|
||||
public String getGlh_result() {
|
||||
return glh_result;
|
||||
}
|
||||
|
||||
public void setDragonTiger(String dragonTiger) {
|
||||
this.dragonTiger = dragonTiger;
|
||||
}
|
||||
|
||||
public List<String> getTails() {
|
||||
return tails;
|
||||
}
|
||||
|
||||
public void setTails(List<String> tails) {
|
||||
this.tails = tails;
|
||||
public void setGlh_result(String glh_result) {
|
||||
this.glh_result = glh_result;
|
||||
}
|
||||
}
|
||||
@@ -220,6 +220,9 @@ public class LotteryWebMagicCrawler implements PageProcessor {
|
||||
resultList.add(rowData);
|
||||
}
|
||||
}
|
||||
// 将数据写入SQLite数据库
|
||||
SQLiteUtil.writeToSQLite(resultList);
|
||||
// 将数据写入JSON文件(保留原有功能)
|
||||
writeToJsonFile(resultList);
|
||||
System.out.println("打印结果===" + resultList);
|
||||
return resultList;
|
||||
|
||||
Reference in New Issue
Block a user