QuestionMapper.xml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.takai.bigmodel.mapper.QuestionMapper">
  6. <resultMap type="Question" id="QuestionResult">
  7. <id property="id" column="id" />
  8. <result property="app_id" column="app_id" />
  9. <result property="question" column="question" />
  10. <result property="create_time" column="create_time" />
  11. </resultMap>
  12. <select id="getQuestionList" resultMap="QuestionResult">
  13. select
  14. q.id,
  15. q.app_id as appId,
  16. q.question,
  17. q.create_time
  18. from question q
  19. where q.app_id = #{appId}
  20. ORDER BY q.create_time desc
  21. </select>
  22. <insert id="insertQuestion" parameterType="Question">
  23. insert into question(
  24. id,
  25. <if test="appId != null">app_id,</if>
  26. <if test="question != null">question,</if>
  27. create_time
  28. )values(
  29. #{id},
  30. <if test="appId != null">#{appId},</if>
  31. <if test="question != null">#{question},</if>
  32. sysdate()
  33. )
  34. </insert>
  35. <select id="selectQuestionById" resultMap="QuestionResult">
  36. select
  37. q.id,
  38. q.app_id as appId,
  39. q.question,
  40. q.create_time
  41. from question q
  42. where q.id = #{id}
  43. </select>
  44. <delete id="delQuestion" parameterType="String">
  45. delete from question where id = #{id}
  46. </delete>
  47. <update id="updateQuestion" parameterType="Question">
  48. update question set question = #{question} where id = #{id}
  49. </update>
  50. <delete id="delQuestionByAppId" parameterType="String">
  51. delete from question where app_id = #{appId}
  52. </delete>
  53. </mapper>