ExamMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.xyz.mapper.ExamMapper">
  4. <resultMap id="BaseResultMap" type="cn.xyz.mianshi.vo.ExamVO">
  5. <result column="id" property="examId" jdbcType="INTEGER" />
  6. <result column="company_id" property="companyId" jdbcType="INTEGER" />
  7. <result column="type" property="examType" jdbcType="INTEGER" />
  8. <result column="name" property="examName" jdbcType="VARCHAR" />
  9. <result column="time" property="time" jdbcType="INTEGER" />
  10. <result column="is_precise_time" property="isPreciseTime"
  11. jdbcType="INTEGER" />
  12. <result column="status" property="status" jdbcType="INTEGER" />
  13. </resultMap>
  14. <insert id="savePaidExam" parameterType="java.util.Map">
  15. <![CDATA[
  16. INSERT INTO tb_company_exam (company_id, exam_id, create_time, status) VALUES (${companyId}, ${examId}, UNIX_TIMESTAMP(), 1)
  17. ]]>
  18. </insert>
  19. <select id="selectPaidExamId" parameterType="java.util.Map"
  20. resultType="java.lang.Integer">
  21. <![CDATA[
  22. SELECT exam_id FROM tb_company_exam WHERE company_id = ${companyId}
  23. ]]>
  24. </select>
  25. <select id="selectExamType" resultType="cn.xyz.mianshi.vo.ExamType">
  26. <![CDATA[
  27. SELECT * FROM tb_exam_type
  28. ]]>
  29. </select>
  30. <select id="get" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  31. <![CDATA[
  32. SELECT * FROM tb_exam WHERE id = ${value}
  33. ]]>
  34. </select>
  35. <select id="countByExample" parameterType="java.util.Map"
  36. resultType="java.lang.Integer">
  37. SELECT COUNT(*) FROM tb_exam WHERE 1 = 1
  38. <if test="companyId != null">AND company_id = ${companyId}</if>
  39. <if test="type != 0">AND type = ${type}</if>
  40. <if test="status != 0">AND status = ${status}</if>
  41. <if test="idList != null">
  42. <foreach item="item" index="index" collection="idList" open="("
  43. separator="," close=")">
  44. #{item}
  45. </foreach>
  46. </if>
  47. </select>
  48. <select id="selectByExample" parameterType="java.util.Map"
  49. resultMap="BaseResultMap">
  50. SELECT * FROM tb_exam WHERE 1 = 1
  51. <if test="companyId != null">AND company_id = ${companyId}</if>
  52. <if test="type != null and type != 0">AND type = ${type}</if>
  53. <if test="status != null and status != 0">AND status = ${status}</if>
  54. <if test="idList != null">
  55. AND id IN
  56. <foreach item="item" index="index" collection="idList" open="("
  57. separator="," close=")">
  58. #{item}
  59. </foreach>
  60. </if>
  61. <if test="limit != null">limit ${limit}</if>
  62. </select>
  63. <insert id="insert" parameterType="cn.xyz.mianshi.vo.ExamVO">
  64. <selectKey keyProperty="examId" resultType="java.lang.Integer"
  65. order="AFTER">
  66. <![CDATA[
  67. SELECT LAST_INSERT_ID() as examId
  68. ]]>
  69. </selectKey>
  70. <![CDATA[
  71. INSERT INTO tb_exam (
  72. company_id,
  73. type,
  74. name,
  75. time,
  76. is_precise_time,
  77. status
  78. )
  79. VALUES
  80. (
  81. #{companyId,jdbcType=INTEGER},
  82. #{examType,jdbcType=INTEGER},
  83. #{examName,jdbcType=VARCHAR},
  84. #{time,jdbcType=INTEGER},
  85. #{isPreciseTime,jdbcType=INTEGER},
  86. 1
  87. )
  88. ]]>
  89. </insert>
  90. <update id="delete" parameterType="java.lang.Integer">
  91. DELETE FROM tb_exam WHERE id =
  92. ${value}
  93. </update>
  94. <update id="update" parameterType="cn.xyz.mianshi.vo.ExamVO">
  95. UPDATE tb_exam
  96. <set>
  97. <if test="examType != null">
  98. type = #{examType,jdbcType=INTEGER},
  99. </if>
  100. <if test="examName != null">
  101. name = #{examName,jdbcType=VARCHAR},
  102. </if>
  103. <if test="time != null">
  104. time = #{time,jdbcType=INTEGER},
  105. </if>
  106. <if test="isPreciseTime != null">
  107. is_precise_time = #{isPreciseTime,jdbcType=INTEGER},
  108. </if>
  109. <if test="status != null">
  110. status = #{status,jdbcType=INTEGER},
  111. </if>
  112. </set>
  113. WHERE id = #{examId,jdbcType=INTEGER}
  114. </update>
  115. <resultMap id="ExamGradingResultMap" type="cn.xyz.mianshi.vo.ExamGrading">
  116. <result column="id" property="id" jdbcType="INTEGER" />
  117. <result column="exam_id" property="examid" jdbcType="INTEGER" />
  118. <result column="min_score" property="minScore" jdbcType="INTEGER" />
  119. <result column="max_score" property="maxScore" jdbcType="INTEGER" />
  120. <result column="title" property="title" jdbcType="VARCHAR" />
  121. <result column="desc" property="desc" jdbcType="VARCHAR" />
  122. </resultMap>
  123. <insert id="saveExamGrading" parameterType="cn.xyz.mianshi.vo.ExamGrading">
  124. <selectKey keyProperty="id" resultType="java.lang.Integer"
  125. order="AFTER">
  126. <![CDATA[
  127. SELECT LAST_INSERT_ID() as id
  128. ]]>
  129. </selectKey>
  130. <![CDATA[
  131. INSERT INTO tb_exam_grading (
  132. exam_id,
  133. min_score,
  134. max_score,
  135. title,
  136. desc
  137. )
  138. VALUES
  139. (
  140. #{examId,jdbcType=INTEGER},
  141. #{minScore,jdbcType=INTEGER},
  142. #{maxScore,jdbcType=INTEGER},
  143. #{title,jdbcType=VARCHAR},
  144. #{desc,jdbcType=VARCHAR}
  145. )
  146. ]]>
  147. </insert>
  148. <select id="selectExamGrading" parameterType="java.lang.Integer"
  149. resultMap="ExamGradingResultMap">
  150. <![CDATA[
  151. SELECT * FROM tb_exam_grading WHERE exam_id = ${value}
  152. ]]>
  153. </select>
  154. <select id="getExamGradingByScore" parameterType="java.lang.Integer"
  155. resultMap="ExamGradingResultMap">
  156. <![CDATA[
  157. SELECT * FROM tb_exam_grading WHERE min_score <= ${value} AND ${value} <= max_score
  158. ]]>
  159. </select>
  160. </mapper>