Commit 319da40b authored by liming's avatar liming

增加汇总统计接口

parent c39821b3
......@@ -69,4 +69,15 @@ public class MatchBicycleController {
public ResponseEntity<Result<List<DtoMatchBicycleResult>>> getMatchBicyclePlayerRecord(@PathVariable Long matchId) {
return success(matchBicyclePlayerService.getMatchBicyclePlayerRecord(matchId));
}
/**
* 自动结束当前比赛并且重新开启一场比赛
*/
@GetMapping("/auto/create")
@ApiOperation(value = "自动关闭当前赛事,创建一个新的比赛",
notes = "创建比赛规则:进入时间=当前时间+1分钟 开始时间=进入时间+1分钟 结束时间=开始时间+20分钟")
public ResponseEntity<Result> autoCreate(){
matchBicycleService.autoCreate();
return success();
}
}
package com.antai.sport.http.server.game.api.business.match.bicycle;
import com.antai.sport.http.server.common.exception.BusinessException;
import com.antai.sport.http.server.constants.DeleteStatus;
import com.antai.sport.http.server.game.api.business.match.bicycle.dto.ReqMatchBicycleSave;
import com.antai.sport.http.server.game.api.business.match.bicycle.dto.RespMatchBicycleList;
import com.antai.sport.http.server.repository.match.entity.MatchBicycle;
import com.antai.sport.http.server.repository.match.mapper.MatchBicycleMapper;
import com.antai.sport.http.server.repository.sport.entity.SportUser;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.time.LocalDateTime;
......@@ -77,4 +80,31 @@ public class MatchBicycleService extends ServiceImpl<MatchBicycleMapper, MatchBi
throw new BusinessException("当前比赛已经开始,您已无法加入");
}
}
public void autoCreate() {
//查询当前进行中的比赛进行,设置结束时间为当前时间
QueryWrapper<MatchBicycle> matchQuery = new QueryWrapper<>();
LocalDateTime now = LocalDateTime.now();
matchQuery.eq("deleted", DeleteStatus.UNDELETED).ge("end_time", now);
List<MatchBicycle> matchList = this.list(matchQuery);
if (matchList != null && matchList.size() > 0) {
for (MatchBicycle item : matchList) {
item.setEndTime(now);
item.setStartTime(now);
}
this.saveOrUpdateBatch(matchList);
}
//调用游戏服务端的暂停接口
RestTemplate restTemplate = new RestTemplate();
restTemplate.getForObject("http://47.100.168.51:3333/close?MatchId=force",String.class);
//创建一场新的比赛 创建比赛规则:进入时间=当前时间+1分钟 开始时间=进入时间+1分钟 结束时间=开始时间+20分钟
MatchBicycle match = new MatchBicycle();
match.setName("赛事");
match.setEntryTime(now.plusMinutes(1));
match.setStartTime(now.plusMinutes(2));
match.setEndTime(now.plusMinutes(22));
this.save(match);
}
}
......@@ -48,6 +48,7 @@ project:
- /match/bicycle
- /match/bicycle/*
- /match/bicycle/player/record
- /match/bicycle/auto/create
swagger:
enable: false
......
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