feat: 群认证
This commit is contained in:
13
src/services/file.ts
Normal file
13
src/services/file.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { request } from '@@/exports';
|
||||
|
||||
import { AdminAPI } from '@/constants/api';
|
||||
|
||||
export async function uploadFile(options: { file: File; type: 'VIDEO' | 'IMAGE' }): Promise<API.UploadFile> {
|
||||
return request<API.UploadFile>(AdminAPI.UPLOAD_FILE, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
data: options,
|
||||
});
|
||||
}
|
||||
@ -4,6 +4,7 @@ import { AdminAPI } from '@/constants/api';
|
||||
import { EmployType, JobType } from '@/constants/job';
|
||||
import { request } from '@umijs/max';
|
||||
import { SortOrder } from 'antd/es/table/interface';
|
||||
import { buildUrl } from '@/services/utils';
|
||||
|
||||
function transformPageParams(params: API.PageParams & Record<string, any>) {
|
||||
params.page = params.current;
|
||||
@ -229,3 +230,71 @@ export async function updateDeclarationInfo(options: API.UpdateDeclarationParams
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getStaffList(
|
||||
params: API.PageParams & Partial<API.StaffListItem>,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
const result = await request<API.TableList<API.StaffListItem>>(AdminAPI.STAFF_LIST, {
|
||||
method: 'GET',
|
||||
params: {
|
||||
...transformPageParams(params),
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function getAllStaffList() {
|
||||
return await request<API.StaffListItem[]>(AdminAPI.STAFF_ALL, { method: 'GET' });
|
||||
}
|
||||
|
||||
export async function updateStaff(options: API.UpdateStaffParams) {
|
||||
return request(AdminAPI.STAFF_UPDATE, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteStaff(id: number) {
|
||||
return request(buildUrl(AdminAPI.STAFF_DELETE, { id }), {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
export async function setDefaultStaff(id: number) {
|
||||
return request(buildUrl(AdminAPI.STAFF_SET_DEFAULT, { id }), {
|
||||
method: 'PUT',
|
||||
});
|
||||
}
|
||||
|
||||
export async function getCityOpratorList(
|
||||
params: API.PageParams & Partial<API.CityOperatorListItem>,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
const result = await request<API.TableList<API.CityOperatorListItem>>(AdminAPI.CITY_OPERATOR_LIST, {
|
||||
method: 'GET',
|
||||
params: {
|
||||
...transformPageParams(params),
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function updateCityOperator(options: API.UpdateCityOperator) {
|
||||
return request<API.GroupListItem>(AdminAPI.CITY_OPERATOR_UPDATE, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteCityOperator(id: number) {
|
||||
return request(buildUrl(AdminAPI.CITY_OPERATOR_DELETE, { id }), {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
46
src/services/typings.d.ts
vendored
46
src/services/typings.d.ts
vendored
@ -322,4 +322,50 @@ declare namespace API {
|
||||
type UpdateDeclarationParams = Pick<DeclarationListItem, 'id' | 'weComStatus'>;
|
||||
|
||||
type UpdateMaterialParams = Pick<MaterialListItem, 'id'> & { adminOpen: number };
|
||||
|
||||
interface UploadFile {
|
||||
id: string;
|
||||
url: string;
|
||||
coverUrl: string;
|
||||
}
|
||||
|
||||
interface StaffListItem {
|
||||
id: number;
|
||||
staffName: string;
|
||||
staffQrCode: string;
|
||||
isDefault: 1 | 0;
|
||||
created: string;
|
||||
updated: string;
|
||||
}
|
||||
|
||||
interface UpdateStaffParams {
|
||||
id?: number;
|
||||
staffName: string;
|
||||
staffQrCode: string;
|
||||
isDefault: 1 | 0;
|
||||
created?: string;
|
||||
updated?: string;
|
||||
}
|
||||
|
||||
interface CityOperatorListItem {
|
||||
cityName: string;
|
||||
staffName: string;
|
||||
created: string;
|
||||
updated: string;
|
||||
staffId: number;
|
||||
cityCode: string;
|
||||
groupLink: string;
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface UpdateCityOperator {
|
||||
id?: number;
|
||||
staffId: number;
|
||||
staffName?: string;
|
||||
cityName?: string;
|
||||
cityCode: string;
|
||||
groupLink: string;
|
||||
created?: string;
|
||||
updated?: string;
|
||||
}
|
||||
}
|
||||
|
||||
5
src/services/utils.ts
Normal file
5
src/services/utils.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export function buildUrl(url: string, params: Record<string, string | number>): string {
|
||||
return Object.entries(params).reduce((result, [key, value]) => {
|
||||
return result.replace(new RegExp(`\\{${key}\\}`, 'g'), String(value));
|
||||
}, url);
|
||||
}
|
||||
Reference in New Issue
Block a user