团队模块

This commit is contained in:
‘Liammcl’
2024-12-28 14:28:00 +08:00
parent b3ac241354
commit 4f0e7be806
7 changed files with 121 additions and 15 deletions

View File

@@ -42,12 +42,35 @@ export const useTeams = () => {
}
};
// 创建团队前检查类型是否已存在
const checkTeamTypeExists = async (type) => {
try {
const {data} = await supabaseService.select('teams', {
filter: {
deleted_at: { is: null },
'attributes->>type': { eq: type }
}
});
return data.length > 0;
} catch (error) {
console.error('检查团队类型失败:', error);
throw error;
}
};
// 创建团队
const createTeam = async (values) => {
try {
if (values.type) {
const result = await checkTeamTypeExists(values.type);
if (result) {
throw new Error(`团队类型 "${values.type}" 已存在,请使用其他类型名称`);
}
}
const newTeam = await supabaseService.insert('teams', {
name: values.name,
description: values.description
description: values.description,
attributes: { type: values.type }
});
// 创建团队成员关系