StudentCourseHomeworkReplyMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.StudentCourseHomeworkReplyDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentCourseHomeworkReply" id="StudentCourseHomeworkReply">
  9. <result column="id_" property="id"/>
  10. <result column="student_course_homework_id_" property="studentCourseHomeworkId"/>
  11. <result column="user_id_" property="userId"/>
  12. <result column="content_" property="content"/>
  13. <result column="create_time_" property="createTime"/>
  14. <result column="parent_id_" property="parentId"/>
  15. </resultMap>
  16. <resultMap id="studentCourseHomeworkComment" type="com.ym.mec.biz.dal.dto.StudentCourseHomeworkCommentDto">
  17. <result property="replyId" column="comment_id_"></result>
  18. <result property="userId" column="comment_user_id_"></result>
  19. <result property="userName" column="comment_user_name_"></result>
  20. <result property="avatar" column="avatar_"/>
  21. <result property="content" column="comment_content_"></result>
  22. <result property="createTime" column="comment_time"></result>
  23. </resultMap>
  24. <!-- 根据主键查询一条记录 -->
  25. <select id="get" resultMap="StudentCourseHomeworkReply">
  26. SELECT * FROM student_course_homework_reply WHERE id_ = #{id}
  27. </select>
  28. <!-- 全查询 -->
  29. <select id="findAll" resultMap="StudentCourseHomeworkReply">
  30. SELECT * FROM student_course_homework_reply ORDER BY id_
  31. </select>
  32. <!-- 向数据库增加一条记录 -->
  33. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomeworkReply" useGeneratedKeys="true"
  34. keyColumn="id" keyProperty="id">
  35. INSERT INTO student_course_homework_reply
  36. (id_,student_course_homework_id_,user_id_,content_,create_time_,parent_id_)
  37. VALUES(#{id},#{studentCourseHomeworkId},#{userId},#{content},now(),#{parentId})
  38. </insert>
  39. <!-- 根据主键查询一条记录 -->
  40. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomeworkReply">
  41. UPDATE student_course_homework_reply
  42. <set>
  43. <if test="parentId != null">
  44. parent_id_ = #{parentId},
  45. </if>
  46. <if test="studentCourseHomeworkId != null">
  47. student_course_homework_id_ = #{studentCourseHomeworkId},
  48. </if>
  49. <if test="userId != null">
  50. user_id_ = #{userId},
  51. </if>
  52. <if test="content != null">
  53. content_ = #{content},
  54. </if>
  55. </set>
  56. WHERE id_ = #{id}
  57. </update>
  58. <!-- 根据主键删除一条记录 -->
  59. <delete id="delete">
  60. DELETE FROM student_course_homework_reply WHERE id_ = #{id}
  61. </delete>
  62. <delete id="batchDeleteReplys">
  63. delete from student_course_homework_reply where id_ IN
  64. <foreach collection="list" item="id" open="(" close=")" separator=",">
  65. #{id}
  66. </foreach>
  67. </delete>
  68. <sql id="queryCondition">
  69. <where>
  70. <if test="parentID!=null">
  71. AND schr.parent_id_ = #{parentID}
  72. </if>
  73. <if test="parentID==null">
  74. AND schr.parent_id_ IS NULL
  75. </if>
  76. <if test="studentCourseHomeworkId != null">
  77. AND schr.student_course_homework_id_=#{studentCourseHomeworkId}
  78. </if>
  79. </where>
  80. </sql>
  81. <!-- 分页查询 -->
  82. <select id="queryPage" resultMap="studentCourseHomeworkComment" parameterType="map">
  83. SELECT
  84. schr.id_ comment_id_,
  85. schr.user_id_ comment_user_id_,
  86. suc.username_ comment_user_name_,
  87. suc.avatar_,
  88. schr.content_ comment_content_,
  89. schr.create_time_ comment_time
  90. FROM
  91. student_course_homework_reply schr
  92. LEFT JOIN sys_user suc ON schr.user_id_=suc.id_
  93. <include refid="queryCondition"/>
  94. <include refid="global.limit"/>
  95. </select>
  96. <!-- 查询当前表的总记录数 -->
  97. <select id="queryCount" resultType="int">
  98. SELECT COUNT(*) FROM student_course_homework_reply schr
  99. <include refid="queryCondition"/>
  100. </select>
  101. <select id="findAllReplyByStudentCourseHomeworkID" resultMap="StudentCourseHomeworkReply">
  102. select id_,IF(parent_id_ IS NULL,0,parent_id_) parent_id_ from student_course_homework_reply where student_course_homework_id_=#{studentCourseHomeworkID}
  103. </select>
  104. </mapper>