feat: 移除目标管理功能模块
删除了完整的目标管理功能,包括目标创建、编辑、任务管理等相关页面和组件。同时移除了相关的API服务、Redux状态管理、类型定义和通知功能。应用版本从1.0.20升级到1.0.21。
This commit is contained in:
@@ -1,123 +0,0 @@
|
||||
import {
|
||||
ApiResponse,
|
||||
BatchGoalOperationRequest,
|
||||
BatchGoalOperationResult,
|
||||
CompleteGoalRequest,
|
||||
CreateGoalRequest,
|
||||
GetGoalCompletionsQuery,
|
||||
GetGoalsQuery,
|
||||
Goal,
|
||||
GoalCompletion,
|
||||
GoalDetailResponse,
|
||||
GoalListItem,
|
||||
GoalStats,
|
||||
PaginatedResponse,
|
||||
UpdateGoalRequest,
|
||||
} from '@/types/goals';
|
||||
import { api } from './api';
|
||||
|
||||
// 目标管理API服务
|
||||
|
||||
/**
|
||||
* 创建目标
|
||||
*/
|
||||
export const createGoal = async (goalData: CreateGoalRequest): Promise<Goal> => {
|
||||
return api.post<Goal>('/goals', goalData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取目标列表
|
||||
*/
|
||||
export const getGoals = async (query: GetGoalsQuery = {}): Promise<PaginatedResponse<GoalListItem>> => {
|
||||
const searchParams = new URLSearchParams();
|
||||
|
||||
Object.entries(query).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null) {
|
||||
searchParams.append(key, String(value));
|
||||
}
|
||||
});
|
||||
|
||||
const queryString = searchParams.toString();
|
||||
const path = queryString ? `/goals?${queryString}` : '/goals';
|
||||
|
||||
return api.get<PaginatedResponse<GoalListItem>>(path);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取目标详情
|
||||
*/
|
||||
export const getGoalById = async (goalId: string): Promise<ApiResponse<GoalDetailResponse>> => {
|
||||
return api.get<ApiResponse<GoalDetailResponse>>(`/goals/${goalId}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新目标
|
||||
*/
|
||||
export const updateGoal = async (goalId: string, goalData: UpdateGoalRequest): Promise<Goal> => {
|
||||
return api.put<Goal>(`/goals/${goalId}`, goalData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除目标
|
||||
*/
|
||||
export const deleteGoal = async (goalId: string): Promise<ApiResponse<boolean>> => {
|
||||
return api.delete<ApiResponse<boolean>>(`/goals/${goalId}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 记录目标完成
|
||||
*/
|
||||
export const completeGoal = async (goalId: string, completionData: CompleteGoalRequest = {}): Promise<ApiResponse<GoalCompletion>> => {
|
||||
return api.post<ApiResponse<GoalCompletion>>(`/goals/${goalId}/complete`, completionData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取目标完成记录
|
||||
*/
|
||||
export const getGoalCompletions = async (
|
||||
goalId: string,
|
||||
query: GetGoalCompletionsQuery = {}
|
||||
): Promise<ApiResponse<PaginatedResponse<GoalCompletion>>> => {
|
||||
const searchParams = new URLSearchParams();
|
||||
|
||||
Object.entries(query).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null) {
|
||||
searchParams.append(key, String(value));
|
||||
}
|
||||
});
|
||||
|
||||
const queryString = searchParams.toString();
|
||||
const path = queryString ? `/goals/${goalId}/completions?${queryString}` : `/goals/${goalId}/completions`;
|
||||
|
||||
return api.get<ApiResponse<PaginatedResponse<GoalCompletion>>>(path);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取目标统计信息
|
||||
*/
|
||||
export const getGoalStats = async (): Promise<ApiResponse<GoalStats>> => {
|
||||
return api.get<ApiResponse<GoalStats>>('/goals/stats/overview');
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量操作目标
|
||||
*/
|
||||
export const batchOperateGoals = async (operationData: BatchGoalOperationRequest): Promise<ApiResponse<BatchGoalOperationResult[]>> => {
|
||||
return api.post<ApiResponse<BatchGoalOperationResult[]>>('/goals/batch', operationData);
|
||||
};
|
||||
|
||||
|
||||
// 导出所有API方法
|
||||
export const goalsApi = {
|
||||
createGoal,
|
||||
getGoals,
|
||||
getGoalById,
|
||||
updateGoal,
|
||||
deleteGoal,
|
||||
completeGoal,
|
||||
getGoalCompletions,
|
||||
getGoalStats,
|
||||
batchOperateGoals,
|
||||
};
|
||||
|
||||
export default goalsApi;
|
||||
@@ -526,7 +526,6 @@ export const notificationService = NotificationService.getInstance();
|
||||
// 预定义的推送通知类型
|
||||
export const NotificationTypes = {
|
||||
WORKOUT_REMINDER: 'workout_reminder',
|
||||
GOAL_ACHIEVEMENT: 'goal_achievement',
|
||||
MOOD_CHECKIN: 'mood_checkin',
|
||||
NUTRITION_REMINDER: 'nutrition_reminder',
|
||||
PROGRESS_UPDATE: 'progress_update',
|
||||
@@ -558,17 +557,7 @@ export const sendWorkoutReminder = (title: string, body: string, date?: Date) =>
|
||||
}
|
||||
};
|
||||
|
||||
export const sendGoalAchievement = (title: string, body: string) => {
|
||||
const notification: NotificationData = {
|
||||
title,
|
||||
body,
|
||||
data: { type: NotificationTypes.GOAL_ACHIEVEMENT },
|
||||
sound: true,
|
||||
priority: 'high',
|
||||
};
|
||||
|
||||
return notificationService.sendImmediateNotification(notification);
|
||||
};
|
||||
// sendGoalAchievement 函数已删除,因为目标功能已移除
|
||||
|
||||
export const sendMoodCheckinReminder = (title: string, body: string, date?: Date) => {
|
||||
const notification: NotificationData = {
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
import {
|
||||
ApiResponse,
|
||||
CompleteTaskRequest,
|
||||
GetTasksQuery,
|
||||
PaginatedResponse,
|
||||
SkipTaskRequest,
|
||||
Task,
|
||||
TaskListItem,
|
||||
TaskStats,
|
||||
} from '@/types/goals';
|
||||
import { api } from './api';
|
||||
|
||||
// 任务管理API服务
|
||||
|
||||
/**
|
||||
* 获取任务列表
|
||||
*/
|
||||
export const getTasks = async (query: GetTasksQuery = {}): Promise<PaginatedResponse<TaskListItem>> => {
|
||||
const searchParams = new URLSearchParams();
|
||||
|
||||
Object.entries(query).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null) {
|
||||
searchParams.append(key, String(value));
|
||||
}
|
||||
});
|
||||
|
||||
const queryString = searchParams.toString();
|
||||
const path = queryString ? `/goals/tasks?${queryString}` : '/goals/tasks';
|
||||
|
||||
return api.get<PaginatedResponse<TaskListItem>>(path);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取特定目标的任务列表
|
||||
*/
|
||||
export const getTasksByGoalId = async (goalId: string, query: GetTasksQuery = {}): Promise<PaginatedResponse<TaskListItem>> => {
|
||||
const searchParams = new URLSearchParams();
|
||||
|
||||
Object.entries(query).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null) {
|
||||
searchParams.append(key, String(value));
|
||||
}
|
||||
});
|
||||
|
||||
const queryString = searchParams.toString();
|
||||
const path = queryString ? `/goals/${goalId}/tasks?${queryString}` : `/goals/${goalId}/tasks`;
|
||||
|
||||
return api.get<PaginatedResponse<TaskListItem>>(path);
|
||||
};
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
*/
|
||||
export const completeTask = async (taskId: string, completionData: CompleteTaskRequest = {}): Promise<Task> => {
|
||||
return api.post<Task>(`/goals/tasks/${taskId}/complete`, completionData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 跳过任务
|
||||
*/
|
||||
export const skipTask = async (taskId: string, skipData: SkipTaskRequest = {}): Promise<Task> => {
|
||||
return api.post<Task>(`/goals/tasks/${taskId}/skip`, skipData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取任务统计
|
||||
*/
|
||||
export const getTaskStats = async (goalId?: string): Promise<TaskStats> => {
|
||||
const path = goalId ? `/goals/tasks/stats/overview?goalId=${goalId}` : '/goals/tasks/stats/overview';
|
||||
const response = await api.get<ApiResponse<TaskStats>>(path);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
// 导出所有API方法
|
||||
export const tasksApi = {
|
||||
getTasks,
|
||||
getTasksByGoalId,
|
||||
completeTask,
|
||||
skipTask,
|
||||
getTaskStats,
|
||||
};
|
||||
|
||||
export default tasksApi;
|
||||
Reference in New Issue
Block a user