Optimize the project structure and introduce DDD design (#394)

This commit is contained in:
Archer
2023-10-12 17:46:37 +08:00
committed by GitHub
parent 76ac5238b6
commit ad7a17bf40
193 changed files with 1169 additions and 1084 deletions

View File

@@ -0,0 +1,26 @@
import { GET, POST, DELETE } from '@/web/common/api/request';
import type { EditApiKeyProps, GetApiKeyProps } from '@/global/support/api/openapiReq.d';
import type { OpenApiSchema } from '@/types/support/openapi';
/**
* crete a api key
*/
export const createAOpenApiKey = (data: EditApiKeyProps) =>
POST<string>('/support/openapi/postKey', data);
/**
* update a api key
*/
export const putOpenApiKey = (data: EditApiKeyProps & { _id: string }) =>
POST<string>('/support/openapi/putKey', data);
/**
* get api keys
*/
export const getOpenApiKeys = (params?: GetApiKeyProps) =>
GET<OpenApiSchema[]>('/support/openapi/getKeys', params);
/**
* delete api by id
*/
export const delOpenApiById = (id: string) => DELETE(`/support/openapi/delKey?id=${id}`);

View File

@@ -0,0 +1,34 @@
import { GET, POST, DELETE } from '@/web/common/api/request';
import type { InitShareChatResponse } from '@/global/support/api/outLinkRes.d';
import type { OutLinkEditType } from '@/types/support/outLink';
import type { OutLinkSchema } from '@/types/support/outLink';
/**
* 初始化分享聊天
*/
export const initShareChatInfo = (data: { shareId: string; authToken?: string }) =>
GET<InitShareChatResponse>(`/support/outLink/init`, data);
/**
* create a shareChat
*/
export const createShareChat = (
data: OutLinkEditType & {
appId: string;
type: OutLinkSchema['type'];
}
) => POST<string>(`/support/outLink/create`, data);
export const putShareChat = (data: OutLinkEditType) =>
POST<string>(`/support/outLink/update`, data);
/**
* get shareChat
*/
export const getShareChatList = (appId: string) =>
GET<OutLinkSchema[]>(`/support/outLink/list`, { appId });
/**
* delete a shareChat
*/
export const delShareChatById = (id: string) => DELETE(`/support/outLink/delete?id=${id}`);

View File

@@ -0,0 +1,88 @@
import { GET, POST, PUT } from '@/web/common/api/request';
import { createHashPassword } from '@/utils/tools';
import type { ResLogin, PromotionRecordType } from '@/global/support/api/userRes.d';
import { UserAuthTypeEnum } from '@/constants/common';
import { UserType, UserUpdateParams } from '@/types/user';
import type { PagingData, RequestPaging } from '@/types';
import { informSchema } from '@/types/mongoSchema';
import { OAuthEnum } from '@/constants/user';
export const sendAuthCode = (data: {
username: string;
type: `${UserAuthTypeEnum}`;
googleToken: string;
}) => POST(`/plusApi/user/inform/sendAuthCode`, data);
export const getTokenLogin = () => GET<UserType>('/user/account/tokenLogin');
export const oauthLogin = (params: {
type: `${OAuthEnum}`;
code: string;
callbackUrl: string;
inviterId?: string;
}) => POST<ResLogin>('/plusApi/user/account/login/oauth', params);
export const postRegister = ({
username,
password,
code,
inviterId
}: {
username: string;
code: string;
password: string;
inviterId?: string;
}) =>
POST<ResLogin>(`/plusApi/user/account/register/emailAndPhone`, {
username,
code,
inviterId,
password: createHashPassword(password)
});
export const postFindPassword = ({
username,
code,
password
}: {
username: string;
code: string;
password: string;
}) =>
POST<ResLogin>(`/plusApi/user/account/password/updateByCode`, {
username,
code,
password: createHashPassword(password)
});
export const updatePasswordByOld = ({ oldPsw, newPsw }: { oldPsw: string; newPsw: string }) =>
POST('/user/account/updatePasswordByOld', {
oldPsw: createHashPassword(oldPsw),
newPsw: createHashPassword(newPsw)
});
export const postLogin = ({ username, password }: { username: string; password: string }) =>
POST<ResLogin>('/user/account/loginByPassword', {
username,
password: createHashPassword(password)
});
export const loginOut = () => GET('/user/account/loginout');
export const putUserInfo = (data: UserUpdateParams) => PUT('/user/account/update', data);
export const getInforms = (data: RequestPaging) =>
POST<PagingData<informSchema>>(`/user/inform/list`, data);
export const getUnreadCount = () => GET<number>(`/user/inform/countUnread`);
export const readInform = (id: string) => GET(`/user/inform/read`, { id });
/* get promotion init data */
export const getPromotionInitData = () =>
GET<{
invitedAmount: number;
earningsAmount: number;
}>('/user/promotion/getPromotionData');
/* promotion records */
export const getPromotionRecords = (data: RequestPaging) =>
POST<PromotionRecordType>(`/user/promotion/getPromotions`, data);