SocialUserDetailMapper.xml 2.15 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.SocialUserDetailMapper" >
  <resultMap id="followerMap" type="com.yoho.search.dal.model.UserFollower" >
    <result column="s_uid" property="s_uid" jdbcType="INTEGER" />
    <result column="s_followers_number" property="s_followers_number" jdbcType="INTEGER" />
    <result column="s_talent" property="s_talent" jdbcType="INTEGER" />
  </resultMap>
  <resultMap id="followingMap" type="com.yoho.search.dal.model.UserFollowing" >
    <result column="s_uid" property="s_uid" jdbcType="INTEGER" />
    <result column="t_uid" property="t_uid" jdbcType="INTEGER" />
    <result column="t_followers_number" property="t_followers_number" jdbcType="INTEGER" />
    <result column="t_follow_back" property="t_follow_back" jdbcType="INTEGER" />
  </resultMap>
  <select id="selectUserFollower" resultMap="followerMap" timeout="20000">
    select s.uid_attention as s_uid,
    count(distinct s.uid) as s_followers_number,
    (
      select 1
      from tbl_shoes_doctor_talent tal
      where tal.uid=s.uid_attention
      and tal.is_certification=1
    ) as s_talent
    from tbl_attention_user s
    where 1=1
    <if test="uids!=null">
        and s.uid_attention
        <foreach collection="uids" item="uid" open="in(" separator="," close=")">
          #{uid}
        </foreach>
    </if>
    group by s.uid_attention
  </select>

  <select id="selectUserFollowing" resultMap="followingMap" timeout="20000">
    select distinct s.uid as s_uid,s.uid_attention as t_uid,
    (
        select count(distinct t1.uid)
        from tbl_attention_user t1
        where t1.uid_attention=s.uid_attention
    ) as t_followers_number,
    (
        select 1
        from tbl_attention_user t2
        where t2.uid=s.uid_attention
        and t2.uid_attention=s.uid
    ) as t_follow_back
    from tbl_attention_user s
    where 1=1
    <if test="uids!=null">
        and s.uid
        <foreach collection="uids" item="uid" open="in(" separator="," close=")">
          #{uid}
        </foreach>
    </if>
  </select>
</mapper>