IContentDao.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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="net.mingsoft.cms.dao.IContentDao">
  4. <resultMap id="resultMap" type="net.mingsoft.cms.entity.ContentEntity">
  5. <id column="id" property="id" /><!--编号 -->
  6. <result column="content_title" property="contentTitle" /><!--文章标题 -->
  7. <result column="category_id" property="categoryId" /><!--所属栏目 -->
  8. <result column="content_type" property="contentType" /><!--文章类型 -->
  9. <result column="content_display" property="contentDisplay" /><!--是否显示 -->
  10. <result column="content_author" property="contentAuthor" /><!--文章作者 -->
  11. <result column="content_source" property="contentSource" /><!--文章来源 -->
  12. <result column="content_datetime" property="contentDatetime" /><!--发布时间 -->
  13. <result column="content_sort" property="contentSort" /><!--自定义顺序 -->
  14. <result column="content_img" property="contentImg" /><!--文章缩略图 -->
  15. <result column="content_description" property="contentDescription" /><!--描述 -->
  16. <result column="content_keyword" property="contentKeyword" /><!--关键字 -->
  17. <result column="content_details" property="contentDetails" /><!--文章内容 -->
  18. <result column="content_url" property="contentUrl" /><!--文章跳转链接地址 -->
  19. <result column="content_hit" property="contentHit" /><!--点击次数 -->
  20. <result column="create_by" property="createBy" /><!--创建人 -->
  21. <result column="create_date" property="createDate" /><!--创建时间 -->
  22. <result column="update_by" property="updateBy" /><!--修改人 -->
  23. <result column="update_date" property="updateDate" /><!--修改时间 -->
  24. <result column="del" property="del" /><!--删除标记 -->
  25. </resultMap>
  26. <resultMap id="resultContentMap" type="net.mingsoft.cms.bean.ContentBean">
  27. <id column="id" property="id" /><!--编号 -->
  28. <result column="content_title" property="contentTitle" /><!--文章标题 -->
  29. <result column="category_id" property="categoryId" /><!--所属栏目 -->
  30. <result column="content_type" property="contentType" /><!--文章类型 -->
  31. <result column="content_display" property="contentDisplay" /><!--是否显示 -->
  32. <result column="content_author" property="contentAuthor" /><!--文章作者 -->
  33. <result column="content_source" property="contentSource" /><!--文章来源 -->
  34. <result column="content_datetime" property="contentDatetime" /><!--发布时间 -->
  35. <result column="content_sort" property="contentSort" /><!--自定义顺序 -->
  36. <result column="content_img" property="contentImg" /><!--文章缩略图 -->
  37. <result column="content_description" property="contentDescription" /><!--描述 -->
  38. <result column="content_keyword" property="contentKeyword" /><!--关键字 -->
  39. <result column="content_details" property="contentDetails" /><!--文章内容 -->
  40. <result column="content_url" property="contentUrl" /><!--文章跳转链接地址 -->
  41. <!-- <result column="static_url" property="staticUrl" />&lt;!&ndash;静态地址 &ndash;&gt;-->
  42. <result column="content_hit" property="contentHit" /><!--点击次数 -->
  43. <result column="create_by" property="createBy" /><!--创建人 -->
  44. <result column="create_date" property="createDate" /><!--创建时间 -->
  45. <result column="update_by" property="updateBy" /><!--修改人 -->
  46. <result column="update_date" property="updateDate" /><!--修改时间 -->
  47. <result column="del" property="del" /><!--删除标记 -->
  48. </resultMap>
  49. <resultMap id="resultBean" type="net.mingsoft.cms.bean.CategoryBean">
  50. <id column="id" property="id" /><!--编号 -->
  51. <id column="article_Id" property="articleId" /><!--编号 -->
  52. <result column="category_title" property="categoryTitle" /><!--栏目管理名称 -->
  53. <result column="category_id" property="categoryId" /><!--所属栏目 -->
  54. <result column="category_type" property="categoryType" /><!--栏目管理属性 -->
  55. <result column="category_sort" property="categorySort" /><!--自定义顺序 -->
  56. <result column="category_list_url" property="categoryListUrl" /><!--列表模板 -->
  57. <result column="category_url" property="categoryUrl" /><!--内容模板 -->
  58. <result column="category_keyword" property="categoryKeyword" /><!--栏目管理关键字 -->
  59. <result column="category_descrip" property="categoryDescrip" /><!--栏目管理描述 -->
  60. <result column="category_img" property="categoryImg" /><!--缩略图 -->
  61. <result column="category_diy_url" property="categoryDiyUrl" /><!--自定义链接 -->
  62. <result column="mdiy_model_id" property="mdiyModelId" /><!--栏目管理的内容模型id -->
  63. <result column="category_datetime" property="categoryDatetime" /><!--类别发布时间 -->
  64. <result column="dict_id" property="dictId" /><!--字典对应编号 -->
  65. <result column="category_flag" property="categoryFlag" /><!--栏目属性 -->
  66. <result column="category_path" property="categoryPath" /><!--栏目路径 -->
  67. <result column="category_parent_ids" property="categoryParentIds" /><!--父类型编号 -->
  68. <result column="create_by" property="createBy" /><!--创建人 -->
  69. <result column="create_date" property="createDate" /><!--创建时间 -->
  70. <result column="update_by" property="updateBy" /><!--修改人 -->
  71. <result column="update_date" property="updateDate" /><!--修改时间 -->
  72. <result column="del" property="del" /><!--删除标记 -->
  73. </resultMap>
  74. <!--保存-->
  75. <insert id="saveEntity" useGeneratedKeys="true" keyProperty="id"
  76. parameterType="net.mingsoft.cms.entity.ContentEntity" >
  77. insert into cms_content
  78. <trim prefix="(" suffix=")" suffixOverrides=",">
  79. <if test="contentTitle != null and contentTitle != ''">content_title,</if>
  80. <if test="categoryId != null and categoryId != ''">category_id,</if>
  81. <if test="contentType != null ">content_type,</if>
  82. <if test="contentDisplay != null and contentDisplay != ''">content_display,</if>
  83. <if test="contentAuthor != null and contentAuthor != ''">content_author,</if>
  84. <if test="contentSource != null and contentSource != ''">content_source,</if>
  85. <if test="contentDatetime != null">content_datetime,</if>
  86. <if test="contentSort != null">content_sort,</if>
  87. <if test="contentImg != null and contentImg != ''">content_img,</if>
  88. <if test="contentDescription != null and contentDescription != ''">content_description,</if>
  89. <if test="contentKeyword != null and contentKeyword != ''">content_keyword,</if>
  90. <if test="contentDetails != null and contentDetails != ''">content_details,</if>
  91. <if test="contentUrl != null and contentUrl != ''">content_url,</if>
  92. <if test="contentHit != null">content_hit,</if>
  93. <if test="createBy &gt; 0">create_by,</if>
  94. <if test="createDate != null">create_date,</if>
  95. <if test="updateBy &gt; 0">update_by,</if>
  96. <if test="updateDate != null">update_date,</if>
  97. <if test="del != null">del,</if>
  98. </trim>
  99. <trim prefix="values (" suffix=")" suffixOverrides=",">
  100. <if test="contentTitle != null and contentTitle != ''">#{contentTitle},</if>
  101. <if test="categoryId != null and categoryId != ''">#{categoryId},</if>
  102. <if test="contentType != null ">#{contentType},</if>
  103. <if test="contentDisplay != null and contentDisplay != ''">#{contentDisplay},</if>
  104. <if test="contentAuthor != null and contentAuthor != ''">#{contentAuthor},</if>
  105. <if test="contentSource != null and contentSource != ''">#{contentSource},</if>
  106. <if test="contentDatetime != null">#{contentDatetime},</if>
  107. <if test="contentSort != null">#{contentSort},</if>
  108. <if test="contentImg != null and contentImg != ''">#{contentImg},</if>
  109. <if test="contentDescription != null and contentDescription != ''">#{contentDescription},</if>
  110. <if test="contentKeyword != null and contentKeyword != ''">#{contentKeyword},</if>
  111. <if test="contentDetails != null and contentDetails != ''">#{contentDetails},</if>
  112. <if test="contentUrl != null and contentUrl != ''">#{contentUrl},</if>
  113. <if test="contentHit != null">#{contentHit},</if>
  114. <if test="createBy &gt; 0">#{createBy},</if>
  115. <if test="createDate != null">#{createDate},</if>
  116. <if test="updateBy &gt; 0">#{updateBy},</if>
  117. <if test="updateDate != null">#{updateDate},</if>
  118. <if test="del != null">#{del},</if>
  119. </trim>
  120. </insert>
  121. <!--更新-->
  122. <update id="updateEntity" parameterType="net.mingsoft.cms.entity.ContentEntity">
  123. update cms_content
  124. <set>
  125. <if test="contentTitle != null and contentTitle != ''">content_title=#{contentTitle},</if>
  126. <if test="categoryId != null and categoryId != ''">category_id=#{categoryId},</if>
  127. <if test="contentType != null ">content_type=#{contentType},</if>
  128. <if test="contentDisplay != null and contentDisplay != ''">content_display=#{contentDisplay},</if>
  129. <if test="contentAuthor != null ">content_author=#{contentAuthor},</if>
  130. <if test="contentSource != null ">content_source=#{contentSource},</if>
  131. <if test="contentDatetime != null">content_datetime=#{contentDatetime},</if>
  132. <if test="contentSort != null">content_sort=#{contentSort},</if>
  133. <if test="contentImg != null and contentImg != ''">content_img=#{contentImg},</if>
  134. <if test="contentDescription != null ">content_description=#{contentDescription},</if>
  135. <if test="contentKeyword != null ">content_keyword=#{contentKeyword},</if>
  136. <if test="contentDetails != null ">content_details=#{contentDetails},</if>
  137. <if test="contentUrl != null and contentUrl != ''">content_url=#{contentUrl},</if>
  138. <if test="contentHit != null">content_hit=#{contentHit},</if>
  139. <if test="createBy &gt; 0">create_by=#{createBy},</if>
  140. <if test="createDate != null">create_date=#{createDate},</if>
  141. <if test="updateBy &gt; 0">update_by=#{updateBy},</if>
  142. <if test="updateDate != null">update_date=#{updateDate},</if>
  143. <if test="del != null">del=#{del},</if>
  144. </set>
  145. where id = #{id}
  146. </update>
  147. <!--根据id获取-->
  148. <select id="getEntity" resultMap="resultMap" parameterType="int">
  149. select * from cms_content where id=#{id} and del=0
  150. </select>
  151. <!--根据实体获取-->
  152. <select id="getByEntity" resultMap="resultMap" parameterType="net.mingsoft.cms.entity.ContentEntity">
  153. select * from cms_content
  154. <where>
  155. del=0
  156. <if test="contentTitle != null and contentTitle != ''">and content_title like CONCAT('%',#{contentTitle},'%')</if>
  157. <if test="categoryId != null and categoryId != ''">and category_id=#{categoryId}</if>
  158. <if test="contentType != null and contentType != ''">and content_type=#{contentType}</if>
  159. <if test="contentDisplay != null and contentDisplay != ''">and content_display=#{contentDisplay}</if>
  160. <if test="contentAuthor != null and contentAuthor != ''">and content_author=#{contentAuthor}</if>
  161. <if test="contentSource != null and contentSource != ''">and content_source=#{contentSource}</if>
  162. <if test="contentDatetime != null"> and content_datetime=#{contentDatetime} </if>
  163. <if test="contentSort != null"> and content_sort=#{contentSort} </if>
  164. <if test="contentImg != null and contentImg != ''">and content_img=#{contentImg}</if>
  165. <if test="contentDescription != null and contentDescription != ''">and content_description=#{contentDescription}</if>
  166. <if test="contentKeyword != null and contentKeyword != ''">and content_keyword=#{contentKeyword}</if>
  167. <if test="contentDetails != null and contentDetails != ''">and content_details=#{contentDetails}</if>
  168. <if test="contentUrl != null and contentUrl != ''">and content_url=#{contentUrl}</if>
  169. <if test="contentHit != null">and content_hit=#{contentHit}</if>
  170. <if test="createBy &gt; 0"> and create_by=#{createBy} </if>
  171. <if test="createDate != null"> and create_date=#{createDate} </if>
  172. <if test="updateBy &gt; 0"> and update_by=#{updateBy} </if>
  173. <if test="updateDate != null"> and update_date=#{updateDate} </if>
  174. </where>
  175. </select>
  176. <!--删除-->
  177. <delete id="deleteEntity" parameterType="int">
  178. update cms_content set del=1 where id=#{id}
  179. </delete>
  180. <!--删除-->
  181. <delete id="deleteEntityByCategoryIds" >
  182. update cms_content set del=1
  183. <where>
  184. category_id in <foreach collection="ids" item="item" index="index"
  185. open="(" separator="," close=")">#{item}</foreach>
  186. </where>
  187. </delete>
  188. <!--批量删除-->
  189. <delete id="delete" >
  190. update cms_content set del=1
  191. <where>
  192. id in <foreach collection="ids" item="item" index="index"
  193. open="(" separator="," close=")">#{item}</foreach>
  194. </where>
  195. </delete>
  196. <!--查询全部-->
  197. <select id="queryAll" resultMap="resultMap">
  198. select * from cms_content where del=0 order by id desc
  199. </select>
  200. <!--条件查询-->
  201. <select id="query" resultMap="resultContentMap">
  202. <!--,CONCAT('/html/',ct.app_id,category_path,'/',ct.id,'.html') AS static_url-->
  203. select ct.* from (
  204. select ct.*,cc.category_path from cms_content ct
  205. join cms_category cc on ct.category_id=cc.id
  206. <where>
  207. ct.del=0
  208. <if test="contentTitle != null and contentTitle != ''"> and content_title like CONCAT('%',#{contentTitle},'%')</if>
  209. <if test="categoryId != null and categoryId != ''"> and (ct.category_id=#{categoryId} or ct.category_id in
  210. (select id FROM cms_category where find_in_set('${categoryId}',CATEGORY_PARENT_IDS)))</if>
  211. <if test="contentType != null and contentType != ''"> and content_type LIKE CONCAT('%',#{contentType},'%')</if>
  212. <if test="contentDisplay != null and contentDisplay != ''"> and content_display=#{contentDisplay}</if>
  213. <if test="contentAuthor != null and contentAuthor != ''"> and content_author=#{contentAuthor}</if>
  214. <if test="contentSource != null and contentSource != ''"> and content_source=#{contentSource}</if>
  215. <if test="contentDatetime != null"> and content_datetime=#{contentDatetime} </if>
  216. <if test="contentSort != null"> and content_sort=#{contentSort} </if>
  217. <if test="contentImg != null and contentImg != ''"> and content_img=#{contentImg}</if>
  218. <if test="contentDescription != null and contentDescription != ''"> and content_description=#{contentDescription}</if>
  219. <if test="contentKeyword != null and contentKeyword != ''"> and content_keyword=#{contentKeyword}</if>
  220. <if test="contentDetails != null and contentDetails != ''"> and content_details=#{contentDetails}</if>
  221. <if test="contentUrl != null and contentUrl != ''"> and content_url=#{contentUrl}</if>
  222. <if test="contentHit != null"> and content_hit=#{contentHit}</if>
  223. <if test="createBy &gt; 0"> and ct.create_by=#{createBy} </if>
  224. <if test="createDate != null"> and ct.create_date=#{createDate} </if>
  225. <if test="updateBy &gt; 0"> and ct.update_by=#{updateBy} </if>
  226. <if test="updateDate != null"> and update_date=#{updateDate} </if>
  227. </where>
  228. )ct ORDER BY ct.content_datetime desc,content_sort desc
  229. </select>
  230. <!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 -->
  231. <select id="queryIdsByCategoryIdForParser" resultMap="resultBean" >
  232. select
  233. ct.id article_id,c.*
  234. FROM cms_content ct
  235. LEFT JOIN cms_category c ON ct.category_id = c.id
  236. where ct.del=0
  237. <!-- 查询子栏目数据 -->
  238. <if test="categoryId &gt; 0">
  239. and (ct.category_id=#{categoryId} or ct.category_id in
  240. (select id FROM cms_category where find_in_set('${categoryId}',CATEGORY_PARENT_IDS)))
  241. </if>
  242. <if test="beginTime!=null and beginTime!=''">
  243. and content_datetime &gt;= #{beginTime}
  244. </if>
  245. <if test="endTime!=null and endTime!=''">
  246. and content_datetime &gt;= #{endTime}
  247. </if>
  248. <if test="flag!=null and flag!=''">
  249. and ct.content_type in ( #{flag})
  250. </if>
  251. <if test="noflag!=null and noflag!=''">
  252. and (ct.content_type not in ( #{noflag} ) or ct.content_type is null)
  253. </if>
  254. <if test="orderBy!=null and orderBy!='' ">
  255. <if test="orderBy=='date'">ORDER BY content_datetime</if>
  256. <if test="orderBy=='hit'">ORDER BY content_hit</if>
  257. <if test="orderBy=='sort'">ORDER BY content_sort</if>
  258. <if test="orderBy!='date' and orderBy!='hit' and orderBy!='sort'">
  259. ORDER BY ct.id
  260. </if>
  261. <choose>
  262. <when test="order!=null and order!=''">
  263. ${order}
  264. </when>
  265. <otherwise>
  266. desc
  267. </otherwise>
  268. </choose>
  269. </if>
  270. </select>
  271. <select id="getSearchCount" resultType="int">
  272. select count(*) from
  273. cms_content a
  274. left join cms_category c
  275. ON a.category_id
  276. = c.id
  277. <if test="tableName!=null and tableName!='' and diyMap!=null">left join ${tableName} d on d.link_id=a.id
  278. </if>
  279. <where>
  280. a.del=0
  281. <if test="ids!=null and ids!=''">
  282. and FIND_IN_SET(a.category_id,#{ids})
  283. </if>
  284. <if test="map.content_title!=null">
  285. and a.content_title like CONCAT("%",#{map.content_title},"%")
  286. </if>
  287. <if test="map.content_author!=null">
  288. and a.content_author like CONCAT("%",#{map.content_author},"%")
  289. </if>
  290. <if test="map.content_source!=null">
  291. and a.content_source like CONCAT("%",#{map.content_source},"%")
  292. </if>
  293. <if test="map.content_type!=null">
  294. and <foreach item="item" index="index" collection="map.content_type.split(',')" open="(" separator="or" close=")">
  295. FIND_IN_SET('${item}',a.content_type)
  296. </foreach>
  297. </if>
  298. <if test="map.content_description!=null">
  299. and a.content_description like CONCAT("%",#{map.content_description},"%")
  300. </if>
  301. <if test="map.content_keyword!=null">
  302. and a.content_keyword like CONCAT("%",#{map.content_keyword},"%")
  303. </if>
  304. <if test="map.content_details!=null">
  305. and a.content_details like CONCAT("%",#{map.content_details},"%")
  306. </if>
  307. <if test="map.content_datetime_start!=null and map.content_datetime_end!=null">
  308. and a.content_datetime between #{map.content_datetime_start} and #{map.content_datetime_end}
  309. </if>
  310. <if test="tableName!=null and tableName!='' and diyMap!=null">
  311. <foreach item="item" index="index" collection="diyList" open=""
  312. separator="" close="">
  313. and d.${field.key} like CONCAT("%",#{item.value},"%")
  314. </foreach>
  315. </if>
  316. </where>
  317. </select>
  318. </mapper>