package com.cyksj.mapper.manage.distribute;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cyksj.model.dto.UserDistributeDto;
import com.cyksj.model.entity.UserDistributeShared;
import org.apache.ibatis.annotations.Select;

/*
 *项目名: netflix
 *文件名: UserDistributeSharedMapper
 *创建者: JavaZou
 *创建时间:2022/11/15 11:51
 */
public interface UserDistributeSharedMapper extends BaseMapper<UserDistributeShared> {
	@Select("select ud.*,u.nickname,(select count(*) from user_distribute_shared where shared_id = ud.user_id) as inviteCount" +
			" from (select user_id,business_id from user_distribute) ud inner join user_distribute_shared us on us.shared_id = ud.user_id and us.user_id = #{userId}" +
			" inner join user u on u.id = ud.user_id")
	UserDistributeDto selectUserDistributeDtoByUserId(Long userId);
}
