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