TCmsContentMapper.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. <select id="selectByContentListBySiteIdAndCategoryIds" resultType="java.util.Map">
  105. SELECT
  106. c.content_id contentId,
  107. c.site_id siteId,
  108. c.user_id userId,
  109. c.category_id categoryId,
  110. c.model_id modelId,
  111. c.title,
  112. c.keywords,
  113. c.description,
  114. c.top,
  115. c.recommend,
  116. c.thumb,
  117. c.updatedate,
  118. c.inputdate,
  119. c.status,
  120. c.url,
  121. c.author,
  122. c.sorts,
  123. c.view_num viewNum,
  124. m.*
  125. FROM
  126. t_cms_content c LEFT JOIN t_cms_content_${tableName} m
  127. ON
  128. c.content_id = m.content_id
  129. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND|OR">
  130. c.status=1
  131. <if test="siteId!=null">
  132. AND c.site_id = #{siteId}
  133. </if>
  134. <if test="categoryIds!=null">
  135. AND
  136. c.category_id in
  137. <foreach item="item" index="index" collection="categoryIds" open="(" separator="," close=")">
  138. #{item}
  139. </foreach>
  140. </if>
  141. <if test='isRecommend!=null and isRecommend==1'>
  142. AND
  143. c.recommend = 1
  144. </if>
  145. <if test='isPic!=null and isPic==1'>
  146. AND
  147. c.thumb!=''
  148. </if>
  149. <if test='isPic!=null and isPic==0'>
  150. AND
  151. c.thumb=''
  152. </if>
  153. <if test='orderBy==6'>
  154. AND
  155. c.thumb!=''
  156. </if>
  157. </trim>
  158. <choose>
  159. <when test="orderBy==1">
  160. order by c.content_id
  161. </when>
  162. <when test="orderBy==2">
  163. order by inputdate DESC
  164. </when>
  165. <when test="orderBy==3">
  166. order by c.inputdate
  167. </when>
  168. <when test="orderBy==4">
  169. order by c.updatedate DESC
  170. </when>
  171. <when test="orderBy==5">
  172. order by c.updatedate
  173. </when>
  174. <when test="orderBy==6">
  175. order by c.sorts,c.updatedate DESC
  176. </when>
  177. <when test="isHot==1">
  178. order by c.view_num DESC
  179. </when>
  180. <otherwise>
  181. order by c.content_id DESC
  182. </otherwise>
  183. </choose>
  184. </select>
  185. <select id="selectByTopicContentListBySiteIdAndCategoryIds" resultType="java.util.Map">
  186. SELECT
  187. *
  188. FROM
  189. t_cms_content
  190. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND|OR">
  191. status=1
  192. <if test="siteId!=null">
  193. AND site_id = #{siteId}
  194. </if>
  195. <if test="categoryIds!=null">
  196. AND
  197. category_id in
  198. <foreach item="item" index="index" collection="categoryIds" open="(" separator="," close=")">
  199. #{item}
  200. </foreach>
  201. </if>
  202. <if test='isRecommend!=null and isRecommend==1'>
  203. AND
  204. recommend = 1
  205. </if>
  206. <if test='isPic!=null and isPic==1'>
  207. AND
  208. thumb!=''
  209. </if>
  210. <if test='isPic!=null and isPic==0'>
  211. AND
  212. thumb=''
  213. </if>
  214. </trim>
  215. <choose>
  216. <when test="orderBy==1">
  217. order by content_id
  218. </when>
  219. <when test="orderBy==2">
  220. order by inputdate DESC
  221. </when>
  222. <when test="orderBy==3">
  223. order by inputdate
  224. </when>
  225. <when test="orderBy==4">
  226. order by updatedate DESC
  227. </when>
  228. <when test="orderBy==5">
  229. order by updatedate
  230. </when>
  231. <when test="isHot==1">
  232. order by view_num DESC
  233. </when>
  234. <otherwise>
  235. order by content_id DESC
  236. </otherwise>
  237. </choose>
  238. </select>
  239. </mapper>