226 lines
6.1 KiB
TypeScript
226 lines
6.1 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import type {
|
|
UserService,
|
|
UserSearchParams,
|
|
UserList,
|
|
UserDetailResponse,
|
|
UserSttsStatsList,
|
|
UserUpdateData,
|
|
UserPasswordUpdateData,
|
|
UserFindPasswordUpdateData,
|
|
UserPasswordMatchData,
|
|
UserUpdateInfoData,
|
|
UserSaveData,
|
|
UserFindPasswordSaveData,
|
|
UserVerifyData,
|
|
UserEmailData,
|
|
UserIdData,
|
|
AdminUserList,
|
|
} from "../model/user-interface";
|
|
|
|
export class UserApiService implements UserService {
|
|
// 사용자 목록 조회
|
|
public async findPageUser(params: UserSearchParams): Promise<UserList> {
|
|
const response = await client.get<UserList>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}`,
|
|
{ params },
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 단건 조회
|
|
public async findByUserUnqId(userUnqId: string): Promise<UserDetailResponse> {
|
|
const response = await client.get<UserDetailResponse>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/${userUnqId}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 로그인한 사용자 정보 조회
|
|
public async findByUserUnqIdByLogin(): Promise<UserDetailResponse> {
|
|
const response = await client.get<UserDetailResponse>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/info/me`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 회원상태 통계 조회
|
|
public async selectUserSttsStats(): Promise<UserSttsStatsList> {
|
|
const response = await client.get<UserSttsStatsList>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/stts/stats`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 저장
|
|
public async saveUser(data: UserSaveData): Promise<string> {
|
|
const response = await client.post<string>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 수정
|
|
public async updateUser(
|
|
userUnqId: string,
|
|
data: UserUpdateData,
|
|
): Promise<string> {
|
|
const response = await client.put<string>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/${userUnqId}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 삭제
|
|
public async deleteUser(userUnqId: string): Promise<boolean> {
|
|
const response = await client.delete<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/delete/${userUnqId}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 계정잠금 처리
|
|
public async lockUser(userUnqId: string): Promise<boolean> {
|
|
const response = await client.put<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/lock/${userUnqId}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 계정잠금 해제처리
|
|
public async unlockUser(userUnqId: string): Promise<boolean> {
|
|
const response = await client.put<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/unlock/${userUnqId}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 리프레시 토큰 정보 재발급
|
|
public async refreshToken(): Promise<void> {
|
|
await client.put(`${ENDPOINT.USER_SERVICE.USERS}/token/refresh`);
|
|
}
|
|
|
|
// 사용자 비밀번호 변경
|
|
public async updatePassword(data: UserPasswordUpdateData): Promise<boolean> {
|
|
const response = await client.put<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/password/update`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 비밀번호 초기화(관리자용)
|
|
public async initializePassword(
|
|
userUnqId: string,
|
|
data: UserPasswordUpdateData,
|
|
): Promise<boolean> {
|
|
const response = await client.put<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/password/initialize/${userUnqId}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 비밀번호 찾기 변경
|
|
public async changePassword(
|
|
data: UserFindPasswordUpdateData,
|
|
): Promise<boolean> {
|
|
const response = await client.put<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/password/change`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 비밀번호 확인
|
|
public async matchPassword(data: UserPasswordMatchData): Promise<boolean> {
|
|
const response = await client.post<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/password/match`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 비밀번호 찾기
|
|
public async findPasswordUser(
|
|
data: UserFindPasswordSaveData,
|
|
): Promise<boolean> {
|
|
const response = await client.post<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/password/find`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 비밀번호 찾기 유효성 확인
|
|
public async validPassword(token: string): Promise<boolean> {
|
|
const response = await client.get<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/password/valid/${token}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 회원정보 변경
|
|
public async updateInfo(
|
|
userUnqId: string,
|
|
data: UserUpdateInfoData,
|
|
): Promise<string> {
|
|
const response = await client.put<string>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/info/${userUnqId}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 승인처리
|
|
public async applyUser(userUnqId: string): Promise<boolean> {
|
|
const response = await client.put<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/apply/${userUnqId}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 회원탈퇴
|
|
public async leaveUser(data: UserVerifyData): Promise<boolean> {
|
|
const response = await client.post<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/leave`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 이메일 중복 체크
|
|
public async existsEmail(data: UserEmailData): Promise<boolean> {
|
|
const response = await client.post<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/exists`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 사용자 아이디 중복 체크
|
|
public async existsUserId(data: UserIdData): Promise<boolean> {
|
|
const response = await client.post<boolean>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/existsUserId`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 관리자 목록 조회
|
|
public async findPageAdminUser(
|
|
params: UserSearchParams,
|
|
): Promise<AdminUserList> {
|
|
const response = await client.get<AdminUserList>(
|
|
`${ENDPOINT.USER_SERVICE.USERS}/admin/list`,
|
|
{ params },
|
|
);
|
|
return response.data;
|
|
}
|
|
}
|
|
|
|
export const UserApi = new UserApiService();
|