Commit 50ec6a8b authored by liming's avatar liming

增加自动创建比赛接口

parent c5b5d634
......@@ -2,6 +2,7 @@ package com.antai.sport.http.server.game.api.business.match.bicycle;
import com.antai.sport.http.server.common.annotation.LoginSportUser;
import com.antai.sport.http.server.common.base.Result;
import com.antai.sport.http.server.game.api.business.match.bicycle.dto.DtoMatchAutoCreate;
import com.antai.sport.http.server.game.api.business.match.bicycle.dto.DtoMatchBicycleResult;
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;
......@@ -73,11 +74,11 @@ public class MatchBicycleController {
/**
* 自动结束当前比赛并且重新开启一场比赛
*/
@GetMapping("/auto/create")
@PostMapping("/auto/create")
@ApiOperation(value = "自动关闭当前赛事,创建一个新的比赛",
notes = "创建比赛规则:进入时间=当前时间+1分钟 开始时间=进入时间+1分钟 结束时间=开始时间+20分钟")
public ResponseEntity<Result> autoCreate(){
matchBicycleService.autoCreate();
public ResponseEntity<Result> autoCreate(@RequestBody DtoMatchAutoCreate param){
matchBicycleService.autoCreate(param);
return success();
}
}
......@@ -2,6 +2,7 @@ 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.DtoMatchAutoCreate;
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;
......@@ -58,6 +59,7 @@ public class MatchBicycleService extends ServiceImpl<MatchBicycleMapper, MatchBi
match.setEntryTime(data.getEntryTime());
match.setStartTime(data.getStartTime());
match.setEndTime(data.getEndTime());
match.setDistance(data.getDistance());
this.save(match);
return match.getId();
}
......@@ -84,7 +86,7 @@ public class MatchBicycleService extends ServiceImpl<MatchBicycleMapper, MatchBi
}
}
public void autoCreate() {
public void autoCreate(DtoMatchAutoCreate param) {
//查询当前进行中的比赛进行,设置结束时间为当前时间
QueryWrapper<MatchBicycle> matchQuery = new QueryWrapper<>();
LocalDateTime now = LocalDateTime.now();
......@@ -103,10 +105,11 @@ public class MatchBicycleService extends ServiceImpl<MatchBicycleMapper, MatchBi
//创建一场新的比赛 创建比赛规则:进入时间=当前时间+1分钟 开始时间=进入时间+1分钟 结束时间=开始时间+20分钟
MatchBicycle match = new MatchBicycle();
match.setName("赛事");
match.setEntryTime(now.plusMinutes(1));
match.setStartTime(now.plusMinutes(2));
match.setEndTime(now.plusMinutes(22));
match.setName(param.getName());
match.setEntryTime(now.plusMinutes(param.getDelayEntryMinute()));
match.setStartTime(now.plusMinutes(param.getDelayEntryMinute() + param.getWarmUpMinute()));
match.setEndTime(now.plusMinutes(param.getDelayEntryMinute() + param.getWarmUpMinute() + param.getMatchMinute()));
match.setDistance(param.getDistance());
this.save(match);
}
......
package com.antai.sport.http.server.game.api.business.match.bicycle.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("自动创建")
public class DtoMatchAutoCreate {
@ApiModelProperty("比赛名称")
private String name;
@ApiModelProperty("延迟进入时间间隔(分钟)")
private Integer delayEntryMinute;
@ApiModelProperty("准备时间(分钟)")
private Integer warmUpMinute;
@ApiModelProperty("比赛总时长(分钟)")
private Integer matchMinute;
@ApiModelProperty("比赛总距离(米)")
private Integer distance;
}
......@@ -21,4 +21,6 @@ public class ReqMatchBicycleSave {
@ApiModelProperty("比赛结束时间 yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime endTime;
@ApiModelProperty("总长度")
private Integer distance;
}
......@@ -29,4 +29,7 @@ public class RespMatchBicycleList {
@ApiModelProperty("比赛结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime endTime;
@ApiModelProperty("总长度")
private Integer distance;
}
......@@ -47,6 +47,11 @@ public class MatchBicycle implements Serializable {
*/
private LocalDateTime endTime;
/**
* 总长度
*/
private Integer distance;
/**
* 显示顺序
*/
......
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