<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<!-- 文章管理持久化层配置文件 -->
<mapper namespace="net.mingsoft.cms.dao.IArticleDao">
	<!-- 表栏目名 开始 -->
	<sql id="column_list">
		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,
		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
	</sql>
	<!-- 表栏目名 结束 -->


	<!-- 获取表字段 开始 -->
	<resultMap type="net.mingsoft.cms.entity.ArticleEntity" id="resultMap">
		<id column="ARTICLE_BASICID" property="articleID" />				<!-- 与cms_article表绑定id -->
		<result column="ARTICLE_CONTENT" property="articleContent" />	<!-- 文章内容 -->
		<result column="ARTICLE_AUTHOR" property="articleAuthor" />		<!-- 文章作者 -->
		<result column="ARTICLE_TYPE" property="articleType" />			<!-- 文章属性 -->
		<result column="ARTICLE_SOURCE" property="articleSource" />		<!-- 文章来源 -->
		<result column="ARTICLE_URL" property="articleUrl" />			<!-- 文章跳转链接地址 -->
		<result column="ARTICLE_KEYWORD" property="articleKeyword" />	<!-- 文章关键字 -->
		<result column="ARTICLE_FREEORDER" property="articleFreeOrder" /><!-- 
			文章自定义显示顺序 -->
		<result column="ARTICLE_WEBID" property="articleWebId" />				<!-- 站点id -->
		<result column="BASIC_ID" property="basicId" />					<!-- 与表basic绑定 自增长ID -->
		<result column="BASIC_TITLE" property="basicTitle" />			<!-- 文章标题 -->
		<result column="BASIC_DESCRIPTION" property="basicDescription" /><!-- 
			文章描述 -->
		<result column="BASIC_THUMBNAILS" property="basicThumbnails" />	<!-- 文章缩略图 -->
		<result column="BASIC_HIT" property="basicHit" />				<!-- 文章点击次数 -->
		<result column="BASIC_DATETIME" property="basicDateTime" />		<!-- 文章发布时间 -->
		<result column="BASIC_UPDATETIME" property="basicUpdateTime" />	<!-- 文章更新时间 -->
		<result column="BASIC_PEOPLEID" property="basicPeopleId" />		<!-- 文章发布者id -->
		<result column="BASIC_CATEGORYID" property="basicCategoryId" />	<!-- 文章所属主栏目id -->
		<result column="BASIC_SORT" property="basicSort" />
		<result column="BASIC_DISPLAY" property="basicDisplay" />
		<!-- 一对一关联栏目 -->
		<association property="column" column="COLUMN_CATEGORY_ID"
			javaType="net.mingsoft.basic.entity.ColumnEntity">
			<result property="columnPath" column="column_path" />
			<result property="categoryTitle" column="category_title" />
			<result property="categoryId" column="category_id" />
			<result property="columnContentModelId" column="COLUMN_CM_ID" />
			<result property="columnType" column="COLUMN_TYPE" />
		</association>
	</resultMap>
	<!-- 获取表字段 结束 -->
	<!-- 通过视图查询返回结果集 开始 -->
	<resultMap type="net.mingsoft.cms.bean.ColumnArticleIdBean" id="resultMapBean">
		<result column="ARTICLE_BASICID" property="articleId" />	
		<result column="column_path" property="columnPath"/>			
		<result column="column_url" property="columnUrl" />
		<result column="category_title" property="categoryTitle" />
		<result column="category_id" property="categoryId" />
		<result column="COLUMN_CM_ID" property="columnContentModelId" />
		<result column="COLUMN_TYPE" property="columnType" />
	</resultMap>
	<!-- 通过视图查询返回结果集 结束 -->
	<!-- 通过视图查询返回结果集 开始 -->
	<resultMap type="net.mingsoft.cms.entity.ArticleEntity" id="viewResultMap">
		<id column="ARTICLE_BASICID" property="articleID" />				<!-- 与cms_article表绑定id -->
		<result column="ARTICLE_CONTENT" property="articleContent" />	<!-- 文章内容 -->
		<result column="ARTICLE_AUTHOR" property="articleAuthor" />		<!-- 文章作者 -->
		<result column="ARTICLE_TYPE" property="articleType" />			<!-- 文章属性 -->
		<result column="ARTICLE_SOURCE" property="articleSource" />		<!-- 文章来源 -->
		<result column="ARTICLE_URL" property="articleUrl" />			<!-- 文章跳转链接地址 -->
		<result column="ARTICLE_KEYWORD" property="articleKeyword" />	<!-- 文章关键字 -->
		<result column="ARTICLE_FREEORDER" property="articleFreeOrder" /><!-- 
			文章自定义显示顺序 -->
		<result column="ARTICLE_WEBID" property="articleWebId" />				<!-- 站点id -->

		<result column="BASIC_ID" property="basicId" />					<!-- 与表basic绑定 自增长ID -->
		<result column="BASIC_TITLE" property="basicTitle" />			<!-- 文章标题 -->
		<result column="BASIC_DESCRIPTION" property="basicDescription" /><!-- 
			文章描述 -->
		<result column="BASIC_THUMBNAILS" property="basicThumbnails" />	<!-- 文章缩略图 -->
		<result column="BASIC_HIT" property="basicHit" />				<!-- 文章点击次数 -->
		<result column="BASIC_DATETIME" property="basicDateTime" />		<!-- 文章发布时间 -->
		<result column="BASIC_UPDATETIME" property="basicUpdateTime" />	<!-- 文章更新时间 -->
		<result column="BASIC_CATEGORYID" property="basicCategoryId" />	<!-- 文章所属主栏目id -->
		<result column="BASIC_SORT" property="basicSort" />
		<result column="BASIC_DISPLAY" property="basicDisplay" />
		<!-- 一对一关联栏目 -->
		<association property="column"
			javaType="net.mingsoft.basic.entity.ColumnEntity">
			<result property="columnPath" column="column_path" />
			<result property="categoryTitle" column="category_title" />
			<result property="categoryId" column="category_id" />
			<result property="columnContentModelId" column="COLUMN_CM_ID" />
			<result property="columnType" column="COLUMN_TYPE" />
		</association>
	</resultMap>
	<!-- 通过视图查询返回结果集 结束 -->

	<!-- 文章bean返回数据列表 开始 -->
	<sql id="bean_column_list">
		BASIC_ID,ARTICLE_AUTHOR,ARTICLE_TYPE,ARTICLE_SOURCE,ARTICLE_URL,ARTICLE_KEYWORD,ARTICLE_FREEORDER,
		BASIC_DISPLAY,BASIC_TITLE,BASIC_DESCRIPTION,BASIC_THUMBNAILS,BASIC_HIT,BASIC_DATETIME,BASIC_UPDATETIME,BASIC_PEOPLEID,BASIC_CATEGORYID,BASIC_SORT
	</sql>
	<!-- 表栏目名结束 -->
	
	<!-- 文章基础数据返回数据列表 开始 -->
	<sql id="basic_data_list">
		BASIC_DISPLAY,BASIC_ID,BASIC_CATEGORYID,BASIC_TITLE,BASIC_DESCRIPTION,BASIC_THUMBNAILS,BASIC_HIT,BASIC_DATETIME,BASIC_UPDATETIME,BASIC_PEOPLEID,BASIC_SORT,
		ARTICLE_BASICID,ARTICLE_AUTHOR,ARTICLE_CONTENT,ARTICLE_TYPE,ARTICLE_SOURCE,ARTICLE_URL,ARTICLE_KEYWORD,ARTICLE_FREEORDER,ARTICLE_WEBID,
		COLUMN_KEYWORD,COLUMN_DESCRIP,COLUMN_TYPE,COLUMN_URL,COLUMN_LISTURL,COLUMN_PATH,COLUMN_CM_ID,COLUMN_CATEGORY_ID,
		CATEGORY_TITLE,CATEGORY_APPID,CATEGORY_ID
	</sql>
	<!-- 文章基础数据返回数据列表结束 -->

	<!-- 添加文章信息 开始 -->
	<insert id="saveEntity" parameterType="net.mingsoft.base.entity.BaseEntity">
		insert into cms_article
		<!-- 添加表字段 -->
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="basicId != null">ARTICLE_BASICID,</if>
			<if test="articleContent != null">ARTICLE_CONTENT,</if>
			<if test="articleAuthor != null">ARTICLE_AUTHOR,</if>
			<if test="articleType != null">ARTICLE_TYPE,</if>
			<if test="articleSource != null">ARTICLE_SOURCE,</if>
			<if test="articleUrl != null">ARTICLE_URL,</if>
			<if test="articleKeyword != null">ARTICLE_KEYWORD,</if>
			<if test="articleFreeOrder != null">ARTICLE_FREEORDER,</if>
			<if test="articleWebId != null">ARTICLE_WEBID,</if>
		</trim>
		<!-- 注入控制层字段 -->
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="basicId != null">#{basicId},</if>
			<if test="articleContent != null">#{articleContent},</if>
			<if test="articleAuthor != null">#{articleAuthor},</if>
			<if test="articleType != null">#{articleType},</if>
			<if test="articleSource != null">#{articleSource},</if>
			<if test="articleUrl != null">#{articleUrl},</if>
			<if test="articleKeyword != null">#{articleKeyword},</if>
			<if test="articleFreeOrder != null">#{articleFreeOrder},</if>
			<if test="articleWebId != null">#{articleWebId},</if>
		</trim>
	</insert>
	<!-- 添加文章信息 结束 -->

	<!-- 删除文章管理的信息 开始 -->
	<delete id="deleteEntity" parameterType="int">
		DELETE b from basic b WHERE b.basic_id=#{basicId};
		DELETE c from cms_article c WHERE c.article_basicid=#{basicId}
	</delete>
	<!-- 删除文章管理的信息 结束 -->

	<!-- 更新文章管理的信息 开始 -->
	<update id="updateEntity" parameterType="net.mingsoft.base.entity.BaseEntity">
		update cms_article
		<set>
			<if test="articleContent != null">ARTICLE_CONTENT=#{articleContent},</if>
			<if test="articleAuthor != null">ARTICLE_AUTHOR=#{articleAuthor},</if>
			<if test="articleType != null">ARTICLE_TYPE=#{articleType},</if>
			<if test="articleSource != null">ARTICLE_SOURCE=#{articleSource},</if>
			<if test="articleUrl != null">ARTICLE_URL=#{articleUrl},</if>
			<if test="articleKeyword != null">ARTICLE_KEYWORD=#{articleKeyword},</if>
			<if test="articleFreeOrder != null">ARTICLE_FREEORDER=#{articleFreeOrder},</if>
			<if test="articleWebId != null">ARTICLE_WEBID=#{articleWebId},</if>
		</set>
		where ARTICLE_BASICID = #{basicId}
	</update>
	<!-- 更新文章管理的信息 开始 -->


	<!-- 查找文章管理的信息 开始 -->
	<select id="getEntity" resultMap="resultMap" parameterType="int">
		select
		<include refid="column_list" />
		,c.CATEGORY_TITLE,cl.column_path,cl.column_type,c.CATEGORY_id,cl.COLUMN_CM_ID
		FROM
		basic b
		LEFT JOIN
		category c ON b.BASIC_CATEGORYID = c.CATEGORY_ID
		LEFT JOIN basic_column
		cl ON c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
		LEFT
		JOIN cms_article a ON
		a.ARTICLE_BASICID = b.BASIC_ID

		<!-- 查询与关联表id相同的信息 -->

		where a.ARTICLE_BASICID=#{basicId}
	</select>
	<!-- 查找文章管理的信息 结束 -->
	
	<!-- 标题字段query -->
	<sql id="queryWhereBasicTitle" databaseId="mysql">
		CONCAT('%',#{article.basicTitle},'%') 
	</sql>
	<sql id="queryWhereBasicTitle" databaseId="oracle">
		'%'||#{ article.basicTitle}||'%'
	</sql>
	<sql id="queryWhereBasicTitle" databaseId="sqlServer">
		'%'+#{ article.basicTitle}+'%'
	</sql>
	<!-- flag字段 -->
	<sql id="queryWhereFlag" databaseId="mysql">
		CONCAT('%',#{flag},'%') 
	</sql>
	<sql id="queryWhereFlag" databaseId="oracle">
		'%'||#{ flag}||'%'
	</sql>
	<sql id="queryWhereFlag" databaseId="sqlServer">
		'%'+#{ flag}+'%'
	</sql>
	<!-- noFlag字段 -->
	<sql id="queryWhereNoFlag" databaseId="mysql">
		CONCAT('%',#{noFlag},'%') 
	</sql>
	<sql id="queryWhereNoFlag" databaseId="oracle">
		'%'||#{ noFlag}||'%'
	</sql>
	<sql id="queryWhereNoFlag" databaseId="sqlServer">
		'%'+#{ noFlag}+'%'
	</sql>
	<!-- 已过期 -->
	<select id="count" resultType="int">
		select count(basic_id) FROM basic b
		LEFT JOIN category c ON
		b.BASIC_CATEGORYID = c.CATEGORY_ID
		LEFT JOIN basic_column cl ON
		c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
		LEFT JOIN cms_article a ON
		a.ARTICLE_BASICID = b.BASIC_ID
		<where>
			a.ARTICLE_WEBID = #{webId}
			<if test="article != null ">
				<if test="article.basicTitle != null and article.basicTitle != ''">
					and b.BASIC_TITLE like
					<include refid="queryWhereBasicTitle"></include>
				</if>
			</if>
			<if test="basicCategoryIds != null">
				and b.BASIC_CATEGORYID in
				<foreach collection="basicCategoryIds" index="index" item="categoryId"
					open="(" separator="," close=")">
					#{categoryId}
				</foreach>
			</if>
			<if test="flag != null">
				and a.ARTICLE_TYPE like <include refid="queryWhereFlag"></include>
			</if>
			<if test="noFlag != null">
				and a.ARTICLE_TYPE not like <include refid="queryWhereNoFlag"></include>
			</if>
		</where>
	</select>
	<!-- 列表查询结束 -->
	
	<!-- 列表查询开始 -->
	<select id="query" resultMap="resultMap" >
		select
		<include refid="column_list" />
		,c.CATEGORY_TITLE,c.CATEGORY_ID
		,cl.COLUMN_PATH,cl.COLUMN_CM_ID,cl.COLUMN_TYPE,cl.COLUMN_CATEGORY_ID 
		FROM cms_article a LEFT JOIN basic b  ON a.ARTICLE_BASICID = b.BASIC_ID 
		LEFT JOIN basic_column cl ON b.BASIC_CATEGORYID = cl.COLUMN_CATEGORY_ID 
		JOIN category c ON c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
		where a.ARTICLE_WEBID = #{webId}
		<if test="article != null ">
			<if test="article.basicTitle != null and article.basicTitle != ''">
				and b.BASIC_TITLE like
				<include refid="queryWhereBasicTitle"></include>
			</if>
		</if>
		<if test="basicCategoryIds != null">
			and b.BASIC_CATEGORYID in
			<foreach collection="basicCategoryIds" index="index" item="categoryId"
				open="(" separator="," close=")">
				#{categoryId}
			</foreach>
		</if>
		<if test="flag != null">
			and a.ARTICLE_TYPE like <include refid="queryWhereFlag"></include>
		</if>
		<if test="noFlag != null">
			and a.ARTICLE_TYPE not like <include refid="queryWhereNoFlag"></include>
		</if>
		<if test="article !=null and article.basicDisplay &gt; -1">
			and b.basic_display = #{article.basicDisplay}
		</if>
		<if test="beginTime!=null and beginTime!=''">
			and basic_updatetime &gt;= #{beginTime}
		</if>
		<if test="endTime!=null and endTime!=''">
			and basic_updatetime &gt;= #{endTime}
		</if>
		<if test="orderBy != null">
			order by
			<choose>
				<when test='orderBy=="sort"'>basic_sort</when>
				<when test='orderBy=="date"'>basic_datetime</when>
				<when test='orderBy=="hit"'>basic_hit</when>
				<when test='orderBy=="updatedate"'>basic_updatedate</when>
				<when test='orderBy=="id"'>basic_id</when>
				<otherwise>
					${orderBy}
				</otherwise>
			</choose>
		</if>
		<if test="orderBy==null">
			order by b.basic_id
		</if>
		<if test="order == true">desc</if>
		<if test="order == false">asc</if>
	</select>

	<!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 -->
	<select id="queryIdsByCategoryIdForParser" resultMap="resultMapBean" >
		select
		ARTICLE_BASICID,cl.*
		FROM cms_article a LEFT JOIN basic b  ON a.ARTICLE_BASICID = b.BASIC_ID 
		LEFT JOIN basic_column cl ON b.BASIC_CATEGORYID = cl.COLUMN_CATEGORY_ID 
		JOIN category c ON c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
		where 
		<if test="appId &gt; 0">
			a.ARTICLE_WEBID = #{appId}
		</if>
		<!-- 查询子栏目数据 -->
		<if test="categoryId &gt; 0">
			and (b.basic_categoryid=#{categoryId} or b.basic_categoryid in 
				(select category_id FROM category where find_in_set(#{categoryId},CATEGORY_PARENT_ID)))
		</if>
		<if test="beginTime!=null and beginTime!=''">
			and b.basic_updatetime &gt;= #{beginTime}
		</if>
		<if test="endTime!=null and endTime!=''">
			and b.basic_updatetime &gt;= #{endTime}
		</if>
	</select>



	<!--查询页面栏目的文章 开始 -->
	<!-- 已过期 -->
	<select id="queryListByColumnId" resultMap="resultMap">
		select
		<include refid="column_list" />
		from cms_article a left join basic b on b.basic_id=a.ARTICLE_BASICID
		where b.BASIC_CATEGORYID = #{basicCategoryId}
	</select>
	<!-- 查询页面栏目的文章 结束 -->




	<!-- 根据字段条件查找文章实体开始 -->
	<sql id="queryLike" databaseId="mysql">
		like CONCAT("%",
			<foreach item="val" index="index" collection="item[3]">
				<if test="index==0">#{val}</if>
			</foreach>
			,"%")
	</sql>
	<sql id="queryLike" databaseId="oracle">
		like '%'||
			<foreach item="val" index="index" collection="item[3]">
				<if test="index==0">#{val}</if>
			</foreach>
			||'%')
	</sql>
	<sql id="queryLike" databaseId="sqlServer">
		like '%'+
			<foreach item="val" index="index" collection="item[3]">
				<if test="index==0">#{val}</if>
			</foreach>
			 +'%')
	</sql>
	<!-- 已过期 -->
	<select id="queryListForSearch" resultMap="resultMap">
		select
		<include refid="column_list" />
		,c.CATEGORY_TITLE,cl.column_path,c.CATEGORY_id,cl.COLUMN_CM_ID,cl.column_type
		from cms_article a
		left join basic b
		on b.basic_id=a.ARTICLE_BASICID
		left join category c
		ON b.BASIC_CATEGORYID = c.CATEGORY_ID
		left join
		basic_column cl
		on c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
		<if test="tableName!=null">left join ${tableName} d on d.basicId=a.ARTICLE_BASICID
		</if>
		where c.DEL=0 and a.ARTICLE_WEBID = #{websiteId}
		<if test="ids!=null">
			and
			b.BASIC_CATEGORYID in
			<foreach item="id" index="key" collection="ids" open="("
				separator="," close=")">
				#{id.categoryId}
			</foreach>
		</if>
		<foreach item="item" index="key" collection="map" open=""
			separator="" close="">
			<if test=" item[0] == false">
				and ${key}
			</if>
			<if test="item[0]== true">
				and d.${key}
			</if>
			<!-- 数字类型的查找 item[1]:字段是否为数字类型false:数字 -->
			<if test="item[1] == false">
				<!--item[2]： 是采用等值还是区间查询。false:区间 itme[3][0]第一个值item[3][1]的二个值 -->
				<if test="item[2] == true">
					=
					<foreach item="val" index="index" collection="item[3]">#{val}
					</foreach>
				</if>
				<if test="item[2] == false">
					between
					<foreach item="val" index="index" collection="item[3]"
						separator="and">
						#{val}
					</foreach>
				</if>
			</if>
			<!-- 字符型数据的查找 item[1]:字段是否为数字类型true:字符串 -->
			<if test="item[1] == true">
				<!--item[2]： 是采用模糊查询。false:不采用模糊 -->
				<if test="item[2] == true">
					<include refid="queryLike"></include>
				</if>
				<if test="item[2] == false">
					=
					<foreach item="val" index="index" collection="item[3]">#{val}
					</foreach>
				</if>
			</if>
		</foreach>
		<if test="sortMap!=null">
			order by ${sortMap.order} ${sortMap.by}
		</if>
	</select>
	<!-- 根据字段条件查找文章实体结束 -->

	<!--已过期 根据字段条件查找文章实体总数开始 -->
	<select id="getSearchCount" resultType="int">
		select count(*) from
		cms_article a
		left join basic b
		on
		b.basic_id=a.ARTICLE_BASICID
		left join category c
		ON b.BASIC_CATEGORYID
		= c.CATEGORY_ID
		left join basic_column cl
		on c.CATEGORY_ID =
		cl.COLUMN_CATEGORY_ID
		<if test="tableName!=null">left join ${tableName} d on d.basicId=a.ARTICLE_BASICID
		</if>
		where a.ARTICLE_WEBID = #{websiteId} 

		<if test="ids!=null">
			and
			b.BASIC_CATEGORYID in
			<foreach item="id" index="key" collection="ids" open="("
				separator="," close=")">
				#{id.categoryId}
			</foreach>
		</if>

		<foreach item="item" index="key" collection="map" open=""
			separator="" close="">
			<if test=" item[0] == false">
				and ${key}
			</if>
			<if test="item[0]== true">
				and d.${key}
			</if>
			<!-- 数字类型的查找 item[1]:字段是否为数字类型false:数字 -->
			<if test="item[1] == false">
				<!--item[2]： 是采用等值还是区间查询。false:区间 itme[3][0]第一个值item[3][1]的二个值 -->
				<if test="item[2] == true">
					=
					<foreach item="val" index="index" collection="item[3]">#{val}
					</foreach>
				</if>
				<if test="item[2] == false">
					between
					<foreach item="val" index="index" collection="item[3]"
						separator="and">
						#{val}
					</foreach>
				</if>
			</if>
			<!-- 字符型数据的查找 item[1]:字段是否为数字类型true:字符串 -->
			<if test="item[1] == true">
				<!--item[2]： 是采用模糊查询。false:不采用模糊 -->
				<if test="item[2] == true">
					<include refid="queryLike"></include>
				</if>
				<if test="item[2] == false">
					=
					<foreach item="val" index="index" collection="item[3]">#{val}
					</foreach>
				</if>
			</if>
		</foreach>
	</select>
	<!-- 根据字段条件查找文章实体总数结束 -->

	<select id="getById" resultMap="viewResultMap">
		select 
		<include refid="basic_data_list" /> 
		from 
		(((basic JOIN cms_article ON (BASIC_ID = ARTICLE_BASICID))
			JOIN basic_column ON (BASIC_CATEGORYID = COLUMN_CATEGORY_ID))
			JOIN category ON (COLUMN_CATEGORY_ID = CATEGORY_ID))
		<if test="contentModelTableName!=null">
			left join ${contentModelTableName} cmt on
			cmt.basicid=basic_id
		</if>
		where basic_id=#{basicId}
	</select>


	<!-- 通过文章标题、应用ID、模块编号来查询文章集合开始 -->
	<resultMap type="java.util.HashMap" id="resultTitleMap">
		<result column="basic_id" property="basicId" />
		<result column="basic_title" property="basicTitle" />
		<result column="basic_hit" property="basicHit" />
		<result column="basic_categoryid" property="basicCategoryId" />
		<result column="model_id" property="modelId" />

	</resultMap>
	<!-- 已过期 -->
	<!-- 查找上一篇下一篇 -->
	<sql id="selectOne">
		from 
		(((basic JOIN cms_article ON (BASIC_ID = ARTICLE_BASICID))
			JOIN basic_column ON (BASIC_CATEGORYID = COLUMN_CATEGORY_ID))
			JOIN category ON (COLUMN_CATEGORY_ID = CATEGORY_ID))
		
		 where category_appid=#{appId}
		<if test="flag==false">
			and basic_id &lt; ${basicId}

		</if>
		<if test="flag==true">
			and basic_id &gt; ${basicId}

		</if>
		<if test="categoryId!=null">
			and BASIC_CATEGORYID = #{categoryId}
		</if>
	</sql>
	<!-- 已过期 -->
	<select id="getNextOrPrevious" resultMap="resultMap" databaseId="mysql">
		select 
		<include refid="basic_data_list" />
		<include refid="selectOne"></include>
		<if test="flag==false">
			order by basic_id desc
		</if>
		<if test="flag==true">
			order by basic_id asc
		</if>
		limit 0,1
	</select>
	<!-- 已过期 -->
	<select id="getNextOrPrevious" resultMap="resultMap" databaseId="oracle">
		select 
		<include refid="basic_data_list" />
		<include refid="selectOne"></include>
		and rownum=1
		<if test="flag==false">
			order by basic_id desc
		</if>
		<if test="flag==true">
			order by basic_id asc
		</if>
	</select>
	<!-- 已过期 -->
	<select id="getNextOrPrevious" resultMap="resultMap" databaseId="sqlServer">
		select top(1)
		<include refid="basic_data_list" />
		<include refid="selectOne"></include>
		<if test="flag==false">
			order by basic_id desc
		</if>
		<if test="flag==true">
			order by basic_id asc
		</if>
	</select>
	<sql id="queryTime" databaseId="oracle">
		to_date(#{dateTime},'yyyy-MM-dd HH24:mi:ss')
	</sql>
	<sql id="queryTime" databaseId="mysql">
		#{dateTime}
	</sql>
	<sql id="queryTime" databaseId="sqlServer">
		#{dateTime}
	</sql>
	<!-- 已过期 -->
	<select id="getByCategoryId" resultMap="resultMap">
		select 
		<include refid="basic_data_list" />
		 from 
		(((basic JOIN cms_article ON (BASIC_ID = ARTICLE_BASICID))
			JOIN basic_column ON (BASIC_CATEGORYID = COLUMN_CATEGORY_ID))
			JOIN category ON (COLUMN_CATEGORY_ID = CATEGORY_ID))
		where basic_categoryId=#{categoryId} order by basic_id desc 
	</select>

	<!-- 根据basicID删除开始 -->
	<delete id="delete">
		delete from cms_article
		<where>
			ARTICLE_BASICID in
			<foreach collection="ids" item="item" index="index" open="("
				separator="," close=")">#{item}</foreach>
		</where>
	</delete>

</mapper>