| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <?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.IContentDao">
- <resultMap id="resultMap" type="net.mingsoft.cms.entity.ContentEntity">
- <id column="id" property="id" /><!--编号 -->
- <result column="content_title" property="contentTitle" /><!--文章标题 -->
- <result column="content_category_id" property="contentCategoryId" /><!--所属栏目 -->
- <result column="content_type" property="contentType" /><!--文章类型 -->
- <result column="content_display" property="contentDisplay" /><!--是否显示 -->
- <result column="content_author" property="contentAuthor" /><!--文章作者 -->
- <result column="content_source" property="contentSource" /><!--文章来源 -->
- <result column="content_datetime" property="contentDatetime" /><!--发布时间 -->
- <result column="content_sort" property="contentSort" /><!--自定义顺序 -->
- <result column="content_img" property="contentImg" /><!--文章缩略图 -->
- <result column="content_description" property="contentDescription" /><!--描述 -->
- <result column="content_keyword" property="contentKeyword" /><!--关键字 -->
- <result column="content_details" property="contentDetails" /><!--文章内容 -->
- <result column="content_url" property="contentUrl" /><!--文章跳转链接地址 -->
- <result column="content_hit" property="contentHit" /><!--点击次数 -->
- <result column="app_id" property="appId" /><!--文章管理的应用id -->
- <result column="create_by" property="createBy" /><!--创建人 -->
- <result column="create_date" property="createDate" /><!--创建时间 -->
- <result column="update_by" property="updateBy" /><!--修改人 -->
- <result column="update_date" property="updateDate" /><!--修改时间 -->
- <result column="del" property="del" /><!--删除标记 -->
- </resultMap>
- <resultMap id="resultContentMap" type="net.mingsoft.cms.bean.ContentBean">
- <id column="id" property="id" /><!--编号 -->
- <result column="content_title" property="contentTitle" /><!--文章标题 -->
- <result column="content_category_id" property="contentCategoryId" /><!--所属栏目 -->
- <result column="content_type" property="contentType" /><!--文章类型 -->
- <result column="content_display" property="contentDisplay" /><!--是否显示 -->
- <result column="content_author" property="contentAuthor" /><!--文章作者 -->
- <result column="content_source" property="contentSource" /><!--文章来源 -->
- <result column="content_datetime" property="contentDatetime" /><!--发布时间 -->
- <result column="content_sort" property="contentSort" /><!--自定义顺序 -->
- <result column="content_img" property="contentImg" /><!--文章缩略图 -->
- <result column="content_description" property="contentDescription" /><!--描述 -->
- <result column="content_keyword" property="contentKeyword" /><!--关键字 -->
- <result column="content_details" property="contentDetails" /><!--文章内容 -->
- <result column="content_url" property="contentUrl" /><!--文章跳转链接地址 -->
- <result column="static_url" property="staticUrl" /><!--静态地址 -->
- <result column="content_hit" property="contentHit" /><!--点击次数 -->
- <result column="app_id" property="appId" /><!--文章管理的应用id -->
- <result column="create_by" property="createBy" /><!--创建人 -->
- <result column="create_date" property="createDate" /><!--创建时间 -->
- <result column="update_by" property="updateBy" /><!--修改人 -->
- <result column="update_date" property="updateDate" /><!--修改时间 -->
- <result column="del" property="del" /><!--删除标记 -->
- </resultMap>
- <resultMap id="resultBean" type="net.mingsoft.cms.bean.CategoryBean">
- <id column="id" property="id" /><!--编号 -->
- <id column="article_Id" property="articleId" /><!--编号 -->
- <result column="category_title" property="categoryTitle" /><!--栏目管理名称 -->
- <result column="category_id" property="categoryId" /><!--所属栏目 -->
- <result column="category_type" property="categoryType" /><!--栏目管理属性 -->
- <result column="category_sort" property="categorySort" /><!--自定义顺序 -->
- <result column="category_list_url" property="categoryListUrl" /><!--列表模板 -->
- <result column="category_url" property="categoryUrl" /><!--内容模板 -->
- <result column="category_keyword" property="categoryKeyword" /><!--栏目管理关键字 -->
- <result column="category_descrip" property="categoryDescrip" /><!--栏目管理描述 -->
- <result column="category_img" property="categoryImg" /><!--缩略图 -->
- <result column="category_diy_url" property="categoryDiyUrl" /><!--自定义链接 -->
- <result column="mdiy_model_id" property="mdiyModelId" /><!--栏目管理的内容模型id -->
- <result column="category_datetime" property="categoryDatetime" /><!--类别发布时间 -->
- <result column="category_manager_id" property="categoryManagerId" /><!--发布用户id -->
- <result column="app_id" property="appId" /><!--应用编号 -->
- <result column="dict_id" property="dictId" /><!--字典对应编号 -->
- <result column="category_flag" property="categoryFlag" /><!--栏目属性 -->
- <result column="category_path" property="categoryPath" /><!--栏目路径 -->
- <result column="category_parent_id" property="categoryParentId" /><!--父类型编号 -->
- <result column="create_by" property="createBy" /><!--创建人 -->
- <result column="create_date" property="createDate" /><!--创建时间 -->
- <result column="update_by" property="updateBy" /><!--修改人 -->
- <result column="update_date" property="updateDate" /><!--修改时间 -->
- <result column="del" property="del" /><!--删除标记 -->
- </resultMap>
- <!--保存-->
- <insert id="saveEntity" useGeneratedKeys="true" keyProperty="id"
- parameterType="net.mingsoft.cms.entity.ContentEntity" >
- insert into cms_content
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="contentTitle != null and contentTitle != ''">content_title,</if>
- <if test="contentCategoryId != null and contentCategoryId != ''">content_category_id,</if>
- <if test="contentType != null ">content_type,</if>
- <if test="contentDisplay != null and contentDisplay != ''">content_display,</if>
- <if test="contentAuthor != null and contentAuthor != ''">content_author,</if>
- <if test="contentSource != null and contentSource != ''">content_source,</if>
- <if test="contentDatetime != null">content_datetime,</if>
- <if test="contentSort != null">content_sort,</if>
- <if test="contentImg != null and contentImg != ''">content_img,</if>
- <if test="contentDescription != null and contentDescription != ''">content_description,</if>
- <if test="contentKeyword != null and contentKeyword != ''">content_keyword,</if>
- <if test="contentDetails != null and contentDetails != ''">content_details,</if>
- <if test="contentUrl != null and contentUrl != ''">content_url,</if>
- <if test="contentHit != null">content_hit,</if>
- <if test="appId != null">app_id,</if>
- <if test="createBy > 0">create_by,</if>
- <if test="createDate != null">create_date,</if>
- <if test="updateBy > 0">update_by,</if>
- <if test="updateDate != null">update_date,</if>
- <if test="del != null">del,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="contentTitle != null and contentTitle != ''">#{contentTitle},</if>
- <if test="contentCategoryId != null and contentCategoryId != ''">#{contentCategoryId},</if>
- <if test="contentType != null ">#{contentType},</if>
- <if test="contentDisplay != null and contentDisplay != ''">#{contentDisplay},</if>
- <if test="contentAuthor != null and contentAuthor != ''">#{contentAuthor},</if>
- <if test="contentSource != null and contentSource != ''">#{contentSource},</if>
- <if test="contentDatetime != null">#{contentDatetime},</if>
- <if test="contentSort != null">#{contentSort},</if>
- <if test="contentImg != null and contentImg != ''">#{contentImg},</if>
- <if test="contentDescription != null and contentDescription != ''">#{contentDescription},</if>
- <if test="contentKeyword != null and contentKeyword != ''">#{contentKeyword},</if>
- <if test="contentDetails != null and contentDetails != ''">#{contentDetails},</if>
- <if test="contentUrl != null and contentUrl != ''">#{contentUrl},</if>
- <if test="contentHit != null">#{contentHit},</if>
- <if test="appId != null">#{appId},</if>
- <if test="createBy > 0">#{createBy},</if>
- <if test="createDate != null">#{createDate},</if>
- <if test="updateBy > 0">#{updateBy},</if>
- <if test="updateDate != null">#{updateDate},</if>
- <if test="del != null">#{del},</if>
- </trim>
- </insert>
- <!--更新-->
- <update id="updateEntity" parameterType="net.mingsoft.cms.entity.ContentEntity">
- update cms_content
- <set>
- <if test="contentTitle != null and contentTitle != ''">content_title=#{contentTitle},</if>
- <if test="contentCategoryId != null and contentCategoryId != ''">content_category_id=#{contentCategoryId},</if>
- <if test="contentType != null ">content_type=#{contentType},</if>
- <if test="contentDisplay != null and contentDisplay != ''">content_display=#{contentDisplay},</if>
- <if test="contentAuthor != null ">content_author=#{contentAuthor},</if>
- <if test="contentSource != null ">content_source=#{contentSource},</if>
- <if test="contentDatetime != null">content_datetime=#{contentDatetime},</if>
- <if test="contentSort != null">content_sort=#{contentSort},</if>
- <if test="contentImg != null and contentImg != ''">content_img=#{contentImg},</if>
- <if test="contentDescription != null ">content_description=#{contentDescription},</if>
- <if test="contentKeyword != null ">content_keyword=#{contentKeyword},</if>
- <if test="contentDetails != null ">content_details=#{contentDetails},</if>
- <if test="contentUrl != null and contentUrl != ''">content_url=#{contentUrl},</if>
- <if test="contentHit != null">content_hit=#{contentHit},</if>
- <if test="appId != null">app_id=#{appId},</if>
- <if test="createBy > 0">create_by=#{createBy},</if>
- <if test="createDate != null">create_date=#{createDate},</if>
- <if test="updateBy > 0">update_by=#{updateBy},</if>
- <if test="updateDate != null">update_date=#{updateDate},</if>
- <if test="del != null">del=#{del},</if>
- </set>
- where id = #{id}
- </update>
- <!--根据id获取-->
- <select id="getEntity" resultMap="resultMap" parameterType="int">
- select * from cms_content where id=#{id}
- </select>
- <!--根据实体获取-->
- <select id="getByEntity" resultMap="resultMap" parameterType="net.mingsoft.cms.entity.ContentEntity">
- select * from cms_content
- <where>
- <if test="contentTitle != null and contentTitle != ''">and content_title like CONCAT('%',#{contentTitle},'%')</if>
- <if test="contentCategoryId != null and contentCategoryId != ''">and content_category_id=#{contentCategoryId}</if>
- <if test="contentType != null and contentType != ''">and content_type=#{contentType}</if>
- <if test="contentDisplay != null and contentDisplay != ''">and content_display=#{contentDisplay}</if>
- <if test="contentAuthor != null and contentAuthor != ''">and content_author=#{contentAuthor}</if>
- <if test="contentSource != null and contentSource != ''">and content_source=#{contentSource}</if>
- <if test="contentDatetime != null"> and content_datetime=#{contentDatetime} </if>
- <if test="contentSort != null"> and content_sort=#{contentSort} </if>
- <if test="contentImg != null and contentImg != ''">and content_img=#{contentImg}</if>
- <if test="contentDescription != null and contentDescription != ''">and content_description=#{contentDescription}</if>
- <if test="contentKeyword != null and contentKeyword != ''">and content_keyword=#{contentKeyword}</if>
- <if test="contentDetails != null and contentDetails != ''">and content_details=#{contentDetails}</if>
- <if test="contentUrl != null and contentUrl != ''">and content_url=#{contentUrl}</if>
- <if test="contentHit != null">and content_hit=#{contentHit}</if>
- <if test="appId != null"> and app_id=#{appId} </if>
- <if test="createBy > 0"> and create_by=#{createBy} </if>
- <if test="createDate != null"> and create_date=#{createDate} </if>
- <if test="updateBy > 0"> and update_by=#{updateBy} </if>
- <if test="updateDate != null"> and update_date=#{updateDate} </if>
- <if test="del != null"> and del=#{del} </if>
- </where>
- limit 0,1
- </select>
- <!--删除-->
- <delete id="deleteEntity" parameterType="int">
- delete from cms_content where id=#{id}
- </delete>
- <!--批量删除-->
- <delete id="delete" >
- delete from cms_content
- <where>
- id in <foreach collection="ids" item="item" index="index"
- open="(" separator="," close=")">#{item}</foreach>
- </where>
- </delete>
- <!--查询全部-->
- <select id="queryAll" resultMap="resultMap">
- select * from cms_content order by id desc
- </select>
- <!--条件查询-->
- <select id="query" resultMap="resultContentMap">
- select ct.*,CONCAT("/html/",ct.app_id,category_path,"/",ct.id,".html") AS static_url from (
- select ct.*,cc.category_path from cms_content ct
- join cms_category cc on ct.content_category_id=cc.id
- <where>
- <if test="contentTitle != null and contentTitle != ''"> and content_title like CONCAT('%',#{contentTitle},'%')</if>
- <if test="contentCategoryId != null and contentCategoryId != ''"> and content_category_id=#{contentCategoryId}</if>
- <if test="contentType != null and contentType != ''"> and content_type LIKE CONCAT('%',#{contentType},'%')</if>
- <if test="contentDisplay != null and contentDisplay != ''"> and content_display=#{contentDisplay}</if>
- <if test="contentAuthor != null and contentAuthor != ''"> and content_author=#{contentAuthor}</if>
- <if test="contentSource != null and contentSource != ''"> and content_source=#{contentSource}</if>
- <if test="contentDatetime != null"> and content_datetime=#{contentDatetime} </if>
- <if test="contentSort != null"> and content_sort=#{contentSort} </if>
- <if test="contentImg != null and contentImg != ''"> and content_img=#{contentImg}</if>
- <if test="contentDescription != null and contentDescription != ''"> and content_description=#{contentDescription}</if>
- <if test="contentKeyword != null and contentKeyword != ''"> and content_keyword=#{contentKeyword}</if>
- <if test="contentDetails != null and contentDetails != ''"> and content_details=#{contentDetails}</if>
- <if test="contentUrl != null and contentUrl != ''"> and content_url=#{contentUrl}</if>
- <if test="contentHit != null"> and content_hit=#{contentHit}</if>
- <if test="appId != null"> and ct.app_id=#{appId} </if>
- <if test="createBy > 0"> and ct.create_by=#{createBy} </if>
- <if test="createDate != null"> and ct.create_date=#{createDate} </if>
- <if test="updateBy > 0"> and ct.update_by=#{updateBy} </if>
- <if test="updateDate != null"> and update_date=#{updateDate} </if>
- <if test="del != null"> and ct.del=#{del} </if>
- </where>
- )ct ORDER BY date_format(ct.content_datetime,'%Y-%m-%d') desc,content_sort desc
- </select>
- <sql id="queryWhereCategoryId" databaseId="mysql">
- find_in_set('${categoryId}',CATEGORY_PARENT_ID)
- </sql>
- <sql id="queryWhereCategoryId" databaseId="oracle" >
- instr(','||'${categoryId}'||',', ','||CATEGORY_PARENT_ID||',')>0
- </sql>
- <sql id="queryWhereCategoryId" databaseId="sqlServer">
- CHARINDEX(','+'${categoryId}'+',' , ','+CATEGORY_PARENT_ID +',')>0
- </sql>
- <!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 -->
- <select id="queryIdsByCategoryIdForParser" resultMap="resultBean">
- select
- cms_content.id article_id,c.*
- FROM cms_content
- LEFT JOIN cms_category c ON content_category_id = c.id
- where
- <if test="appId > 0">
- cms_content.app_id = #{appId}
- </if>
- <!-- 查询子栏目数据 -->
- <if test="categoryId > 0">
- and (content_category_id=#{categoryId} or content_category_id in
- (select id FROM cms_category where <include refid="queryWhereCategoryId"></include>))
- </if>
- <if test="beginTime!=null and beginTime!=''">
- and content_datetime >= #{beginTime}
- </if>
- <if test="endTime!=null and endTime!=''">
- and content_datetime >= #{endTime}
- </if>
- <if test="orderBy!=null and order!=null and orderBy!='' and order!=''">
- ORDER BY `${orderBy}` ${order}
- </if>
- </select>
- <select id="getSearchCount" resultType="int">
- select count(*) from
- cms_content a
- left join cms_category c
- ON a.content_category_id
- = c.id
- <if test="tableName!=null and tableName!='' and diyMap!=null">left join ${tableName} d on d.link_id=a.id
- </if>
- <where>
- a.app_id = #{websiteId}
- <if test="ids!=null and ids!=''">
- and FIND_IN_SET(content_category_id,#{ids})
- </if>
- <if test="map.content_title!=null">
- and a.content_title like CONCAT("%",#{map.content_title},"%")
- </if>
- <if test="map.content_author!=null">
- and a.content_author like CONCAT("%",#{map.content_author},"%")
- </if>
- <if test="map.content_source!=null">
- and a.content_source like CONCAT("%",#{map.content_source},"%")
- </if>
- <if test="map.content_type!=null">
- and a.content_type like CONCAT("%",#{map.content_type},"%")
- </if>
- <if test="map.content_description!=null">
- and a.content_description like CONCAT("%",#{map.content_description},"%")
- </if>
- <if test="map.content_keyword!=null">
- and a.content_keyword like CONCAT("%",#{map.content_keyword},"%")
- </if>
- <if test="map.content_details!=null">
- and a.content_details like CONCAT("%",#{map.content_details},"%")
- </if>
- <if test="tableName!=null and tableName!='' and diyMap!=null">
- <foreach item="item" index="index" collection="diyList" open=""
- separator="" close="">
- and d.${field.key} like CONCAT("%",#{item.value},"%")
- </foreach>
- </if>
- </where>
- </select>
- </mapper>
|