初始化项目
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.tem.bocai.controller;
|
||||
|
||||
import com.tem.bocai.entity.LotteryResult;
|
||||
import com.tem.bocai.repository.LotteryResultRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/lottery")
|
||||
public class LotteryResultController {
|
||||
|
||||
@Autowired
|
||||
private LotteryResultRepository lotteryResultRepository;
|
||||
|
||||
// 获取所有彩票开奖结果
|
||||
@GetMapping("/results")
|
||||
public List<LotteryResult> getAllLotteryResults() {
|
||||
return lotteryResultRepository.findAll();
|
||||
}
|
||||
|
||||
// 根据期号获取彩票开奖结果
|
||||
@GetMapping("/results/{issue}")
|
||||
public LotteryResult getLotteryResultByIssue(@PathVariable String issue) {
|
||||
return lotteryResultRepository.findAll()
|
||||
.stream()
|
||||
.filter(result -> result.getIssue().equals(issue))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
||||
153
src/main/java/com/tem/bocai/entity/LotteryResult.java
Normal file
153
src/main/java/com/tem/bocai/entity/LotteryResult.java
Normal file
@@ -0,0 +1,153 @@
|
||||
package com.tem.bocai.entity;
|
||||
|
||||
import java.util.List;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "lottery_results")
|
||||
public class LotteryResult {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long 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 = "sum", nullable = false)
|
||||
private String sum; // 总和值
|
||||
|
||||
@Column(name = "first_second_sum", nullable = false)
|
||||
private String firstSecondSum; // 冠亚和
|
||||
|
||||
@Column(name = "two_series", nullable = false)
|
||||
private String twoSeries; // 2串
|
||||
|
||||
@Column(name = "four_series", nullable = false)
|
||||
private String fourSeries; // 4串
|
||||
|
||||
@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尾
|
||||
|
||||
// getter和setter方法
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getIssue() {
|
||||
return issue;
|
||||
}
|
||||
|
||||
public void setIssue(String issue) {
|
||||
this.issue = issue;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public List<String> getNumbers() {
|
||||
return numbers;
|
||||
}
|
||||
|
||||
public void setNumbers(List<String> numbers) {
|
||||
this.numbers = numbers;
|
||||
}
|
||||
|
||||
public String getSum() {
|
||||
return sum;
|
||||
}
|
||||
|
||||
public void setSum(String sum) {
|
||||
this.sum = sum;
|
||||
}
|
||||
|
||||
public String getFirstSecondSum() {
|
||||
return firstSecondSum;
|
||||
}
|
||||
|
||||
public void setFirstSecondSum(String firstSecondSum) {
|
||||
this.firstSecondSum = firstSecondSum;
|
||||
}
|
||||
|
||||
public String getTwoSeries() {
|
||||
return twoSeries;
|
||||
}
|
||||
|
||||
public void setTwoSeries(String twoSeries) {
|
||||
this.twoSeries = twoSeries;
|
||||
}
|
||||
|
||||
public String getFourSeries() {
|
||||
return fourSeries;
|
||||
}
|
||||
|
||||
public void setFourSeries(String fourSeries) {
|
||||
this.fourSeries = fourSeries;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(String size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getDragonTiger() {
|
||||
return dragonTiger;
|
||||
}
|
||||
|
||||
public void setDragonTiger(String dragonTiger) {
|
||||
this.dragonTiger = dragonTiger;
|
||||
}
|
||||
|
||||
public List<String> getTails() {
|
||||
return tails;
|
||||
}
|
||||
|
||||
public void setTails(List<String> tails) {
|
||||
this.tails = tails;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tem.bocai.repository;
|
||||
|
||||
import com.tem.bocai.entity.LotteryResult;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface LotteryResultRepository extends JpaRepository<LotteryResult, Long> {
|
||||
// 可以添加自定义查询方法
|
||||
}
|
||||
Reference in New Issue
Block a user