团队模块
This commit is contained in:
@@ -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 }
|
||||
});
|
||||
|
||||
// 创建团队成员关系
|
||||
|
||||
Reference in New Issue
Block a user