StudentCourseHomeworkReplyMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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="isTeacher" column="is_teacher_"/>
  22. <result property="content" column="comment_content_"></result>
  23. <result property="createTime" column="comment_time"></result>
  24. </resultMap>
  25. <!-- 根据主键查询一条记录 -->
  26. <select id="get" resultMap="StudentCourseHomeworkReply">
  27. SELECT * FROM student_course_homework_reply WHERE id_ = #{id}
  28. </select>
  29. <!-- 全查询 -->
  30. <select id="findAll" resultMap="StudentCourseHomeworkReply">
  31. SELECT * FROM student_course_homework_reply ORDER BY id_
  32. </select>
  33. <!-- 向数据库增加一条记录 -->
  34. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomeworkReply" useGeneratedKeys="true"
  35. keyColumn="id" keyProperty="id">
  36. INSERT INTO student_course_homework_reply
  37. (id_,student_course_homework_id_,user_id_,content_,create_time_,parent_id_)
  38. VALUES(#{id},#{studentCourseHomeworkId},#{userId},#{content},now(),#{parentId})
  39. </insert>
  40. <!-- 根据主键查询一条记录 -->
  41. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomeworkReply">
  42. UPDATE student_course_homework_reply
  43. <set>
  44. <if test="parentId != null">
  45. parent_id_ = #{parentId},
  46. </if>
  47. <if test="studentCourseHomeworkId != null">
  48. student_course_homework_id_ = #{studentCourseHomeworkId},
  49. </if>
  50. <if test="userId != null">
  51. user_id_ = #{userId},
  52. </if>
  53. <if test="content != null">
  54. content_ = #{content},
  55. </if>
  56. </set>
  57. WHERE id_ = #{id}
  58. </update>
  59. <!-- 根据主键删除一条记录 -->
  60. <delete id="delete">
  61. DELETE FROM student_course_homework_reply WHERE id_ = #{id}
  62. </delete>
  63. <delete id="batchDeleteReplys">
  64. delete from student_course_homework_reply where id_ IN
  65. <foreach collection="list" item="id" open="(" close=")" separator=",">
  66. #{id}
  67. </foreach>
  68. </delete>
  69. <sql id="queryCondition">
  70. <where>
  71. <if test="parentID!=null">
  72. AND schr.parent_id_ = #{parentID}
  73. </if>
  74. <if test="parentID==null">
  75. AND schr.parent_id_ IS NULL
  76. </if>
  77. <if test="studentCourseHomeworkId != null">
  78. AND schr.student_course_homework_id_=#{studentCourseHomeworkId}
  79. </if>
  80. </where>
  81. </sql>
  82. <!-- 分页查询 -->
  83. <select id="queryPage" resultMap="studentCourseHomeworkComment" parameterType="map">
  84. SELECT
  85. schr.id_ comment_id_,
  86. schr.user_id_ comment_user_id_,
  87. suc.username_ comment_user_name_,
  88. suc.avatar_,
  89. IF(suc.user_type_!='STUDENT',1,0) is_teacher_,
  90. schr.content_ comment_content_,
  91. schr.create_time_ comment_time
  92. FROM
  93. student_course_homework_reply schr
  94. LEFT JOIN sys_user suc ON schr.user_id_=suc.id_
  95. <include refid="queryCondition"/>
  96. <include refid="global.limit"/>
  97. </select>
  98. <!-- 查询当前表的总记录数 -->
  99. <select id="queryCount" resultType="int">
  100. SELECT COUNT(*) FROM student_course_homework_reply schr
  101. <include refid="queryCondition"/>
  102. </select>
  103. <select id="findAllReplyByStudentCourseHomeworkID" resultMap="StudentCourseHomeworkReply">
  104. select id_,IF(parent_id_ IS NULL,0,parent_id_) parent_id_ from student_course_homework_reply where student_course_homework_id_=#{studentCourseHomeworkID}
  105. </select>
  106. </mapper>