Commit c810434a by lenx065@gmail.com

赛事

parent 25fdd5db
package com.live.common.domain.dto.api;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MatchHomeListByDayResponse {
private String matchDay;
private List<MatchInfo> matchInfos;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class MatchInfo{
private String matchShortName;
private String matchTime;
private MatchListInfo home;
private MatchListInfo away;
//是否已订阅
private boolean subscribed;
}
}
package com.live.common.domain.dto.api;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MatchTypeListResponse {
private String sportsId;
private String sportsName;
private String sportsIcon;
}
......@@ -31,7 +31,7 @@ public class Sports extends BaseStringIdEntity {
private String competitionType;
//参加球队的类型(club: 俱乐部, national: 国家队)
private String teamType;
//1显示在文章搜索top上
//1显示在赛程搜索top上
private int searchTop;
//1显示在赛程页面
private int showMatch;
......
package com.live.common.domain.request;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class GetMatchListByRequest {
private String sportsId;
@ApiModelProperty("-1 全部 0 展示正在进行 和 未开始 1 正在进行 2未开始 3完场")
private Integer status;
@ApiModelProperty("比赛日期 yyyy-MM-dd 格式")
private String matchTime;
}
......@@ -2,6 +2,8 @@ package com.live.common.service;
import com.live.common.domain.ResponseData;
import javax.servlet.http.HttpServletRequest;
public interface CategoryService {
ResponseData<?> getTitleTab();
......@@ -10,4 +12,6 @@ public interface CategoryService {
ResponseData<?> getLiveTitleTab();
ResponseData<?> getMatchHomeType(HttpServletRequest request);
}
......@@ -14,6 +14,10 @@ import java.util.List;
public interface MatchService {
ResponseData<?> getMatchListBySportsId(GetMatchListByRequest commonStringId, HttpServletRequest request);
ResponseData<?> getMatchList(GetMatchListRequest commonStringId, HttpServletRequest request);
ResponseData<?> getMatchInfo(CommonStringId commonStringId, HttpServletRequest request);
......
......@@ -2,9 +2,11 @@ package com.live.common.service.impl;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.live.common.constant.ConstantValue;
import com.live.common.domain.ResponseData;
import com.live.common.domain.dto.api.CategoryListResponse;
import com.live.common.domain.dto.api.MatchSportsTypeResponse;
import com.live.common.domain.dto.api.MatchTypeListResponse;
import com.live.common.domain.entity.Category;
import com.live.common.domain.entity.Match;
import com.live.common.domain.entity.Sports;
......@@ -15,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
......@@ -105,4 +109,28 @@ public class CategoryServiceImpl implements CategoryService {
.sportsName(b.getSportsName())
.build()).collect(Collectors.toList()));
}
@Override
public ResponseData<?> getMatchHomeType(HttpServletRequest request) {
List<Sports> sports = sportsMapper.selectList(Wrappers.<Sports>lambdaQuery()
.eq(Sports::getDeleted, 0)
.eq(Sports::getSourceType, 1)
.eq(Sports::getShowMatch, 1)
.orderByDesc(Sports::getSort)
);
List<MatchTypeListResponse> matchTypeListResponses = new LinkedList<>();
matchTypeListResponses.add(MatchTypeListResponse.builder()
.sportsId("-1")
.sportsIcon(null)
.sportsName("热门")
.build());
sports.forEach(b -> matchTypeListResponses.add(MatchTypeListResponse.builder()
.sportsId(b.getId())
.sportsIcon(ConstantValue.completeAddress(b.getCompetitionIcon()))
.sportsName(b.getCompetitionShortName())
.build()));
return ResponseData.successResponse(matchTypeListResponses);
}
}
......@@ -109,6 +109,98 @@ public class MatchServiceImpl implements MatchService {
}
@Override
public ResponseData<?> getMatchListBySportsId(GetMatchListByRequest commonStringId, HttpServletRequest request) {
List<Match> matches;
QueryWrapper<Match> wrapper = new QueryWrapper<>();
wrapper.eq("deleted", StatusEnum.ENABLE.getCode());
wrapper.eq("source_type", 1);
if (StringUtils.isNotBlank(commonStringId.getSportsId())) {
wrapper.eq("sports_id", commonStringId.getSportsId());
}
//-1 全部 0 展示正在进行 和 未开始 1 正在进行 2未开始 3完场
//1正在进行 2未开始 3完场 4 未知
Integer status = commonStringId.getStatus() == null ? 0 : commonStringId.getStatus();
switch (status) {
case -1:
wrapper.notIn("competition_status", 4);
wrapper.orderByDesc("match_time");
wrapper.last(String.format(" limit %s,%s", 0, 30));
matches = matchMapper.selectList(wrapper);
break;
case 1:
case 2:
case 3:
wrapper.eq("competition_status", status);
wrapper.orderByDesc("match_time");
wrapper.last(String.format(" limit %s,%s", 0, 30));
matches = matchMapper.selectList(wrapper);
break;
default:
wrapper.in("competition_status", 1, 2);
wrapper.orderByDesc("match_time");
wrapper.last(String.format(" limit %s,%s", 0, 30));
matches = matchMapper.selectList(wrapper);
break;
}
MatchHomeListByDayResponse response = new MatchHomeListByDayResponse();
for (int i = matches.size() - 1; i >= 0; i--) {
if (i == matches.size()) {
response.setMatchDay(DateUtil.format(matches.get(0).getMatchTime(), DateUtil.YMD_));
}
Match match = matches.get(i);
MatchHomeListByDayResponse.MatchInfo matchInfo = new MatchHomeListByDayResponse.MatchInfo();
matchInfo.setSubscribed(false);
if (DateUtil.format(match.getMatchTime(), DateUtil.YMD_).equals(response.getMatchDay())) {
try {
String phone = CommonMethod.getUserPhone(request);
User account = userMapper.selectOne(Wrappers.<User>lambdaQuery()
.eq(User::getPhone, phone)
);
if (account != null) {
UserReserve userReserves = userReserveMapper.selectOne(Wrappers.<UserReserve>lambdaQuery()
.eq(UserReserve::getUserId, account.getId())
.eq(UserReserve::getMatchId, match.getId())
.eq(UserReserve::getDeleted, 0)
);
if (userReserves != null)
matchInfo.setSubscribed(true);
}
} catch (Exception e) {
log.warn("未携带 Token");
}
Team home = teamMapper.selectById(match.getHomeId());
Team away = teamMapper.selectById(match.getAwayId());
matchInfo.setMatchShortName(match.getCompetitionShortName());
matchInfo.setAway(MatchListInfo.builder()
.teamName(away.getTeamName())
.teamLogo(away.getTeamIcon())
.score(match.getAwayScore())
.build());
matchInfo.setHome(MatchListInfo.builder()
.teamName(home.getTeamName())
.teamLogo(home.getTeamIcon())
.score(match.getHomeScore())
.build());
matchInfo.setMatchTime(DateUtil.format(match.getMatchTime(), DateUtil.HM_));
response.getMatchInfos().add(matchInfo);
}
}
return ResponseData.successResponse(response);
}
@Override
public ResponseData<?> getMatchList(GetMatchListRequest commonStringId, HttpServletRequest request) {
List<Match> matches;
......@@ -122,7 +214,7 @@ public class MatchServiceImpl implements MatchService {
case -1:
wrapper.notIn("competition_status", 4);
if (StringUtils.isNotBlank(commonStringId.getId())) {
if(commonStringId.getId().length() < 10){
if (commonStringId.getId().length() < 10) {
wrapper.apply("FIND_IN_SET({0},category_id)", commonStringId.getId());
} else {
wrapper.eq("sports_id", commonStringId.getId());
......@@ -136,7 +228,7 @@ public class MatchServiceImpl implements MatchService {
case 3:
wrapper.eq("competition_status", status);
if (StringUtils.isNotBlank(commonStringId.getId())) {
if(commonStringId.getId().length() < 10){
if (commonStringId.getId().length() < 10) {
wrapper.apply("FIND_IN_SET({0},category_id)", commonStringId.getId());
} else {
wrapper.eq("sports_id", commonStringId.getId());
......@@ -149,7 +241,7 @@ public class MatchServiceImpl implements MatchService {
default:
wrapper.in("competition_status", 1, 2);
if (StringUtils.isNotBlank(commonStringId.getId())) {
if(commonStringId.getId().length() < 10){
if (commonStringId.getId().length() < 10) {
wrapper.apply("FIND_IN_SET({0},category_id)", commonStringId.getId());
} else {
wrapper.eq("sports_id", commonStringId.getId());
......@@ -2046,7 +2138,7 @@ public class MatchServiceImpl implements MatchService {
.matchId(quizRecord.getMatchId())
.title(quizRecord.getTitle())
.userId(quizRecord.getUserId())
.homeVsAway(home.getTeamName()+"VS"+away.getTeamName())
.homeVsAway(home.getTeamName() + "VS" + away.getTeamName())
.id(quizRecord.getId())
.matchName(match.getCompetitionShortName())
.userName(user.getUserName())
......@@ -2061,7 +2153,6 @@ public class MatchServiceImpl implements MatchService {
}
@Override
public ResponseData<?> editHotRankInfo(EditHotRankInfoRequest rankListRequest, HttpServletRequest request) {
QuizRecord quizRecord = quizRecordMapper.selectById(rankListRequest.getId());
......@@ -2075,7 +2166,7 @@ public class MatchServiceImpl implements MatchService {
quizRecord.setDeleted(rankListRequest.getDeleted());
quizRecord.setUserId(rankListRequest.getUserId());
if(quizRecord.getId() == null || quizRecord.getId() == 0){
if (quizRecord.getId() == null || quizRecord.getId() == 0) {
quizRecord.setId(null);
quizRecordMapper.insert(quizRecord);
} else {
......
......@@ -35,7 +35,7 @@ public class ChatTimedSendingServiceImpl {
private ThreadPoolTaskScheduler taskScheduler;
// @Scheduled(fixedRate = 10 * 60 * 1000)
@Scheduled(cron = "01 01/01 * * * ?")
// @Scheduled(cron = "01 01/01 * * * ?")
public void timedSendingServiceImpl() {
List<Room> rooms = roomMapper.selectList(Wrappers.<Room>lambdaQuery()
.eq(Room::getDeleted, 0)
......
......@@ -116,7 +116,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取赛事信息 (英超 - 等)
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 10 02/6 * * ?")
// @Scheduled(cron = "01 10 02/6 * * ?")
public void crawlSportsInfoFootball() {
log.info("爬取赛事基本信息 -> 足球");
String url = "http://data43.aistat.cn/competitions/infos?key=" + footballKey;
......@@ -161,7 +161,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取赛事信息 (美国职业篮球赛 - 等)
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 01 02/6 * * ?")
// @Scheduled(cron = "01 01 02/6 * * ?")
public void crawlSportsInfoBasketball() {
log.info("爬取赛事基本信息 -> 篮球");
String url = "http://data71.aistat.cn/basketball/competitions/infos?key=" + basketballKey;
......@@ -209,7 +209,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取指数公司信息 -> 足球
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 01 01/5 * * ?")
// @Scheduled(cron = "01 01 01/5 * * ?")
public void crawlIndexCompanyInfoFootball() {
log.info("爬取指数公司信息 -> 足球");
String url = "http://data61.aistat.cn/companies/infos?key=" + footballKey;
......@@ -245,7 +245,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取指数公司信息 -> 篮球
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 01 10/5 * * ?")
// @Scheduled(cron = "01 01 10/5 * * ?")
public void crawlIndexCompanyInfoBasketball() {
log.info("爬取指数公司信息 -> 篮球");
String url = "http://data91.aistat.cn/basketball/companies/infos?key=" + basketballKey;
......@@ -280,7 +280,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取赛事积分榜 -> 足球
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 01 0 * * ?")
// @Scheduled(cron = "01 01 0 * * ?")
public void crawlFootballLeagueRank() {
log.info("爬取赛事积分榜 -> 足球");
List<SystemConfig> systemConfigs = systemConfigMapper.selectList(Wrappers.<SystemConfig>lambdaQuery()
......@@ -362,7 +362,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取赛事积分榜 -> 篮球
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "02 02 0 * * ?")
// @Scheduled(cron = "02 02 0 * * ?")
public void crawlBasketballLeagueRank() {
log.info("爬取赛事积分榜 -> 篮球");
List<SystemConfig> systemConfigs = systemConfigMapper.selectList(Wrappers.<SystemConfig>lambdaQuery()
......@@ -452,7 +452,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 10 分钟爬取一次 AlStat 足球实时比分
*/
// @Scheduled(fixedRate = 2 * 60 * 60 * 1000)
@Scheduled(cron = "11 11/10 * * * ?")
// @Scheduled(cron = "11 11/10 * * * ?")
public void crawlAlStatFootballScore() {
String url = String.format("http://data43.aistat.cn/matchs/liveScores?key=%s", footballKey);
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
......
......@@ -42,7 +42,7 @@ public class CrawlChatHistoryServiceImpl implements CrawlChatHistoryService {
@Override
// @Scheduled(fixedRate = 20 * 60 * 1000)
@Scheduled(cron = "01 10/20 * * * ?")
// @Scheduled(cron = "01 10/20 * * * ?")
public void crawlTg2ChatHistory() {
log.info("爬取http://tg2.qqzb.vip/正在直播列表");
String url = "http://tg2.qqzb.vip/home/index-pc1";
......@@ -64,7 +64,7 @@ public class CrawlChatHistoryServiceImpl implements CrawlChatHistoryService {
@Override
// @Scheduled(fixedRate = 20 * 60 * 1000)
@Scheduled(cron = "10 10/20 * * * ?")
// @Scheduled(cron = "10 10/20 * * * ?")
public void crawlQiuShenChatHistory() {
log.info("爬取 https://qiushenzhibo1.com/d 正在直播列表");
String url = "https://api.zclhsq.com/schedules/broadcaster/replay/1/?getReplayData";
......
......@@ -51,21 +51,21 @@ public class MatchController {
// return categoryService.getMatchSportsType();
// }
// @PostMapping(value = "/getMatchHomeType")
// @ApiOperation(value = "获取比赛页赛程分类")
// @ApiResponses({
// @ApiResponse(code = 200, message = "成功处理请求"),
// @ApiResponse(code = 401, message = "没有权限访问该服务"),
// @ApiResponse(code = 403, message = "权限不足无法访问该服务"),
// @ApiResponse(code = 404, message = "未发现该服务"),
// @ApiResponse(code = 500, message = "服务器内部错误")
// })
// public ResponseData<?> getMatchHomeType(HttpServletRequest request) {
// return categoryService.getMatchHomeType(request);
// }
@PostMapping(value = "/getMatchHomeType")
@ApiOperation(value = "获取比赛页赛程分类")
@ApiResponses({
@ApiResponse(code = 200, message = "成功处理请求"),
@ApiResponse(code = 401, message = "没有权限访问该服务"),
@ApiResponse(code = 403, message = "权限不足无法访问该服务"),
@ApiResponse(code = 404, message = "未发现该服务"),
@ApiResponse(code = 500, message = "服务器内部错误")
})
public ResponseData<?> getMatchHomeType(HttpServletRequest request) {
return categoryService.getMatchHomeType(request);
}
@PostMapping(value = "/getMatchList")
@ApiOperation(value = "根据 sportsId 获取赛程列表(可带可不带token,带token判断预约)")
@PostMapping(value = "/getMatchListBySportsId")
@ApiOperation(value = "根据 sportsId 获取赛程列表(可带可不带token,带token判断关注)")
@ApiResponses({
@ApiResponse(code = 200, message = "成功处理请求"),
@ApiResponse(code = 401, message = "没有权限访问该服务"),
......@@ -76,10 +76,26 @@ public class MatchController {
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "登录凭证(登录后 token 值)", dataType = "String", paramType = "header", required = true)
})
public ResponseData<?> getMatchList(@RequestBody GetMatchListRequest commonStringId, HttpServletRequest request) {
return matchService.getMatchList(commonStringId, request);
public ResponseData<?> getMatchListBySportsId(@RequestBody GetMatchListByRequest commonStringId, HttpServletRequest request) {
return matchService.getMatchListBySportsId(commonStringId, request);
}
// @PostMapping(value = "/getMatchList")
// @ApiOperation(value = "根据 sportsId 获取赛程列表(可带可不带token,带token判断预约)")
// @ApiResponses({
// @ApiResponse(code = 200, message = "成功处理请求"),
// @ApiResponse(code = 401, message = "没有权限访问该服务"),
// @ApiResponse(code = 403, message = "权限不足无法访问该服务"),
// @ApiResponse(code = 404, message = "未发现该服务"),
// @ApiResponse(code = 500, message = "服务器内部错误")
// })
// @ApiImplicitParams({
// @ApiImplicitParam(name = "token", value = "登录凭证(登录后 token 值)", dataType = "String", paramType = "header", required = true)
// })
// public ResponseData<?> getMatchList(@RequestBody GetMatchListRequest commonStringId, HttpServletRequest request) {
// return matchService.getMatchList(commonStringId, request);
// }
@PostMapping(value = "/getMatchInfo")
@ApiOperation(value = "获取赛事详情")
@ApiResponses({
......@@ -94,7 +110,7 @@ public class MatchController {
}
@PostMapping(value = "/userReserveMatch")
@ApiOperation(value = "用户预约比赛")
@ApiOperation(value = "用户关注比赛")
@ApiResponses({
@ApiResponse(code = 200, message = "成功处理请求"),
@ApiResponse(code = 401, message = "没有权限访问该服务"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment