feat:
This commit is contained in:
224
src/services/list.ts
Normal file
224
src/services/list.ts
Normal file
@ -0,0 +1,224 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import { AdminAPI } from '@/constants/api';
|
||||
import { EmployType, JobType } from '@/constants/job';
|
||||
import { request } from '@umijs/max';
|
||||
import { SortOrder } from 'antd/es/table/interface';
|
||||
|
||||
function transformPageParams(params: API.PageParams & Record<string, any>) {
|
||||
params.page = params.current;
|
||||
delete params.current;
|
||||
Object.keys(params).forEach((key: string) => {
|
||||
if (typeof params[key] === 'string' && !params[key]) {
|
||||
delete params[key];
|
||||
}
|
||||
});
|
||||
return params;
|
||||
}
|
||||
|
||||
function transformSort(sort: Record<string, SortOrder>) {
|
||||
if (!sort) {
|
||||
return {};
|
||||
}
|
||||
const sortField = Object.keys(sort)[0];
|
||||
if (!sort[sortField]) {
|
||||
return {};
|
||||
}
|
||||
const asc = sort[sortField] === 'ascend';
|
||||
return { sortField, asc };
|
||||
}
|
||||
|
||||
function sortTableList<T extends { created: number; updated: number }>(
|
||||
response: API.TableList<T>,
|
||||
{ sortField, asc }: ReturnType<typeof transformSort>,
|
||||
): API.TableList<T> {
|
||||
if (sortField === 'created' || sortField === 'updated') {
|
||||
response.data.sort((itemA, itemB) => {
|
||||
const valueA = Number(itemA[sortField]);
|
||||
const valueB = Number(itemB[sortField]);
|
||||
return asc ? valueA - valueB : valueB - valueA;
|
||||
});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function getJobList(params: API.PageParams & Partial<API.JobListItem>, options?: {
|
||||
[key: string]: any
|
||||
}) {
|
||||
if (!params.category) {
|
||||
params.category = JobType.All;
|
||||
}
|
||||
if (!params.cityCode) {
|
||||
params.cityCode = 'ALL';
|
||||
}
|
||||
if (!params.employType) {
|
||||
params.employType = EmployType.All;
|
||||
}
|
||||
const result = await request<API.TableList<API.JobListItem>>(AdminAPI.JOB_LIST, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...transformPageParams(params),
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
result.success = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新通告接口,必须传 数据库 id 和 jobId
|
||||
*/
|
||||
export async function updateJobInfo(options: API.UpdateJobParams) {
|
||||
return request<API.JobListItem>(AdminAPI.JOB_UPDATE, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getGroupList(
|
||||
params: API.PageParams & Partial<API.GroupListItem>,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
const result = await request<API.TableList<API.GroupListItem>>(AdminAPI.GROUP_LIST, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...transformPageParams(params),
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
result.success = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新群信息,必须传 数据库 id
|
||||
*/
|
||||
export async function updateGroupInfo(options: API.UpdateGroupParams) {
|
||||
return request<API.GroupListItem>(AdminAPI.GROUP_UPDATE, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAnchorGroupList(
|
||||
params: API.PageParams & Partial<API.AnchorGroupListItem>,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
const result = await request<API.TableList<API.AnchorGroupListItem>>(AdminAPI.ANCHOR_GROUP_LIST, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...transformPageParams(params),
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function addAnchorGroup(options?: { [key: string]: any }) {
|
||||
return request<API.GroupListItem>(AdminAPI.ADD_ANCHOR_GROUP, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getPublisherList(
|
||||
params: API.PageParams & Partial<API.PublisherListItem>,
|
||||
sort: Record<string, SortOrder>,
|
||||
) {
|
||||
const url = params.hasDeclareOrder ? AdminAPI.PUBLISHER_DECLARATION_LIST : AdminAPI.PUBLISHER_LIST;
|
||||
const result = await request<API.TableList<API.PublisherListItem>>(url, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...transformPageParams(params),
|
||||
...transformSort(sort),
|
||||
},
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function updatePublisherInfo(options: API.UpdatePublisherParams) {
|
||||
return request<API.PublisherListItem>(AdminAPI.PUBLISHER_UPDATE, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAnchorList(
|
||||
params: API.PageParams & Partial<API.AnchorListItem>,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
const result = await request<API.TableList<API.AnchorListItem>>(AdminAPI.ANCHOR_LIST, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...transformPageParams(params),
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function updateAnchorInfo(options: API.UpdateAnchorParams) {
|
||||
return request<API.DeclarationListItem>(AdminAPI.ANCHOR_UPDATE, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getMaterialList(
|
||||
params: API.PageParams & Partial<API.MaterialListItem>,
|
||||
sort: Record<string, SortOrder>,
|
||||
) {
|
||||
const formatedSort = transformSort(sort);
|
||||
const result = await request<API.TableList<API.MaterialListItem>>(AdminAPI.MATERIAL_LIST, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...transformPageParams(params),
|
||||
...formatedSort,
|
||||
},
|
||||
});
|
||||
|
||||
return sortTableList<API.MaterialListItem>(result, formatedSort);
|
||||
}
|
||||
|
||||
export async function updateMaterialInfo(options: API.UpdateMaterialParams) {
|
||||
return request<API.DeclarationListItem>(AdminAPI.MATERIAL_UPDATE, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getDeclarationList(
|
||||
params: API.PageParams & Partial<API.DeclarationListItem>,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
const result = await request<API.TableList<API.DeclarationListItem>>(AdminAPI.DECLARATION_LIST, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...transformPageParams(params),
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function updateDeclarationInfo(options: API.UpdateDeclarationParams) {
|
||||
return request<API.DeclarationListItem>(AdminAPI.DECLARATION_UPDATE, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
...(options || {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
325
src/services/typings.d.ts
vendored
Normal file
325
src/services/typings.d.ts
vendored
Normal file
@ -0,0 +1,325 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
|
||||
declare namespace API {
|
||||
type CurrentUser = {
|
||||
id: string; // 数据库 id
|
||||
userId: string;
|
||||
userName: string;
|
||||
created: string;
|
||||
updated: string;
|
||||
avatar?: string;
|
||||
};
|
||||
|
||||
interface LoginParams {
|
||||
userName?: string;
|
||||
pwd?: string;
|
||||
}
|
||||
|
||||
interface LoginResult {
|
||||
token?: string;
|
||||
expires?: number;
|
||||
}
|
||||
|
||||
interface PageParams {
|
||||
// proTable 给的分页页数
|
||||
current?: number;
|
||||
pageSize?: number;
|
||||
// 实际接口需要的分页页数
|
||||
page?: number;
|
||||
}
|
||||
|
||||
interface JobListItem {
|
||||
// 数据库 id
|
||||
id: string;
|
||||
// 小程序用户 id
|
||||
appUid: string;
|
||||
// 通告 id
|
||||
jobId: string;
|
||||
// 通告标题
|
||||
title: string;
|
||||
// 简介
|
||||
jobDescription: string;
|
||||
// 详细描述(原始信息)
|
||||
sourceText: string;
|
||||
// 城市 code,查询时必传:默认为 ALL
|
||||
cityCode: string;
|
||||
// 品类,查询时必传:默认为 ALL
|
||||
category: string;
|
||||
// 工作类型,查询时必传:默认为 ALL
|
||||
employType: string;
|
||||
// 发布人微信昵称
|
||||
publisher: string;
|
||||
// 发布人 id
|
||||
blPublisherId: string;
|
||||
// 发布人微信号
|
||||
publisherAcctNo: string;
|
||||
// 群昵称
|
||||
imGroupNick: string;
|
||||
// 微信群id
|
||||
imGroupId: string;
|
||||
// 播络群 id
|
||||
blGroupId: string;
|
||||
// 机器人 id
|
||||
robotId: string;
|
||||
// 机器人微信昵称
|
||||
robotImNick: string;
|
||||
// 机器人微信号
|
||||
robotImNo: string;
|
||||
// 通告发布群数量
|
||||
relateGroupCount: number;
|
||||
// 创建时间,时间戳
|
||||
created: string;
|
||||
// 更新时间,时间戳
|
||||
updated: string;
|
||||
// 是否禁用,默认为 false
|
||||
disable: boolean;
|
||||
}
|
||||
|
||||
interface GroupListItem {
|
||||
// 播络群 id
|
||||
id: string;
|
||||
// 微信群id
|
||||
imGroupId: string;
|
||||
// 群昵称
|
||||
imGroupNick: string;
|
||||
groupType: string;
|
||||
// 群主微信昵称
|
||||
groupOwnerNick: string;
|
||||
// 群主微信号
|
||||
groupOwnerImAcctNo: string;
|
||||
// 群主boluo账号
|
||||
groupOwnerAcctNo: string;
|
||||
// 机器人 id
|
||||
robotId: string;
|
||||
// 机器人微信昵称
|
||||
robotImNick: string;
|
||||
// 机器人微信号
|
||||
robotImNo: string;
|
||||
// 城市 code
|
||||
city: string;
|
||||
// 通告数量
|
||||
jobCount: number;
|
||||
// 创建时间,时间戳
|
||||
created: string;
|
||||
// 更新时间,时间戳
|
||||
updated: string;
|
||||
// 是否禁用,默认为 false
|
||||
disable: boolean;
|
||||
// 是否删除
|
||||
isDeleted: boolean;
|
||||
}
|
||||
|
||||
interface AnchorGroupListItem {
|
||||
// 主播用户 id
|
||||
userId: string;
|
||||
// 主播昵称
|
||||
nickName: string;
|
||||
// 主播手机号
|
||||
userPhone: string;
|
||||
// 群名称
|
||||
imGroupNick: string;
|
||||
// 微信群id
|
||||
imGroupId: string;
|
||||
// 播络群 id
|
||||
blGroupId: string;
|
||||
// 是否已经支付
|
||||
payed: boolean;
|
||||
// 支付方式, vx、alipay、other
|
||||
payType: string;
|
||||
// 群定制时间,时间戳
|
||||
created: string;
|
||||
// 绑定群的客服操作人员
|
||||
creator: string;
|
||||
// 备注
|
||||
mark?: string;
|
||||
// 加群状态:0 已申请加群 1已申请加群未进群 2 已申请加群已进群
|
||||
status: number;
|
||||
}
|
||||
|
||||
interface PublisherListItem {
|
||||
// 发布人微信昵称
|
||||
publisher: string;
|
||||
// 发布人 id
|
||||
blPublisherId: string;
|
||||
// 小程序用户 id
|
||||
appUid: string;
|
||||
// 发布人微信号
|
||||
publisherAcctNo: string;
|
||||
// 发布人微信状态, 0 空,1 非空
|
||||
publisherAcctStatus: number;
|
||||
// 账号状态: 0 正常,1 暂停
|
||||
status: number;
|
||||
// 申请好友状态: 0 待申请,1 已申请,2 不能添加,3 被封号
|
||||
addAcctStatus: number;
|
||||
phone: string;
|
||||
email: string;
|
||||
// 机器人微信昵称
|
||||
robotImNick: string;
|
||||
// 客服操作人员
|
||||
operator: string;
|
||||
// 群名称
|
||||
imGroupNick: string;
|
||||
// 微信群id
|
||||
imGroupId: string;
|
||||
// 播络群 id
|
||||
blGroupId: string;
|
||||
// 创建时间
|
||||
created: string;
|
||||
// 更新时间
|
||||
updated: string;
|
||||
// 是否有报单
|
||||
hasDeclareOrder?: boolean;
|
||||
// 最新报单时间
|
||||
declareTime?: string;
|
||||
jobId?: string;
|
||||
}
|
||||
|
||||
interface AnchorListItem {
|
||||
// 主播用户 id
|
||||
userId: string;
|
||||
// 主播昵称
|
||||
nickName: string;
|
||||
// 主播手机号
|
||||
userPhone: string;
|
||||
// 是否绑定了手机号
|
||||
isBindPhone: boolean;
|
||||
// 注册时间
|
||||
created: string;
|
||||
// 最后一次登录时间
|
||||
lastLoginDate: string;
|
||||
// 状态: 0 正常,1 封禁
|
||||
status: number;
|
||||
// 所属城市 code
|
||||
city: string;
|
||||
}
|
||||
|
||||
interface DeclarationListItem {
|
||||
// 报单 id
|
||||
id: string;
|
||||
// 报单类型
|
||||
type: number;
|
||||
// 主播用户 id
|
||||
userId: string;
|
||||
// 主播昵称
|
||||
nickName: string;
|
||||
// 主播手机号
|
||||
userPhone: string;
|
||||
// 通告 id
|
||||
jobId: string;
|
||||
// 通告标题
|
||||
title: string;
|
||||
// 解锁时间
|
||||
useDate: string;
|
||||
// 发布人微信昵称
|
||||
publisher: string;
|
||||
// 发布人 id
|
||||
blPublisherId: string;
|
||||
// 发布人微信号
|
||||
publisherAcctNo: string;
|
||||
// 报单时间
|
||||
declarationDate: string;
|
||||
// 报单处理状态
|
||||
declaredStatus: number;
|
||||
// 报单处理时间
|
||||
declaredDate: string;
|
||||
// 备注
|
||||
declaredMark?: string;
|
||||
// 加企微状态
|
||||
weComStatus: number;
|
||||
// 通告城市信息,如 400100
|
||||
jobCityCode: string;
|
||||
}
|
||||
|
||||
interface MaterialVideoInfo {
|
||||
url: string;
|
||||
coverUrl: string;
|
||||
type: 'image' | 'video';
|
||||
title: string;
|
||||
isDefault: boolean;
|
||||
}
|
||||
|
||||
interface MaterialProfile {
|
||||
materialVideoInfoList: MaterialVideoInfo[];
|
||||
// 基础信息
|
||||
id: string;
|
||||
userId: string;
|
||||
name: string;
|
||||
age: number;
|
||||
height: number; // cm
|
||||
weight: number; // kg
|
||||
gender: GenderType;
|
||||
shoeSize: number; // 鞋码
|
||||
// 求职意向
|
||||
employType: EmployType; // 工作类型
|
||||
fullTimeMinPrice: number; // 全职期望薪资下限
|
||||
fullTimeMaxPrice: number; // 全职期望薪资上限
|
||||
partyTimeMinPrice: number; // 兼职期望薪资下限
|
||||
partyTimeMaxPrice: number; // 兼职期望薪资上限
|
||||
cityCode: string; // 城市
|
||||
cityCodes: string; // 城市。多个城市用 、分割,如 '110100、141100'
|
||||
acceptWorkForSit: boolean; // 是否接受坐班
|
||||
// 直播经验
|
||||
workedYear: WorkedYears; // 工作年限,单位年,无为0、半年 0.5、1、2、3、4、5年及以上用100表示,默认为1年
|
||||
workedAccounts: string; // 直播过的账号
|
||||
newAccountExperience: number; // 是否有起号经验,0无 1有
|
||||
workedCategory: string; // 直播过的品类
|
||||
workedSecCategoryStr: string; // 直播过的二级品类
|
||||
style: string; // 风格。多个分割用 、分割
|
||||
maxGmv: number; // 最高 GMV,单位 w
|
||||
maxOnline: number; // 最高在线人数
|
||||
// 自身优势
|
||||
advantages: string;
|
||||
// 其他
|
||||
approveStatus: boolean; // 审核状态:0 待审 ,1 成功 ,2 不通过
|
||||
isOpen: boolean; // 整体状态是否开放 1开放 0不开放
|
||||
createType: ProfileCreateSource;
|
||||
creator: string; // 创建人id
|
||||
progressBar: number; // 进度百分比
|
||||
filledItems: number; // 已填资料项数
|
||||
created: number; // 时间戳
|
||||
updated: number; // 时间戳
|
||||
}
|
||||
|
||||
interface MaterialListItem extends MaterialProfile {
|
||||
// 主播用户 id
|
||||
userId: string;
|
||||
// 主播昵称
|
||||
nickname: string;
|
||||
// 主播手机号
|
||||
userPhone: string;
|
||||
userOpen: boolean;
|
||||
adminOpen: boolean; // 后台控制是否开放 1开放 0不开放
|
||||
}
|
||||
|
||||
interface ListResult<T> {
|
||||
data: T[];
|
||||
total: number;
|
||||
hasMore: boolean;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
// 排序字段
|
||||
sortField: string;
|
||||
// 是否升序
|
||||
asc: string;
|
||||
}
|
||||
|
||||
interface TableList<T> extends ListResult<T> {
|
||||
success?: boolean;
|
||||
}
|
||||
|
||||
type UpdateJobParams = Pick<JobListItem, 'id' | 'jobId' | 'disable'>;
|
||||
|
||||
type UpdateGroupParams = Pick<GroupListItem, 'id' | 'city' | 'disable'>;
|
||||
|
||||
type UpdatePublisherParams = Pick<
|
||||
PublisherListItem,
|
||||
'blPublisherId' | 'publisherAcctNo' | 'status' | 'addAcctStatus'
|
||||
>;
|
||||
|
||||
type UpdateAnchorParams = Pick<AnchorListItem, 'userId' | 'status'>;
|
||||
|
||||
type UpdateDeclarationParams = Pick<DeclarationListItem, 'id' | 'weComStatus'>;
|
||||
|
||||
type UpdateMaterialParams = Pick<MaterialListItem, 'id'> & { adminOpen: number };
|
||||
}
|
||||
31
src/services/user.ts
Normal file
31
src/services/user.ts
Normal file
@ -0,0 +1,31 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import { AdminAPI } from '@/constants/api';
|
||||
import { request } from '@umijs/max';
|
||||
import { md5 } from 'js-md5';
|
||||
|
||||
export async function currentUser(options?: { [key: string]: any }) {
|
||||
return request<API.CurrentUser>(AdminAPI.USER, {
|
||||
method: 'POST',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
|
||||
body.pwd = md5(body.pwd || '');
|
||||
return request<API.LoginResult>(AdminAPI.LOGIN, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function outLogin(options?: { [key: string]: any }) {
|
||||
// return request<Record<string, any>>(AdminAPI.OUT_LOGIN, {
|
||||
// method: 'POST',
|
||||
// ...(options || {}),
|
||||
// });
|
||||
}
|
||||
Reference in New Issue
Block a user