LearnPaperMapper.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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="com.ruoyi.learn.mapper.LearnPaperMapper">
  6. <resultMap type="LearnPaper" id="LearnPaperResult">
  7. <result property="id" column="id" />
  8. <result property="subjectId" column="subjectId" />
  9. <result property="paperName" column="paperName" />
  10. <result property="year" column="year" />
  11. <result property="paperType" column="paperType" />
  12. <result property="status" column="status" />
  13. <result property="number" column="number" />
  14. <result property="fenshu" column="fenshu" />
  15. <result property="paperSource" column="paperSource" />
  16. <result property="directKey" column="direct_key" />
  17. <result property="tiid" column="tiid" />
  18. <result property="osspath" column="osspath" />
  19. <result property="filename" column="filename" />
  20. <result property="relateId" column="relate_id" />
  21. <result property="locations" column="locations" />
  22. <result property="examineeTypes" column="examineeTypes" />
  23. <result property="createTime" column="createTime" />
  24. </resultMap>
  25. <sql id="selectLearnPaperVo">
  26. select id, subjectId, paperName, year, paperType, number, fenshu, paperSource, direct_key, tiid, osspath, filename, relate_id, locations, examineeTypes, createTime from learn_paper
  27. </sql>
  28. <select id="selectLearnPaperList" parameterType="LearnPaper" resultMap="LearnPaperResult">
  29. <include refid="selectLearnPaperVo"/>
  30. <where>
  31. <if test="subjectId != null "> and subjectId = #{subjectId}</if>
  32. <if test="paperName != null and paperName != ''"> and paperName like concat('%', #{paperName}, '%')</if>
  33. <if test="year != null "> and year = #{year}</if>
  34. <if test="paperType != null and paperType != ''"> and paperType = #{paperType}</if>
  35. <if test="status != null"> and status = #{status}</if>
  36. <if test="number != null and number != ''"> and number = #{number}</if>
  37. <if test="fenshu != null "> and fenshu = #{fenshu}</if>
  38. <if test="paperSource != null "> and paperSource = #{paperSource}</if>
  39. <if test="directKey != null and directKey != ''"> and direct_key = #{directKey}</if>
  40. <if test="tiid != null and tiid != ''"> and tiid = #{tiid}</if>
  41. <if test="osspath != null and osspath != ''"> and osspath = #{osspath}</if>
  42. <if test="filename != null and filename != ''"> and filename like concat('%', #{filename}, '%')</if>
  43. <if test="relateId != null "> and relate_id = #{relateId}</if>
  44. <if test="locations != null and locations != ''"> and locations = #{locations}</if>
  45. <if test="examineeTypes != null and examineeTypes != ''"> and examineeTypes = #{examineeTypes}</if>
  46. <if test="createTime != null "> and createTime = #{createTime}</if>
  47. </where>
  48. </select>
  49. <select id="selectLearnPaperForStudent" resultMap="LearnPaperResult">
  50. SELECT p.*
  51. FROM `learn_test_student` ts JOIN `learn_paper` p on ts.paper_id = p.id
  52. <where> ts.student_id = #{studentId}
  53. <if test="status != null "> and ts.status = #{status}</if>
  54. </where>
  55. </select>
  56. <select id="selectLearnPaperById" parameterType="Long" resultMap="LearnPaperResult">
  57. <include refid="selectLearnPaperVo"/>
  58. where id = #{id}
  59. </select>
  60. <insert id="insertLearnPaper" parameterType="LearnPaper" useGeneratedKeys="true" keyProperty="id">
  61. insert into learn_paper
  62. <trim prefix="(" suffix=")" suffixOverrides=",">
  63. <if test="subjectId != null">subjectId,</if>
  64. <if test="paperName != null">paperName,</if>
  65. <if test="year != null">year,</if>
  66. <if test="paperType != null">paperType,</if>
  67. <if test="status != null">status,</if>
  68. <if test="number != null">number,</if>
  69. <if test="fenshu != null">fenshu,</if>
  70. <if test="paperSource != null">paperSource,</if>
  71. <if test="directKey != null and directKey != ''">direct_key,</if>
  72. <if test="tiid != null">tiid,</if>
  73. <if test="osspath != null">osspath,</if>
  74. <if test="filename != null">filename,</if>
  75. <if test="relateId != null">relate_id,</if>
  76. <if test="locations != null">locations,</if>
  77. <if test="examineeTypes != null">examineeTypes,</if>
  78. <if test="createTime != null">createTime,</if>
  79. </trim>
  80. <trim prefix="values (" suffix=")" suffixOverrides=",">
  81. <if test="subjectId != null">#{subjectId},</if>
  82. <if test="paperName != null">#{paperName},</if>
  83. <if test="year != null">#{year},</if>
  84. <if test="paperType != null">#{paperType},</if>
  85. <if test="status != null">#{status},</if>
  86. <if test="number != null">#{number},</if>
  87. <if test="fenshu != null">#{fenshu},</if>
  88. <if test="paperSource != null">#{paperSource},</if>
  89. <if test="directKey != null and directKey != ''">#{directKey},</if>
  90. <if test="tiid != null">#{tiid},</if>
  91. <if test="osspath != null">#{osspath},</if>
  92. <if test="filename != null">#{filename},</if>
  93. <if test="relateId != null">#{relateId},</if>
  94. <if test="locations != null">#{locations},</if>
  95. <if test="examineeTypes != null">#{examineeTypes},</if>
  96. <if test="createTime != null">#{createTime},</if>
  97. </trim>
  98. </insert>
  99. <update id="updateLearnPaper" parameterType="LearnPaper">
  100. update learn_paper
  101. <trim prefix="SET" suffixOverrides=",">
  102. <if test="subjectId != null">subjectId = #{subjectId},</if>
  103. <if test="paperName != null">paperName = #{paperName},</if>
  104. <if test="year != null">year = #{year},</if>
  105. <if test="paperType != null">paperType = #{paperType},</if>
  106. <if test="status != null">status = #{status},</if>
  107. <if test="number != null">number = #{number},</if>
  108. <if test="fenshu != null">fenshu = #{fenshu},</if>
  109. <if test="paperSource != null">paperSource = #{paperSource},</if>
  110. <if test="directKey != null and directKey != ''">direct_key = #{directKey},</if>
  111. <if test="tiid != null">tiid = #{tiid},</if>
  112. <if test="osspath != null">osspath = #{osspath},</if>
  113. <if test="filename != null">filename = #{filename},</if>
  114. <if test="relateId != null">relate_id = #{relateId},</if>
  115. <if test="locations != null">locations = #{locations},</if>
  116. <if test="examineeTypes != null">examineeTypes = #{examineeTypes},</if>
  117. <if test="createTime != null">createTime = #{createTime},</if>
  118. </trim>
  119. where id = #{id}
  120. </update>
  121. <delete id="deleteLearnPaperById" parameterType="Long">
  122. delete from learn_paper where id = #{id}
  123. </delete>
  124. <delete id="deleteLearnPaperByIds" parameterType="String">
  125. delete from learn_paper where id in
  126. <foreach item="id" collection="array" open="(" separator="," close=")">
  127. #{id}
  128. </foreach>
  129. </delete>
  130. <select id="selectPapersListFromFavorites" parameterType="LearnPaper" resultMap="LearnPaperResult">
  131. select p.*,0 readNum from b_customer_favorites f
  132. left join learn_paper p on f.refId = p.id
  133. where f.type = 'paper' and f.customercode = #{examineeId} and f.course = #{subjectId} <if test="collect "> and f.status = 1</if>
  134. </select>
  135. </mapper>