lrj
5 天以前 4fa9591629721797386fc11836e3a9deb69cd58c
backend/src/main/java/com/rongyichuang/player/service/PlayerApplicationService.java
@@ -15,20 +15,33 @@
    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 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 " +
            "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.activity_id = :activityId");
            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,9 +50,12 @@
        }
        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);
        }
        List<Object[]> rows = q.getResultList();
        List<ActivityPlayerApplicationResponse> list = new ArrayList<>();
        for (Object[] r : rows) {