Initial commit
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Example sysUserDetails template template
|
||||
### Example sysUserDetails template
|
||||
|
||||
# IntelliJ project files
|
||||
.idea
|
||||
*.iml
|
||||
out
|
||||
gen
|
||||
target
|
||||
*.log
|
||||
logs
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.datao</groupId>
|
||||
<artifactId>DataPro</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<name>DataPro</name>
|
||||
<description>数据处理</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<skipTests>true</skipTests>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.32</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>24.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.16.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.2.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>gframework</groupId>-->
|
||||
<!-- <artifactId>spring-beans</artifactId>-->
|
||||
<!-- <version>6.0.9</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<layout>ZIP</layout>
|
||||
<includes>
|
||||
<include>
|
||||
<groupId>nothing</groupId>
|
||||
<artifactId>nothing</artifactId>
|
||||
</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.datao;
|
||||
|
||||
import com.datao.config.ScheduleConfig;
|
||||
import com.datao.controller.DataServiceController;
|
||||
import com.datao.service.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Arrays;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class DataProApplication implements CommandLineRunner {
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext ac = SpringApplication.run(DataProApplication.class, args);
|
||||
try {
|
||||
// ===== 在项目初始化bean后检验数据库连接是否
|
||||
DataSource dataSource = (DataSource) ac.getBean("dataSource");
|
||||
dataSource.getConnection().close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// ===== 当检测数据库连接失败时, 停止项目启动
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
ScheduleConfig schedule = ac.getBean(ScheduleConfig.class);
|
||||
schedule.checkAutoScan();
|
||||
|
||||
if(Arrays.asList(args).contains("vhour")){
|
||||
Thread th = new HourThreadService(ac.getBean(MatchService.class),
|
||||
ac.getBean(OurateService.class),
|
||||
ac.getBean(OustatService.class));
|
||||
th.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DataServiceController controller;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
controller.startService();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.datao.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MpConfig {
|
||||
@Bean // MP 3.5.2版格式
|
||||
public MybatisPlusInterceptor paginationInterceptor() {
|
||||
MybatisPlusInterceptor mpInterceptor = new MybatisPlusInterceptor();
|
||||
mpInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
return mpInterceptor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.datao.config;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface PassToken {
|
||||
boolean value() default true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.datao.config;
|
||||
|
||||
import com.datao.domain.Scan;
|
||||
import com.datao.service.FetchService;
|
||||
import com.datao.service.ScanService;
|
||||
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import static java.lang.Thread.sleep;
|
||||
|
||||
@Component
|
||||
public class ScheduleConfig {
|
||||
@Autowired
|
||||
private ScanService scanService;
|
||||
@Autowired
|
||||
private FetchService fetchService;
|
||||
|
||||
@Scheduled(cron = "0 0 7 * * ?")
|
||||
// @Scheduled(cron = "0 0/1 * * * ?")
|
||||
public void checkAutoScan(){
|
||||
Date now = new Date();
|
||||
System.out.println("[" + now + "] checkAutoScan started");
|
||||
List<Scan> newScans = scanService.listAutoScan();
|
||||
for(int i=0; i<newScans.size(); i++) {
|
||||
Scan scan = newScans.get(i);
|
||||
|
||||
fetchService.scanSubAvailable(scan); //先检查有无未处理的附加比赛
|
||||
|
||||
String season = scan.getSeason();
|
||||
String[] aYear = season.split("-");
|
||||
if (aYear.length == 2) {
|
||||
Integer y1 = Integer.parseInt(aYear[0]) + 1;
|
||||
Integer y2 = Integer.parseInt(aYear[1]) + 1;
|
||||
season = y1 + "-" + y2;
|
||||
}
|
||||
else{
|
||||
season = String.valueOf(Integer.parseInt(season) + 1);
|
||||
}
|
||||
|
||||
scan.setSeason(season);
|
||||
|
||||
try {
|
||||
if (fetchService.scanAvailable(scan)) {
|
||||
scan.setId(null);
|
||||
scan.setState(0);
|
||||
scanService.save(scan);
|
||||
}
|
||||
|
||||
if(i<newScans.size()-1) sleep(2000); //休息2秒,避免网站警告
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.out.println("checkAutoScan finished");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.datao.config;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 添加拦截器
|
||||
*/
|
||||
//@Component
|
||||
public class TokenInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
// System.out.println(String.format("[%s]", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))
|
||||
// +" preHandle "+request.getRequestURL());
|
||||
//如果不是映射到方法直接放行
|
||||
if(!(handler instanceof HandlerMethod)){
|
||||
return true;
|
||||
}
|
||||
HandlerMethod handlerMethod = (HandlerMethod)handler;
|
||||
Method method = handlerMethod.getMethod();
|
||||
|
||||
HashMap<String,String> hashMap = new HashMap<>();
|
||||
String token = request.getHeader("Authorization");
|
||||
if((token == null || token.isEmpty())
|
||||
&& method.isAnnotationPresent(PassToken.class)) { //带有PassToken注解的方法不处理
|
||||
return true;
|
||||
}
|
||||
|
||||
// String msg = "";
|
||||
// try {
|
||||
// if(token != null && token!="") {
|
||||
// TokenUtil.verifyToken(token.substring(7));
|
||||
// return true;
|
||||
// }
|
||||
// else{
|
||||
// msg = "token无效";
|
||||
// }
|
||||
// }catch (SignatureVerificationException e){
|
||||
//// e.printStackTrace();
|
||||
// msg = "签名不一致";
|
||||
// }catch (TokenExpiredException e){
|
||||
//// e.printStackTrace();
|
||||
// msg = "令牌过期异常";
|
||||
// }catch (AlgorithmMismatchException e) {
|
||||
//// e.printStackTrace();
|
||||
// msg = "算法不匹配异常";
|
||||
// }catch (InvalidClaimException e){
|
||||
//// e.printStackTrace();
|
||||
// msg = "失效的claim异常";
|
||||
// }catch (Exception e){
|
||||
//// e.printStackTrace();
|
||||
// msg = "token无效";
|
||||
// }
|
||||
|
||||
// AjaxResult result = new AjaxResult(HttpStatus.UNAUTHORIZED.value(),msg);
|
||||
//
|
||||
// String resultJson = JSON.toJSONString(result);
|
||||
// response.setContentType("application/json;charset=utf-8");
|
||||
// response.getWriter().print(resultJson);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
|
||||
ModelAndView modelAndView) throws Exception {
|
||||
// System.out.println("postHandle");
|
||||
HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler, Exception ex) throws Exception {
|
||||
// System.out.println("afterCompletion");
|
||||
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.datao.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
//import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
|
||||
//配置拦截事件
|
||||
//@Configuration
|
||||
public class TokenWebMvcConfigurer implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
private TokenInterceptor tokenInterceptor;
|
||||
|
||||
/**
|
||||
* 配置跨域请求
|
||||
*
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
//定义哪些URL接受跨域
|
||||
registry.addMapping("/**")
|
||||
//定义哪些origin可以跨域请求
|
||||
// .allowedOrigins("*")
|
||||
.allowedOriginPatterns("*")
|
||||
//定义接受的跨域请求方法
|
||||
.allowedMethods("POST", "GET", "PUT", "DELETE")
|
||||
.exposedHeaders("Set-Token")
|
||||
.allowCredentials(true)
|
||||
.allowedHeaders("*")
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("/error");
|
||||
// list.add("/Api/**");
|
||||
|
||||
registry.addInterceptor(tokenInterceptor)
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
package com.datao.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.datao.domain.*;
|
||||
import com.datao.result.PageResult;
|
||||
import com.datao.result.Result;
|
||||
import com.datao.service.*;
|
||||
import com.datao.vo.*;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class DataServiceController {
|
||||
private final FetchService fetchService;
|
||||
private final ScanService scanService;
|
||||
private final MatchService matchService;
|
||||
private final OurateService rateService;
|
||||
private final OustatService oustatService;
|
||||
private final GameService gameService;
|
||||
private final TeamService teamService;
|
||||
// private final PredMatchService predMatchService;
|
||||
// private final PredWjrulesService predWjRulesService;
|
||||
|
||||
private DataThreadService thread = null;
|
||||
// private static String startServiceTime = "";
|
||||
// private static String stopServiceTime = "";
|
||||
// private static String lastScanTime = "";
|
||||
|
||||
@GetMapping("/startService")
|
||||
public Result<ServiceVo> startService() {
|
||||
int res = 1;
|
||||
if(thread == null){
|
||||
thread = new DataThreadService(fetchService,scanService,matchService,
|
||||
rateService,oustatService);//,predMatchService,predWjRulesService);
|
||||
thread.start();
|
||||
}
|
||||
else{
|
||||
if(thread.isInterrupted()){
|
||||
thread = null;
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return Result.success(new ServiceVo(res));
|
||||
}
|
||||
|
||||
@GetMapping("/stopService")
|
||||
public Result<ServiceVo> stopService() {
|
||||
int res = 0;
|
||||
if(thread != null) {
|
||||
thread.interrupt();
|
||||
try {
|
||||
thread.join();
|
||||
} catch (InterruptedException e) {
|
||||
// result = e.getMessage();
|
||||
e.printStackTrace();
|
||||
res = -1;
|
||||
}
|
||||
thread = null;
|
||||
}
|
||||
|
||||
return Result.success(new ServiceVo(res));
|
||||
}
|
||||
|
||||
@GetMapping("/checkService")
|
||||
public Result<ServiceVo> checkService() {
|
||||
int res = 1;
|
||||
if(thread == null){
|
||||
res = 0;
|
||||
}
|
||||
else{
|
||||
if(thread.isInterrupted()) {
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return Result.success(new ServiceVo(res));
|
||||
}
|
||||
|
||||
@GetMapping("/scan")
|
||||
public PageResult<Scan> getScanPage(@ParameterObject BasePageQuery query) {
|
||||
IPage<Scan> page = scanService.page(
|
||||
new Page<>(query.getPageNum(), query.getPageSize()),
|
||||
new LambdaQueryWrapper<Scan>()
|
||||
.orderByDesc(Scan::getState)
|
||||
.orderByDesc(Scan::getSeason)
|
||||
.orderByAsc(Scan::getGid)
|
||||
.orderByAsc(Scan::getSubid)
|
||||
);
|
||||
return PageResult.success(page);
|
||||
}
|
||||
|
||||
@PutMapping("/scan")
|
||||
public Result updateScan(@RequestBody @Validated Scan scanData) {
|
||||
boolean result = scanService.updateById(scanData);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@PostMapping("/scan")
|
||||
public Result addScan(@RequestBody @Validated Scan scanData) {
|
||||
boolean result = scanService.save(scanData);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@GetMapping("/game")
|
||||
public PageResult<Game> getGamePage(@ParameterObject BasePageQuery query) {
|
||||
IPage<Game> page = gameService.page(new Page<>(query.getPageNum(), query.getPageSize()),
|
||||
new QueryWrapper<Game>().orderByAsc("gid"));
|
||||
return PageResult.success(page);
|
||||
}
|
||||
|
||||
@PostMapping("/game")
|
||||
public Result saveGame(@RequestBody @Validated Game gameData) {
|
||||
boolean result = gameService.saveOrUpdate(gameData);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
private QueryWrapper<Match> buildWrapper(OUStatQuery query){
|
||||
QueryWrapper<Match> wrapper = new QueryWrapper<>();
|
||||
wrapper.ge(ObjectUtils.isNotEmpty(query.getDtstart()),"time",query.getDtstart())
|
||||
.le(ObjectUtils.isNotEmpty(query.getDtend()),"time",query.getDtend())
|
||||
.eq(ObjectUtils.isNotEmpty(query.getIhand()),"ihand",query.getIhand())
|
||||
.eq(ObjectUtils.isNotEmpty(query.getEhand()),"ehand",query.getEhand())
|
||||
.eq(ObjectUtils.isNotEmpty(query.getHname()),"th.name",query.getHname())
|
||||
.in(ObjectUtils.isNotEmpty(query.getGids()),"g.gid", (Object[]) query.getGids());
|
||||
|
||||
if(ObjectUtils.isNotEmpty(query.getIorate())){
|
||||
wrapper.ge("iorate", query.getIorate() - query.getFluct())
|
||||
.le("iorate", query.getIorate() + query.getFluct());
|
||||
}
|
||||
if(ObjectUtils.isNotEmpty(query.getIurate())){
|
||||
wrapper.ge("iurate", query.getIurate() - query.getFluct())
|
||||
.le("iurate", query.getIurate() + query.getFluct());
|
||||
}
|
||||
if(ObjectUtils.isNotEmpty(query.getEorate())){
|
||||
wrapper.ge("eorate", query.getEorate() - query.getFluct())
|
||||
.le("eorate", query.getEorate() + query.getFluct());
|
||||
}
|
||||
if(ObjectUtils.isNotEmpty(query.getEurate())){
|
||||
wrapper.ge("eurate", query.getEurate() - query.getFluct())
|
||||
.le("eurate", query.getEurate() + query.getFluct());
|
||||
}
|
||||
if(ObjectUtils.isNotEmpty(query.getGoal())){
|
||||
String cmp = (query.getGoal()<5 ? "=" : ">=");
|
||||
wrapper.apply("(hgoal+agoal)" + cmp + "{0}", query.getGoal());
|
||||
}
|
||||
if(ObjectUtils.isNotEmpty(query.getChgnum())){
|
||||
String cmp = (query.getChgnum()<5 ? "=" : ">=");
|
||||
wrapper.apply("chgnum" + cmp + "{0}", query.getChgnum());
|
||||
}
|
||||
if(ObjectUtils.isNotEmpty(query.getVhour()) && query.getVhour()>0){
|
||||
int hrMax = query.getVhour() + query.getVhfluct() * 100,
|
||||
hrMin = query.getVhour() - query.getVhfluct() * 100;
|
||||
wrapper.isNotNull("vhour")
|
||||
.ge("vhour", Math.max(hrMin, 0))
|
||||
.le("vhour", hrMax );
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@PostMapping("/oustat")
|
||||
public Result<OUStatVo> getOUStat(@RequestBody @Validated OUStatQuery query) {
|
||||
QueryWrapper<Match> wrapper = buildWrapper(query);
|
||||
wrapper.apply("LENGTH(hgoal)>0"); //只计算完场比赛
|
||||
|
||||
OUStatVo stat = matchService.getOUStat(wrapper);
|
||||
return Result.success(stat);
|
||||
}
|
||||
|
||||
@PostMapping("/ouinfos")
|
||||
public PageResult<OUInfoVo> getOUInfoPage(@RequestBody @Validated OUInfoQuery query) {
|
||||
QueryWrapper<Match> wrapper = buildWrapper(query);
|
||||
wrapper.orderByDesc("time");
|
||||
|
||||
IPage<OUInfoVo> page = matchService.getOUInfo(new Page<>(query.getPageNum(), query.getPageSize()), wrapper);
|
||||
return PageResult.success(page);
|
||||
}
|
||||
|
||||
@GetMapping("/dbinfo")
|
||||
public Result<DBInfoVo> getDBInfo(){
|
||||
DBInfoVo dbInfo = new DBInfoVo();
|
||||
|
||||
dbInfo.setGameNum( (int)gameService.count() );
|
||||
dbInfo.setTeamNum( (int)teamService.count() );
|
||||
dbInfo.setMatchNum(matchService.getMatchCount());
|
||||
|
||||
Map<String, Object> map = matchService.getMap(new QueryWrapper<Match>().select("min(time) as dtMin, max(time) as dtMax"));
|
||||
LocalDateTime dt = LocalDateTime.ofEpochSecond((Integer) map.get("dtMin"), 0, ZoneOffset.ofHours(8));
|
||||
dbInfo.setYearStart( dt.getYear() );
|
||||
dt = LocalDateTime.ofEpochSecond((Integer) map.get("dtMax"), 0, ZoneOffset.ofHours(8));
|
||||
dbInfo.setYearEnd( dt.getYear() );
|
||||
|
||||
return Result.success(dbInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/ourate/{id}")
|
||||
public Result<Ourate> getOurate(@Parameter @PathVariable Integer id){
|
||||
Ourate rate = rateService.getById(id);
|
||||
return Result.success(rate);
|
||||
}
|
||||
|
||||
// @GetMapping("/predmatches")
|
||||
// public Result<List<PredMatchVo>> getPredMatches(@RequestParam(required=false) Integer sid){
|
||||
// List<PredMatchVo> list = new ArrayList<>();
|
||||
//
|
||||
// if(sid==null)
|
||||
// sid = 20;
|
||||
//
|
||||
// LambdaQueryWrapper<PredMatch> wrapper = sid==21 ? new LambdaQueryWrapper<PredMatch>().gt(PredMatch::getWjstate, 0)
|
||||
// : new LambdaQueryWrapper<PredMatch>().eq(PredMatch::getState, 1);
|
||||
// List<PredMatch> matches = predMatchService.list(wrapper);
|
||||
// for(PredMatch m : matches){
|
||||
// PredMatchVo vo = new PredMatchVo();
|
||||
// vo.setMid( m.getMid() );
|
||||
// vo.setLname( m.getLname() );
|
||||
// vo.setTime( m.getTime() );
|
||||
// vo.setHname( m.getHname() );
|
||||
// vo.setGname( m.getGname() );
|
||||
// vo.setPred( sid==21 ? m.getWjstate() : m.getPred() );
|
||||
//
|
||||
// list.add( vo );
|
||||
// }
|
||||
//
|
||||
// return Result.success(list);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.datao.domain.Game;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface GameDao extends BaseMapper<Game> {
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.datao.domain.Match;
|
||||
import com.datao.vo.OUInfoVo;
|
||||
import com.datao.vo.OUStatVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface MatchDao extends BaseMapper<Match> {
|
||||
String SELECTGOALS_SQL = """
|
||||
SELECT COUNT(*) total,
|
||||
COUNT(hgoal+agoal=0 OR NULL) num0,
|
||||
COUNT(hgoal+agoal=1 OR NULL) num1,
|
||||
COUNT(hgoal+agoal=2 OR NULL) num2,
|
||||
COUNT(hgoal+agoal=3 OR NULL) num3,
|
||||
COUNT(hgoal+agoal=4 OR NULL) num4,
|
||||
COUNT(hgoal+agoal>=5 OR NULL) num5
|
||||
FROM dg_match m
|
||||
INNER JOIN dg_oustat s ON m.id=s.id
|
||||
INNER JOIN dg_game g ON m.gid=g.gid
|
||||
INNER JOIN dg_team th ON m.hid=th.id
|
||||
${ew.customSqlSegment}""";
|
||||
|
||||
String SELECTOUINFO_SQL = """
|
||||
SELECT m.id, g.abbr gname, time, sub, season, th.`name` hname, ta.`name` aname,
|
||||
hgoal, agoal, ihand, iorate, iurate, ehand, eorate, eurate, chgnum, vhour, m.state
|
||||
FROM dg_match m
|
||||
INNER JOIN dg_oustat s ON m.id=s.id
|
||||
INNER JOIN dg_game g ON m.gid=g.gid
|
||||
INNER JOIN dg_team th ON m.hid=th.id
|
||||
INNER JOIN dg_team ta ON m.aid=ta.id
|
||||
${ew.customSqlSegment}""";
|
||||
|
||||
String SELECTMATCHCOUNT_SQL = """
|
||||
SELECT count(m.id)
|
||||
FROM dg_match m
|
||||
INNER JOIN dg_oustat s ON m.id=s.id
|
||||
INNER JOIN dg_game g ON m.gid=g.gid
|
||||
""";
|
||||
|
||||
@Select(SELECTGOALS_SQL)
|
||||
OUStatVo selectGoals(@Param(Constants.WRAPPER) QueryWrapper<Match> wrapper);
|
||||
|
||||
@Select(SELECTOUINFO_SQL)
|
||||
IPage<OUInfoVo> selectOUInfo(Page<Match> page, @Param(Constants.WRAPPER) QueryWrapper<Match> wrapper);
|
||||
|
||||
@Select(SELECTMATCHCOUNT_SQL)
|
||||
Integer selectMatchCount();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.datao.domain.Ourate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface OurateDao extends BaseMapper<Ourate> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.datao.domain.Oustat;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface OustatDao extends BaseMapper<Oustat> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.datao.domain.PredLeague;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PredLeagueDao extends BaseMapper<PredLeague> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.datao.domain.PredMatch;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PredMatchDao extends BaseMapper<PredMatch> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.datao.domain.PredTeam;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PredTeamDao extends BaseMapper<PredTeam> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.datao.domain.PredWjrules;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PredWjrulesDao extends BaseMapper<PredWjrules> {
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.datao.domain.Match;
|
||||
import com.datao.domain.Scan;
|
||||
import com.datao.vo.OUStatVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ScanDao extends BaseMapper<Scan> {
|
||||
String AUTOSCAN_SQL = """
|
||||
SELECT A.id id, A.gid gid, A.subid subid, A.subgame subgame, A.season season, A.state state
|
||||
FROM dg_scan A
|
||||
JOIN (
|
||||
SELECT max(season) season, gid
|
||||
FROM dg_scan
|
||||
GROUP BY gid
|
||||
) C ON A.gid=C.gid AND C.season=A.season
|
||||
WHERE LENGTH(IFNULL(subgame,''))=0 AND state=-1;
|
||||
""";
|
||||
|
||||
@Select(AUTOSCAN_SQL)
|
||||
List<Scan> listAutoScan();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.datao.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.datao.domain.Team;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface TeamDao extends BaseMapper<Team> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.datao.domain;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 基础分页请求对象
|
||||
*
|
||||
* @author haoxr
|
||||
* @date 2021/2/28
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class BasePageQuery {
|
||||
private int pageNum = 0;
|
||||
private int pageSize = 15;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.datao.domain;
|
||||
|
||||
public class Detail {
|
||||
public String hand;
|
||||
public int over;
|
||||
public int under;
|
||||
public String time;
|
||||
public int state;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.datao.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Game {
|
||||
@TableId(type = IdType.AUTO)
|
||||
Integer id;
|
||||
Integer gid;
|
||||
String name;
|
||||
String abbr;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.datao.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Match {
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Integer id;
|
||||
private Integer gid;
|
||||
private String season;
|
||||
private String sub;
|
||||
private Integer time;
|
||||
private Integer hid;
|
||||
private Integer aid;
|
||||
private Integer hgoal;
|
||||
private Integer agoal;
|
||||
private Integer state;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.datao.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class OUInfoQuery extends OUStatQuery{
|
||||
private int pageNum;
|
||||
private int pageSize;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.datao.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OUStatQuery {
|
||||
String hname; //主队名
|
||||
Integer dtstart;//开始时间
|
||||
Integer dtend; //截止时间
|
||||
String ihand; //初盘口
|
||||
Integer iorate; //初盘大赔
|
||||
Integer iurate; //初盘小赔
|
||||
String ehand; //早盘口
|
||||
Integer eorate; //早盘大赔
|
||||
Integer eurate; //早盘小赔
|
||||
Integer fluct; //赔率浮动范围
|
||||
Integer chgnum; //早动盘次数
|
||||
Integer goal; //总进球数
|
||||
Integer vhour; //有效时长
|
||||
Integer vhfluct;//有效时长浮动
|
||||
Integer gids[]; //赛事列表
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.datao.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Ourate {
|
||||
@TableId(type = IdType.INPUT)
|
||||
Integer id;
|
||||
String rates;
|
||||
Integer count;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.datao.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Oustat {
|
||||
Integer id;
|
||||
String ihand;
|
||||
Integer iorate;
|
||||
Integer iurate;
|
||||
String ehand;
|
||||
Integer eorate;
|
||||
Integer eurate;
|
||||
Integer chgnum;
|
||||
Integer vhour;
|
||||
Integer state;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.datao.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PredLeague {
|
||||
@TableId(type = IdType.INPUT)
|
||||
Integer lid;
|
||||
String lname;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.datao.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PredMatch {
|
||||
@TableId(type = IdType.INPUT)
|
||||
Integer mid;
|
||||
Integer lid;
|
||||
String lname;
|
||||
Integer htid;
|
||||
String hname;
|
||||
Integer gtid;
|
||||
String gname;
|
||||
Integer time;
|
||||
Integer stage;
|
||||
Integer state;
|
||||
Integer pred;
|
||||
Integer wjstate;
|
||||
|
||||
@TableField(exist = false)
|
||||
Integer hhgoals; //上半场主队进球数
|
||||
@TableField(exist = false)
|
||||
Integer hggoals; //上半场客队进球数
|
||||
@TableField(exist = false)
|
||||
Integer fhgoals; //全场主队进球数
|
||||
@TableField(exist = false)
|
||||
Integer fggoals; //全场客队进球数
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.datao.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PredTeam {
|
||||
@TableId(type = IdType.INPUT)
|
||||
Integer tid;
|
||||
String tname3;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user