EsmTrainCountMapper.xml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.ydtech.modules.esm.dao.EsmTrainCountMapper">
  4. <resultMap id="BaseResultMap" type="com.ydtech.modules.esm.model.EsmTrainCount">
  5. <id column="user_id" jdbcType="VARCHAR" property="userId"/>
  6. <id column="trainid" jdbcType="VARCHAR" property="trainid"/>
  7. <result column="speak_time" jdbcType="TIMESTAMP" property="speakTime"/>
  8. </resultMap>
  9. <sql id="Example_Where_Clause">
  10. <where>
  11. <foreach collection="oredCriteria" item="criteria" separator="or">
  12. <if test="criteria.valid">
  13. <trim prefix="(" prefixOverrides="and" suffix=")">
  14. <foreach collection="criteria.criteria" item="criterion">
  15. <choose>
  16. <when test="criterion.noValue">
  17. and ${criterion.condition}
  18. </when>
  19. <when test="criterion.singleValue">
  20. and ${criterion.condition} #{criterion.value}
  21. </when>
  22. <when test="criterion.betweenValue">
  23. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  24. </when>
  25. <when test="criterion.listValue">
  26. and ${criterion.condition}
  27. <foreach close=")" collection="criterion.value" item="listItem" open="("
  28. separator=",">
  29. #{listItem}
  30. </foreach>
  31. </when>
  32. </choose>
  33. </foreach>
  34. </trim>
  35. </if>
  36. </foreach>
  37. </where>
  38. </sql>
  39. <sql id="Update_By_Example_Where_Clause">
  40. <where>
  41. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  42. <if test="criteria.valid">
  43. <trim prefix="(" prefixOverrides="and" suffix=")">
  44. <foreach collection="criteria.criteria" item="criterion">
  45. <choose>
  46. <when test="criterion.noValue">
  47. and ${criterion.condition}
  48. </when>
  49. <when test="criterion.singleValue">
  50. and ${criterion.condition} #{criterion.value}
  51. </when>
  52. <when test="criterion.betweenValue">
  53. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  54. </when>
  55. <when test="criterion.listValue">
  56. and ${criterion.condition}
  57. <foreach close=")" collection="criterion.value" item="listItem" open="("
  58. separator=",">
  59. #{listItem}
  60. </foreach>
  61. </when>
  62. </choose>
  63. </foreach>
  64. </trim>
  65. </if>
  66. </foreach>
  67. </where>
  68. </sql>
  69. <sql id="Base_Column_List">
  70. user_id, trainid, speak_time
  71. </sql>
  72. <select id="selectByExample" parameterType="com.ydtech.modules.esm.model.EsmTrainCountExample"
  73. resultMap="BaseResultMap">
  74. select
  75. <if test="distinct">
  76. distinct
  77. </if>
  78. 'true' as QUERYID,
  79. <include refid="Base_Column_List"/>
  80. from esm_train_count
  81. <if test="_parameter != null">
  82. <include refid="Example_Where_Clause"/>
  83. </if>
  84. <if test="orderByClause != null">
  85. order by ${orderByClause}
  86. </if>
  87. </select>
  88. <select id="selectByPrimaryKey" parameterType="com.ydtech.modules.esm.model.EsmTrainCountKey"
  89. resultMap="BaseResultMap">
  90. select
  91. <include refid="Base_Column_List"/>
  92. from esm_train_count
  93. where user_id = #{userId,jdbcType=VARCHAR}
  94. and trainid = #{trainid,jdbcType=VARCHAR}
  95. </select>
  96. <delete id="deleteByPrimaryKey" parameterType="com.ydtech.modules.esm.model.EsmTrainCountKey">
  97. delete
  98. from esm_train_count
  99. where user_id = #{userId,jdbcType=VARCHAR}
  100. and trainid = #{trainid,jdbcType=VARCHAR}
  101. </delete>
  102. <delete id="deleteByExample" parameterType="com.ydtech.modules.esm.model.EsmTrainCountExample">
  103. delete from esm_train_count
  104. <if test="_parameter != null">
  105. <include refid="Example_Where_Clause"/>
  106. </if>
  107. </delete>
  108. <insert id="insert" parameterType="com.ydtech.modules.esm.model.EsmTrainCount">
  109. insert into esm_train_count (user_id, trainid,
  110. speak_time)
  111. values (#{userId,jdbcType=VARCHAR}, #{trainid,jdbcType=VARCHAR},
  112. #{speakTime,jdbcType=TIMESTAMP})
  113. </insert>
  114. <insert id="insertSelective" parameterType="com.ydtech.modules.esm.model.EsmTrainCount">
  115. insert into esm_train_count
  116. <trim prefix="(" suffix=")" suffixOverrides=",">
  117. <if test="userId != null">
  118. user_id,
  119. </if>
  120. <if test="trainid != null">
  121. trainid,
  122. </if>
  123. <if test="speakTime != null">
  124. speak_time,
  125. </if>
  126. </trim>
  127. <trim prefix="values (" suffix=")" suffixOverrides=",">
  128. <if test="userId != null">
  129. #{userId,jdbcType=VARCHAR},
  130. </if>
  131. <if test="trainid != null">
  132. #{trainid,jdbcType=VARCHAR},
  133. </if>
  134. <if test="speakCount != null">
  135. #{speakCount,jdbcType=VARCHAR},
  136. </if>
  137. <if test="speakTime != null">
  138. #{speakTime,jdbcType=TIMESTAMP},
  139. </if>
  140. </trim>
  141. </insert>
  142. <select id="countByExample" parameterType="com.ydtech.modules.esm.model.EsmTrainCountExample"
  143. resultType="java.lang.Long">
  144. select count(*) from esm_train_count
  145. <if test="_parameter != null">
  146. <include refid="Example_Where_Clause"/>
  147. </if>
  148. </select>
  149. <select id="querySpeakCount" resultType="com.ydtech.modules.esm.model.vo.res.EsmTrainCountVO">
  150. SELECT
  151. a.user_id userId,
  152. c.name userName,
  153. a.trainid trainid,
  154. a.speak_time speakTime,
  155. b.title title
  156. FROM esm_train_count a left join esm_train b on a.trainid=b.trainid
  157. left join sys_user c on a.user_id=c.id
  158. WHERE 1=1
  159. <if test="userId != null and userId !=''">
  160. AND a.user_id=#{userId}
  161. </if>
  162. <if test="userName != null and userName !=''">
  163. AND c.name like concat('%',#{userName},'%')
  164. </if>
  165. <if test="title != null and title !=''">
  166. AND b.title like concat('%',#{title},'%')
  167. </if>
  168. order by a.user_id, a.speak_time desc
  169. </select>
  170. <update id="updateByExampleSelective" parameterType="map">
  171. update esm_train_count
  172. <set>
  173. <if test="record.userId != null">
  174. user_id = #{record.userId,jdbcType=VARCHAR},
  175. </if>
  176. <if test="record.trainid != null">
  177. trainid = #{record.trainid,jdbcType=VARCHAR},
  178. </if>
  179. <if test="record.speakTime != null">
  180. speak_time = #{record.speakTime,jdbcType=TIMESTAMP},
  181. </if>
  182. </set>
  183. <if test="_parameter != null">
  184. <include refid="Update_By_Example_Where_Clause"/>
  185. </if>
  186. </update>
  187. <update id="updateByExample" parameterType="map">
  188. update esm_train_count
  189. set user_id = #{record.userId,jdbcType=VARCHAR},
  190. trainid = #{record.trainid,jdbcType=VARCHAR},
  191. speak_time = #{record.speakTime,jdbcType=TIMESTAMP}
  192. <if test="_parameter != null">
  193. <include refid="Update_By_Example_Where_Clause"/>
  194. </if>
  195. </update>
  196. <update id="updateByPrimaryKeySelective" parameterType="com.ydtech.modules.esm.model.EsmTrainCount">
  197. update esm_train_count
  198. <set>
  199. <if test="speakTime != null">
  200. speak_time = #{speakTime,jdbcType=TIMESTAMP},
  201. </if>
  202. </set>
  203. where user_id = #{userId,jdbcType=VARCHAR}
  204. and trainid = #{trainid,jdbcType=VARCHAR}
  205. </update>
  206. <update id="updateByPrimaryKey" parameterType="com.ydtech.modules.esm.model.EsmTrainCount">
  207. update esm_train_count
  208. set speak_time = #{speakTime,jdbcType=TIMESTAMP}
  209. where user_id = #{userId,jdbcType=VARCHAR}
  210. and trainid = #{trainid,jdbcType=VARCHAR}
  211. </update>
  212. </mapper>