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