This commit is contained in:
2025-04-03 17:50:45 +08:00
parent d61b8a62ff
commit f32a45d24a
3 changed files with 59 additions and 2 deletions

View File

@@ -25,6 +25,11 @@ export async function GET(request: NextRequest) {
const endTime = searchParams.get('endTime');
const linkId = searchParams.get('linkId');
// 获取团队、项目和标签筛选参数
const teamIds = searchParams.getAll('teamId');
const projectIds = searchParams.getAll('projectId');
const tagIds = searchParams.getAll('tagId');
// 获取UTM类型参数
const utmType = searchParams.get('utmType') || 'source';
@@ -44,6 +49,37 @@ export async function GET(request: NextRequest) {
conditions.push(`link_id = '${linkId}'`);
}
// 添加团队筛选
if (teamIds && teamIds.length > 0) {
// 如果只有一个团队ID
if (teamIds.length === 1) {
conditions.push(`team_id = '${teamIds[0]}'`);
} else {
// 多个团队ID
conditions.push(`team_id IN ('${teamIds.join("','")}')`);
}
}
// 添加项目筛选
if (projectIds && projectIds.length > 0) {
// 如果只有一个项目ID
if (projectIds.length === 1) {
conditions.push(`project_id = '${projectIds[0]}'`);
} else {
// 多个项目ID
conditions.push(`project_id IN ('${projectIds.join("','")}')`);
}
}
// 添加标签筛选
if (tagIds && tagIds.length > 0) {
// 使用与buildFilter函数相同的处理方式
const tagConditions = tagIds.map(tag =>
`link_tags LIKE '%${tag}%'`
);
conditions.push(`(${tagConditions.join(' OR ')})`);
}
if (conditions.length > 0) {
whereClause = `WHERE ${conditions.join(' AND ')}`;
}