GameEventProjectMapper.xml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="org.dromara.system.mapper.GameEventProjectMapper">
  6. <resultMap type="org.dromara.system.domain.vo.GameEventProjectVo" id="GameEventProjectVoWithStatsResult">
  7. <result property="athleteCount" column="athlete_count"/>
  8. <result property="teamCount" column="team_count"/>
  9. <result property="groupCount" column="group_count"/>
  10. </resultMap>
  11. <select id="selectPageWithStats" resultMap="GameEventProjectVoWithStatsResult">
  12. SELECT p.*,
  13. IFNULL((SELECT COUNT(*) FROM game_athlete a WHERE a.event_id = p.event_id AND a.del_flag = '0'
  14. AND (JSON_CONTAINS(a.project_value, JSON_ARRAY(p.project_id))
  15. OR JSON_CONTAINS(a.project_value, JSON_ARRAY(CAST(p.project_id AS CHAR))))), 0) as athlete_count,
  16. IFNULL((SELECT COUNT(DISTINCT team_id) FROM game_athlete a WHERE a.event_id = p.event_id AND a.del_flag = '0'
  17. AND (JSON_CONTAINS(a.project_value, JSON_ARRAY(p.project_id))
  18. OR JSON_CONTAINS(a.project_value, JSON_ARRAY(CAST(p.project_id AS CHAR))))), 0) as team_count,
  19. IFNULL((SELECT COUNT(*) FROM game_event_group g WHERE g.project_id = p.project_id AND g.del_flag = '0'), 0) as group_count
  20. FROM game_event_project p
  21. <where>
  22. p.del_flag = '0'
  23. <if test="query.eventId != null">
  24. AND p.event_id = #{query.eventId}
  25. </if>
  26. <if test="query.classification != null and query.classification != ''">
  27. AND p.classification = #{query.classification}
  28. </if>
  29. <if test="query.projectName != null and query.projectName != ''">
  30. AND p.project_name LIKE CONCAT('%', #{query.projectName}, '%')
  31. </if>
  32. <if test="query.gender != null and query.gender != ''">
  33. AND p.gender = #{query.gender}
  34. </if>
  35. <if test="query.groups != null and query.groups != ''">
  36. AND FIND_IN_SET(#{query.groups}, p.groups)
  37. </if>
  38. <!-- 数据权限 -->
  39. ${query.params.dataScope}
  40. </where>
  41. ORDER BY p.create_time DESC
  42. </select>
  43. </mapper>