feat(admin): 收藏/点赞/观看记录支持按客户端平台筛选
- 设备画像按 device_id 命中,登录用户按最近一次登录会话的平台命中 - 修正 orderBy 先于动态条件导致 SQL 拼接错误的问题
This commit is contained in:
1 parent
229f1d0198
commit
8999ff395d
8 files changed
+118
-6
No files matched your search
+21
@@ -4,6 +4,27 @@ package com.fruitshorts.user.dal.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fruitshorts.user.dal.entity.AppUserSession;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AppUserSessionMapper extends BaseMapper<AppUserSession> {
|
||||
|
||||
/**
|
||||
* 最近一次登录会话平台等于指定值的用户。
|
||||
* 必须取「最近一次」而不是「存在过」:否则同一用户在 Android 登录过、
|
||||
* 后来又换 iOS,会被两端都命中,筛选结果与实际展示的系统不一致。
|
||||
*/
|
||||
@Select("""
|
||||
SELECT t.user_id
|
||||
FROM (
|
||||
SELECT DISTINCT ON (user_id) user_id, platform
|
||||
FROM app_user_session
|
||||
WHERE deleted = 0
|
||||
ORDER BY user_id, last_active_at DESC NULLS LAST, id DESC
|
||||
) t
|
||||
WHERE t.platform = #{platform}
|
||||
""")
|
||||
List<Long> selectUserIdsByLatestPlatform(@Param("platform") String platform);
|
||||
}
|
||||
Reference in new issue
Block a user