|
|
@@ -11,11 +11,18 @@ const router = new Router();
|
|
|
router.get('/list', optionalAuth, async (ctx: Context) => {
|
|
|
// 开发环境使用测试用户ID
|
|
|
const userId = ctx.state.user?.userId || TEST_USER_ID;
|
|
|
+ const userIdNum = parseInt(userId as string);
|
|
|
const page = parseInt(ctx.query.page as string) || 1;
|
|
|
const pageSize = parseInt(ctx.query.pageSize as string) || 20;
|
|
|
const startDate = ctx.query.startDate as string;
|
|
|
|
|
|
- const where: any = {};
|
|
|
+ // 用户隔离:只返回本人(或游客 null)的音频记录
|
|
|
+ const where: any = {
|
|
|
+ OR: [
|
|
|
+ { userId: userIdNum },
|
|
|
+ { userId: null },
|
|
|
+ ],
|
|
|
+ };
|
|
|
if (startDate) {
|
|
|
where.createdAt = { gte: new Date(startDate) };
|
|
|
}
|
|
|
@@ -67,11 +74,18 @@ router.get('/list', optionalAuth, async (ctx: Context) => {
|
|
|
router.get('/', optionalAuth, async (ctx: Context) => {
|
|
|
// 开发环境使用测试用户ID
|
|
|
const userId = ctx.state.user?.userId || TEST_USER_ID;
|
|
|
+ const userIdNum = parseInt(userId as string);
|
|
|
const page = parseInt(ctx.query.page as string) || 1;
|
|
|
const pageSize = parseInt(ctx.query.pageSize as string) || 20;
|
|
|
const startDate = ctx.query.startDate as string;
|
|
|
|
|
|
- const where: any = {};
|
|
|
+ // 用户隔离:只返回本人(或游客 null)的音频记录,避免显示别人的创作
|
|
|
+ const where: any = {
|
|
|
+ OR: [
|
|
|
+ { userId: userIdNum },
|
|
|
+ { userId: null },
|
|
|
+ ],
|
|
|
+ };
|
|
|
if (startDate) {
|
|
|
where.createdAt = { gte: new Date(startDate) };
|
|
|
}
|