feat(image): 新建 knowai-core:1.0.0 镜像并完成推送
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
- 搭建 api、auth、utils 等逻辑模块 - 通过 tsc、eslint、vitest 测试验证 BREAKING CHANGE: 新镜像分支
This commit is contained in:
51
api/modules/user.ts
Normal file
51
api/modules/user.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import type { ApiClient } from '../types';
|
||||
import type {
|
||||
LoginRequest,
|
||||
LoginResponse,
|
||||
RegisterRequest,
|
||||
RegisterResponse,
|
||||
RefreshTokenRequest,
|
||||
RefreshTokenResponse,
|
||||
UserProfileUpdateRequest,
|
||||
UserProfileUpdateResponse,
|
||||
UserFollowRequest,
|
||||
UserFollowResponse
|
||||
} from '@/types/user';
|
||||
|
||||
// 用户API服务工厂函数
|
||||
export const userApi = (client: ApiClient) => ({
|
||||
// 用户登录
|
||||
login: (data: LoginRequest): Promise<LoginResponse> => {
|
||||
return client.post('/auth/login', data);
|
||||
},
|
||||
|
||||
// 用户注册
|
||||
register: (data: RegisterRequest): Promise<RegisterResponse> => {
|
||||
return client.post('/auth/register', data);
|
||||
},
|
||||
|
||||
// 刷新令牌
|
||||
refreshToken: (data: RefreshTokenRequest): Promise<RefreshTokenResponse> => {
|
||||
return client.post('/auth/refresh', data);
|
||||
},
|
||||
|
||||
// 获取用户档案
|
||||
getProfile: (): Promise<UserProfileUpdateResponse> => {
|
||||
return client.get('/user/profile');
|
||||
},
|
||||
|
||||
// 更新用户档案
|
||||
updateProfile: (data: UserProfileUpdateRequest): Promise<UserProfileUpdateResponse> => {
|
||||
return client.put('/user/profile', data);
|
||||
},
|
||||
|
||||
// 关注用户
|
||||
followUser: ({ userId }: UserFollowRequest): Promise<UserFollowResponse> => {
|
||||
return client.put(`/user/follow/${userId}`);
|
||||
},
|
||||
|
||||
// 取消关注用户
|
||||
unfollowUser: ({ userId }: UserFollowRequest): Promise<UserFollowResponse> => {
|
||||
return client.delete(`/user/follow/${userId}`);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user