EduTrainCommentMapper.xml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. <mapper namespace="com.jeeplus.modules.train.mapper.EduTrainCommentMapper">
  4. <sql id="eduTrainCommentColumns">
  5. a.id AS "id",
  6. a.train_id AS "train.id",
  7. a.content AS "content",
  8. a.score AS "score",
  9. a.create_by AS "createBy.id",
  10. a.create_date AS "createDate",
  11. a.update_by AS "updateBy.id",
  12. a.update_date AS "updateDate",
  13. a.del_flag AS "delFlag",
  14. train.title AS "train.title",
  15. user.name AS "createBy.name"
  16. </sql>
  17. <sql id="eduTrainCommentJoins">
  18. LEFT JOIN edu_train_plan train ON train.id = a.train_id
  19. LEFT JOIN sys_user user ON user.id = a.create_by
  20. </sql>
  21. <select id="get" resultType="EduTrainComment" >
  22. SELECT
  23. <include refid="eduTrainCommentColumns"/>
  24. FROM edu_train_comment a
  25. <include refid="eduTrainCommentJoins"/>
  26. WHERE a.id = #{id}
  27. </select>
  28. <select id="findList" resultType="EduTrainComment" >
  29. SELECT
  30. <include refid="eduTrainCommentColumns"/>
  31. FROM edu_train_comment a
  32. <include refid="eduTrainCommentJoins"/>
  33. <where>
  34. a.del_flag = #{DEL_FLAG_NORMAL}
  35. ${dataScope}
  36. <if test="train != null and train.id != null and train.id != ''">
  37. AND a.train_id = #{train.id}
  38. </if>
  39. <if test="createBy != null and createBy.id != null and createBy.id != ''">
  40. AND a.create_by = #{createBy.id}
  41. </if>
  42. </where>
  43. <choose>
  44. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  45. ORDER BY ${page.orderBy}
  46. </when>
  47. <otherwise>
  48. ORDER BY a.update_date DESC
  49. </otherwise>
  50. </choose>
  51. </select>
  52. <select id="findAllList" resultType="EduTrainComment" >
  53. SELECT
  54. <include refid="eduTrainCommentColumns"/>
  55. FROM edu_train_comment a
  56. <include refid="eduTrainCommentJoins"/>
  57. <where>
  58. a.del_flag = #{DEL_FLAG_NORMAL}
  59. ${dataScope}
  60. </where>
  61. <choose>
  62. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  63. ORDER BY ${page.orderBy}
  64. </when>
  65. <otherwise>
  66. ORDER BY a.update_date DESC
  67. </otherwise>
  68. </choose>
  69. </select>
  70. <insert id="insert">
  71. INSERT INTO edu_train_comment(
  72. id,
  73. train_id,
  74. content,
  75. score,
  76. create_by,
  77. create_date,
  78. update_by,
  79. update_date,
  80. del_flag
  81. ) VALUES (
  82. #{id},
  83. #{train.id},
  84. #{content},
  85. #{score},
  86. #{createBy.id},
  87. #{createDate},
  88. #{updateBy.id},
  89. #{updateDate},
  90. #{delFlag}
  91. )
  92. </insert>
  93. <update id="update">
  94. UPDATE edu_train_comment SET
  95. train_id = #{train.id},
  96. content = #{content},
  97. score = #{score},
  98. update_by = #{updateBy.id},
  99. update_date = #{updateDate}
  100. WHERE id = #{id}
  101. </update>
  102. <!--物理删除-->
  103. <update id="delete">
  104. DELETE FROM edu_train_comment
  105. WHERE id = #{id}
  106. </update>
  107. <!--逻辑删除-->
  108. <update id="deleteByLogic">
  109. UPDATE edu_train_comment SET
  110. del_flag = #{DEL_FLAG_DELETE}
  111. WHERE id = #{id}
  112. </update>
  113. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  114. <select id="findUniqueByProperty" resultType="EduTrainComment" statementType="STATEMENT">
  115. select * FROM edu_train_comment where ${propertyName} = '${value}'
  116. </select>
  117. </mapper>