From 93eb6b470773bc49ea6e1a9d4cbd914eb95d525b Mon Sep 17 00:00:00 2001 From: lrj <owen.stl@gmail.com> Date: 星期二, 30 九月 2025 17:38:04 +0800 Subject: [PATCH] feat: 完善比赛晋级功能并清理测试文件 --- backend/src/main/java/com/rongyichuang/player/service/PlayerApplicationService.java | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 40 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/com/rongyichuang/player/service/PlayerApplicationService.java b/backend/src/main/java/com/rongyichuang/player/service/PlayerApplicationService.java index 62583da..f78ffc1 100644 --- a/backend/src/main/java/com/rongyichuang/player/service/PlayerApplicationService.java +++ b/backend/src/main/java/com/rongyichuang/player/service/PlayerApplicationService.java @@ -15,20 +15,41 @@ private EntityManager em; /** - * 璇诲彇鎶ュ悕鐢宠锛屾寜鎶ュ悕鏃堕棿鍊掑簭 - * 娉ㄦ剰锛氬疄闄呭簱琛ㄤ负 t_avtivity_player锛堟嫾鍐欎互搴撲负鍑嗭級 + * 鏌ヨ娲诲姩鎶ュ悕淇℃伅 */ @SuppressWarnings("unchecked") - public List<ActivityPlayerApplicationResponse> listApplications(String name, Integer page, Integer size) { + public List<ActivityPlayerApplicationResponse> listApplications(String name, Long activityId, Integer state, Integer page, Integer size) { String baseSql = - "SELECT ap.id, p.name AS player_name, a.name AS activity_name, p.phone AS phone, ap.create_time AS apply_time, p.audit_state AS state " + - "FROM t_avtivity_player ap " + + "SELECT ap.id, p.name AS player_name, a.name AS activity_name, ap.project_name AS project_name, p.phone AS phone, ap.create_time AS apply_time, ap.state AS state " + + "FROM t_activity_player ap " + "JOIN t_player p ON p.id = ap.player_id " + "JOIN t_activity a ON a.id = ap.activity_id "; - String where = ""; + + StringBuilder whereClause = new StringBuilder(); + boolean hasCondition = false; + if (name != null && !name.isEmpty()) { - where = "WHERE p.name LIKE CONCAT('%', :name, '%') "; + whereClause.append("p.name LIKE CONCAT('%', :name, '%')"); + hasCondition = true; } + + if (activityId != null) { + if (hasCondition) { + whereClause.append(" AND "); + } + whereClause.append("ap.stage_id = :activityId"); + hasCondition = true; + } + + if (state != null) { + if (hasCondition) { + whereClause.append(" AND "); + } + whereClause.append("ap.state = :state"); + hasCondition = true; + } + + String where = hasCondition ? "WHERE " + whereClause.toString() + " " : ""; String order = "ORDER BY ap.create_time DESC "; String limit = ""; if (page != null && size != null && page > 0 && size > 0) { @@ -37,8 +58,14 @@ } var q = em.createNativeQuery(baseSql + where + order + limit); - if (!where.isEmpty()) { + if (name != null && !name.isEmpty()) { q.setParameter("name", name); + } + if (activityId != null) { + q.setParameter("activityId", activityId); + } + if (state != null) { + q.setParameter("state", state); } List<Object[]> rows = q.getResultList(); List<ActivityPlayerApplicationResponse> list = new ArrayList<>(); @@ -47,10 +74,11 @@ dto.setId(r[0] != null ? Long.valueOf(r[0].toString()) : null); // activity_player_id dto.setPlayerName(r[1] != null ? r[1].toString() : ""); dto.setActivityName(r[2] != null ? r[2].toString() : ""); - dto.setPhone(r[3] != null ? r[3].toString() : ""); - dto.setApplyTime(r[4] != null ? r[4].toString() : ""); - // 鏄犲皠鐘舵�侊細浣跨敤 t_player.audit_state锛�0=鏈鏍革紝1=杩涜涓紝2=宸查┏鍥烇紝3=缁撴潫锛� - dto.setState(r[5] != null ? Integer.valueOf(r[5].toString()) : 0); + dto.setProjectName(r[3] != null ? r[3].toString() : ""); // project_name + dto.setPhone(r[4] != null ? r[4].toString() : ""); + dto.setApplyTime(r[5] != null ? r[5].toString() : ""); + // 鏄犲皠鐘舵�侊細浣跨敤 t_activity_player.state锛�0=鏈鏍革紝1=瀹℃牳閫氳繃锛�2=瀹℃牳椹冲洖锛� + dto.setState(r[6] != null ? Integer.valueOf(r[6].toString()) : 0); list.add(dto); } return list; -- Gitblit v1.8.0