feat: 新增报名端专用选手列表接口 public-list
- 新增 /martial/athlete/public-list 接口 - 报名未结束时返回空列表和提示信息 - 新增 AthleteListResultVO 返回报名状态 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
+39
-3
@@ -1,9 +1,10 @@
|
||||
package org.springblade.modules.martial.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.qiniu.util.Auth;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -15,8 +16,11 @@ import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.modules.martial.pojo.entity.MartialAthlete;
|
||||
import org.springblade.modules.martial.pojo.entity.MartialCompetition;
|
||||
import org.springblade.modules.martial.pojo.vo.AthleteListResultVO;
|
||||
import org.springblade.modules.martial.pojo.vo.MartialAthleteVO;
|
||||
import org.springblade.modules.martial.service.IMartialAthleteService;
|
||||
import org.springblade.modules.martial.service.IMartialCompetitionService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
@@ -32,6 +36,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class MartialAthleteController extends BladeController {
|
||||
|
||||
private final IMartialAthleteService athleteService;
|
||||
private final IMartialCompetitionService competitionService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
@@ -44,7 +49,7 @@ public class MartialAthleteController extends BladeController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表(包含关联字段)
|
||||
* 分页列表(包含关联字段)- 管理后台使用
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "分页列表", description = "分页查询")
|
||||
@@ -53,6 +58,38 @@ public class MartialAthleteController extends BladeController {
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公开分页列表 - 报名端使用
|
||||
* 报名未结束时返回空列表和提示信息
|
||||
*/
|
||||
@GetMapping("/public-list")
|
||||
@Operation(summary = "公开分页列表", description = "报名端使用,报名未结束时返回空列表")
|
||||
public R<AthleteListResultVO> publicList(MartialAthlete athlete, Query query) {
|
||||
AthleteListResultVO result = new AthleteListResultVO();
|
||||
|
||||
if (athlete.getCompetitionId() != null) {
|
||||
MartialCompetition competition = competitionService.getById(athlete.getCompetitionId());
|
||||
if (competition != null && competition.getRegistrationEndTime() != null) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
boolean registrationEnded = now.isAfter(competition.getRegistrationEndTime());
|
||||
|
||||
result.setRegistrationEnded(registrationEnded);
|
||||
result.setRegistrationEndTime(competition.getRegistrationEndTime());
|
||||
|
||||
if (!registrationEnded) {
|
||||
result.setPage(new Page<>());
|
||||
result.setMessage("报名尚未结束,暂不显示参赛选手");
|
||||
return R.data(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IPage<MartialAthleteVO> pages = athleteService.selectAthleteVOPage(Condition.getPage(query), athlete);
|
||||
result.setPage(pages);
|
||||
result.setRegistrationEnded(true);
|
||||
return R.data(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@@ -61,7 +98,6 @@ public class MartialAthleteController extends BladeController {
|
||||
public R submit(@RequestBody MartialAthlete athlete) {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
log.info("=== 提交选手 === userId: {}, playerName: {}", userId, athlete.getPlayerName());
|
||||
// Only set createUser for new records (when id is null)
|
||||
if (athlete.getId() == null) {
|
||||
athlete.setCreateUser(userId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.springblade.modules.martial.pojo.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 参赛选手列表返回结果(包含报名状态)
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "参赛选手列表返回结果")
|
||||
public class AthleteListResultVO {
|
||||
|
||||
@Schema(description = "选手分页数据")
|
||||
private IPage<MartialAthleteVO> page;
|
||||
|
||||
@Schema(description = "报名是否已结束")
|
||||
private Boolean registrationEnded;
|
||||
|
||||
@Schema(description = "报名截止时间")
|
||||
private LocalDateTime registrationEndTime;
|
||||
|
||||
@Schema(description = "提示信息")
|
||||
private String message;
|
||||
}
|
||||
Reference in New Issue
Block a user