package com.example.system.mapper;

import com.example.system.model.ResultCompetitionTable;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CompetitionMapper {
    //获取所有竞赛信息
//    @Select("select * from competition_table;")
    @Select("SELECT c.*, (SELECT COUNT(*) FROM registration_table r WHERE r.competition_id = c.competition_id) AS registration_count FROM competition_table c;")
    List<ResultCompetitionTable> getCompetition();

    @Select("select competition_name from competition_table where competition_id=#{competitionId}")
    String getNameById(Long competitionId);
}
