ContentMapper.xml 2.47 KB
<?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="com.yoho.search.dal.ContentMapper">
    <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.Content">
        <result column="id" property="id" jdbcType="INTEGER"/>
        <result column="cid" property="cid" jdbcType="INTEGER"/>
        <result column="type" property="type" jdbcType="INTEGER"/>
        <result column="app" property="app" jdbcType="INTEGER"/>
        <result column="title" property="title" jdbcType="VARCHAR"/>
        <result column="cover" property="cover" jdbcType="VARCHAR"/>
        <result column="summary" property="summary" jdbcType="VARCHAR"/>
        <result column="relate_account" property="relateAccount" jdbcType="INTEGER"/>
    </resultMap>
    <resultMap id="ContentTagsResultMap" type="com.yoho.search.dal.model.ContentTag">
        <result column="cid" property="cid" jdbcType="INTEGER"/>
        <result column="tag_id" property="tagId" jdbcType="INTEGER"/>
        <result column="tag_name" property="tagName" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
      id,cid,`type`,app,title,cover,summary,relate_account
    </sql>
    <select id="selectMinId" resultType="java.lang.Integer" timeout="20000">
        SELECT min(id) FROM tbl_merge_content_merge
    </select>
    <select id="selectMaxId" resultType="java.lang.Integer" timeout="20000">
        SELECT max(id) FROM tbl_merge_content_merge
    </select>
    <select id="selectListByRange" resultMap="BaseResultMap" timeout="20000">
        select
        <include refid="Base_Column_List"/>
        from tbl_merge_content_merge
        where id BETWEEN #{minId} AND #{maxId}
    </select>
    <select id="selectTagsByIds" resultMap="ContentTagsResultMap" timeout="20000">
        select ts.content_id as cid,t.id as tag_id,t.name as tag_name
        from tbl_tags t,tbl_tags_show ts
        where ts.tag_id=t.id and
        ts.content_id
        <foreach collection="contentIds" item="contentId" open="in (" separator="," close=")">
            #{contentId}
        </foreach>
        union all
        select ts.content_id as cid,t.id as tag_id,t.name as tag_name
        from tbl_tags t,tbl_tags_show_girl ts
        where ts.tag_id=t.id and
        ts.content_id
        <foreach collection="contentIds" item="contentId" open="in (" separator="," close=")">
            #{contentId}
        </foreach>
    </select>
</mapper>