LearnPaperMapper.xml 8.2 KB

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