TCmsContentMapper.xml 11 KB

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