UserExamMapper.xml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.user.exam.mapper.UserExamMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.ydl.exam.modules.user.exam.entity.UserExam">
  6. <id column="id" property="id" />
  7. <result column="user_id" property="userId" />
  8. <result column="exam_id" property="examId" />
  9. <result column="try_count" property="tryCount" />
  10. <result column="max_score" property="maxScore" />
  11. <result column="passed" property="passed" />
  12. <result column="create_time" property="createTime" />
  13. <result column="update_time" property="updateTime" />
  14. </resultMap>
  15. <!-- 通用查询结果列 -->
  16. <sql id="Base_Column_List">
  17. `id`,`user_id`,`exam_id`,`try_count`,`max_score`,`passed`,`create_time`,`update_time`
  18. </sql>
  19. <resultMap id="ListResultMap"
  20. type="com.ydl.exam.modules.user.exam.dto.response.UserExamRespDTO"
  21. extends="BaseResultMap">
  22. <result column="title" property="title" />
  23. <result column="real_name" property="realName" />
  24. </resultMap>
  25. <select id="paging" resultMap="ListResultMap">
  26. SELECT ue.*,ee.title,uc.real_name FROM el_user_exam ue
  27. LEFT JOIN el_exam ee ON ue.exam_id=ee.id
  28. LEFT JOIN sys_user uc ON ue.user_id=uc.id
  29. WHERE ee.id IS NOT NULL AND uc.id IS NOT NULL
  30. <if test="query!=null">
  31. <if test="query.userId!=null and query.userId!=''">
  32. AND ue.user_id='{{userId}}'
  33. </if>
  34. <if test="query.examId!=null and query.examId!=''">
  35. AND ue.exam_id = #{query.examId}
  36. </if>
  37. <if test="query.title!=null and query.title!=''">
  38. AND ee.title LIKE '%${query.title}%'
  39. </if>
  40. <if test="query.realName!=null and query.realName!=''">
  41. AND uc.real_name LIKE '%${query.realName}%'
  42. </if>
  43. </if>
  44. </select>
  45. </mapper>