CmRelatedImageMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.caimei.modules.user.dao.CmRelatedImageMapper">
  6. <resultMap type="com.caimei.modules.user.entity.CmRelatedImage" id="CmRelatedImageResult">
  7. <result property="id" column="id" />
  8. <result property="type" column="type" />
  9. <result property="authorId" column="authorId" />
  10. <result property="image" column="image" />
  11. <result property="delFlag" column="delFlag" />
  12. <result property="updateTime" column="updateTime" />
  13. <result property="createTime" column="createTime" />
  14. </resultMap>
  15. <sql id="selectCmRelatedImageVo">
  16. select
  17. cm_related_image.id,
  18. cm_related_image.type,
  19. cm_related_image.authorId,
  20. cm_related_image.image,
  21. cm_related_image.delFlag,
  22. cm_related_image.updateTime,
  23. cm_related_image.createTime
  24. </sql>
  25. <select id="getByCmRelatedImage" parameterType="com.caimei.modules.user.entity.CmRelatedImage" resultMap="CmRelatedImageResult">
  26. <include refid="selectCmRelatedImageVo"/>
  27. from cm_related_image AS cm_related_image
  28. <where> cm_related_image.delFlag = 0
  29. <if test="id != null and id != ''">
  30. and cm_related_image.id
  31. <if test="id.toUpperCase().indexOf('=')==-1">
  32. = #{id}
  33. </if>
  34. <if test="id.toUpperCase().indexOf('=')!=-1">
  35. <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
  36. <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
  37. <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
  38. #{idIn}
  39. </foreach>
  40. </if>
  41. </if>
  42. <if test="type != null and type != ''">
  43. and cm_related_image.type
  44. <if test="type.toUpperCase().indexOf('=')==-1">
  45. = #{type}
  46. </if>
  47. <if test="type.toUpperCase().indexOf('=')!=-1">
  48. <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
  49. <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
  50. <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
  51. #{typeIn}
  52. </foreach>
  53. </if>
  54. </if>
  55. <if test="authorId != null and authorId != ''"> and cm_related_image.authorId = #{authorId}</if>
  56. <if test="image != null and image != ''"> and cm_related_image.image = #{image}</if>
  57. <if test="updateTime != null "> and cm_related_image.updateTime = #{updateTime}</if>
  58. <if test="createTime != null "> and cm_related_image.createTime = #{createTime}</if>
  59. </where>
  60. group by cm_related_image.id
  61. order by cm_related_image.createTime desc
  62. limit 0,1
  63. </select>
  64. <select id="getCmRelatedImageList" parameterType="com.caimei.modules.user.entity.CmRelatedImage" resultMap="CmRelatedImageResult">
  65. <include refid="selectCmRelatedImageVo"/>
  66. from cm_related_image AS cm_related_image
  67. <where> cm_related_image.delFlag = 0
  68. <if test="id != null and id != ''">
  69. and cm_related_image.id
  70. <if test="id.toUpperCase().indexOf('=')==-1">
  71. = #{id}
  72. </if>
  73. <if test="id.toUpperCase().indexOf('=')!=-1">
  74. <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
  75. <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
  76. <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
  77. #{idIn}
  78. </foreach>
  79. </if>
  80. </if>
  81. <if test="type != null and type != ''">
  82. and cm_related_image.type
  83. <if test="type.toUpperCase().indexOf('=')==-1">
  84. = #{type}
  85. </if>
  86. <if test="type.toUpperCase().indexOf('=')!=-1">
  87. <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
  88. <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
  89. <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
  90. #{typeIn}
  91. </foreach>
  92. </if>
  93. </if>
  94. <if test="authorId != null and authorId != ''"> and cm_related_image.authorId = #{authorId}</if>
  95. <if test="image != null and image != ''"> and cm_related_image.image = #{image}</if>
  96. <if test="updateTime != null "> and cm_related_image.updateTime = #{updateTime}</if>
  97. <if test="createTime != null "> and cm_related_image.createTime = #{createTime}</if>
  98. </where>
  99. group by cm_related_image.id
  100. order by cm_related_image.createTime desc
  101. </select>
  102. <select id="getCmRelatedImageCount" parameterType="com.caimei.modules.user.entity.CmRelatedImage" resultType="String">
  103. select count(1)
  104. from cm_related_image AS cm_related_image
  105. <where> cm_related_image.delFlag = 0
  106. <if test="id != null and id != ''">
  107. and cm_related_image.id
  108. <if test="id.toUpperCase().indexOf('=')==-1">
  109. = #{id}
  110. </if>
  111. <if test="id.toUpperCase().indexOf('=')!=-1">
  112. <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
  113. <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
  114. <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
  115. #{idIn}
  116. </foreach>
  117. </if>
  118. </if>
  119. <if test="type != null and type != ''">
  120. and cm_related_image.type
  121. <if test="type.toUpperCase().indexOf('=')==-1">
  122. = #{type}
  123. </if>
  124. <if test="type.toUpperCase().indexOf('=')!=-1">
  125. <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
  126. <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
  127. <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
  128. #{typeIn}
  129. </foreach>
  130. </if>
  131. </if>
  132. <if test="authorId != null and authorId != ''"> and cm_related_image.authorId = #{authorId}</if>
  133. <if test="image != null and image != ''"> and cm_related_image.image = #{image}</if>
  134. <if test="updateTime != null "> and cm_related_image.updateTime = #{updateTime}</if>
  135. <if test="createTime != null "> and cm_related_image.createTime = #{createTime}</if>
  136. </where>
  137. group by cm_related_image.id
  138. </select>
  139. <select id="getCmRelatedImageById" parameterType="String" resultMap="CmRelatedImageResult">
  140. <include refid="selectCmRelatedImageVo"/>
  141. from cm_related_image AS cm_related_image
  142. where cm_related_image.delFlag = 0 and cm_related_image.id = #{id}
  143. </select>
  144. <select id="getByIds" parameterType="com.caimei.modules.user.entity.CmRelatedImage" resultType="String">
  145. select id
  146. from cm_related_image AS cm_related_image
  147. <where> cm_related_image.delFlag = 0
  148. <if test="id != null and id != ''">
  149. and cm_related_image.id
  150. <if test="id.toUpperCase().indexOf('=')==-1">
  151. = #{id}
  152. </if>
  153. <if test="id.toUpperCase().indexOf('=')!=-1">
  154. <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
  155. <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
  156. <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
  157. #{idIn}
  158. </foreach>
  159. </if>
  160. </if>
  161. <if test="type != null and type != ''">
  162. and cm_related_image.type
  163. <if test="type.toUpperCase().indexOf('=')==-1">
  164. = #{type}
  165. </if>
  166. <if test="type.toUpperCase().indexOf('=')!=-1">
  167. <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
  168. <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
  169. <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
  170. #{typeIn}
  171. </foreach>
  172. </if>
  173. </if>
  174. <if test="authorId != null and authorId != ''"> and cm_related_image.authorId = #{authorId}</if>
  175. <if test="image != null and image != ''"> and cm_related_image.image = #{image}</if>
  176. <if test="updateTime != null "> and cm_related_image.updateTime = #{updateTime}</if>
  177. <if test="createTime != null "> and cm_related_image.createTime = #{createTime}</if>
  178. </where>
  179. group by cm_related_image.id
  180. </select>
  181. <select id="getById" parameterType="com.caimei.modules.user.entity.CmRelatedImage" resultType="String">
  182. select id
  183. from cm_related_image AS cm_related_image
  184. <where> cm_related_image.delFlag = 0
  185. <if test="id != null and id != ''">
  186. and cm_related_image.id
  187. <if test="id.toString().toUpperCase().indexOf('=')==-1">
  188. = #{id}
  189. </if>
  190. <if test="id.toString().toUpperCase().indexOf('=')!=-1">
  191. <if test="id.toString().toUpperCase().indexOf('NOT')!=-1"> not </if>
  192. <if test="id.toString().toUpperCase().indexOf('IN')!=-1"> in </if>
  193. <foreach item="idIn" collection="id.toString().substring(id.toString().toUpperCase().indexOf('=')+1,id.toString().length()).trim().split(',')" open="(" separator="," close=")">
  194. #{idIn}
  195. </foreach>
  196. </if>
  197. </if>
  198. <if test="type != null and type != ''">
  199. and cm_related_image.type
  200. <if test="type.toUpperCase().indexOf('=')==-1">
  201. = #{type}
  202. </if>
  203. <if test="type.toUpperCase().indexOf('=')!=-1">
  204. <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
  205. <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
  206. <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
  207. #{typeIn}
  208. </foreach>
  209. </if>
  210. </if>
  211. <if test="authorId != null and authorId != ''"> and cm_related_image.authorId = #{authorId}</if>
  212. <if test="image != null and image != ''"> and cm_related_image.image = #{image}</if>
  213. <if test="updateTime != null "> and cm_related_image.updateTime = #{updateTime}</if>
  214. <if test="createTime != null "> and cm_related_image.createTime = #{createTime}</if>
  215. </where>
  216. group by cm_related_image.id
  217. limit 0,1
  218. </select>
  219. <insert id="addCmRelatedImage" parameterType="com.caimei.modules.user.entity.CmRelatedImage" useGeneratedKeys="true" keyProperty="id">
  220. insert into cm_related_image
  221. <trim prefix="(" suffix=")" suffixOverrides=",">
  222. <if test="id != null and id != ''">id,</if>
  223. <if test="type != null and type != ''">type,</if>
  224. <if test="authorId != null and authorId != ''">authorId,</if>
  225. <if test="image != null and image != ''">image,</if>
  226. <if test="delFlag != null">delFlag,</if>
  227. <if test="updateTime != null">updateTime,</if>
  228. <if test="createTime != null">createTime,</if>
  229. </trim>
  230. <trim prefix="values (" suffix=")" suffixOverrides=",">
  231. <if test="id != null and id != ''">#{id},</if>
  232. <if test="type != null and type != ''">#{type},</if>
  233. <if test="authorId != null and authorId != ''">#{authorId},</if>
  234. <if test="image != null and image != ''">#{image},</if>
  235. <if test="delFlag != null">#{delFlag},</if>
  236. <if test="updateTime != null">#{updateTime},</if>
  237. <if test="createTime != null">#{createTime},</if>
  238. </trim>
  239. </insert>
  240. <update id="updateCmRelatedImage" parameterType="com.caimei.modules.user.entity.CmRelatedImage">
  241. update cm_related_image
  242. <trim prefix="SET" suffixOverrides=",">
  243. <if test="type != null and type != ''">type = #{type},</if>
  244. <if test="authorId != null and authorId != ''">authorId = #{authorId},</if>
  245. <if test="image != null and image != ''">image = #{image},</if>
  246. <if test="delFlag != null">delFlag = #{delFlag},</if>
  247. <if test="updateTime != null">updateTime = #{updateTime},</if>
  248. <if test="createTime != null">createTime = #{createTime},</if>
  249. </trim>
  250. where id = #{id}
  251. </update>
  252. <update id="updateDelCmRelatedImageByIds" parameterType="String">
  253. update cm_related_image set delFlag=#{delFlag} where id in
  254. <foreach item="id" collection="ids" open="(" separator="," close=")">
  255. #{id}
  256. </foreach>
  257. </update>
  258. <delete id="delCmRelatedImageById" parameterType="String">
  259. delete
  260. from cm_related_image where id = #{id}
  261. </delete>
  262. <delete id="delCmRelatedImage" parameterType="com.caimei.modules.user.entity.CmRelatedImage">
  263. delete
  264. from cm_related_image AS cm_related_image
  265. <where>
  266. <if test="id != null and id != ''">
  267. and cm_related_image.id
  268. <if test="id.toUpperCase().indexOf('=')==-1">
  269. = #{id}
  270. </if>
  271. <if test="id.toUpperCase().indexOf('=')!=-1">
  272. <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
  273. <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
  274. <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
  275. #{idIn}
  276. </foreach>
  277. </if>
  278. </if>
  279. <if test="type != null and type != ''">
  280. and cm_related_image.type
  281. <if test="type.toUpperCase().indexOf('=')==-1">
  282. = #{type}
  283. </if>
  284. <if test="type.toUpperCase().indexOf('=')!=-1">
  285. <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
  286. <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
  287. <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
  288. #{typeIn}
  289. </foreach>
  290. </if>
  291. </if>
  292. <if test="authorId != null and authorId != ''"> and cm_related_image.authorId = #{authorId}</if>
  293. <if test="image != null and image != ''"> and cm_related_image.image = #{image}</if>
  294. <if test="delFlag != null "> and cm_related_image.delFlag = #{delFlag}</if>
  295. <if test="updateTime != null "> and cm_related_image.updateTime = #{updateTime}</if>
  296. <if test="createTime != null "> and cm_related_image.createTime = #{createTime}</if>
  297. </where>
  298. </delete>
  299. <delete id="delCmRelatedImageByIds" parameterType="String">
  300. delete from cm_related_image where id in
  301. <foreach item="id" collection="ids" open="(" separator="," close=")">
  302. #{id}
  303. </foreach>
  304. </delete>
  305. </mapper>