164 lines
3.6 KiB
TypeScript
164 lines
3.6 KiB
TypeScript
import { request } from '../request';
|
|
|
|
/**
|
|
* Login
|
|
*
|
|
* @param username User name
|
|
* @param password Password
|
|
*/
|
|
export function fetchLogin(body: Api.Auth.LoginBody) {
|
|
return request<Api.Auth.LoginToken>({
|
|
url: '/auth/login',
|
|
method: 'post',
|
|
data: body
|
|
});
|
|
}
|
|
|
|
//邮箱验证码接口
|
|
export function sendCaptcha(body: Api.Auth.EmailCaptcha) {
|
|
return request({
|
|
url: `/code?email=${body.email}`,
|
|
method: 'get'
|
|
});
|
|
}
|
|
|
|
//验证注册
|
|
export function doCheckUserRepeat(body: Api.Auth.CheckBody) {
|
|
return request<boolean>({
|
|
url: '/auth/checkRepeat',
|
|
method: 'post',
|
|
data: body
|
|
});
|
|
}
|
|
|
|
//添加注册
|
|
export function fetchRegister(body: Api.Auth.RegisterBody) {
|
|
return request({
|
|
url: '/auth/register',
|
|
method: 'post',
|
|
data: body
|
|
});
|
|
}
|
|
|
|
/** logout */
|
|
export function doDeleteLogout() {
|
|
return request<App.Service.Response<null>>({
|
|
url: '/auth/logout',
|
|
method: 'delete'
|
|
});
|
|
}
|
|
|
|
/** Get user info */
|
|
export function doGetUserInfo() {
|
|
return request<Api.Auth.UserInfo>({ url: '/u/user/getInfo',method:'get' });
|
|
}
|
|
/** change user info */
|
|
export function doChangeUserInfo(body: Api.Auth.ChangeInfoBody){
|
|
return request({
|
|
url:'/u/user/profile',
|
|
method:'put',
|
|
data:body
|
|
});
|
|
}
|
|
/**
|
|
* Refresh token
|
|
*
|
|
* @param refreshToken Refresh token
|
|
*/
|
|
export function fetchRefreshToken(refreshToken: string) {
|
|
return request<Api.Auth.LoginToken>({
|
|
url: '/auth/refreshToken',
|
|
method: 'post',
|
|
data: {
|
|
refreshToken
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* return custom backend error
|
|
*
|
|
* @param code error code
|
|
* @param msg error message
|
|
*/
|
|
export function fetchCustomBackendError(code: string, msg: string) {
|
|
return request({ url: '/auth/error', params: { code, msg } });
|
|
}
|
|
|
|
/** Get check code */
|
|
export function doGetCheckCode() {
|
|
return request<{ uuid: string; img: string }>({
|
|
url: '/code'
|
|
});
|
|
}
|
|
//首页仪表盘
|
|
/** Get dashboard gauge data */
|
|
export function fetchDashboardData() {
|
|
return request<Api.Dashboard.GaugeData>({
|
|
url: '/u/account/dashboard',
|
|
method: 'get'
|
|
});
|
|
}
|
|
/** Get current connected devices */
|
|
export function fetchCurrentDevices() {
|
|
return request<Api.Device.DeviceListResponse>({
|
|
url: '/u/client/pageCurrentClient',
|
|
method: 'get'
|
|
});
|
|
}
|
|
/** Get historical devices */
|
|
export function fetchHistoricalDevices() {
|
|
return request<Api.Device.HistoricalDeviceListResponse>({
|
|
url: '/u/client/pageHistoryClient',
|
|
method: 'get'
|
|
});
|
|
}
|
|
/** Get CDR history records */
|
|
export function fetchCDRHistory(params: Api.CDR.CDRQueryParams) {
|
|
return request<Api.CDR.CDRListResponse>({
|
|
url: '/u/cdr/pageHistory',
|
|
method: 'get',
|
|
params
|
|
});
|
|
}
|
|
/** Get package list */
|
|
export function fetchPackageList() {
|
|
return request<Api.Package.PackageListResponse>({
|
|
url: '/u/package/list',
|
|
method: 'get'
|
|
});
|
|
}
|
|
/** Submit order with different types */
|
|
export function submitOrder(data: Api.Order.SubmitOrderParams) {
|
|
return request({
|
|
url: '/u/order',
|
|
method: 'post',
|
|
data
|
|
});
|
|
}
|
|
/** Get bill history records */
|
|
export function fetchBillHistory(params: Api.Bill.BillQueryParams) {
|
|
return request<Api.Bill.BillListResponse>({
|
|
url: '/u/bill/page',
|
|
method: 'get',
|
|
params
|
|
});
|
|
}
|
|
/** Get recharge history records */
|
|
export function fetchRechargeHistory(params: Api.Recharge.RechargeQueryParams) {
|
|
return request<Api.Recharge.RechargeListResponse>({
|
|
url: '/u/order/rechargePage',
|
|
method: 'get',
|
|
params
|
|
});
|
|
}
|
|
/** Get package history records */
|
|
export function fetchPackageHistory(params: Api.Package.PackageHistoryQueryParams) {
|
|
return request<Api.Package.PackageHistoryListResponse>({
|
|
url: '/u/order/packagePage',
|
|
method: 'get',
|
|
params
|
|
});
|
|
}
|
|
|