<?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.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformGzhAccountMapperExt">

  <select id="getGhIdExists"
          resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformAccount">
    select *
    from content_platform_gzh_account
    where gh_id = #{ghId}
      and create_account_id != #{createAccountId}
      and status = 1
    limit 1
  </select>

  <select id="getCooperateAccountCount" resultType="java.lang.Integer">
    select count(1)
    from content_platform_gzh_account
    where create_account_id = #{createAccountId}
    and status = 1
    <if test="param.name!= null and param.name!= ''">
      and name like concat('%', #{param.name}, '%')
    </if>
    <if test="param.ghId!= null and param.ghId!= ''">
      and gh_id = #{param.ghId}
    </if>
    <if test="param.type!= null">
      and type = #{param.type}
    </if>
  </select>

  <select id="getCooperateAccountList"
          resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhAccount">
    select *
    from content_platform_gzh_account
    where create_account_id = #{createAccountId}
      and status = 1
    <if test="param.name!= null and param.name!= ''">
      and name like concat('%', #{param.name}, '%')
    </if>
    <if test="param.ghId!= null and param.ghId!= ''">
      and gh_id = #{param.ghId}
    </if>
    <if test="param.type!= null">
      and type = #{param.type}
    </if>
    order by create_timestamp desc
    limit #{offset}, #{pageSize}
  </select>

  <select id="getGzhAccountList" resultType="com.tzld.piaoquan.api.model.vo.contentplatform.GzhAccountItem">
    select id, name
    from content_platform_gzh_account
    where create_account_id = #{createAccountId}
    and status = 1
    <if test="name != null and name != ''">
      and name like concat('%', #{name}, '%')
    </if>
    <if test="accountType!= null">
      and type = #{accountType}
    </if>
    order by create_timestamp desc
  </select>

</mapper>