<?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.playlet.system.mapper.PlayletPublicAccountMapper">

    <resultMap type="PlayletPublicAccount" id="PlayletPublicAccountResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="publicType"    column="public_type"    />
        <result property="detailType"    column="detail_type"    />
        <result property="detailTags"    column="detail_tags"    />
        <result property="introduction"    column="introduction"    />
        <result property="authorAlias"    column="author_alias"    />
        <result property="managerId"    column="manager_id"    />
        <result property="managerIds"    column="manager_ids"    />
        <result property="logoUrl"    column="logo_url"    />
        <result property="address"    column="address"    />
        <result property="originalContentCount"    column="original_content_count"    />
        <result property="followersCount"    column="followers_count"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectPlayletPublicAccountVo">
        select id, name, public_type, detail_type, detail_tags, introduction, author_alias, manager_id, manager_ids, logo_url, address, original_content_count, followers_count, create_by, create_time, update_by, update_time, remark from playlet_public_account
    </sql>

    <select id="selectPlayletPublicAccountList" parameterType="PlayletPublicAccount" resultMap="PlayletPublicAccountResult">
        <include refid="selectPlayletPublicAccountVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="managerId != null"> and manager_id = #{managerId}</if>
            <if test="managerIds != null"> and manager_ids like concat('%',#{managerIds},'%') </if>
            <if test="introduction != null  and introduction != ''"> and introduction = #{introduction}</if>
            <if test="authorAlias != null  and authorAlias != ''"> and author_alias = #{authorAlias}</if>
            <if test="logoUrl != null  and logoUrl != ''"> and logo_url = #{logoUrl}</if>
            <if test="publicType != null  and publicType != ''"> and public_type = #{publicType}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="originalContentCount != null "> and original_content_count = #{originalContentCount}</if>
            <if test="followersCount != null "> and followers_count = #{followersCount}</if>
        </where>
    </select>

    <select id="selectPlayletPublicAccountById" parameterType="Long" resultMap="PlayletPublicAccountResult">
        <include refid="selectPlayletPublicAccountVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlayletPublicAccount" parameterType="PlayletPublicAccount" useGeneratedKeys="true" keyProperty="id">
        insert into playlet_public_account
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="publicType != null">public_type,</if>
            <if test="detailType != null">detail_type,</if>
            <if test="detailTags != null">detail_tags,</if>
            <if test="introduction != null">introduction,</if>
            <if test="authorAlias != null">author_alias,</if>
            <if test="managerId != null">manager_id,</if>
            <if test="managerIds != null">manager_ids,</if>
            <if test="logoUrl != null">logo_url,</if>
            <if test="address != null">address,</if>
            <if test="originalContentCount != null">original_content_count,</if>
            <if test="followersCount != null">followers_count,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="publicType != null">#{publicType},</if>
            <if test="detailType != null">#{detailType},</if>
            <if test="detailTags != null">#{detailTags},</if>
            <if test="introduction != null">#{introduction},</if>
            <if test="authorAlias != null">#{authorAlias},</if>
            <if test="managerId != null">#{managerId},</if>
            <if test="managerIds != null">#{managerIds},</if>
            <if test="logoUrl != null">#{logoUrl},</if>
            <if test="address != null">#{address},</if>
            <if test="originalContentCount != null">#{originalContentCount},</if>
            <if test="followersCount != null">#{followersCount},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updatePlayletPublicAccount" parameterType="PlayletPublicAccount">
        update playlet_public_account
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="publicType != null and publicType != ''">public_type = #{publicType},</if>
            <if test="detailType != null and detailType != ''">detail_type = #{detailType},</if>
            <if test="detailTags != null and detailTags != ''">detail_tags = #{detailTags},</if>
            <if test="introduction != null and introduction != ''">introduction = #{introduction},</if>
            <if test="authorAlias != null and authorAlias != ''">author_alias = #{authorAlias},</if>
            <if test="managerId != null and managerId != ''">manager_id = #{managerId},</if>
            <if test="managerIds != null and managerIds != ''">manager_ids = #{managerIds},</if>
            <if test="logoUrl != null and logoUrl != ''">logo_url = #{logoUrl},</if>
            <if test="address != null and address != ''">address = #{address},</if>
            <if test="originalContentCount != null">original_content_count = #{originalContentCount},</if>
            <if test="followersCount != null">followers_count = #{followersCount},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlayletPublicAccountById" parameterType="Long">
        delete from playlet_public_account where id = #{id}
    </delete>

    <delete id="deletePlayletPublicAccountByIds" parameterType="String">
        delete from playlet_public_account where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>