TCmsContentMapper.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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.sooka.mybatis.mapper.TCmsContentMapper">
  4. <resultMap id="BaseResultMap" type="com.sooka.mybatis.model.TCmsContent">
  5. <!--
  6. WARNING - @mbg.generated
  7. -->
  8. <id column="content_id" jdbcType="BIGINT" property="contentId" />
  9. <result column="site_id" jdbcType="INTEGER" property="siteId" />
  10. <result column="user_id" jdbcType="INTEGER" property="userId" />
  11. <result column="category_id" jdbcType="BIGINT" property="categoryId" />
  12. <result column="model_id" jdbcType="INTEGER" property="modelId" />
  13. <result column="title" jdbcType="VARCHAR" property="title" />
  14. <result column="keywords" jdbcType="CHAR" property="keywords" />
  15. <result column="top" jdbcType="BIT" property="top" />
  16. <result column="recommend" jdbcType="BIT" property="recommend" />
  17. <result column="thumb" jdbcType="VARCHAR" property="thumb" />
  18. <result column="status" jdbcType="INTEGER" property="status" />
  19. <result column="inputdate" jdbcType="TIMESTAMP" property="inputdate" />
  20. <result column="updatedate" jdbcType="TIMESTAMP" property="updatedate" />
  21. <result column="url" jdbcType="CHAR" property="url" />
  22. <result column="author" jdbcType="CHAR" property="author" />
  23. <result column="view_num" jdbcType="INTEGER" property="viewNum" />
  24. <result column="description" jdbcType="LONGVARCHAR" property="description" />
  25. <result column="sorts" jdbcType="INTEGER" property="sorts" />
  26. </resultMap>
  27. <select id="selectByContentIdAndTableName" resultType="java.util.Map">
  28. SELECT
  29. c.content_id contentId,
  30. c.site_id siteId,
  31. c.user_id userId,
  32. c.category_id categoryId,
  33. c.model_id modelId,
  34. c.title,
  35. c.keywords,
  36. c.description,
  37. c.top,
  38. c.recommend,
  39. c.thumb,
  40. c.updatedate,
  41. c.inputdate,
  42. c.status,
  43. c.url,
  44. c.author,
  45. c.sorts,
  46. c.view_num viewNum,
  47. c.qy_id,
  48. m.*
  49. FROM
  50. t_cms_content c LEFT JOIN t_cms_content_${tableName} m
  51. ON
  52. c.content_id = m.content_id
  53. WHERE
  54. c.content_id =#{contentId}
  55. </select>
  56. <select id="selectByTableNameAndMap" resultMap="BaseResultMap">
  57. SELECT
  58. *
  59. FROM
  60. t_cms_content c LEFT JOIN t_cms_content_${tableName} m
  61. ON
  62. c.content_id = m.content_id
  63. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND|OR">
  64. category_id = #{categoryId}
  65. <foreach item="value" index="key" collection="param.entrySet()" >
  66. and ${key} = #{value}
  67. </foreach>
  68. </trim>
  69. </select>
  70. <select id="selectByCondition" parameterType="com.sooka.mybatis.model.TCmsContent" resultMap="BaseResultMap">
  71. SELECT
  72. *
  73. FROM
  74. t_cms_content
  75. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND|OR">
  76. <if test="title!=null and title!=''">
  77. title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
  78. </if>
  79. <if test="siteId!=null">
  80. and site_id = #{siteId,jdbcType=INTEGER}
  81. </if>
  82. <if test="categoryId!=null">
  83. and category_id = #{categoryId,jdbcType=BIGINT}
  84. </if>
  85. <if test="qy_id!=null">
  86. and qy_id = #{qy_id,jdbcType=VARCHAR}
  87. </if>
  88. <if test="status!=null">
  89. and status = #{status,jdbcType=INTEGER}
  90. </if>
  91. <if test="status==null">
  92. and status in(0,1,2)
  93. </if>
  94. </trim>
  95. <choose>
  96. <when test="orderField!=null and orderField!='' and orderDirection!=null and orderDirection!='' ">
  97. order by ${orderField} ${orderDirection}
  98. </when>
  99. <otherwise>
  100. order by inputdate DESC
  101. </otherwise>
  102. </choose>
  103. </select>
  104. <!-- or b.content like CONCAT('%',#{title,jdbcType=VARCHAR},'%')-->
  105. <select id="selectByConditionSousuo" parameterType="com.sooka.mybatis.model.TCmsContent" resultMap="BaseResultMap">
  106. SELECT
  107. *
  108. FROM
  109. t_cms_content a
  110. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND|OR">
  111. <if test="title!=null and title!=''">
  112. a.title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
  113. </if>
  114. <if test="siteId!=null">
  115. and a.site_id = #{siteId,jdbcType=INTEGER}
  116. </if>
  117. <if test="categoryId!=null">
  118. and a.category_id = #{categoryId,jdbcType=BIGINT}
  119. </if>
  120. <if test="qy_id!=null">
  121. and a.qy_id = #{qy_id,jdbcType=VARCHAR}
  122. </if>
  123. <if test="status!=null">
  124. and a.status = #{status,jdbcType=INTEGER}
  125. </if>
  126. <if test="status==null">
  127. and a.status in(0,1,2)
  128. </if>
  129. </trim>
  130. <choose>
  131. <when test="orderField!=null and orderField!='' and orderDirection!=null and orderDirection!='' ">
  132. order by ${orderField} ${orderDirection}
  133. </when>
  134. <otherwise>
  135. order by a.inputdate DESC
  136. </otherwise>
  137. </choose>
  138. </select>
  139. <select id="selectByContentListBySiteIdAndCategoryIds" resultType="java.util.Map">
  140. SELECT
  141. c.content_id contentId,
  142. c.site_id siteId,
  143. c.user_id userId,
  144. c.category_id categoryId,
  145. c.model_id modelId,
  146. c.title,
  147. c.keywords,
  148. c.description,
  149. c.top,
  150. c.recommend,
  151. c.thumb,
  152. c.updatedate,
  153. c.inputdate,
  154. c.status,
  155. c.url,
  156. c.author,
  157. c.sorts,
  158. c.view_num viewNum,
  159. m.*
  160. FROM
  161. t_cms_content c LEFT JOIN t_cms_content_${tableName} m
  162. ON
  163. c.content_id = m.content_id
  164. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND|OR">
  165. c.status=1
  166. <if test="siteId!=null">
  167. AND c.site_id = #{siteId}
  168. </if>
  169. <if test="categoryIds!=null">
  170. AND
  171. c.category_id in
  172. <foreach item="item" index="index" collection="categoryIds" open="(" separator="," close=")">
  173. #{item}
  174. </foreach>
  175. </if>
  176. <if test='isRecommend!=null and isRecommend==1'>
  177. AND
  178. c.recommend = 1
  179. </if>
  180. <if test='isPic!=null and isPic==1'>
  181. AND
  182. c.thumb!=''
  183. </if>
  184. <if test='isPic!=null and isPic==0'>
  185. AND
  186. c.thumb=''
  187. </if>
  188. <if test='orderBy==6'>
  189. AND
  190. c.thumb!=''
  191. </if>
  192. </trim>
  193. <choose>
  194. <when test="orderBy==1">
  195. order by c.content_id
  196. </when>
  197. <when test="orderBy==2">
  198. order by inputdate DESC
  199. </when>
  200. <when test="orderBy==3">
  201. order by c.inputdate
  202. </when>
  203. <when test="orderBy==4">
  204. order by c.updatedate DESC
  205. </when>
  206. <when test="orderBy==5">
  207. order by c.updatedate
  208. </when>
  209. <when test="orderBy==6">
  210. order by c.sorts,c.updatedate DESC
  211. </when>
  212. <when test="isHot==1">
  213. order by c.view_num DESC
  214. </when>
  215. <otherwise>
  216. order by c.content_id DESC
  217. </otherwise>
  218. </choose>
  219. </select>
  220. <select id="selectByTopicContentListBySiteIdAndCategoryIds" resultType="java.util.Map">
  221. SELECT
  222. *
  223. FROM
  224. t_cms_content
  225. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND|OR">
  226. status=1
  227. <if test="siteId!=null">
  228. AND site_id = #{siteId}
  229. </if>
  230. <if test="categoryIds!=null">
  231. AND
  232. category_id in
  233. <foreach item="item" index="index" collection="categoryIds" open="(" separator="," close=")">
  234. #{item}
  235. </foreach>
  236. </if>
  237. <if test='isRecommend!=null and isRecommend==1'>
  238. AND
  239. recommend = 1
  240. </if>
  241. <if test='isPic!=null and isPic==1'>
  242. AND
  243. thumb!=''
  244. </if>
  245. <if test='isPic!=null and isPic==0'>
  246. AND
  247. thumb=''
  248. </if>
  249. </trim>
  250. <choose>
  251. <when test="orderBy==1">
  252. order by content_id
  253. </when>
  254. <when test="orderBy==2">
  255. order by inputdate DESC
  256. </when>
  257. <when test="orderBy==3">
  258. order by inputdate
  259. </when>
  260. <when test="orderBy==4">
  261. order by updatedate DESC
  262. </when>
  263. <when test="orderBy==5">
  264. order by updatedate
  265. </when>
  266. <when test="isHot==1">
  267. order by view_num DESC
  268. </when>
  269. <otherwise>
  270. order by content_id DESC
  271. </otherwise>
  272. </choose>
  273. </select>
  274. </mapper>