|
@@ -18,42 +18,39 @@ public interface LifeFansMapper extends BaseMapper<LifeFans> {
|
|
|
@Select("<script>" +
|
|
@Select("<script>" +
|
|
|
"select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, MAX(foll.blockedType) blockedType, MAX(foll.blockedId) blockedId, MAX(foll.username) username, MAX(foll.accountBlurb) accountBlurb, MAX(foll.isMerchant) isMerchant, MAX(foll.created_time) created_time, " +
|
|
"select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, MAX(foll.blockedType) blockedType, MAX(foll.blockedId) blockedId, MAX(foll.username) username, MAX(foll.accountBlurb) accountBlurb, MAX(foll.isMerchant) isMerchant, MAX(foll.created_time) created_time, " +
|
|
|
" MAX(lb.id) blackListid, MAX(if(isnull(fans.id), 0, 1)) isFollowMe, MAX(if(isnull(fans_this.id), 0, 1)) isFollowThis, MAX(if(isnull(lb.id), '0', '1')) isBlocked, " +
|
|
" MAX(lb.id) blackListid, MAX(if(isnull(fans.id), 0, 1)) isFollowMe, MAX(if(isnull(fans_this.id), 0, 1)) isFollowThis, MAX(if(isnull(lb.id), '0', '1')) isBlocked, " +
|
|
|
- " (select count(1) from life_fans where fans_id= foll.phoneId and delete_flag =0) followNum, " +
|
|
|
|
|
- " (select count(1) from life_fans where followed_id= foll.phoneId and delete_flag =0) fansNum from ( " +
|
|
|
|
|
|
|
+ " (select count(1) from life_fans lf_cnt where lf_cnt.fans_user_type = foll.followedUserType and lf_cnt.fans_ref_id = foll.followedRefId and lf_cnt.delete_flag = 0) followNum, " +
|
|
|
|
|
+ " (select count(1) from life_fans lf_cnt2 where lf_cnt2.followed_user_type = foll.followedUserType and lf_cnt2.followed_ref_id = foll.followedRefId and lf_cnt2.delete_flag = 0) fansNum from ( " +
|
|
|
" with follow as ( " +
|
|
" with follow as ( " +
|
|
|
- " select substring_index(followed_id, '_', 1) as flag, substring_index(followed_id, '_', -1) as phone, created_time " +
|
|
|
|
|
|
|
+ " select followed_user_type as followedUserType, followed_ref_id as followedRefId, created_time " +
|
|
|
" from life_fans " +
|
|
" from life_fans " +
|
|
|
- " where delete_flag = 0 and (fans_id = #{fansId} " +
|
|
|
|
|
|
|
+ " where delete_flag = 0 " +
|
|
|
"<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
"<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
- " or (fans_user_type = #{identityUserType} and fans_ref_id = #{identityRefId}) " +
|
|
|
|
|
|
|
+ " and fans_user_type = #{identityUserType} and fans_ref_id = #{identityRefId} " +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
- ") " +
|
|
|
|
|
" ) " +
|
|
" ) " +
|
|
|
" select info.id, IF(info.store_application_status = 0, user.nick_name, info.store_name) AS NAME," +
|
|
" select info.id, IF(info.store_application_status = 0, user.nick_name, info.store_name) AS NAME," +
|
|
|
- " user.head_img image, concat('store_', user.phone) phoneId, IF(info.store_application_status = 0, user.account_blurb, info.store_blurb) AS blurb, 1 blockedType,user.id blockedId ,IFNULL(user.nick_name, user.name) username, user.account_blurb accountBlurb, IF(info.store_application_status = 1, '1', '0') AS isMerchant, foll.created_time " +
|
|
|
|
|
|
|
+ " user.head_img image, concat('store_', user.phone) phoneId, IF(info.store_application_status = 0, user.account_blurb, info.store_blurb) AS blurb, 1 blockedType,user.id blockedId ,IFNULL(user.nick_name, user.name) username, user.account_blurb accountBlurb, IF(info.store_application_status = 1, '1', '0') AS isMerchant, foll.created_time, 2 as followedUserType, user.id as followedRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join store_user user on foll.phone = user.phone " +
|
|
|
|
|
|
|
+ " join store_user user on foll.followedUserType = 2 and user.id = foll.followedRefId " +
|
|
|
" join store_info info on info.id = user.store_id " +
|
|
" join store_info info on info.id = user.store_id " +
|
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
|
- " where foll.flag = 'store' and user.delete_flag = 0 and info.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " where user.delete_flag = 0 and info.delete_flag = 0 " +
|
|
|
"<if test=\"onlyStoreFollowed == false\">" +
|
|
"<if test=\"onlyStoreFollowed == false\">" +
|
|
|
" union " +
|
|
" union " +
|
|
|
- " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb, 2 blockedType,user.id blockedId,'' username, '' accountBlurb, '0' AS isMerchant, foll.created_time " +
|
|
|
|
|
|
|
+ " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb, 2 blockedType,user.id blockedId,'' username, '' accountBlurb, '0' AS isMerchant, foll.created_time, 1 as followedUserType, user.id as followedRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join life_user user on foll.phone = user.user_phone " +
|
|
|
|
|
- " where foll.flag = 'user' and user.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " join life_user user on foll.followedUserType = 1 and user.id = foll.followedRefId " +
|
|
|
|
|
+ " where user.delete_flag = 0 " +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
") foll " +
|
|
") foll " +
|
|
|
- "left join life_fans fans on fans.fans_id = foll.phoneId and fans.delete_flag = 0 and (fans.followed_id = #{relationFansId} " +
|
|
|
|
|
|
|
+ "left join life_fans fans on fans.fans_user_type = foll.followedUserType and fans.fans_ref_id = foll.followedRefId and fans.delete_flag = 0 " +
|
|
|
"<if test=\"relationIdentityUserType != null and relationIdentityRefId != null\">" +
|
|
"<if test=\"relationIdentityUserType != null and relationIdentityRefId != null\">" +
|
|
|
- " or (fans.followed_user_type = #{relationIdentityUserType} and fans.followed_ref_id = #{relationIdentityRefId})" +
|
|
|
|
|
|
|
+ " and fans.followed_user_type = #{relationIdentityUserType} and fans.followed_ref_id = #{relationIdentityRefId} " +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
- ") " +
|
|
|
|
|
- "left join life_fans fans_this on fans_this.followed_id = foll.phoneId and fans_this.delete_flag = 0 and (fans_this.fans_id = #{relationFansId} " +
|
|
|
|
|
|
|
+ "left join life_fans fans_this on fans_this.followed_user_type = foll.followedUserType and fans_this.followed_ref_id = foll.followedRefId and fans_this.delete_flag = 0 " +
|
|
|
"<if test=\"relationIdentityUserType != null and relationIdentityRefId != null\">" +
|
|
"<if test=\"relationIdentityUserType != null and relationIdentityRefId != null\">" +
|
|
|
- " or (fans_this.fans_user_type = #{relationIdentityUserType} and fans_this.fans_ref_id = #{relationIdentityRefId})" +
|
|
|
|
|
|
|
+ " and fans_this.fans_user_type = #{relationIdentityUserType} and fans_this.fans_ref_id = #{relationIdentityRefId} " +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
- ") " +
|
|
|
|
|
"left join life_blacklist lb on lb.blocked_type = foll.blockedType and lb.blocked_id = foll.blockedId and lb.blocker_type = #{blockerType} and lb.blocker_id = #{blockerId} and lb.delete_flag = 0 " +
|
|
"left join life_blacklist lb on lb.blocked_type = foll.blockedType and lb.blocked_id = foll.blockedId and lb.blocker_type = #{blockerType} and lb.blocker_id = #{blockerId} and lb.delete_flag = 0 " +
|
|
|
"${ew.customSqlSegment} " +
|
|
"${ew.customSqlSegment} " +
|
|
|
"</script>")
|
|
"</script>")
|
|
@@ -63,106 +60,75 @@ public interface LifeFansMapper extends BaseMapper<LifeFans> {
|
|
|
@Select("<script>" +
|
|
@Select("<script>" +
|
|
|
"select foll.*, if(isnull(fans.id), 0, 1) isFollowMe, 1 as isFollowThis from ( " +
|
|
"select foll.*, if(isnull(fans.id), 0, 1) isFollowMe, 1 as isFollowThis from ( " +
|
|
|
" with follow as ( " +
|
|
" with follow as ( " +
|
|
|
- " select substring_index(followed_id, '_', 1) as flag, substring_index(followed_id, '_', -1) as phone " +
|
|
|
|
|
|
|
+ " select followed_user_type as followedUserType, followed_ref_id as followedRefId " +
|
|
|
" from life_fans " +
|
|
" from life_fans " +
|
|
|
- " where delete_flag = 0 and (fans_id = #{fansId} " +
|
|
|
|
|
|
|
+ " where delete_flag = 0 " +
|
|
|
"<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
"<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
- " or (fans_user_type = #{identityUserType} and fans_ref_id = #{identityRefId}) " +
|
|
|
|
|
|
|
+ " and fans_user_type = #{identityUserType} and fans_ref_id = #{identityRefId} " +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
- ") " +
|
|
|
|
|
" ) " +
|
|
" ) " +
|
|
|
- " select info.id, info.store_name name, img.img_url image, concat('store_', user.phone) phoneId " +
|
|
|
|
|
|
|
+ " select info.id, info.store_name name, img.img_url image, concat('store_', user.phone) phoneId, 2 as followedUserType, user.id as followedRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join store_user user on foll.phone = user.phone " +
|
|
|
|
|
|
|
+ " join store_user user on foll.followedUserType = 2 and user.id = foll.followedRefId " +
|
|
|
" join store_info info on info.id = user.store_id " +
|
|
" join store_info info on info.id = user.store_id " +
|
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
|
- " where foll.flag = 'store' and user.delete_flag = 0 and info.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " where user.delete_flag = 0 and info.delete_flag = 0 " +
|
|
|
" union " +
|
|
" union " +
|
|
|
- " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId " +
|
|
|
|
|
|
|
+ " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, 1 as followedUserType, user.id as followedRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join life_user user on foll.phone = user.user_phone " +
|
|
|
|
|
- " where foll.flag = 'user' and user.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " join life_user user on foll.followedUserType = 1 and user.id = foll.followedRefId " +
|
|
|
|
|
+ " where user.delete_flag = 0 " +
|
|
|
") foll " +
|
|
") foll " +
|
|
|
- "left join life_fans fans on fans.fans_id = foll.phoneId and fans.delete_flag = 0 and (fans.followed_id = #{fansId} " +
|
|
|
|
|
|
|
+ "left join life_fans fans on fans.fans_user_type = foll.followedUserType and fans.fans_ref_id = foll.followedRefId and fans.delete_flag = 0 " +
|
|
|
"<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
"<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
- " or (fans.followed_user_type = #{identityUserType} and fans.followed_ref_id = #{identityRefId})" +
|
|
|
|
|
|
|
+ " and fans.followed_user_type = #{identityUserType} and fans.followed_ref_id = #{identityRefId}" +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
- ") " +
|
|
|
|
|
"</script>")
|
|
"</script>")
|
|
|
List<LifeFansVo> getMyFollowedAll(@Param("fansId") String fansId, @Param("identityUserType") Integer identityUserType, @Param("identityRefId") Integer identityRefId);
|
|
List<LifeFansVo> getMyFollowedAll(@Param("fansId") String fansId, @Param("identityUserType") Integer identityUserType, @Param("identityRefId") Integer identityRefId);
|
|
|
|
|
|
|
|
@Select("<script>" +
|
|
@Select("<script>" +
|
|
|
"select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, MAX(foll.blockedType) blockedType, MAX(foll.blockedId) blockedId, MAX(foll.isMerchant) isMerchant, MAX(foll.created_time) created_time, " +
|
|
"select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, MAX(foll.blockedType) blockedType, MAX(foll.blockedId) blockedId, MAX(foll.isMerchant) isMerchant, MAX(foll.created_time) created_time, " +
|
|
|
" MAX(lb.id) blackListid, MAX(if(isnull(fans.id), 0, 1)) isFollowThis, MAX(if(isnull(fans_me.id), 0, 1)) isFollowMe, MAX(if(isnull(lb.id), '0', '1')) isBlocked, " +
|
|
" MAX(lb.id) blackListid, MAX(if(isnull(fans.id), 0, 1)) isFollowThis, MAX(if(isnull(fans_me.id), 0, 1)) isFollowMe, MAX(if(isnull(lb.id), '0', '1')) isBlocked, " +
|
|
|
- " (select count(1) from life_fans fans2 where fans2.followed_id = foll.phoneId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
- " (select count(1) from life_fans fans3 where fans3.fans_id = foll.phoneId and fans3.delete_flag = 0) followNum " +
|
|
|
|
|
|
|
+ " (select count(1) from life_fans fans2 where fans2.followed_user_type = foll.fansUserType and fans2.followed_ref_id = foll.fansRefId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
+ " (select count(1) from life_fans fans3 where fans3.fans_user_type = foll.fansUserType and fans3.fans_ref_id = foll.fansRefId and fans3.delete_flag = 0) followNum " +
|
|
|
"from ( " +
|
|
"from ( " +
|
|
|
" with follow as ( " +
|
|
" with follow as ( " +
|
|
|
- " select substring_index(fans_id, '_', 1) as flag, substring_index(fans_id, '_', -1) as phone, created_time " +
|
|
|
|
|
|
|
+ " select fans_user_type as fansUserType, fans_ref_id as fansRefId, created_time " +
|
|
|
" from life_fans " +
|
|
" from life_fans " +
|
|
|
- " where delete_flag = 0 and (followed_id = #{fansId} " +
|
|
|
|
|
|
|
+ " where delete_flag = 0 " +
|
|
|
"<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
"<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
- " or (followed_user_type = #{identityUserType} and followed_ref_id = #{identityRefId}) " +
|
|
|
|
|
|
|
+ " and followed_user_type = #{identityUserType} and followed_ref_id = #{identityRefId} " +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
- ") " +
|
|
|
|
|
" ) " +
|
|
" ) " +
|
|
|
- " select user.id, IF(info.store_application_status = 0, user.nick_name, info.store_name) AS name, user.head_img image, concat('store_', user.phone) phoneId, IF(info.store_application_status = 0, user.account_blurb, info.store_blurb) AS blurb, 1 blockedType,user.id blockedId, IF(info.store_application_status = 1, '1', '0') AS isMerchant, foll.created_time " +
|
|
|
|
|
|
|
+ " select user.id, IF(info.store_application_status = 0, user.nick_name, info.store_name) AS name, user.head_img image, concat('store_', user.phone) phoneId, IF(info.store_application_status = 0, user.account_blurb, info.store_blurb) AS blurb, 1 blockedType,user.id blockedId, IF(info.store_application_status = 1, '1', '0') AS isMerchant, foll.created_time, 2 as fansUserType, user.id as fansRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join store_user user on foll.phone = user.phone " +
|
|
|
|
|
|
|
+ " join store_user user on foll.fansUserType = 2 and user.id = foll.fansRefId " +
|
|
|
" join store_info info on info.id = user.store_id " +
|
|
" join store_info info on info.id = user.store_id " +
|
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
|
- " where foll.flag = 'store' and user.delete_flag = 0 and info.delete_flag = 0" +
|
|
|
|
|
|
|
+ " where user.delete_flag = 0 and info.delete_flag = 0" +
|
|
|
"<if test=\"onlyStoreFans == false\">" +
|
|
"<if test=\"onlyStoreFans == false\">" +
|
|
|
" union " +
|
|
" union " +
|
|
|
- " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb, 2 blockedType,user.id blockedId, '0' AS isMerchant, foll.created_time " +
|
|
|
|
|
|
|
+ " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb, 2 blockedType,user.id blockedId, '0' AS isMerchant, foll.created_time, 1 as fansUserType, user.id as fansRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join life_user user on foll.phone = user.user_phone " +
|
|
|
|
|
- " where foll.flag = 'user' and user.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " join life_user user on foll.fansUserType = 1 and user.id = foll.fansRefId " +
|
|
|
|
|
+ " where user.delete_flag = 0 " +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
") foll " +
|
|
") foll " +
|
|
|
- "left join life_fans fans on fans.followed_id = foll.phoneId and fans.delete_flag = 0 and (fans.fans_id = #{relationFansId} " +
|
|
|
|
|
|
|
+ "left join life_fans fans on fans.followed_user_type = foll.fansUserType and fans.followed_ref_id = foll.fansRefId and fans.delete_flag = 0 " +
|
|
|
"<if test=\"relationIdentityUserType != null and relationIdentityRefId != null\">" +
|
|
"<if test=\"relationIdentityUserType != null and relationIdentityRefId != null\">" +
|
|
|
- " or (fans.fans_user_type = #{relationIdentityUserType} and fans.fans_ref_id = #{relationIdentityRefId})" +
|
|
|
|
|
|
|
+ " and fans.fans_user_type = #{relationIdentityUserType} and fans.fans_ref_id = #{relationIdentityRefId}" +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
- ") " +
|
|
|
|
|
- "left join life_fans fans_me on fans_me.fans_id = foll.phoneId and fans_me.delete_flag = 0 and (fans_me.followed_id = #{relationFansId} " +
|
|
|
|
|
|
|
+ "left join life_fans fans_me on fans_me.fans_user_type = foll.fansUserType and fans_me.fans_ref_id = foll.fansRefId and fans_me.delete_flag = 0 " +
|
|
|
"<if test=\"relationIdentityUserType != null and relationIdentityRefId != null\">" +
|
|
"<if test=\"relationIdentityUserType != null and relationIdentityRefId != null\">" +
|
|
|
- " or (fans_me.followed_user_type = #{relationIdentityUserType} and fans_me.followed_ref_id = #{relationIdentityRefId})" +
|
|
|
|
|
|
|
+ " and fans_me.followed_user_type = #{relationIdentityUserType} and fans_me.followed_ref_id = #{relationIdentityRefId}" +
|
|
|
"</if>" +
|
|
"</if>" +
|
|
|
- ") " +
|
|
|
|
|
"left join life_blacklist lb on lb.blocked_type = foll.blockedType and lb.blocked_id = foll.blockedId and lb.blocker_type = #{blockerType} and lb.blocker_id = #{blockerId} and lb.delete_flag = 0 " +
|
|
"left join life_blacklist lb on lb.blocked_type = foll.blockedType and lb.blocked_id = foll.blockedId and lb.blocker_type = #{blockerType} and lb.blocker_id = #{blockerId} and lb.delete_flag = 0 " +
|
|
|
"${ew.customSqlSegment} " +
|
|
"${ew.customSqlSegment} " +
|
|
|
"</script>")
|
|
"</script>")
|
|
|
IPage<LifeFansVo> getMyFans(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param("identityUserType") Integer identityUserType, @Param("identityRefId") Integer identityRefId, @Param("relationFansId") String relationFansId, @Param("relationIdentityUserType") Integer relationIdentityUserType, @Param("relationIdentityRefId") Integer relationIdentityRefId, @Param("blockerType") String blockerType, @Param("blockerId") String blockerId, @Param("onlyStoreFans") boolean onlyStoreFans, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
IPage<LifeFansVo> getMyFans(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param("identityUserType") Integer identityUserType, @Param("identityRefId") Integer identityRefId, @Param("relationFansId") String relationFansId, @Param("relationIdentityUserType") Integer relationIdentityUserType, @Param("relationIdentityRefId") Integer relationIdentityRefId, @Param("blockerType") String blockerType, @Param("blockerId") String blockerId, @Param("onlyStoreFans") boolean onlyStoreFans, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
|
|
|
|
|
|
-// @Select("select foll.*, if(isnull(fans.id), 0, 1) isFollowThis, 1 as isFollowMe, count(fans2.id) fansNum, count(fans3.id) followNum from ( " +
|
|
|
|
|
-// " with follow as ( " +
|
|
|
|
|
-// " select substring_index(fans_id, '_', 1) as flag, substring_index(fans_id, '_', -1) as phone " +
|
|
|
|
|
-// " from life_fans " +
|
|
|
|
|
-// " where delete_flag = 0 and followed_id = #{fansId} " +
|
|
|
|
|
-// " ) " +
|
|
|
|
|
-// " select info.id," +
|
|
|
|
|
-// " \"CASE \" +\n" +
|
|
|
|
|
-// " \"WHEN user.store_id IS NULL OR info.store_application_status = 0 THEN user.nick_name \" +\n" +
|
|
|
|
|
-// " \"ELSE info.store_name \" +\n" +
|
|
|
|
|
-// " \"END AS name, \" +\n" +
|
|
|
|
|
-// " \"CASE \" +\n" +
|
|
|
|
|
-// " \"WHEN user.store_id IS NULL OR info.store_application_status IN (0, 2) THEN user.account_blurb \" +\n" +
|
|
|
|
|
-// " \"ELSE info.store_blurb \" +\n" +
|
|
|
|
|
-// " \"END AS store_blurb, \" + " +
|
|
|
|
|
-// " user.head_img image, concat('store_', user.phone) phoneId" +
|
|
|
|
|
-// " from follow foll " +
|
|
|
|
|
-// " join store_user user on foll.phone = user.phone " +
|
|
|
|
|
-// " LEFT JOIN store_info info ON user.store_id IS NOT NULL AND info.id = user.store_id " +
|
|
|
|
|
-// " and info.delete_flag = 0" +
|
|
|
|
|
-// " left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
|
|
|
-// " where foll.flag = 'store' and user.delete_flag = 0 " +
|
|
|
|
|
-// ") foll " +
|
|
|
|
|
-// "left join life_fans fans on fans.followed_id = foll.phoneId and fans.fans_id = #{fansId} and fans.delete_flag = 0 " +
|
|
|
|
|
-// "left join life_fans fans2 on fans2.followed_id = foll.phoneId and fans2.delete_flag = 0 " +
|
|
|
|
|
-// "left join life_fans fans3 on fans3.fans_id = foll.phoneId and fans3.delete_flag = 0 " +
|
|
|
|
|
-// "${ew.customSqlSegment} ")
|
|
|
|
|
- @Select("SELECT " +
|
|
|
|
|
|
|
+ @Select("<script>" +
|
|
|
|
|
+ "SELECT " +
|
|
|
"MAX(foll.id) id, " +
|
|
"MAX(foll.id) id, " +
|
|
|
"MAX(foll.name) name, " +
|
|
"MAX(foll.name) name, " +
|
|
|
"MAX(foll.blurb) blurb, " +
|
|
"MAX(foll.blurb) blurb, " +
|
|
@@ -176,14 +142,12 @@ public interface LifeFansMapper extends BaseMapper<LifeFans> {
|
|
|
"FROM " +
|
|
"FROM " +
|
|
|
"( " +
|
|
"( " +
|
|
|
"WITH follow AS ( " +
|
|
"WITH follow AS ( " +
|
|
|
- "SELECT " +
|
|
|
|
|
- "substring_index(fans_id, '_', 1) AS flag, " +
|
|
|
|
|
- "substring_index(fans_id, '_', -1) AS phone " +
|
|
|
|
|
- "FROM " +
|
|
|
|
|
- "life_fans " +
|
|
|
|
|
- "WHERE " +
|
|
|
|
|
- "delete_flag = 0 " +
|
|
|
|
|
- "AND followed_id = #{fansId} " +
|
|
|
|
|
|
|
+ "SELECT fans_user_type AS fansUserType, fans_ref_id AS fansRefId " +
|
|
|
|
|
+ "FROM life_fans " +
|
|
|
|
|
+ "WHERE delete_flag = 0 AND fans_user_type = 2 " +
|
|
|
|
|
+ "<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
|
|
+ "AND followed_user_type = #{identityUserType} AND followed_ref_id = #{identityRefId} " +
|
|
|
|
|
+ "</if>" +
|
|
|
") " +
|
|
") " +
|
|
|
"SELECT " +
|
|
"SELECT " +
|
|
|
"info.id, " +
|
|
"info.id, " +
|
|
@@ -200,119 +164,151 @@ public interface LifeFansMapper extends BaseMapper<LifeFans> {
|
|
|
"CASE " +
|
|
"CASE " +
|
|
|
"WHEN user.store_id IS NOT NULL AND info.store_application_status = 1 THEN '1' " +
|
|
"WHEN user.store_id IS NOT NULL AND info.store_application_status = 1 THEN '1' " +
|
|
|
"ELSE '0' " +
|
|
"ELSE '0' " +
|
|
|
- "END AS isMerchant " +
|
|
|
|
|
- "FROM " +
|
|
|
|
|
- "follow foll " +
|
|
|
|
|
- "JOIN store_user user ON foll.phone = user.phone " +
|
|
|
|
|
|
|
+ "END AS isMerchant, " +
|
|
|
|
|
+ "2 AS fansUserType, user.id AS fansRefId " +
|
|
|
|
|
+ "FROM follow foll " +
|
|
|
|
|
+ "JOIN store_user user ON foll.fansUserType = 2 AND user.id = foll.fansRefId " +
|
|
|
"LEFT JOIN store_info info ON user.store_id IS NOT NULL " +
|
|
"LEFT JOIN store_info info ON user.store_id IS NOT NULL " +
|
|
|
"AND info.id = user.store_id " +
|
|
"AND info.id = user.store_id " +
|
|
|
"AND info.delete_flag = 0 " +
|
|
"AND info.delete_flag = 0 " +
|
|
|
"LEFT JOIN store_img img ON img.store_id = user.store_id " +
|
|
"LEFT JOIN store_img img ON img.store_id = user.store_id " +
|
|
|
"AND img.img_type = '10' " +
|
|
"AND img.img_type = '10' " +
|
|
|
"AND img.delete_flag = 0 " +
|
|
"AND img.delete_flag = 0 " +
|
|
|
- "WHERE " +
|
|
|
|
|
- "foll.flag = 'store' " +
|
|
|
|
|
- "AND user.delete_flag = 0 " +
|
|
|
|
|
|
|
+ "WHERE user.delete_flag = 0 " +
|
|
|
") foll " +
|
|
") foll " +
|
|
|
- "LEFT JOIN life_fans fans ON fans.followed_id = foll.phoneId " +
|
|
|
|
|
- "AND fans.fans_id = #{fansId} " +
|
|
|
|
|
|
|
+ "LEFT JOIN life_fans fans ON fans.followed_user_type = foll.fansUserType AND fans.followed_ref_id = foll.fansRefId " +
|
|
|
|
|
+ "<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
|
|
+ "AND fans.fans_user_type = #{identityUserType} AND fans.fans_ref_id = #{identityRefId} " +
|
|
|
|
|
+ "</if>" +
|
|
|
"AND fans.delete_flag = 0 " +
|
|
"AND fans.delete_flag = 0 " +
|
|
|
- "LEFT JOIN life_fans fans2 ON fans2.followed_id = foll.phoneId " +
|
|
|
|
|
|
|
+ "LEFT JOIN life_fans fans2 ON fans2.followed_user_type = foll.fansUserType AND fans2.followed_ref_id = foll.fansRefId " +
|
|
|
"AND fans2.delete_flag = 0 " +
|
|
"AND fans2.delete_flag = 0 " +
|
|
|
- "LEFT JOIN life_fans fans3 ON fans3.fans_id = foll.phoneId " +
|
|
|
|
|
|
|
+ "LEFT JOIN life_fans fans3 ON fans3.fans_user_type = foll.fansUserType AND fans3.fans_ref_id = foll.fansRefId " +
|
|
|
"AND fans3.delete_flag = 0 " +
|
|
"AND fans3.delete_flag = 0 " +
|
|
|
- "${ew.customSqlSegment}")
|
|
|
|
|
- IPage<LifeFansVo> getMyStoreFans(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
|
|
|
|
|
+ "${ew.customSqlSegment}" +
|
|
|
|
|
+ "</script>")
|
|
|
|
|
+ IPage<LifeFansVo> getMyStoreFans(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param("identityUserType") Integer identityUserType, @Param("identityRefId") Integer identityRefId, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
|
|
|
|
|
|
- @Select("select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, " +
|
|
|
|
|
|
|
+ @Select("<script>" +
|
|
|
|
|
+ "select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, " +
|
|
|
" MAX(if(isnull(fans.id), 0, 1)) isFollowThis, 1 as isFollowMe, " +
|
|
" MAX(if(isnull(fans.id), 0, 1)) isFollowThis, 1 as isFollowMe, " +
|
|
|
- " (select count(1) from life_fans fans2 where fans2.followed_id = foll.phoneId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
- " (select count(1) from life_fans fans3 where fans3.fans_id = foll.phoneId and fans3.delete_flag = 0) followNum " +
|
|
|
|
|
|
|
+ " (select count(1) from life_fans fans2 where fans2.followed_user_type = foll.fansUserType and fans2.followed_ref_id = foll.fansRefId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
+ " (select count(1) from life_fans fans3 where fans3.fans_user_type = foll.fansUserType and fans3.fans_ref_id = foll.fansRefId and fans3.delete_flag = 0) followNum " +
|
|
|
" from ( " +
|
|
" from ( " +
|
|
|
" with follow as ( " +
|
|
" with follow as ( " +
|
|
|
- " select substring_index(fans_id, '_', 1) as flag, substring_index(fans_id, '_', -1) as phone " +
|
|
|
|
|
|
|
+ " select fans_user_type as fansUserType, fans_ref_id as fansRefId " +
|
|
|
" from life_fans " +
|
|
" from life_fans " +
|
|
|
- " where delete_flag = 0 and followed_id = #{fansId} " +
|
|
|
|
|
|
|
+ " where delete_flag = 0 and fans_user_type = 1 " +
|
|
|
|
|
+ "<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
|
|
+ " and followed_user_type = #{identityUserType} and followed_ref_id = #{identityRefId} " +
|
|
|
|
|
+ "</if>" +
|
|
|
" ) " +
|
|
" ) " +
|
|
|
- " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb " +
|
|
|
|
|
|
|
+ " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb, 1 as fansUserType, user.id as fansRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join life_user user on foll.phone = user.user_phone " +
|
|
|
|
|
- " where foll.flag = 'user' and user.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " join life_user user on foll.fansUserType = 1 and user.id = foll.fansRefId " +
|
|
|
|
|
+ " where user.delete_flag = 0 " +
|
|
|
") foll " +
|
|
") foll " +
|
|
|
- "left join life_fans fans on fans.followed_id = foll.phoneId and fans.fans_id = #{fansId} and fans.delete_flag = 0 " +
|
|
|
|
|
- "${ew.customSqlSegment} ")
|
|
|
|
|
- IPage<LifeFansVo> getMyUserFans(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
|
|
|
|
|
+ "left join life_fans fans on fans.followed_user_type = foll.fansUserType and fans.followed_ref_id = foll.fansRefId and fans.delete_flag = 0 " +
|
|
|
|
|
+ "<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
|
|
+ " and fans.fans_user_type = #{identityUserType} and fans.fans_ref_id = #{identityRefId}" +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "${ew.customSqlSegment} " +
|
|
|
|
|
+ "</script>")
|
|
|
|
|
+ IPage<LifeFansVo> getMyUserFans(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param("identityUserType") Integer identityUserType, @Param("identityRefId") Integer identityRefId, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
|
|
|
|
|
|
- @Select("select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, MAX(foll.blockedType) blockedType, MAX(foll.blockedId) blockedId, MAX(foll.username) username, MAX(foll.accountBlurb) accountBlurb, MAX(foll.isMerchant) isMerchant, MAX(foll.created_time) created_time, " +
|
|
|
|
|
|
|
+ @Select("<script>" +
|
|
|
|
|
+ "select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, MAX(foll.blockedType) blockedType, MAX(foll.blockedId) blockedId, MAX(foll.username) username, MAX(foll.accountBlurb) accountBlurb, MAX(foll.isMerchant) isMerchant, MAX(foll.created_time) created_time, " +
|
|
|
" MAX(lb.id) blackListid, 1 as isFollowThis, 1 as isFollowMe, " +
|
|
" MAX(lb.id) blackListid, 1 as isFollowThis, 1 as isFollowMe, " +
|
|
|
- " (select count(1) from life_fans fans2 where fans2.followed_id = foll.phoneId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
- " (select count(1) from life_fans fans3 where fans3.fans_id = foll.phoneId and fans3.delete_flag = 0) followNum " +
|
|
|
|
|
|
|
+ " (select count(1) from life_fans fans2 where fans2.followed_user_type = foll.followedUserType and fans2.followed_ref_id = foll.followedRefId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
+ " (select count(1) from life_fans fans3 where fans3.fans_user_type = foll.followedUserType and fans3.fans_ref_id = foll.followedRefId and fans3.delete_flag = 0) followNum " +
|
|
|
"from ( " +
|
|
"from ( " +
|
|
|
" with follow as ( " +
|
|
" with follow as ( " +
|
|
|
- " select substring_index(fans1.followed_id, '_', 1) as flag, substring_index(fans1.followed_id, '_', -1) as phone, " +
|
|
|
|
|
|
|
+ " select fans1.followed_user_type as followedUserType, fans1.followed_ref_id as followedRefId, " +
|
|
|
" GREATEST(fans1.created_time, fans2.created_time) as created_time " +
|
|
" GREATEST(fans1.created_time, fans2.created_time) as created_time " +
|
|
|
" from life_fans fans1 " +
|
|
" from life_fans fans1 " +
|
|
|
- " join life_fans fans2 on fans1.followed_id = fans2.fans_id and fans1.fans_id = fans2.followed_id " +
|
|
|
|
|
- " where fans1.delete_flag = 0 and fans2.delete_flag = 0 and fans1.fans_id = #{fansId} " +
|
|
|
|
|
|
|
+ " join life_fans fans2 on fans1.followed_user_type = fans2.fans_user_type and fans1.followed_ref_id = fans2.fans_ref_id " +
|
|
|
|
|
+ " and fans1.fans_user_type = fans2.followed_user_type and fans1.fans_ref_id = fans2.followed_ref_id " +
|
|
|
|
|
+ " where fans1.delete_flag = 0 and fans2.delete_flag = 0 " +
|
|
|
|
|
+ "<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
|
|
+ " and fans1.fans_user_type = #{identityUserType} and fans1.fans_ref_id = #{identityRefId} " +
|
|
|
|
|
+ "</if>" +
|
|
|
" ) " +
|
|
" ) " +
|
|
|
- " select info.id, IF(info.store_application_status = 0, user.nick_name, info.store_name) AS name, user.head_img image, concat('store_', user.phone) phoneId, IF(info.store_application_status = 0, user.account_blurb, info.store_blurb) AS blurb, 1 blockedType,user.id blockedId ,IFNULL(user.nick_name, user.name) username, user.account_blurb accountBlurb, IF(info.store_application_status = 1, '1', '0') AS isMerchant, foll.created_time " +
|
|
|
|
|
|
|
+ " select info.id, IF(info.store_application_status = 0, user.nick_name, info.store_name) AS name, user.head_img image, concat('store_', user.phone) phoneId, IF(info.store_application_status = 0, user.account_blurb, info.store_blurb) AS blurb, 1 blockedType,user.id blockedId ,IFNULL(user.nick_name, user.name) username, user.account_blurb accountBlurb, IF(info.store_application_status = 1, '1', '0') AS isMerchant, foll.created_time, 2 as followedUserType, user.id as followedRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join store_user user on foll.phone = user.phone " +
|
|
|
|
|
|
|
+ " join store_user user on foll.followedUserType = 2 and user.id = foll.followedRefId " +
|
|
|
" join store_info info on info.id = user.store_id " +
|
|
" join store_info info on info.id = user.store_id " +
|
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
|
- " where foll.flag = 'store' and user.delete_flag = 0 and info.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " where user.delete_flag = 0 and info.delete_flag = 0 " +
|
|
|
" union " +
|
|
" union " +
|
|
|
- " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb, 2 blockedType,user.id blockedId,'' username, '' accountBlurb, '0' AS isMerchant, foll.created_time " +
|
|
|
|
|
|
|
+ " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb, 2 blockedType,user.id blockedId,'' username, '' accountBlurb, '0' AS isMerchant, foll.created_time, 1 as followedUserType, user.id as followedRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join life_user user on foll.phone = user.user_phone " +
|
|
|
|
|
- " where foll.flag = 'user' and user.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " join life_user user on foll.followedUserType = 1 and user.id = foll.followedRefId " +
|
|
|
|
|
+ " where user.delete_flag = 0 " +
|
|
|
") foll " +
|
|
") foll " +
|
|
|
"left join life_blacklist lb on lb.blocked_type = foll.blockedType and lb.blocked_id = foll.blockedId and lb.blocker_type = #{blockerType} and lb.blocker_id = #{blockerId} and lb.delete_flag = 0 " +
|
|
"left join life_blacklist lb on lb.blocked_type = foll.blockedType and lb.blocked_id = foll.blockedId and lb.blocker_type = #{blockerType} and lb.blocker_id = #{blockerId} and lb.delete_flag = 0 " +
|
|
|
- "${ew.customSqlSegment} ")
|
|
|
|
|
- IPage<LifeFansVo> getMutualAttention(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param("blockerType") String blockerType, @Param("blockerId") String blockerId, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
|
|
|
|
|
+ "${ew.customSqlSegment} " +
|
|
|
|
|
+ "</script>")
|
|
|
|
|
+ IPage<LifeFansVo> getMutualAttention(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param("identityUserType") Integer identityUserType, @Param("identityRefId") Integer identityRefId, @Param("blockerType") String blockerType, @Param("blockerId") String blockerId, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
|
|
|
|
|
|
- @Select("select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, 1 as isFollowThis, 1 as isFollowMe, " +
|
|
|
|
|
- " (select count(1) from life_fans fans2 where fans2.followed_id = foll.phoneId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
- " (select count(1) from life_fans fans3 where fans3.fans_id = foll.phoneId and fans3.delete_flag = 0) followNum " +
|
|
|
|
|
|
|
+ @Select("<script>" +
|
|
|
|
|
+ "select MAX(foll.id) id, MAX(foll.name) name, MAX(foll.image) image, foll.phoneId, MAX(foll.blurb) blurb, 1 as isFollowThis, 1 as isFollowMe, " +
|
|
|
|
|
+ " (select count(1) from life_fans fans2 where fans2.followed_user_type = foll.followedUserType and fans2.followed_ref_id = foll.followedRefId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
+ " (select count(1) from life_fans fans3 where fans3.fans_user_type = foll.followedUserType and fans3.fans_ref_id = foll.followedRefId and fans3.delete_flag = 0) followNum " +
|
|
|
"from ( " +
|
|
"from ( " +
|
|
|
" with follow as ( " +
|
|
" with follow as ( " +
|
|
|
- " select substring_index(fans1.followed_id, '_', 1) as flag, substring_index(fans1.followed_id, '_', -1) as phone " +
|
|
|
|
|
|
|
+ " select fans1.followed_user_type as followedUserType, fans1.followed_ref_id as followedRefId " +
|
|
|
" from life_fans fans1 " +
|
|
" from life_fans fans1 " +
|
|
|
- " join life_fans fans2 on fans1.followed_id = fans2.fans_id and fans1.fans_id = fans2.followed_id " +
|
|
|
|
|
- " where fans1.delete_flag = 0 and fans2.delete_flag = 0 and fans1.fans_id = #{fansId} " +
|
|
|
|
|
|
|
+ " join life_fans fans2 on fans1.followed_user_type = fans2.fans_user_type and fans1.followed_ref_id = fans2.fans_ref_id " +
|
|
|
|
|
+ " and fans1.fans_user_type = fans2.followed_user_type and fans1.fans_ref_id = fans2.followed_ref_id " +
|
|
|
|
|
+ " where fans1.delete_flag = 0 and fans2.delete_flag = 0 " +
|
|
|
|
|
+ "<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
|
|
+ " and fans1.fans_user_type = #{identityUserType} and fans1.fans_ref_id = #{identityRefId} " +
|
|
|
|
|
+ "</if>" +
|
|
|
" ) " +
|
|
" ) " +
|
|
|
- " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb " +
|
|
|
|
|
|
|
+ " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, user.jianjie blurb, 1 as followedUserType, user.id as followedRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join life_user user on foll.phone = user.user_phone " +
|
|
|
|
|
- " where foll.flag = 'user' and user.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " join life_user user on foll.followedUserType = 1 and user.id = foll.followedRefId " +
|
|
|
|
|
+ " where user.delete_flag = 0 " +
|
|
|
") foll " +
|
|
") foll " +
|
|
|
- "${ew.customSqlSegment} ")
|
|
|
|
|
- IPage<LifeFansVo> getMutualAttentionUser(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
|
|
|
|
|
+ "${ew.customSqlSegment} " +
|
|
|
|
|
+ "</script>")
|
|
|
|
|
+ IPage<LifeFansVo> getMutualAttentionUser(IPage<LifeFansVo> iPage, @Param("fansId") String fansId, @Param("identityUserType") Integer identityUserType, @Param("identityRefId") Integer identityRefId, @Param(Constants.WRAPPER) QueryWrapper<LifeFansVo> wrapper);
|
|
|
|
|
|
|
|
- @Select("select (select count(1) from life_fans where fans_id = #{phoneId} and delete_flag = 0 and followed_id not REGEXP '_$') followNum, " +
|
|
|
|
|
- "(select count(1) from life_fans where followed_id= #{phoneId} and delete_flag = 0 and fans_id not REGEXP '_$') fansNum, " +
|
|
|
|
|
|
|
+ @Select("<script>" +
|
|
|
|
|
+ "select " +
|
|
|
|
|
+ "<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
|
|
+ "(select count(1) from life_fans where delete_flag = 0 and fans_user_type = #{identityUserType} and fans_ref_id = #{identityRefId}) followNum, " +
|
|
|
|
|
+ "(select count(1) from life_fans where delete_flag = 0 and followed_user_type = #{identityUserType} and followed_ref_id = #{identityRefId}) fansNum, " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test=\"identityUserType == null or identityRefId == null\">" +
|
|
|
|
|
+ "0 followNum, 0 fansNum, " +
|
|
|
|
|
+ "</if>" +
|
|
|
"(select count(1) from ( " +
|
|
"(select count(1) from ( " +
|
|
|
" select foll.*, 1 as isFollowThis, 1 as isFollowMe, " +
|
|
" select foll.*, 1 as isFollowThis, 1 as isFollowMe, " +
|
|
|
- " (select count(1) from life_fans fans2 where fans2.followed_id = foll.phoneId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
- " (select count(1) from life_fans fans3 where fans3.fans_id = foll.phoneId and fans3.delete_flag = 0) followNum " +
|
|
|
|
|
|
|
+ " (select count(1) from life_fans fans2 where fans2.followed_user_type = foll.followedUserType and fans2.followed_ref_id = foll.followedRefId and fans2.delete_flag = 0) fansNum, " +
|
|
|
|
|
+ " (select count(1) from life_fans fans3 where fans3.fans_user_type = foll.followedUserType and fans3.fans_ref_id = foll.followedRefId and fans3.delete_flag = 0) followNum " +
|
|
|
" from ( " +
|
|
" from ( " +
|
|
|
" with follow as ( " +
|
|
" with follow as ( " +
|
|
|
- " select substring_index(fans1.followed_id, '_', 1) as flag, substring_index(fans1.followed_id, '_', -1) as phone " +
|
|
|
|
|
|
|
+ " select fans1.followed_user_type as followedUserType, fans1.followed_ref_id as followedRefId " +
|
|
|
" from life_fans fans1 " +
|
|
" from life_fans fans1 " +
|
|
|
- " join life_fans fans2 on fans1.followed_id = fans2.fans_id and fans1.fans_id = fans2.followed_id " +
|
|
|
|
|
- " where fans1.delete_flag = 0 and fans2.delete_flag = 0 and fans1.fans_id = #{phoneId} " +
|
|
|
|
|
|
|
+ " join life_fans fans2 on fans1.followed_user_type = fans2.fans_user_type and fans1.followed_ref_id = fans2.fans_ref_id " +
|
|
|
|
|
+ " and fans1.fans_user_type = fans2.followed_user_type and fans1.fans_ref_id = fans2.followed_ref_id " +
|
|
|
|
|
+ " where fans1.delete_flag = 0 and fans2.delete_flag = 0 " +
|
|
|
|
|
+ "<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
|
|
+ " and fans1.fans_user_type = #{identityUserType} and fans1.fans_ref_id = #{identityRefId} " +
|
|
|
|
|
+ "</if>" +
|
|
|
" ) " +
|
|
" ) " +
|
|
|
- " select info.id, info.store_name name, img.img_url image, concat('store_', user.phone) phoneId " +
|
|
|
|
|
|
|
+ " select info.id, info.store_name name, img.img_url image, concat('store_', user.phone) phoneId, 2 as followedUserType, user.id as followedRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join store_user user on foll.phone = user.phone " +
|
|
|
|
|
|
|
+ " join store_user user on foll.followedUserType = 2 and user.id = foll.followedRefId " +
|
|
|
" join store_info info on info.id = user.store_id " +
|
|
" join store_info info on info.id = user.store_id " +
|
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
" left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0 " +
|
|
|
- " where foll.flag = 'store' and user.delete_flag = 0 and info.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " where user.delete_flag = 0 and info.delete_flag = 0 " +
|
|
|
" union " +
|
|
" union " +
|
|
|
- " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId " +
|
|
|
|
|
|
|
+ " select user.id, user.user_name name, user.user_image image, concat('user_', user.user_phone) phoneId, 1 as followedUserType, user.id as followedRefId " +
|
|
|
" from follow foll " +
|
|
" from follow foll " +
|
|
|
- " join life_user user on foll.phone = user.user_phone " +
|
|
|
|
|
- " where foll.flag = 'user' and user.delete_flag = 0 " +
|
|
|
|
|
|
|
+ " join life_user user on foll.followedUserType = 1 and user.id = foll.followedRefId " +
|
|
|
|
|
+ " where user.delete_flag = 0 " +
|
|
|
" ) foll " +
|
|
" ) foll " +
|
|
|
" ) a " +
|
|
" ) a " +
|
|
|
") friendNum, " +
|
|
") friendNum, " +
|
|
@@ -320,10 +316,10 @@ public interface LifeFansMapper extends BaseMapper<LifeFans> {
|
|
|
" select count(id) " +
|
|
" select count(id) " +
|
|
|
" from life_user_dynamics " +
|
|
" from life_user_dynamics " +
|
|
|
" where delete_flag = 0 and draft = 0 and enable_status != 1 " +
|
|
" where delete_flag = 0 and draft = 0 and enable_status != 1 " +
|
|
|
- " and phone_user_type = (case when #{phoneId} like 'user\\_%' then 1 when #{phoneId} like 'store\\_%' then 2 when #{phoneId} like 'lawyer\\_%' then 3 else null end) " +
|
|
|
|
|
- " and phone_ref_id = (case when #{phoneId} like 'user\\_%' then (select id from life_user where concat('user_', user_phone) = #{phoneId} and delete_flag = 0 limit 1) " +
|
|
|
|
|
- " when #{phoneId} like 'store\\_%' then (select id from store_user where concat('store_', phone) = #{phoneId} and delete_flag = 0 limit 1) " +
|
|
|
|
|
- " when #{phoneId} like 'lawyer\\_%' then (select id from lawyer_user where concat('lawyer_', phone) = #{phoneId} and delete_flag = 0 limit 1) else null end) " +
|
|
|
|
|
- ") dynamicsNum")
|
|
|
|
|
- LifeFansVo getHomePageInfo(@Param("phoneId") String phoneId);
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ "<if test=\"identityUserType != null and identityRefId != null\">" +
|
|
|
|
|
+ " and phone_user_type = #{identityUserType} and phone_ref_id = #{identityRefId} " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ ") dynamicsNum" +
|
|
|
|
|
+ "</script>")
|
|
|
|
|
+ LifeFansVo getHomePageInfo(@Param("phoneId") String phoneId, @Param("identityUserType") Integer identityUserType, @Param("identityRefId") Integer identityRefId);
|
|
|
|
|
+}
|