Commit dd8b7d4e authored by liming's avatar liming

用户主页骑行记录查询

parent 42fd6d20
package com.antai.sport.http.server.server.api.business.traininglog.dto;
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;
@Data
@ApiModel("用户训练记录")
public class SportUserTrainingLogVO {
@ApiModelProperty("运动类型 1:自行车 2:跑步")
private Integer sportType;
@ApiModelProperty("运动模式 10:漫游 20:日常赛 30:系列赛 40:课程训练 50: 团练 60:房间模式")
private Integer gameMode;
@ApiModelProperty("玩家id")
private Long playerId;
@ApiModelProperty("主数据id 如比赛为比赛id 房间模式为房间id 漫游为漫游记录id")
private Long sourceId;
@ApiModelProperty("运动记录Id")
private Long recordId;
@ApiModelProperty("地图名称")
private String mapName;
@ApiModelProperty("赛道名称")
private String pathName;
@ApiModelProperty("卡路里 临时没有数据可以先不显示")
private Integer calorie;
@ApiModelProperty("点赞数量")
private Integer praiseNum;
@ApiModelProperty("比赛名次")
private Integer matchRank;
@ApiModelProperty("用时(秒)")
private Integer duration;
@ApiModelProperty("骑行总长度")
private BigDecimal distance;
@ApiModelProperty("爬坡高度")
private BigDecimal climbDistance;
@ApiModelProperty("平均功率")
private BigDecimal avgFtp;
@ApiModelProperty("平均速度")
private BigDecimal avgSpeed;
@ApiModelProperty("记录实际那 yyyy-MM-dd HH:mm")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
private LocalDateTime createTime;
}
...@@ -2,9 +2,11 @@ package com.antai.sport.http.server.server.api.business.traininglog.mapper; ...@@ -2,9 +2,11 @@ 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 org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List;
public interface SportUserTrainingLogBusinessMapper { public interface SportUserTrainingLogBusinessMapper {
SportUserTrainingLog getLongestTrainingLog(@Param("sportType") Integer sportType, @Param("userId") Long userId); SportUserTrainingLog getLongestTrainingLog(@Param("sportType") Integer sportType, @Param("userId") Long userId);
...@@ -13,4 +15,6 @@ public interface SportUserTrainingLogBusinessMapper { ...@@ -13,4 +15,6 @@ public interface SportUserTrainingLogBusinessMapper {
@Param("userId") Long userId, @Param("userId") Long userId,
@Param("beginDate") LocalDate beginDate, @Param("beginDate") LocalDate beginDate,
@Param("endDate") LocalDate endDate); @Param("endDate") LocalDate endDate);
List<SportUserTrainingLogVO> getSportUserTrainingLog(@Param("userId") Long userId,@Param("date") LocalDate date,@Param("gameMode") Integer gameMod);
} }
...@@ -8,7 +8,9 @@ import com.antai.sport.http.server.repository.sport.mapper.SportUserSummaryMappe ...@@ -8,7 +8,9 @@ import com.antai.sport.http.server.repository.sport.mapper.SportUserSummaryMappe
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.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.mapper.SportUserTrainingLogBusinessMapper; import com.antai.sport.http.server.server.api.business.traininglog.mapper.SportUserTrainingLogBusinessMapper;
import com.antai.sport.http.server.server.api.business.user.dto.ReqSportUserTrainingLog;
import com.antai.sport.http.server.server.api.common.dto.CyclingDataDTO; import com.antai.sport.http.server.server.api.common.dto.CyclingDataDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -17,6 +19,7 @@ import javax.annotation.Resource; ...@@ -17,6 +19,7 @@ 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.List;
@Service @Service
public class SportUserTrainingLogService { public class SportUserTrainingLogService {
...@@ -103,4 +106,14 @@ public class SportUserTrainingLogService { ...@@ -103,4 +106,14 @@ public class SportUserTrainingLogService {
} }
return summaryVO; return summaryVO;
} }
/**
* 查询用户训练记录
*
* @param param
* @return
*/
public List<SportUserTrainingLogVO> getSportUserTrainingLog(ReqSportUserTrainingLog param) {
return sportUserTrainingLogBusinessMapper.getSportUserTrainingLog(param.getPlayerId(), param.getDate(), param.getGameMode());
}
} }
package com.antai.sport.http.server.server.api.business.user.controller; 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.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.RespUserHomeInfo; import com.antai.sport.http.server.server.api.business.user.dto.RespUserHomeInfo;
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;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import static com.antai.sport.http.server.common.util.ResultUtil.success; import static com.antai.sport.http.server.common.util.ResultUtil.success;
...@@ -21,10 +22,18 @@ import static com.antai.sport.http.server.common.util.ResultUtil.success; ...@@ -21,10 +22,18 @@ import static com.antai.sport.http.server.common.util.ResultUtil.success;
public class SportUserController { public class SportUserController {
@Resource @Resource
private SportUserService sportUserService; private SportUserService sportUserService;
@Resource
private SportUserTrainingLogService sportUserTrainingLogService;
@ApiOperation("查询用户主页数据") @ApiOperation("查询用户主页数据")
@GetMapping("{userId}") @GetMapping("{userId}")
public ResponseEntity<Result<RespUserHomeInfo>> getUserHomeInfo(@PathVariable("userId") Long userId) { public ResponseEntity<Result<RespUserHomeInfo>> getUserHomeInfo(@PathVariable("userId") Long userId) {
return success(sportUserService.getUserHomeInfo(userId)); return success(sportUserService.getUserHomeInfo(userId));
} }
@ApiOperation("查询用户运动记录")
@PostMapping("/training/log")
public ResponseEntity<Result<List<SportUserTrainingLogVO>>> getSportUserTrainingLog(@RequestBody ReqSportUserTrainingLog param) {
return success(sportUserTrainingLogService.getSportUserTrainingLog(param));
}
} }
package com.antai.sport.http.server.server.api.business.user.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
@ApiModel("用户训练记录查询")
@Data
public class ReqSportUserTrainingLog {
@ApiModelProperty("玩家id")
private Long playerId;
@ApiModelProperty("查询日期 yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private LocalDate date;
@ApiModelProperty("模式 10:漫游 20:日常赛 30:系列赛 40:课程训练 50: 团练 60:房间模式")
private Integer gameMode;
}
...@@ -14,4 +14,21 @@ ...@@ -14,4 +14,21 @@
where player_id = #{userId} and sport_type = #{sportType} where player_id = #{userId} and sport_type = #{sportType}
and create_date &gt;= #{beginDate} and create_date &lt;= #{endDate} and create_date &gt;= #{beginDate} and create_date &lt;= #{endDate}
</select> </select>
<select id="getSportUserTrainingLog" resultType="com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogVO">
select t1.sport_type,t1.game_mode,t1.player_id,t1.source_id,t1.record_id,
t2.map_name,t3.path_name,t1.calorie,t1.duration,t1.match_rank,
t1.distance,t1.climb_distance,t1.avg_ftp,t1.avg_speed,t1.praise_num,t1.create_time
from sport_user_training_log t1
left join map t2 on t1.map = t2.map_key
left join map_path t3 on t1.path = t3.path_key
where t1.player_id = #{userId}
<if test="date != null">
and t1.date = #{date}
</if>
<if test="gameMode != null">
and t1.game_mode = #{gameMode}
</if>
order by t1.id desc
</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