Commit 56fde268 authored by liming's avatar liming

排行列表页

parent b2cdc19b
package com.antai.sport.http.server.server.api.business.simplematch.dto;
import lombok.Data;
@Data
public class SimpleMatchUserScheduleVO {
private Integer day;
private String time;
}
...@@ -2,8 +2,10 @@ package com.antai.sport.http.server.server.api.business.simplematch.mapper; ...@@ -2,8 +2,10 @@ package com.antai.sport.http.server.server.api.business.simplematch.mapper;
import com.antai.sport.http.server.server.api.business.simplematch.dto.RespSimpleMatchList; import com.antai.sport.http.server.server.api.business.simplematch.dto.RespSimpleMatchList;
import com.antai.sport.http.server.server.api.business.simplematch.dto.RespSimpleMatchRank; import com.antai.sport.http.server.server.api.business.simplematch.dto.RespSimpleMatchRank;
import com.antai.sport.http.server.server.api.business.simplematch.dto.SimpleMatchUserScheduleVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
...@@ -15,4 +17,6 @@ public interface SimpleMatchBusinessMapper { ...@@ -15,4 +17,6 @@ public interface SimpleMatchBusinessMapper {
List<RespSimpleMatchRank> getSimpleMatchRank(@Param("matchId") Long matchId); List<RespSimpleMatchRank> getSimpleMatchRank(@Param("matchId") Long matchId);
List<Long> getRegisterList(@Param("matchId") Long matchId); List<Long> getRegisterList(@Param("matchId") Long matchId);
List<SimpleMatchUserScheduleVO> getUserRegistSchedule(@Param("playerId") Long playerId, @Param("beginDate") LocalDate beginDate, @Param("endDate")LocalDate endDate, @Param("today") LocalDate today);
} }
...@@ -3,6 +3,7 @@ package com.antai.sport.http.server.server.api.business.traininglog.mapper; ...@@ -3,6 +3,7 @@ package com.antai.sport.http.server.server.api.business.traininglog.mapper;
import com.antai.sport.http.server.repository.sport.entity.SportUserTrainingLog; import com.antai.sport.http.server.repository.sport.entity.SportUserTrainingLog;
import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogSummaryVO; import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogSummaryVO;
import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogVO; import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogVO;
import com.antai.sport.http.server.server.api.business.user.dto.ScheduleResponseDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -17,4 +18,6 @@ public interface SportUserTrainingLogBusinessMapper { ...@@ -17,4 +18,6 @@ public interface SportUserTrainingLogBusinessMapper {
@Param("endDate") LocalDate endDate); @Param("endDate") LocalDate endDate);
List<SportUserTrainingLogVO> getSportUserTrainingLog(@Param("userId") Long userId,@Param("date") LocalDate date,@Param("gameMode") Integer gameMod); List<SportUserTrainingLogVO> getSportUserTrainingLog(@Param("userId") Long userId,@Param("date") LocalDate date,@Param("gameMode") Integer gameMod);
List<ScheduleResponseDTO> getMonthTrainingSummary(@Param("playerId") Long playerId,@Param("beginDate") LocalDate beginDate,@Param("endDate")LocalDate endDate,@Param("today") LocalDate today);
} }
package com.antai.sport.http.server.server.api.business.traininglog.service; package com.antai.sport.http.server.server.api.business.traininglog.service;
import com.antai.sport.http.server.constants.DeleteStatus; import com.antai.sport.http.server.constants.DeleteStatus;
import com.antai.sport.http.server.constants.GameMode;
import com.antai.sport.http.server.constants.RankType; import com.antai.sport.http.server.constants.RankType;
import com.antai.sport.http.server.constants.SportType; import com.antai.sport.http.server.constants.SportType;
import com.antai.sport.http.server.repository.sport.entity.SportUser; import com.antai.sport.http.server.repository.sport.entity.SportUser;
...@@ -11,14 +12,14 @@ import com.antai.sport.http.server.repository.sport.mapper.SportUserMapper; ...@@ -11,14 +12,14 @@ import com.antai.sport.http.server.repository.sport.mapper.SportUserMapper;
import com.antai.sport.http.server.repository.sport.mapper.SportUserMonthRankMapper; import com.antai.sport.http.server.repository.sport.mapper.SportUserMonthRankMapper;
import com.antai.sport.http.server.repository.sport.mapper.SportUserSummaryMapper; import com.antai.sport.http.server.repository.sport.mapper.SportUserSummaryMapper;
import com.antai.sport.http.server.repository.sport.mapper.SportUserTrainingLogMapper; import com.antai.sport.http.server.repository.sport.mapper.SportUserTrainingLogMapper;
import com.antai.sport.http.server.server.api.business.simplematch.dto.SimpleMatchUserScheduleVO;
import com.antai.sport.http.server.server.api.business.simplematch.mapper.SimpleMatchBusinessMapper;
import com.antai.sport.http.server.server.api.business.traininglog.converter.SportUserTrainingLogConverter; import com.antai.sport.http.server.server.api.business.traininglog.converter.SportUserTrainingLogConverter;
import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogSummaryVO; import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogSummaryVO;
import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogVO; import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogVO;
import com.antai.sport.http.server.server.api.business.traininglog.mapper.SportUserTrainingLogBusinessMapper; import com.antai.sport.http.server.server.api.business.traininglog.mapper.SportUserTrainingLogBusinessMapper;
import com.antai.sport.http.server.server.api.business.user.converter.SportUserConverter; import com.antai.sport.http.server.server.api.business.user.converter.SportUserConverter;
import com.antai.sport.http.server.server.api.business.user.dto.ReqSportUserTrainingLog; import com.antai.sport.http.server.server.api.business.user.dto.*;
import com.antai.sport.http.server.server.api.business.user.dto.SportUserMonthRankRequestDTO;
import com.antai.sport.http.server.server.api.business.user.dto.SportUserMonthRankResponseDTO;
import com.antai.sport.http.server.server.api.business.user.mapper.SportUserMonthRankBusinessMapper; import com.antai.sport.http.server.server.api.business.user.mapper.SportUserMonthRankBusinessMapper;
import com.antai.sport.http.server.server.api.common.dto.CyclingDataDTO; import com.antai.sport.http.server.server.api.common.dto.CyclingDataDTO;
import com.antai.sport.http.server.server.api.utils.ScoreUtils; import com.antai.sport.http.server.server.api.utils.ScoreUtils;
...@@ -32,7 +33,10 @@ import javax.annotation.Resource; ...@@ -32,7 +33,10 @@ import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Service @Service
public class SportUserTrainingLogService { public class SportUserTrainingLogService {
...@@ -49,6 +53,8 @@ public class SportUserTrainingLogService { ...@@ -49,6 +53,8 @@ public class SportUserTrainingLogService {
private SportUserTrainingLogBusinessMapper sportUserTrainingLogBusinessMapper; private SportUserTrainingLogBusinessMapper sportUserTrainingLogBusinessMapper;
@Resource @Resource
private SportUserMonthRankBusinessMapper sportUserMonthRankBusinessMapper; private SportUserMonthRankBusinessMapper sportUserMonthRankBusinessMapper;
@Resource
private SimpleMatchBusinessMapper simpleMatchBusinessMapper;
@Resource @Resource
private SportUserTrainingLogConverter sportUserTrainingLogConverter; private SportUserTrainingLogConverter sportUserTrainingLogConverter;
...@@ -231,9 +237,51 @@ public class SportUserTrainingLogService { ...@@ -231,9 +237,51 @@ public class SportUserTrainingLogService {
pageParam.addOrder(new OrderItem("update_time", true)); pageParam.addOrder(new OrderItem("update_time", true));
pageParam.addOrder(new OrderItem("t1.id", true)); pageParam.addOrder(new OrderItem("t1.id", true));
IPage<SportUserMonthRankResponseDTO> result = sportUserMonthRankBusinessMapper.getRank(pageParam, param); IPage<SportUserMonthRankResponseDTO> result = sportUserMonthRankBusinessMapper.getRank(pageParam, param);
System.out.println(result.getPages());
return result.getRecords(); return result.getRecords();
} }
/**
* 查询用户运动日历
*
* @param userId
* @return
*/
public List<ScheduleResponseDTO> getSchedule(Long userId, Integer year, Integer month) {
List<ScheduleResponseDTO> resultList = new ArrayList<>();
Map<Integer, ScheduleResponseDTO> resultMap = new HashMap<>();
LocalDate beginDate = LocalDate.of(year, month, 1);
LocalDate endDate = beginDate.plusMonths(1);
LocalDate today = LocalDate.now();
List<ScheduleResponseDTO> trainList = sportUserTrainingLogBusinessMapper.getMonthTrainingSummary(userId, beginDate, endDate, today);
trainList.forEach(item -> {
item.setActive(true);
item.setScheduleList(new ArrayList<>());
resultMap.put(item.getDay(), item);
});
List<SimpleMatchUserScheduleVO> userScheduleList = simpleMatchBusinessMapper.getUserRegistSchedule(userId, beginDate, endDate, today);
userScheduleList.forEach(item -> {
if (!resultMap.containsKey(item.getDay())) {
ScheduleResponseDTO scheduleResponseDTO = new ScheduleResponseDTO();
scheduleResponseDTO.setScheduleList(new ArrayList<>());
scheduleResponseDTO.setDay(item.getDay());
scheduleResponseDTO.setActive(false);
resultMap.put(item.getDay(), scheduleResponseDTO);
}
ScheduleVO schedule = new ScheduleVO();
schedule.setTime(item.getTime());
schedule.setType(GameMode.SIMPLE_MATCH);
schedule.setTypeName("日常赛");
resultMap.get(item.getDay()).getScheduleList().add(schedule);
});
for (Integer i = 1; i <= 31; i++) {
if (resultMap.containsKey(i)) {
resultList.add(resultMap.get(i));
}
}
return resultList;
}
} }
...@@ -3,10 +3,7 @@ package com.antai.sport.http.server.server.api.business.user.controller; ...@@ -3,10 +3,7 @@ package com.antai.sport.http.server.server.api.business.user.controller;
import com.antai.sport.http.server.common.base.Result; import com.antai.sport.http.server.common.base.Result;
import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogVO; import com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogVO;
import com.antai.sport.http.server.server.api.business.traininglog.service.SportUserTrainingLogService; import com.antai.sport.http.server.server.api.business.traininglog.service.SportUserTrainingLogService;
import com.antai.sport.http.server.server.api.business.user.dto.ReqSportUserTrainingLog; import com.antai.sport.http.server.server.api.business.user.dto.*;
import com.antai.sport.http.server.server.api.business.user.dto.RespUserHomeInfo;
import com.antai.sport.http.server.server.api.business.user.dto.SportUserMonthRankRequestDTO;
import com.antai.sport.http.server.server.api.business.user.dto.SportUserMonthRankResponseDTO;
import com.antai.sport.http.server.server.api.business.user.service.SportUserService; import com.antai.sport.http.server.server.api.business.user.service.SportUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -51,4 +48,11 @@ public class SportUserController { ...@@ -51,4 +48,11 @@ public class SportUserController {
public ResponseEntity<Result<List<SportUserMonthRankResponseDTO>>> geRank(@RequestBody SportUserMonthRankRequestDTO param) { public ResponseEntity<Result<List<SportUserMonthRankResponseDTO>>> geRank(@RequestBody SportUserMonthRankRequestDTO param) {
return success(sportUserTrainingLogService.geRank(param)); return success(sportUserTrainingLogService.geRank(param));
} }
@ApiOperation("查询玩家运动日历")
@PostMapping("/{userId}/schedule")
public ResponseEntity<Result<List<ScheduleResponseDTO>>> getSchedule(@PathVariable("userId") Long userId, @RequestParam Integer year, @RequestParam Integer month) {
return success(sportUserTrainingLogService.getSchedule(userId, year, month));
}
} }
package com.antai.sport.http.server.server.api.business.user.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
@ApiModel("用户运动日历")
public class ScheduleResponseDTO {
@ApiModelProperty("日期")
private Integer day;
@ApiModelProperty("当日是否活跃 true 有训练记录 false 没有训练记录")
private Boolean active;
@ApiModelProperty("骑行长度")
private BigDecimal distance;
@ApiModelProperty("爬坡高度")
private BigDecimal climbDistance;
@ApiModelProperty("骑行时长")
private Integer duration;
@ApiModelProperty("日程安排")
List<ScheduleVO> scheduleList;
}
package com.antai.sport.http.server.server.api.business.user.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("日程安排")
public class ScheduleVO {
@ApiModelProperty("日程时间")
private String time;
@ApiModelProperty("日程类型 20:日常赛 30:系列赛 40:训练模式 50: 团练")
private Integer type;
@ApiModelProperty("日程类型 20:日常赛 30:系列赛 40:训练模式 50: 团练")
private String typeName;
}
...@@ -44,4 +44,12 @@ ...@@ -44,4 +44,12 @@
<select id="getRegisterList" resultType="java.lang.Long"> <select id="getRegisterList" resultType="java.lang.Long">
select player_id from simple_match_player_regist_log t1 where t1.match_id = #{matchId} select player_id from simple_match_player_regist_log t1 where t1.match_id = #{matchId}
</select> </select>
<select id="getUserRegistSchedule" resultType="com.antai.sport.http.server.server.api.business.simplematch.dto.SimpleMatchUserScheduleVO">
select DAYOFMONTH(t2.start_time) day,date_format(t2.start_time,'%H:%i') as time
from simple_match_player_regist_log t1
join simple_match t2 on t1.match_id = t2.id
where t1.player_id = #{playerId} and t2.start_time &gt;= #{today} and t2.start_time &gt;= #{beginDate} and t2.start_time &lt; #{endDate}
order by t2.start_time asc
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -31,4 +31,15 @@ ...@@ -31,4 +31,15 @@
</if> </if>
order by t1.id desc order by t1.id desc
</select> </select>
<select id="getMonthTrainingSummary" resultType="com.antai.sport.http.server.server.api.business.user.dto.ScheduleResponseDTO">
select day,sum(distance) distance,sum(climb_distance) climb_distance,sum(duration) duration
from (
select DAYOFMONTH(create_time) as day,distance,climb_distance,duration
from sport_user_training_log
where player_id = #{playerId} and sport_type = 1
and create_date &gt;= #{beginDate} and create_date &lt; #{endDate} and create_date &lt; #{today}
) t1
group by day
</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