ExercisePaperRelationMapper.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.qxgmat.data.relation.ExercisePaperRelationMapper">
  4. <resultMap id="IdMap" type="com.qxgmat.data.dao.entity.ExercisePaper">
  5. <!--
  6. WARNING - @mbg.generated
  7. -->
  8. <id column="id" jdbcType="INTEGER" property="id" />
  9. </resultMap>
  10. <resultMap id="placeMap" type="com.qxgmat.data.dao.entity.ExercisePaper">
  11. <!--
  12. WARNING - @mbg.generated
  13. -->
  14. <id column="logic_extend" jdbcType="VARCHAR" property="logicExtend" />
  15. </resultMap>
  16. <sql id="Id_Column_List">
  17. <!--
  18. WARNING - @mbg.generated
  19. -->
  20. ep.`id`
  21. </sql>
  22. <!--获取考点分组所有考点信息-->
  23. <select id="groupPlace" resultMap="placeMap">
  24. select
  25. ep.`logic_extend`
  26. from `exercise_paper` ep
  27. where ep.`logic` = "place" and ep.`status` = 1
  28. <if test="structId != null">
  29. and (ep.`struct_three` = #{structId,jdbcType=VARCHAR} or ep.`struct_four` = #{structId,jdbcType=VARCHAR})
  30. </if>
  31. group by ep.`logic_extend`
  32. </select>
  33. <!--
  34. 用户练习-练习册列表: 用户端
  35. -->
  36. <select id="listWithUser" resultMap="IdMap">
  37. select
  38. <include refid="Id_Column_List" />
  39. from `exercise_paper` ep
  40. <if test="userId != null">
  41. left join `user_paper` up on ep.`id` = up.`origin_id`
  42. and up.`paper_origin` = 'exercise'
  43. and up.`user_id` = #{userId,jdbcType=VARCHAR}
  44. <if test="times != null">
  45. <if test="times == 0">
  46. and up.`times` = 0
  47. </if>
  48. <if test="times > 0">
  49. and up.`times` >= #{times,jdbcType=VARCHAR}
  50. </if>
  51. </if>
  52. </if>
  53. where ep.`status` = 1
  54. <if test="structId != null">
  55. and (ep.`struct_three` = #{structId,jdbcType=VARCHAR} or ep.`struct_four` = #{structId,jdbcType=VARCHAR})
  56. </if>
  57. <if test="userId != null">
  58. <if test="times == 0">
  59. and (up.`id` &gt; 0 or up.`id` is null)
  60. </if>
  61. <if test="times > 0">
  62. and up.`id` &gt; 0
  63. </if>
  64. </if>
  65. <if test="logic != null">
  66. and ep.`logic` = #{logic,jdbcType=VARCHAR}
  67. <if test="logicExtend != null">
  68. and ep.`logic_extend` = #{logicExtend,jdbcType=VARCHAR}
  69. </if>
  70. </if>
  71. </select>
  72. </mapper>