|
|
@@ -4,4 +4,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="org.dromara.system.mapper.GameEventProjectMapper">
|
|
|
|
|
|
+ <resultMap type="org.dromara.system.domain.vo.GameEventProjectVo" id="GameEventProjectVoWithStatsResult">
|
|
|
+ <result property="athleteCount" column="athlete_count"/>
|
|
|
+ <result property="teamCount" column="team_count"/>
|
|
|
+ <result property="groupCount" column="group_count"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <select id="selectPageWithStats" resultMap="GameEventProjectVoWithStatsResult">
|
|
|
+ SELECT p.*,
|
|
|
+ IFNULL((SELECT COUNT(*) FROM game_athlete a WHERE a.event_id = p.event_id AND a.del_flag = '0'
|
|
|
+ AND (JSON_CONTAINS(a.project_value, JSON_ARRAY(p.project_id))
|
|
|
+ OR JSON_CONTAINS(a.project_value, JSON_ARRAY(CAST(p.project_id AS CHAR))))), 0) as athlete_count,
|
|
|
+ IFNULL((SELECT COUNT(DISTINCT team_id) FROM game_athlete a WHERE a.event_id = p.event_id AND a.del_flag = '0'
|
|
|
+ AND (JSON_CONTAINS(a.project_value, JSON_ARRAY(p.project_id))
|
|
|
+ OR JSON_CONTAINS(a.project_value, JSON_ARRAY(CAST(p.project_id AS CHAR))))), 0) as team_count,
|
|
|
+ IFNULL((SELECT COUNT(*) FROM game_event_group g WHERE g.project_id = p.project_id AND g.del_flag = '0'), 0) as group_count
|
|
|
+ FROM game_event_project p
|
|
|
+ <where>
|
|
|
+ p.del_flag = '0'
|
|
|
+ <if test="query.eventId != null">
|
|
|
+ AND p.event_id = #{query.eventId}
|
|
|
+ </if>
|
|
|
+ <if test="query.classification != null and query.classification != ''">
|
|
|
+ AND p.classification = #{query.classification}
|
|
|
+ </if>
|
|
|
+ <if test="query.projectName != null and query.projectName != ''">
|
|
|
+ AND p.project_name LIKE CONCAT('%', #{query.projectName}, '%')
|
|
|
+ </if>
|
|
|
+ <!-- 数据权限 -->
|
|
|
+ ${query.params.dataScope}
|
|
|
+ </where>
|
|
|
+ ORDER BY p.create_time DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|