Commit 97942240 authored by liming's avatar liming

预选赛查主页查询接口

parent 1cb03dfd
......@@ -29,6 +29,11 @@ public class SeriesRound implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 系列赛id
*/
private Long seriesId;
/**
* 轮次名称
*/
......
......@@ -13,5 +13,7 @@ public interface BaseBusinessMapper {
String getMapPath(@Param("pathKey") String pathKey);
String getMapPathName(@Param("pathKey") String pathKey);
AppLatestVersionVO getAppLatestVersion(@Param("clientType") Integer clientType);
}
......@@ -6,6 +6,7 @@ import com.antai.sport.http.server.server.api.business.series.service.SeriesServ
import com.antai.sport.http.server.server.api.business.series.vo.SeriesApplyPreLoadVO;
import com.antai.sport.http.server.server.api.business.series.vo.SeriesDetailsVO;
import com.antai.sport.http.server.server.api.business.series.vo.SeriesListVO;
import com.antai.sport.http.server.server.api.business.series.vo.SeriesQualifyingMatchHomeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
......@@ -47,9 +48,18 @@ public class SeriesController {
@PostMapping("apply")
@ApiOperation(value = "报名方法")
public ResponseEntity<Result> seriesApply(@RequestBody SeriesApplyDTO dto){
public ResponseEntity<Result> seriesApply(@RequestBody SeriesApplyDTO dto) {
seriesService.seriesApply(dto);
return success();
}
@GetMapping("qualifying/{roundId}/{areaId}/{sportUserId}")
@ApiOperation(value = "查询预选赛轮次主页数据")
public ResponseEntity<Result<SeriesQualifyingMatchHomeVO>> getSeriesQualifyingMatchHomeData(
@PathVariable("roundId") Long roundId,
@PathVariable("areaId") Long areaId,
@PathVariable("sportUserId") Long sportUserId) {
return success(seriesService.getSeriesQualifyingMatchHomeData(roundId, areaId, sportUserId));
}
}
package com.antai.sport.http.server.server.api.business.series.mapper;
import com.antai.sport.http.server.repository.series.entity.SeriesApply;
import com.antai.sport.http.server.server.api.business.series.vo.SeriesAreaVO;
import com.antai.sport.http.server.server.api.business.series.vo.SeriesListVO;
import com.antai.sport.http.server.server.api.business.series.vo.SeriesNoticeVO;
import com.antai.sport.http.server.server.api.business.series.vo.SeriesRoundVO;
import com.antai.sport.http.server.server.api.business.series.vo.*;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.util.List;
public interface SeriesBusinessMapper {
......@@ -22,4 +20,16 @@ public interface SeriesBusinessMapper {
List<SeriesAreaVO> getSeriesAreaList(@Param("seriesId") Long seriesId);
SeriesApply getLatestUserSeriesApplyInfo(@Param("sportUserId") Long sportUserId);
Integer getBestResult(@Param("roundId") Long roundId, @Param("sportUserId") Long sportUserId);
Integer getSeriesQualifyingMatchLeftChance(@Param("roundId") Long roundId, @Param("sportUserId") Long sportUserId);
SeriesApply getSeriesApply(@Param("seriesId") Long seriesId, @Param("sportUserId") Long sportUserId);
List<SeriesQualifyingMatchVO> getSeriesQualifyingMatchList(@Param("roundId") Long roundId,
@Param("areaId") Long areaId,
@Param("sportUserId") Long sportUserId,
@Param("today") LocalDate today,
@Param("tomorrow") LocalDate tomorrow);
}
......@@ -3,10 +3,13 @@ package com.antai.sport.http.server.server.api.business.series.service;
import com.antai.sport.http.server.common.exception.BusinessException;
import com.antai.sport.http.server.repository.series.entity.Series;
import com.antai.sport.http.server.repository.series.entity.SeriesApply;
import com.antai.sport.http.server.repository.series.entity.SeriesRound;
import com.antai.sport.http.server.repository.series.mapper.SeriesApplyMapper;
import com.antai.sport.http.server.repository.series.mapper.SeriesMapper;
import com.antai.sport.http.server.repository.series.mapper.SeriesRoundMapper;
import com.antai.sport.http.server.repository.sport.entity.SportUser;
import com.antai.sport.http.server.repository.sport.mapper.SportUserMapper;
import com.antai.sport.http.server.server.api.business.base.mapper.BaseBusinessMapper;
import com.antai.sport.http.server.server.api.business.series.converter.SeriesConverter;
import com.antai.sport.http.server.server.api.business.series.dto.SeriesApplyDTO;
import com.antai.sport.http.server.server.api.business.series.mapper.SeriesBusinessMapper;
......@@ -14,10 +17,10 @@ import com.antai.sport.http.server.server.api.business.series.vo.SeriesApplyPreL
import com.antai.sport.http.server.server.api.business.series.vo.SeriesDetailsVO;
import com.antai.sport.http.server.server.api.business.series.vo.SeriesListVO;
import com.antai.sport.http.server.server.api.business.series.vo.SeriesQualifyingMatchHomeVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
......@@ -29,6 +32,8 @@ public class SeriesService {
@Resource
private SeriesApplyMapper seriesApplyMapper;
@Resource
private SeriesRoundMapper seriesRoundMapper;
@Resource
private SportUserMapper sportUserMapper;
@Resource
......@@ -36,6 +41,8 @@ public class SeriesService {
@Resource
private SeriesBusinessMapper seriesBusinessMapper;
@Resource
private BaseBusinessMapper baseBusinessMapper;
public List<SeriesListVO> getSeriesList() {
return seriesBusinessMapper.getSeriesList();
......@@ -70,7 +77,7 @@ public class SeriesService {
SeriesApplyPreLoadVO result = seriesConverter.toSeriesApplyPreLoadVO(sportUser);
result.setAreaList(seriesBusinessMapper.getSeriesAreaList(seriesId));
SeriesApply seriesApply = seriesBusinessMapper.getLatestUserSeriesApplyInfo(sportUserId);
if(seriesApply!=null){
if (seriesApply != null) {
result.setRealName(seriesApply.getName());
result.setIdCard(seriesApply.getIdCard());
}
......@@ -79,7 +86,7 @@ public class SeriesService {
}
public void seriesApply(SeriesApplyDTO dto) {
if(seriesBusinessMapper.checkExistUserSeriesApply(dto.getSeriesId(),dto.getSportUserId())){
if (seriesBusinessMapper.checkExistUserSeriesApply(dto.getSeriesId(), dto.getSportUserId())) {
throw new BusinessException("您已经报名当前比赛,无需重复报名");
}
......@@ -88,8 +95,35 @@ public class SeriesService {
seriesApplyMapper.insert(seriesApply);
}
public SeriesQualifyingMatchHomeVO getSeriesQualifyingMatchHomeData(){
public SeriesQualifyingMatchHomeVO getSeriesQualifyingMatchHomeData(Long roundId, Long areaId, Long sportUserId) {
SeriesQualifyingMatchHomeVO result = new SeriesQualifyingMatchHomeVO();
SeriesRound seriesRound = seriesRoundMapper.selectById(roundId);
if (seriesRound == null) {
throw new BusinessException("当前轮次比赛不存在,请后退,重新打开当亲你赛事");
}
result.setChance(0);
result.setLeftChance(0);
result.setPath(seriesRound.getPath());
result.setMap(seriesRound.getMap());
result.setDistance(seriesRound.getDistance());
result.setClimbDistance(seriesRound.getClimbDistance());
result.setPathName(baseBusinessMapper.getMapPathName(seriesRound.getPath()));
LocalDate today = LocalDate.now();
LocalDate tomorrow = today.plusDays(1);
result.setMatchList(seriesBusinessMapper
.getSeriesQualifyingMatchList(roundId, areaId, sportUserId, today, tomorrow));
SeriesApply apply = seriesBusinessMapper.getSeriesApply(seriesRound.getSeriesId(), sportUserId);
if (apply != null) {
result.setAreaId(apply.getAreaId());
if (areaId.equals(apply.getAreaId())) {
result.setChance(seriesRound.getChance());
result.setLeftChance(seriesRound.getChance() - seriesBusinessMapper.getSeriesQualifyingMatchLeftChance(roundId, sportUserId));
result.setBestResult(seriesBusinessMapper.getBestResult(roundId, sportUserId));
}
}
return result;
}
......
package com.antai.sport.http.server.server.api.business.series.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@ApiModel("预选赛主页VO")
......
......@@ -22,6 +22,13 @@
select path_name from map_path where path_key = #{pathKey}
</select>
<select id="getMapPathName" resultType="java.lang.String">
select concat(t2.map_name,t1.path_name)
from map_path t1
left join map t2 on t1.map_key = t2.map_key
where t1.path_key = #{pathKey}
</select>
<select id="getAppLatestVersion" resultType="com.antai.sport.http.server.server.api.business.base.dto.AppLatestVersionVO">
select version,content,download_page_url,force_update
from app_version
......
......@@ -40,4 +40,45 @@
<select id="getLatestUserSeriesApplyInfo" resultType="com.antai.sport.http.server.repository.series.entity.SeriesApply">
select * from series_apply where sport_user_id = #{sportUserId} order by id desc limit 1
</select>
<select id="getBestResult" resultType="java.lang.Integer">
select min(duration)
from series_match_player_record t1
where t1.round_id = #{roundId} and t1.player_id = #{sportUserId} and t1.status = 20
</select>
<select id="getSeriesQualifyingMatchLeftChance" resultType="java.lang.Integer">
select count(1)
from series_match_player_record t1
where t1.round_id = #{roundId} and t1.player_id = #{sportUserId}
</select>
<select id="getSeriesApply" resultType="com.antai.sport.http.server.repository.series.entity.SeriesApply">
select * from series_apply where series_id = #{seriesId} and sport_user_id = #{sportUserId}
</select>
<select id="getSeriesQualifyingMatchList"
resultType="com.antai.sport.http.server.server.api.business.series.vo.SeriesQualifyingMatchVO">
(select t1.id,t1.name,t1.entry_time,t1.start_time,t1.end_time,0 as result
from (
select timestampdiff(SECOND,now(),t1.start_time) as timediff,t1.*
from series_match t1
where t1.deleted = 0 and t1.status = 20 and t1.round_id = #{roundId} and t1.area_id = #{areaId}
and t1.start_time &gt;= #{today}
and t1.start_time &lt; #{tomorrow} and end_time &gt;= now()
) t1 order by timediff
)
union all (
select t1.id,t1.name,t1.entry_time,t1.start_time,t1.end_time,t2.duration as result
from series_match t1
left join (
select j1.match_id,j1.duration
from series_match_player_record j1
where j1.round_id = #{roundId}
and j1.status = 20 and j1.player_id = #{sportUserId}
) t2 on t1.id = t2.match_id
where t1.deleted = 0 and t1.status = 20 and t1.round_id = #{roundId} and t1.area_id = #{areaId}
and (t1.start_time &lt; #{today} or t1.start_time &gt;= #{tomorrow} or t1.end_time &lt; now() )
order by t1.start_time desc
)
</select>
</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