Commit 1498e484 authored by liming's avatar liming

系列赛完结接口

parent 53c546e1
...@@ -107,9 +107,10 @@ public class SeriesController { ...@@ -107,9 +107,10 @@ public class SeriesController {
} }
@ApiOperation("12.获取系列赛完结结果") @ApiOperation("12.获取系列赛完结结果")
@PostMapping("result/{seriesId}") @PostMapping("result/{seriesId}/{sportUserId}")
public ResponseEntity<Result<List<SeriesMatchResultVO>>> getSeriesMatchResult(@PathVariable("seriesId") Long seriesId){ public ResponseEntity<Result<List<SeriesMatchResultVO>>> getSeriesMatchResult(@PathVariable("seriesId") Long seriesId,
return success(seriesService.getSeriesMatchResult(seriesId)); @PathVariable("sportUserId") Long sportUserId) {
return success(seriesService.getSeriesMatchResult(seriesId, sportUserId));
} }
......
...@@ -62,4 +62,7 @@ public interface SeriesBusinessMapper { ...@@ -62,4 +62,7 @@ public interface SeriesBusinessMapper {
List<SeriesMatchForGameServerVO> getSeriesMatchForGameServer(@Param("now") LocalDateTime now); List<SeriesMatchForGameServerVO> getSeriesMatchForGameServer(@Param("now") LocalDateTime now);
List<SeriesMatchResultTopVO> getSeriesMatchResult(@Param("seriesId") Long seriesId); List<SeriesMatchResultTopVO> getSeriesMatchResult(@Param("seriesId") Long seriesId);
List<SeriesMatchResultVO> getFinalRoundMatchList(@Param("seriesId") Long seriesId,
@Param("sportUserId") Long sportUserId);
} }
...@@ -365,31 +365,17 @@ public class SeriesService { ...@@ -365,31 +365,17 @@ public class SeriesService {
return seriesBusinessMapper.getSeriesMatchForGameServer(LocalDateTime.now()); return seriesBusinessMapper.getSeriesMatchForGameServer(LocalDateTime.now());
} }
public List<SeriesMatchResultVO> getSeriesMatchResult(Long seriesId) { public List<SeriesMatchResultVO> getSeriesMatchResult(Long seriesId, Long sportUserId) {
List<SeriesMatchResultVO> result = new ArrayList<>(); List<SeriesMatchResultVO> result = seriesBusinessMapper.getFinalRoundMatchList(seriesId,
QueryWrapper<SeriesRound> roundQuery = new QueryWrapper<>(); sportUserId);
roundQuery.lambda().eq(SeriesRound::getSeriesId, seriesId) if (result.isEmpty()) {
.eq(SeriesRound::getStatus, 20)
.eq(SeriesRound::getDeleted, DeleteStatus.UNDELETED)
.eq(SeriesRound::getFinalRound, true);
SeriesRound round = seriesRoundMapper.selectOne(roundQuery);
if (round == null) {
return result;
}
QueryWrapper<SeriesMatch> matchQuery = new QueryWrapper<>();
matchQuery.lambda().eq(SeriesMatch::getDeleted, DeleteStatus.UNDELETED)
.eq(SeriesMatch::getStatus, 20)
.eq(SeriesMatch::getRoundId, round.getId());
List<SeriesMatch> matchList = seriesMatchMapper.selectList(matchQuery);
if (matchList.isEmpty()) {
return result; return result;
} }
Map<Long, SeriesMatchResultVO> resultMap = new HashMap<>(); Map<Long, SeriesMatchResultVO> resultMap = new HashMap<>();
for (SeriesMatch match : matchList) { for (SeriesMatchResultVO match : result) {
SeriesMatchResultVO resultVO = new SeriesMatchResultVO(match); match.setMatchResultTopList(new ArrayList<>());
result.add(resultVO); resultMap.put(match.getId(), match);
resultMap.put(resultVO.getId(), resultVO);
} }
List<SeriesMatchResultTopVO> topList = seriesBusinessMapper.getSeriesMatchResult(seriesId); List<SeriesMatchResultTopVO> topList = seriesBusinessMapper.getSeriesMatchResult(seriesId);
......
package com.antai.sport.http.server.server.api.business.series.vo; package com.antai.sport.http.server.server.api.business.series.vo;
import com.antai.sport.http.server.repository.series.entity.SeriesMatch;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@ApiModel("系列赛完结比赛对象") @ApiModel("系列赛完结比赛对象")
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public class SeriesMatchResultVO { public class SeriesMatchResultVO {
public SeriesMatchResultVO (SeriesMatch match){
this.id = match.getId();
this.name = match.getName();
this.matchResultTopList = new ArrayList<>();
}
@ApiModelProperty("比赛id") @ApiModelProperty("比赛id")
private Long id; private Long id;
@ApiModelProperty("比赛名称") @ApiModelProperty("比赛名称")
private String name; private String name;
@ApiModelProperty("我的排名")
private Integer myRank;
@ApiModelProperty("系列赛完结Top选手") @ApiModelProperty("系列赛完结Top选手")
private List<SeriesMatchResultTopVO> matchResultTopList; private List<SeriesMatchResultTopVO> matchResultTopList;
} }
...@@ -191,6 +191,31 @@ ...@@ -191,6 +191,31 @@
) )
order by t1.match_id,t1.match_rank order by t1.match_id,t1.match_rank
</select> </select>
<select id="getFinalRoundMatchList" resultType="com.antai.sport.http.server.server.api.business.series.vo.SeriesMatchResultVO">
select id,name,my_rank
from (
select id,name,show_order,my_rank,if(my_rank is null,2,1) as base_order
from (
select t1.id,t1.name,t1.show_order,
(select s1.match_rank
from series_match_player_record s1
where s1.match_id = t1.id
and s1.player_id = #{sportUserId} limit 1) as my_rank
from series_match t1
where t1.deleted = 0 and t1.status = 20
and t1.round_id in (
select id
from series_round w1
where w1.deleted = 0
and w1.status = 20
and w1.final_round = 1
and w1.series_id = #{seriesId}
)
) wrapper2
) wrapper1
order by base_order,show_order,id
</select>
</mapper> </mapper>
\ No newline at end of file
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