IArticleDao.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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. <!-- 文章管理持久化层配置文件 -->
  4. <mapper namespace="net.mingsoft.cms.dao.IArticleDao">
  5. <!-- 表栏目名 开始 -->
  6. <sql id="column_list">
  7. a.ARTICLE_BASICID,a.ARTICLE_CONTENT,a.ARTICLE_AUTHOR,a.ARTICLE_TYPE,a.ARTICLE_SOURCE,a.ARTICLE_URL,a.ARTICLE_KEYWORD,a.ARTICLE_FREEORDER,a.ARTICLE_WEBID,
  8. b.BASIC_ID,b.BASIC_TITLE,b.BASIC_DESCRIPTION,b.BASIC_THUMBNAILS,b.BASIC_HIT,b.BASIC_DISPLAY,b.BASIC_DATETIME,b.BASIC_UPDATETIME,b.BASIC_PEOPLEID,b.BASIC_CATEGORYID,b.BASIC_SORT
  9. </sql>
  10. <!-- 表栏目名 结束 -->
  11. <!-- 获取表字段 开始 -->
  12. <resultMap type="net.mingsoft.cms.entity.ArticleEntity" id="resultMap">
  13. <id column="ARTICLE_BASICID" property="articleID" /> <!-- 与cms_article表绑定id -->
  14. <result column="ARTICLE_CONTENT" property="articleContent" /> <!-- 文章内容 -->
  15. <result column="ARTICLE_AUTHOR" property="articleAuthor" /> <!-- 文章作者 -->
  16. <result column="ARTICLE_TYPE" property="articleType" /> <!-- 文章属性 -->
  17. <result column="ARTICLE_SOURCE" property="articleSource" /> <!-- 文章来源 -->
  18. <result column="ARTICLE_URL" property="articleUrl" /> <!-- 文章跳转链接地址 -->
  19. <result column="ARTICLE_KEYWORD" property="articleKeyword" /> <!-- 文章关键字 -->
  20. <result column="ARTICLE_FREEORDER" property="articleFreeOrder" /><!--
  21. 文章自定义显示顺序 -->
  22. <result column="ARTICLE_WEBID" property="articleWebId" /> <!-- 站点id -->
  23. <result column="BASIC_ID" property="basicId" /> <!-- 与表basic绑定 自增长ID -->
  24. <result column="BASIC_TITLE" property="basicTitle" /> <!-- 文章标题 -->
  25. <result column="BASIC_DESCRIPTION" property="basicDescription" /><!--
  26. 文章描述 -->
  27. <result column="BASIC_THUMBNAILS" property="basicThumbnails" /> <!-- 文章缩略图 -->
  28. <result column="BASIC_HIT" property="basicHit" /> <!-- 文章点击次数 -->
  29. <result column="BASIC_DATETIME" property="basicDateTime" /> <!-- 文章发布时间 -->
  30. <result column="BASIC_UPDATETIME" property="basicUpdateTime" /> <!-- 文章更新时间 -->
  31. <result column="BASIC_PEOPLEID" property="basicPeopleId" /> <!-- 文章发布者id -->
  32. <result column="BASIC_CATEGORYID" property="basicCategoryId" /> <!-- 文章所属主栏目id -->
  33. <result column="BASIC_SORT" property="basicSort" />
  34. <result column="BASIC_DISPLAY" property="basicDisplay" />
  35. <!-- 一对一关联栏目 -->
  36. <association property="column" column="COLUMN_CATEGORY_ID"
  37. javaType="net.mingsoft.basic.entity.ColumnEntity">
  38. <result property="columnPath" column="column_path" />
  39. <result property="categoryTitle" column="category_title" />
  40. <result property="categoryId" column="category_id" />
  41. <result property="columnContentModelId" column="COLUMN_CM_ID" />
  42. <result property="columnType" column="COLUMN_TYPE" />
  43. </association>
  44. </resultMap>
  45. <!-- 获取表字段 结束 -->
  46. <!-- 通过视图查询返回结果集 开始 -->
  47. <resultMap type="net.mingsoft.cms.bean.ColumnArticleIdBean" id="resultMapBean">
  48. <result column="ARTICLE_BASICID" property="articleId" />
  49. <result column="column_path" property="columnPath"/>
  50. <result column="column_url" property="columnUrl" />
  51. <result column="column_listurl" property="columnListUrl" />
  52. <result column="category_title" property="categoryTitle" />
  53. <result column="category_id" property="categoryId" />
  54. <result column="COLUMN_CM_ID" property="columnContentModelId" />
  55. <result column="category_categoryid" property="categoryCategoryId" /><!--关联表category的父类别ID category_categoryid字段 -->
  56. <result column="category_modelId" property="categoryModelId" /><!--关联表category的所属模块ID category_modelid字段 -->
  57. <result column="COLUMN_TYPE" property="columnType" />
  58. <result column="category_parent_id" property="categoryParentId" /><!--关联表category的字典对应编号 -->
  59. </resultMap>
  60. <!-- 通过视图查询返回结果集 结束 -->
  61. <!-- 通过视图查询返回结果集 开始 -->
  62. <resultMap type="net.mingsoft.cms.entity.ArticleEntity" id="viewResultMap">
  63. <id column="ARTICLE_BASICID" property="articleID" /> <!-- 与cms_article表绑定id -->
  64. <result column="ARTICLE_CONTENT" property="articleContent" /> <!-- 文章内容 -->
  65. <result column="ARTICLE_AUTHOR" property="articleAuthor" /> <!-- 文章作者 -->
  66. <result column="ARTICLE_TYPE" property="articleType" /> <!-- 文章属性 -->
  67. <result column="ARTICLE_SOURCE" property="articleSource" /> <!-- 文章来源 -->
  68. <result column="ARTICLE_URL" property="articleUrl" /> <!-- 文章跳转链接地址 -->
  69. <result column="ARTICLE_KEYWORD" property="articleKeyword" /> <!-- 文章关键字 -->
  70. <result column="ARTICLE_FREEORDER" property="articleFreeOrder" /><!--
  71. 文章自定义显示顺序 -->
  72. <result column="ARTICLE_WEBID" property="articleWebId" /> <!-- 站点id -->
  73. <result column="BASIC_ID" property="basicId" /> <!-- 与表basic绑定 自增长ID -->
  74. <result column="BASIC_TITLE" property="basicTitle" /> <!-- 文章标题 -->
  75. <result column="BASIC_DESCRIPTION" property="basicDescription" /><!--
  76. 文章描述 -->
  77. <result column="BASIC_THUMBNAILS" property="basicThumbnails" /> <!-- 文章缩略图 -->
  78. <result column="BASIC_HIT" property="basicHit" /> <!-- 文章点击次数 -->
  79. <result column="BASIC_DATETIME" property="basicDateTime" /> <!-- 文章发布时间 -->
  80. <result column="BASIC_UPDATETIME" property="basicUpdateTime" /> <!-- 文章更新时间 -->
  81. <result column="BASIC_CATEGORYID" property="basicCategoryId" /> <!-- 文章所属主栏目id -->
  82. <result column="BASIC_SORT" property="basicSort" />
  83. <result column="BASIC_DISPLAY" property="basicDisplay" />
  84. <!-- 一对一关联栏目 -->
  85. <association property="column"
  86. javaType="net.mingsoft.basic.entity.ColumnEntity">
  87. <result property="columnPath" column="column_path" />
  88. <result property="categoryTitle" column="category_title" />
  89. <result property="categoryId" column="category_id" />
  90. <result property="columnContentModelId" column="COLUMN_CM_ID" />
  91. <result property="columnType" column="COLUMN_TYPE" />
  92. </association>
  93. </resultMap>
  94. <!-- 通过视图查询返回结果集 结束 -->
  95. <!-- 文章bean返回数据列表 开始 -->
  96. <sql id="bean_column_list">
  97. BASIC_ID,ARTICLE_AUTHOR,ARTICLE_TYPE,ARTICLE_SOURCE,ARTICLE_URL,ARTICLE_KEYWORD,ARTICLE_FREEORDER,
  98. BASIC_DISPLAY,BASIC_TITLE,BASIC_DESCRIPTION,BASIC_THUMBNAILS,BASIC_HIT,BASIC_DATETIME,BASIC_UPDATETIME,BASIC_PEOPLEID,BASIC_CATEGORYID,BASIC_SORT
  99. </sql>
  100. <!-- 表栏目名结束 -->
  101. <!-- 文章基础数据返回数据列表 开始 -->
  102. <sql id="basic_data_list">
  103. BASIC_DISPLAY,BASIC_ID,BASIC_CATEGORYID,BASIC_TITLE,BASIC_DESCRIPTION,BASIC_THUMBNAILS,BASIC_HIT,BASIC_DATETIME,BASIC_UPDATETIME,BASIC_PEOPLEID,BASIC_SORT,
  104. ARTICLE_BASICID,ARTICLE_AUTHOR,ARTICLE_CONTENT,ARTICLE_TYPE,ARTICLE_SOURCE,ARTICLE_URL,ARTICLE_KEYWORD,ARTICLE_FREEORDER,ARTICLE_WEBID,
  105. COLUMN_KEYWORD,COLUMN_DESCRIP,COLUMN_TYPE,COLUMN_URL,COLUMN_LISTURL,COLUMN_PATH,COLUMN_CM_ID,COLUMN_CATEGORY_ID,
  106. CATEGORY_TITLE,CATEGORY_APPID,CATEGORY_ID
  107. </sql>
  108. <!-- 文章基础数据返回数据列表结束 -->
  109. <!-- 添加文章信息 开始 -->
  110. <insert id="saveEntity" parameterType="net.mingsoft.base.entity.BaseEntity">
  111. insert into cms_article
  112. <!-- 添加表字段 -->
  113. <trim prefix="(" suffix=")" suffixOverrides=",">
  114. <if test="basicId != null">ARTICLE_BASICID,</if>
  115. <if test="articleContent != null">ARTICLE_CONTENT,</if>
  116. <if test="articleAuthor != null">ARTICLE_AUTHOR,</if>
  117. <if test="articleType != null">ARTICLE_TYPE,</if>
  118. <if test="articleSource != null">ARTICLE_SOURCE,</if>
  119. <if test="articleUrl != null">ARTICLE_URL,</if>
  120. <if test="articleKeyword != null">ARTICLE_KEYWORD,</if>
  121. <if test="articleFreeOrder != null">ARTICLE_FREEORDER,</if>
  122. <if test="articleWebId != null">ARTICLE_WEBID,</if>
  123. </trim>
  124. <!-- 注入控制层字段 -->
  125. <trim prefix="values (" suffix=")" suffixOverrides=",">
  126. <if test="basicId != null">#{basicId},</if>
  127. <if test="articleContent != null">#{articleContent},</if>
  128. <if test="articleAuthor != null">#{articleAuthor},</if>
  129. <if test="articleType != null">#{articleType},</if>
  130. <if test="articleSource != null">#{articleSource},</if>
  131. <if test="articleUrl != null">#{articleUrl},</if>
  132. <if test="articleKeyword != null">#{articleKeyword},</if>
  133. <if test="articleFreeOrder != null">#{articleFreeOrder},</if>
  134. <if test="articleWebId != null">#{articleWebId},</if>
  135. </trim>
  136. </insert>
  137. <!-- 添加文章信息 结束 -->
  138. <!-- 删除文章管理的信息 开始 -->
  139. <delete id="deleteEntity" parameterType="int">
  140. DELETE b from basic b WHERE b.basic_id=#{basicId};
  141. DELETE c from cms_article c WHERE c.article_basicid=#{basicId}
  142. </delete>
  143. <!-- 删除文章管理的信息 结束 -->
  144. <!-- 更新文章管理的信息 开始 -->
  145. <update id="updateEntity" parameterType="net.mingsoft.base.entity.BaseEntity">
  146. update cms_article
  147. <set>
  148. <if test="articleContent != null">ARTICLE_CONTENT=#{articleContent},</if>
  149. <if test="articleAuthor != null">ARTICLE_AUTHOR=#{articleAuthor},</if>
  150. <if test="articleType != null">ARTICLE_TYPE=#{articleType},</if>
  151. <if test="articleSource != null">ARTICLE_SOURCE=#{articleSource},</if>
  152. <if test="articleUrl != null">ARTICLE_URL=#{articleUrl},</if>
  153. <if test="articleKeyword != null">ARTICLE_KEYWORD=#{articleKeyword},</if>
  154. <if test="articleFreeOrder != null">ARTICLE_FREEORDER=#{articleFreeOrder},</if>
  155. <if test="articleWebId != null">ARTICLE_WEBID=#{articleWebId},</if>
  156. </set>
  157. where ARTICLE_BASICID = #{basicId}
  158. </update>
  159. <!-- 更新文章管理的信息 开始 -->
  160. <!-- 查找文章管理的信息 开始 -->
  161. <select id="getEntity" resultMap="resultMap" parameterType="int">
  162. select
  163. <include refid="column_list" />
  164. ,c.CATEGORY_TITLE,cl.column_path,cl.column_type,c.CATEGORY_id,cl.COLUMN_CM_ID
  165. FROM
  166. basic b
  167. LEFT JOIN
  168. category c ON b.BASIC_CATEGORYID = c.CATEGORY_ID
  169. LEFT JOIN basic_column
  170. cl ON c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
  171. LEFT
  172. JOIN cms_article a ON
  173. a.ARTICLE_BASICID = b.BASIC_ID
  174. <!-- 查询与关联表id相同的信息 -->
  175. where a.ARTICLE_BASICID=#{basicId}
  176. </select>
  177. <!-- 查找文章管理的信息 结束 -->
  178. <!-- 标题字段query -->
  179. <sql id="queryWhereBasicTitle" databaseId="mysql">
  180. CONCAT('%',#{article.basicTitle},'%')
  181. </sql>
  182. <sql id="queryWhereBasicTitle" databaseId="oracle">
  183. '%'||#{ article.basicTitle}||'%'
  184. </sql>
  185. <sql id="queryWhereBasicTitle" databaseId="sqlServer">
  186. '%'+#{ article.basicTitle}+'%'
  187. </sql>
  188. <!-- flag字段 -->
  189. <sql id="queryWhereFlag" databaseId="mysql">
  190. CONCAT('%',#{flag},'%')
  191. </sql>
  192. <sql id="queryWhereFlag" databaseId="oracle">
  193. '%'||#{ flag}||'%'
  194. </sql>
  195. <sql id="queryWhereFlag" databaseId="sqlServer">
  196. '%'+#{ flag}+'%'
  197. </sql>
  198. <!-- noFlag字段 -->
  199. <sql id="queryWhereNoFlag" databaseId="mysql">
  200. CONCAT('%',#{noFlag},'%')
  201. </sql>
  202. <sql id="queryWhereNoFlag" databaseId="oracle">
  203. '%'||#{ noFlag}||'%'
  204. </sql>
  205. <sql id="queryWhereNoFlag" databaseId="sqlServer">
  206. '%'+#{ noFlag}+'%'
  207. </sql>
  208. <!-- 已过期 -->
  209. <select id="count" resultType="int">
  210. select count(basic_id) FROM basic b
  211. LEFT JOIN category c ON
  212. b.BASIC_CATEGORYID = c.CATEGORY_ID
  213. LEFT JOIN basic_column cl ON
  214. c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
  215. LEFT JOIN cms_article a ON
  216. a.ARTICLE_BASICID = b.BASIC_ID
  217. <where>
  218. a.ARTICLE_WEBID = #{webId}
  219. <if test="article != null ">
  220. <if test="article.basicTitle != null and article.basicTitle != ''">
  221. and b.BASIC_TITLE like
  222. <include refid="queryWhereBasicTitle"></include>
  223. </if>
  224. </if>
  225. <if test="basicCategoryIds != null">
  226. and b.BASIC_CATEGORYID in
  227. <foreach collection="basicCategoryIds" index="index" item="categoryId"
  228. open="(" separator="," close=")">
  229. #{categoryId}
  230. </foreach>
  231. </if>
  232. <if test="flag != null">
  233. and a.ARTICLE_TYPE like <include refid="queryWhereFlag"></include>
  234. </if>
  235. <if test="noFlag != null">
  236. and a.ARTICLE_TYPE not like <include refid="queryWhereNoFlag"></include>
  237. </if>
  238. </where>
  239. </select>
  240. <!-- 列表查询结束 -->
  241. <!-- 列表查询开始 -->
  242. <select id="query" resultMap="resultMap" >
  243. select
  244. <include refid="column_list" />
  245. ,c.CATEGORY_TITLE,c.CATEGORY_ID
  246. ,cl.COLUMN_PATH,cl.COLUMN_CM_ID,cl.COLUMN_TYPE,cl.COLUMN_CATEGORY_ID
  247. FROM cms_article a LEFT JOIN basic b ON a.ARTICLE_BASICID = b.BASIC_ID
  248. LEFT JOIN basic_column cl ON b.BASIC_CATEGORYID = cl.COLUMN_CATEGORY_ID
  249. JOIN category c ON c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
  250. where a.ARTICLE_WEBID = #{webId}
  251. <if test="article != null ">
  252. <if test="article.basicTitle != null and article.basicTitle != ''">
  253. and b.BASIC_TITLE like
  254. <include refid="queryWhereBasicTitle"></include>
  255. </if>
  256. </if>
  257. <if test="basicCategoryIds != null">
  258. and b.BASIC_CATEGORYID in
  259. <foreach collection="basicCategoryIds" index="index" item="categoryId"
  260. open="(" separator="," close=")">
  261. #{categoryId}
  262. </foreach>
  263. </if>
  264. <if test="flag != null">
  265. and a.ARTICLE_TYPE like <include refid="queryWhereFlag"></include>
  266. </if>
  267. <if test="noFlag != null">
  268. and a.ARTICLE_TYPE not like <include refid="queryWhereNoFlag"></include>
  269. </if>
  270. <if test="article !=null and article.basicDisplay &gt; -1">
  271. and b.basic_display = #{article.basicDisplay}
  272. </if>
  273. <if test="beginTime!=null and beginTime!=''">
  274. and basic_updatetime &gt;= #{beginTime}
  275. </if>
  276. <if test="endTime!=null and endTime!=''">
  277. and basic_updatetime &gt;= #{endTime}
  278. </if>
  279. <if test="orderBy != null">
  280. order by
  281. <choose>
  282. <when test='orderBy=="sort"'>basic_sort</when>
  283. <when test='orderBy=="date"'>basic_datetime</when>
  284. <when test='orderBy=="hit"'>basic_hit</when>
  285. <when test='orderBy=="updatedate"'>basic_updatedate</when>
  286. <when test='orderBy=="id"'>basic_id</when>
  287. <otherwise>
  288. ${orderBy}
  289. </otherwise>
  290. </choose>
  291. </if>
  292. <if test="orderBy==null">
  293. order by b.basic_id
  294. </if>
  295. <if test="order == true">desc</if>
  296. <if test="order == false">asc</if>
  297. </select>
  298. <sql id="queryWhereCategoryId" databaseId="mysql">
  299. find_in_set('${categoryId}',CATEGORY_PARENT_ID)
  300. </sql>
  301. <sql id="queryWhereCategoryId" databaseId="oracle" >
  302. instr(','||'${categoryId}'||',', ','||CATEGORY_PARENT_ID||',')>0
  303. </sql>
  304. <sql id="queryWhereCategoryId" databaseId="sqlServer">
  305. CHARINDEX(','+'${categoryId}'+',' , ','+CATEGORY_PARENT_ID +',')>0
  306. </sql>
  307. <!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 -->
  308. <select id="queryIdsByCategoryIdForParser" resultMap="resultMapBean" >
  309. select
  310. ARTICLE_BASICID,cl.*,c.*
  311. FROM cms_article a LEFT JOIN basic ON a.ARTICLE_BASICID = basic.BASIC_ID
  312. LEFT JOIN basic_column cl ON basic.BASIC_CATEGORYID = cl.COLUMN_CATEGORY_ID
  313. JOIN category c ON c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
  314. where
  315. <if test="appId &gt; 0">
  316. a.ARTICLE_WEBID = #{appId}
  317. </if>
  318. <!-- 查询子栏目数据 -->
  319. <if test="categoryId &gt; 0">
  320. and (basic.basic_categoryid=#{categoryId} or basic.basic_categoryid in
  321. (select category_id FROM category where <include refid="queryWhereCategoryId"></include>))
  322. </if>
  323. <if test="beginTime!=null and beginTime!=''">
  324. and basic.basic_updatetime &gt;= #{beginTime}
  325. </if>
  326. <if test="endTime!=null and endTime!=''">
  327. and basic.basic_updatetime &gt;= #{endTime}
  328. </if>
  329. <if test="orderBy!=null and order!=null and orderBy!='' and order!=''">
  330. ORDER BY `${orderBy}` ${order}
  331. </if>
  332. </select>
  333. <!--查询页面栏目的文章 开始 -->
  334. <!-- 已过期 -->
  335. <select id="queryListByColumnId" resultMap="resultMap">
  336. select
  337. <include refid="column_list" />
  338. from cms_article a left join basic b on b.basic_id=a.ARTICLE_BASICID
  339. where b.BASIC_CATEGORYID = #{basicCategoryId}
  340. </select>
  341. <!-- 查询页面栏目的文章 结束 -->
  342. <!-- 根据字段条件查找文章实体开始 -->
  343. <sql id="queryLike" databaseId="mysql">
  344. like CONCAT("%",
  345. <foreach item="val" index="index" collection="item[3]">
  346. <if test="index==0">#{val}</if>
  347. </foreach>
  348. ,"%")
  349. </sql>
  350. <sql id="queryLike" databaseId="oracle">
  351. like '%'||
  352. <foreach item="val" index="index" collection="item[3]">
  353. <if test="index==0">#{val}</if>
  354. </foreach>
  355. ||'%'
  356. </sql>
  357. <sql id="queryLike" databaseId="sqlServer">
  358. like '%'+
  359. <foreach item="val" index="index" collection="item[3]">
  360. <if test="index==0">#{val}</if>
  361. </foreach>
  362. +'%'
  363. </sql>
  364. <!-- 已过期 -->
  365. <select id="queryListForSearch" resultMap="resultMap">
  366. select
  367. <include refid="column_list" />
  368. ,c.CATEGORY_TITLE,cl.column_path,c.CATEGORY_id,cl.COLUMN_CM_ID,cl.column_type
  369. from cms_article a
  370. left join basic b
  371. on b.basic_id=a.ARTICLE_BASICID
  372. left join category c
  373. ON b.BASIC_CATEGORYID = c.CATEGORY_ID
  374. left join
  375. basic_column cl
  376. on c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
  377. <if test="tableName!=null">left join ${tableName} d on d.basicId=a.ARTICLE_BASICID
  378. </if>
  379. where c.DEL=0 and a.ARTICLE_WEBID = #{websiteId}
  380. <if test="ids!=null">
  381. and
  382. b.BASIC_CATEGORYID in
  383. <foreach item="id" index="key" collection="ids" open="("
  384. separator="," close=")">
  385. #{id.categoryId}
  386. </foreach>
  387. </if>
  388. <foreach item="item" index="key" collection="map" open=""
  389. separator="" close="">
  390. <if test=" item[0] == false">
  391. and ${key}
  392. </if>
  393. <if test="item[0]== true">
  394. and d.${key}
  395. </if>
  396. <!-- 数字类型的查找 item[1]:字段是否为数字类型false:数字 -->
  397. <if test="item[1] == false">
  398. <!--item[2]: 是采用等值还是区间查询。false:区间 itme[3][0]第一个值item[3][1]的二个值 -->
  399. <if test="item[2] == true">
  400. =
  401. <foreach item="val" index="index" collection="item[3]">#{val}
  402. </foreach>
  403. </if>
  404. <if test="item[2] == false">
  405. between
  406. <foreach item="val" index="index" collection="item[3]"
  407. separator="and">
  408. #{val}
  409. </foreach>
  410. </if>
  411. </if>
  412. <!-- 字符型数据的查找 item[1]:字段是否为数字类型true:字符串 -->
  413. <if test="item[1] == true">
  414. <!--item[2]: 是采用模糊查询。false:不采用模糊 -->
  415. <if test="item[2] == true">
  416. <include refid="queryLike"></include>
  417. </if>
  418. <if test="item[2] == false">
  419. =
  420. <foreach item="val" index="index" collection="item[3]">#{val}
  421. </foreach>
  422. </if>
  423. </if>
  424. </foreach>
  425. <if test="sortMap!=null">
  426. order by ${sortMap.order} ${sortMap.by}
  427. </if>
  428. </select>
  429. <!-- 根据字段条件查找文章实体结束 -->
  430. <!--已过期 根据字段条件查找文章实体总数开始 -->
  431. <select id="getSearchCount" resultType="int">
  432. select count(*) from
  433. cms_article a
  434. left join basic b
  435. on
  436. b.basic_id=a.ARTICLE_BASICID
  437. left join category c
  438. ON b.BASIC_CATEGORYID
  439. = c.CATEGORY_ID
  440. left join basic_column cl
  441. on c.CATEGORY_ID =
  442. cl.COLUMN_CATEGORY_ID
  443. <if test="tableName!=null and tableName!=''">left join ${tableName} d on d.basicId=a.ARTICLE_BASICID
  444. </if>
  445. where a.ARTICLE_WEBID = #{websiteId}
  446. <if test="ids!=null and ids!=''">
  447. and FIND_IN_SET(category_categoryid,'${ids}')
  448. </if>
  449. <foreach item="item" index="key" collection="map" open=""
  450. separator="" close="">
  451. <if test=" item[0] == false">
  452. and ${key}
  453. </if>
  454. <if test="item[0]== true">
  455. and d.${key}
  456. </if>
  457. <!-- 数字类型的查找 item[1]:字段是否为数字类型false:数字 -->
  458. <if test="item[1] == false">
  459. <!--item[2]: 是采用等值还是区间查询。false:区间 itme[3][0]第一个值item[3][1]的二个值 -->
  460. <if test="item[2] == true">
  461. =
  462. <foreach item="val" index="index" collection="item[3]">#{val}
  463. </foreach>
  464. </if>
  465. <if test="item[2] == false">
  466. between
  467. <foreach item="val" index="index" collection="item[3]"
  468. separator="and">
  469. #{val}
  470. </foreach>
  471. </if>
  472. </if>
  473. <!-- 字符型数据的查找 item[1]:字段是否为数字类型true:字符串 -->
  474. <if test="item[1] == true">
  475. <!--item[2]: 是采用模糊查询。false:不采用模糊 -->
  476. <if test="item[2] == true">
  477. <include refid="queryLike"></include>
  478. </if>
  479. <if test="item[2] == false">
  480. =
  481. <foreach item="val" index="index" collection="item[3]">#{val}
  482. </foreach>
  483. </if>
  484. </if>
  485. </foreach>
  486. </select>
  487. <!-- 根据字段条件查找文章实体总数结束 -->
  488. <select id="getById" resultMap="viewResultMap">
  489. select
  490. <include refid="basic_data_list" />
  491. from
  492. (((basic JOIN cms_article ON (BASIC_ID = ARTICLE_BASICID))
  493. JOIN basic_column ON (BASIC_CATEGORYID = COLUMN_CATEGORY_ID))
  494. JOIN category ON (COLUMN_CATEGORY_ID = CATEGORY_ID))
  495. <if test="contentModelTableName!=null">
  496. left join ${contentModelTableName} cmt on
  497. cmt.basicid=basic_id
  498. </if>
  499. where basic_id=#{basicId}
  500. </select>
  501. <!-- 通过文章标题、应用ID、模块编号来查询文章集合开始 -->
  502. <resultMap type="java.util.HashMap" id="resultTitleMap">
  503. <result column="basic_id" property="basicId" />
  504. <result column="basic_title" property="basicTitle" />
  505. <result column="basic_hit" property="basicHit" />
  506. <result column="basic_categoryid" property="basicCategoryId" />
  507. <result column="model_id" property="modelId" />
  508. </resultMap>
  509. <!-- 已过期 -->
  510. <!-- 查找上一篇下一篇 -->
  511. <sql id="selectOne">
  512. from
  513. (((basic JOIN cms_article ON (BASIC_ID = ARTICLE_BASICID))
  514. JOIN basic_column ON (BASIC_CATEGORYID = COLUMN_CATEGORY_ID))
  515. JOIN category ON (COLUMN_CATEGORY_ID = CATEGORY_ID))
  516. where category_appid=#{appId}
  517. <if test="flag==false">
  518. and basic_id &lt; ${basicId}
  519. </if>
  520. <if test="flag==true">
  521. and basic_id &gt; ${basicId}
  522. </if>
  523. <if test="categoryId!=null">
  524. and BASIC_CATEGORYID = #{categoryId}
  525. </if>
  526. </sql>
  527. <!-- 已过期 -->
  528. <select id="getNextOrPrevious" resultMap="resultMap" databaseId="mysql">
  529. select
  530. <include refid="basic_data_list" />
  531. <include refid="selectOne"></include>
  532. <if test="flag==false">
  533. order by basic_id desc
  534. </if>
  535. <if test="flag==true">
  536. order by basic_id asc
  537. </if>
  538. limit 0,1
  539. </select>
  540. <!-- 已过期 -->
  541. <select id="getNextOrPrevious" resultMap="resultMap" databaseId="oracle">
  542. select
  543. <include refid="basic_data_list" />
  544. <include refid="selectOne"></include>
  545. and rownum=1
  546. <if test="flag==false">
  547. order by basic_id desc
  548. </if>
  549. <if test="flag==true">
  550. order by basic_id asc
  551. </if>
  552. </select>
  553. <!-- 已过期 -->
  554. <select id="getNextOrPrevious" resultMap="resultMap" databaseId="sqlServer">
  555. select top(1)
  556. <include refid="basic_data_list" />
  557. <include refid="selectOne"></include>
  558. <if test="flag==false">
  559. order by basic_id desc
  560. </if>
  561. <if test="flag==true">
  562. order by basic_id asc
  563. </if>
  564. </select>
  565. <sql id="queryTime" databaseId="oracle">
  566. to_date(#{dateTime},'yyyy-MM-dd HH24:mi:ss')
  567. </sql>
  568. <sql id="queryTime" databaseId="mysql">
  569. #{dateTime}
  570. </sql>
  571. <sql id="queryTime" databaseId="sqlServer">
  572. #{dateTime}
  573. </sql>
  574. <!-- 已过期 -->
  575. <select id="getByCategoryId" resultMap="resultMap">
  576. select
  577. <include refid="basic_data_list" />
  578. from
  579. (((basic JOIN cms_article ON (BASIC_ID = ARTICLE_BASICID))
  580. JOIN basic_column ON (BASIC_CATEGORYID = COLUMN_CATEGORY_ID))
  581. JOIN category ON (COLUMN_CATEGORY_ID = CATEGORY_ID))
  582. where basic_categoryId=#{categoryId} order by basic_id desc
  583. </select>
  584. <!-- 根据basicID删除开始 -->
  585. <delete id="delete">
  586. delete from cms_article
  587. <where>
  588. ARTICLE_BASICID in
  589. <foreach collection="ids" item="item" index="index" open="("
  590. separator="," close=")">#{item}</foreach>
  591. </where>
  592. </delete>
  593. </mapper>