RepoMapper.xml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.ydl.exam.modules.repo.mapper.RepoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.ydl.exam.modules.repo.entity.Repo">
  6. <id column="id" property="id" />
  7. <result column="code" property="code" />
  8. <result column="title" property="title" />
  9. <result column="radio_count" property="radioCount" />
  10. <result column="multi_count" property="multiCount" />
  11. <result column="judge_count" property="judgeCount" />
  12. <result column="remark" property="remark" />
  13. <result column="create_time" property="createTime" />
  14. <result column="update_time" property="updateTime" />
  15. </resultMap>
  16. <!-- 通用查询结果列 -->
  17. <sql id="Base_Column_List">
  18. `id`,`code`,`title`,`radio_count`,`multi_count`,`judge_count`,`remark`,`create_time`,`update_time`
  19. </sql>
  20. <resultMap id="ListResultMap"
  21. type="com.ydl.exam.modules.repo.dto.response.RepoRespDTO"
  22. extends="BaseResultMap">
  23. </resultMap>
  24. <select id="paging" resultMap="ListResultMap">
  25. SELECT * FROM el_repo repo
  26. <where>
  27. <if test="query!=null">
  28. <if test="query.title!=null and query.title!=''">
  29. AND title LIKE '%${query.title}%'
  30. </if>
  31. </if>
  32. </where>
  33. </select>
  34. <update id="refreshStat">
  35. UPDATE el_repo a
  36. SET
  37. radio_count=(SELECT COUNT(0) FROM el_qu_repo WHERE repo_id=a.id AND qu_type=1),
  38. multi_count=(SELECT COUNT(0) FROM el_qu_repo WHERE repo_id=a.id AND qu_type=2),
  39. judge_count=(SELECT COUNT(0) FROM el_qu_repo WHERE repo_id=a.id AND qu_type=3)
  40. WHERE a.id=#{repoId}
  41. </update>
  42. </mapper>