@tcatche/swagger-ts
Version:
Codegen from swagger to TS & Axios Functions
435 lines (378 loc) • 14 kB
text/typescript
/* eslint-disable */
import axios, { AxiosInstance, AxiosResponse } from 'axios'
import qs from 'qs'
export interface ObjectType {
[key: string]: any;
}
export interface Config {
$domain?: string;
$config?: any;
}
export interface Parameters {
[key: string]: any;
}
let domain = ''
let axiosInstance = axios.create()
export function getDomain(): string {
return domain
}
export function setDomain($domain: string): void {
domain = $domain
}
export function getAxiosInstance(): AxiosInstance {
return axiosInstance
}
export function setAxiosInstance($axiosInstance: AxiosInstance): void {
axiosInstance = $axiosInstance
}
type RequestMethod = 'get' | 'post' | 'put' | 'delete' | 'head' | 'option' | 'patch'
export function request(method: RequestMethod, url: string, body?: ObjectType, config: ObjectType = {}) {
let queryUrl = url
if (method === 'delete') {
return axiosInstance[method](queryUrl,{...config, data: body || {} })
} else if (method === 'get') {
let params = body ? qs.stringify(body) : ''
if (params) {
if (queryUrl.indexOf('?') < 0) {
params = '?' + params
} else if (!queryUrl.endsWith('?')) {
params = '&' + params
}
}
return axiosInstance[method](queryUrl + params, config)
} else if(method === 'post' || method === 'put' || method === 'patch'){
return axiosInstance[method](queryUrl, body, config)
} else if (method === 'head' || method === 'option') {
return axiosInstance[method](queryUrl, config)
}
}
// 公共响应对象<T>
export interface 公共响应对象<T> {
data?: T; // 业务数据
errorCode?: string; // 错误码
errorMsg?: string; // 错误信息
status?: boolean; // 响应状态
}
// 参与活动状态
export interface 参与活动状态 {
isFirst?: boolean; // 是否首次加入 true是 false否
isJoin?: number; // 0-未加入 1-已加入 2-加入已退出
}
// 参与退出请求
export interface 参与退出请求 {
activityId: string; // 活动id
check: number; // 0-参与 1-退出
mobile: string; // 用户手机号码
userId: string; // 用户id
vin: string; // 车架号
}
// 基础校验
export interface 基础校验 {
activityId: string; // 活动id
mobile: string; // 用户手机号码
userId: string; // 用户id
}
// 持续天数
export interface 持续天数 {
day?: number; // 持续天数
isShow?: boolean; // 是否展示弹窗
nxtPoint?: string; // 明日继续打卡的积分
point?: string; // 增加的积分
}
// 排行榜
export interface 排行榜 {
avatar?: string; // 用户头像
isOwn?: boolean; // 是否用户自己排名
nickName?: string; // 昵称
order?: number; // 排名
point?: string; // 积分
userName?: string; // 用户名
}
// 权益信息
export interface 权益信息 {
code?: string; // 权益兑换码和APP积分值
exchange?: string; // 兑换链接
expireTime?: string; // 过期日期
isCurrent?: boolean; // 是否当月权益
isDraw?: boolean; // 是否领取权益
isExpire?: boolean; // 是否过期
isLocked?: boolean; // 是否解锁 false:解锁
isUsed?: boolean; // 是否已经使用
name?: string; // 权益名称
picUrl?: string; // 权益的图片地址
poolNum?: string; // 权益的库存数量
rightId?: string; // 权益id
type?: number; // 权益类型 0-mosi 1-ubi 2-app积分 3-1元购
unlockNum?: string; // 解锁需要的分数
unlockTime?: string; // 解锁日期
}
// 权益明细
export interface 权益明细 {
code?: string; // 权益兑换码和APP积分值
exchange?: string; // 兑换链接
}
// 活动状态查询
export interface 活动状态查询 {
activityId: string; // 活动id
mobile: string; // 用户手机号码
userId: string; // 用户id
vin: string; // 车架号
}
// 用户信息<T>
export interface 用户信息<T> {
avatar?: string; // 用户头像
nickName?: string; // 用户昵称
vehicles?: Array<T>; // 车辆列表
}
// 用户信息查询
export interface 用户信息查询 {
activityId: string; // 活动id
mobile: string; // 用户手机号码
userId: string; // 用户id
}
// 车辆信息
export interface 车辆信息 {
isTest?: boolean; // 是否试驾车辆 true:试驾车
modelName?: string; // 车型名称
nickName?: string; // 市场名称+车架后四位
seriesName?: string; // 车系名称
type?: number; // 车辆类型 0-自有车 1-授权车
vin?: string; // 车架号
}
// 车辆收益查询实体
export interface 车辆收益查询实体 {
avgSocScore?: string; // 平均soc评分
avgSpeed?: string; // 平均时速
avgSpeedScore?: string; // 平均时速评分
commonProfit?: string; // 保险权益兑换额度
duration?: string; // 驾驶时长
lastProfit?: string; // 昨日收益
maxSpeed?: string; // 最高时速
monthAward?: string; // 当月奖励收益
monthDrive?: string; // 当月驾驶收益
overSpeedScore?: string; // 超速评分
points?: string; // 驾驶评分
pointsMsg?: string; // 评分评语
rank?: number; // 优驾之星排名
tripOdoScore?: string; // 行驶里程评分
tripTimeScore?: string; // 行驶时间评分
tripTimesScore?: string; // 行驶次数评分
vin?: string; // 车架号
}
// 车辆收益查询请求
export interface 车辆收益查询请求 {
activityId: string; // 活动id
mobile: string; // 用户手机号码
userId: string; // 用户id
vin: string; // 车架号
}
// 车辆收益记录列表查询
export interface 车辆收益记录列表查询 {
activityId: string; // 活动id
mobile: string; // 用户手机号码
pageNum: number; // 页码,从1开始
pageSize?: number; // 默认展示条数,缺省10条
userId: string; // 用户id
vin: string; // 车架号
}
// 车辆收益记录查询<T>
export interface 车辆收益记录查询<T> {
createTime?: string; // 发生日期
details?: Array<T>; // 收益记录
}
// 车辆收益详细记录
export interface 车辆收益详细记录 {
income?: string; // 收益积分,负数表示减少
message?: string; // 描述文案
}
// 车辆权益查询
export interface 车辆权益查询 {
activityId: string; // 活动id
mobile: string; // 用户手机号码
userId: string; // 用户id
vin: string; // 车架号
}
// 领取权益
export interface 领取权益 {
activityId: string; // 活动id
mobile: string; // 用户手机号码
rightId?: string; // 权益id
userId: string; // 用户id
vin: string; // 车架号
}
export interface JoinActivitycheckActivityParameters {
checkStatus: 参与退出请求; // checkStatus
}
/**
* @name: JoinActivitycheckActivity
* @date: 2022/1/21
* @description: 参加退出活动(隐私协议)
* @param: {checkStatus} [参与退出请求]
* @return: Promise<AxiosResponse<公共响应对象<any>>>
*/
export function JoinActivitycheckActivity(parameters: Config & JoinActivitycheckActivityParameters): Promise<AxiosResponse<公共响应对象<any>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/activities/check-status'
return request('post', host + path, body, $config)
}
export interface JoinActivitygetUserInfoParameters {
userInfoQuery: 用户信息查询; // userInfoQuery
}
/**
* @name: JoinActivitygetUserInfo
* @date: 2022/1/21
* @description: 获取首页用户信息
* @param: {userInfoQuery} [用户信息查询]
* @return: Promise<AxiosResponse<公共响应对象<用户信息<车辆信息>>>>
*/
export function JoinActivitygetUserInfo(parameters: Config & JoinActivitygetUserInfoParameters): Promise<AxiosResponse<公共响应对象<用户信息<车辆信息>>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/activities/getUserInfo'
return request('post', host + path, body, $config)
}
export interface JoinActivitygetCurrentActivityParameters {
joinStatusQuery: 活动状态查询; // joinStatusQuery
}
/**
* @name: JoinActivitygetCurrentActivity
* @date: 2022/1/21
* @description: 获取参与状态
* @param: {joinStatusQuery} [活动状态查询]
* @return: Promise<AxiosResponse<公共响应对象<参与活动状态>>>
*/
export function JoinActivitygetCurrentActivity(parameters: Config & JoinActivitygetCurrentActivityParameters): Promise<AxiosResponse<公共响应对象<参与活动状态>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/activities/join-status'
return request('post', host + path, body, $config)
}
export interface JoinActivityrefreshVehParameters {
baseCheck: 基础校验; // baseCheck
}
/**
* @name: JoinActivityrefreshVeh
* @date: 2022/1/21
* @description: 刷新用户车辆列表
* @param: {baseCheck} [基础校验]
* @return: Promise<AxiosResponse<公共响应对象<boolean>>>
*/
export function JoinActivityrefreshVeh(parameters: Config & JoinActivityrefreshVehParameters): Promise<AxiosResponse<公共响应对象<boolean>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/activities/refreshVeh'
return request('post', host + path, body, $config)
}
export interface MedallastParameters {
baseCheck: 基础校验; // baseCheck
}
/**
* @name: Medallast
* @date: 2022/1/21
* @description: 获取连续第几天的弹窗信息
* @param: {baseCheck} [基础校验]
* @return: Promise<AxiosResponse<公共响应对象<持续天数>>>
*/
export function Medallast(parameters: Config & MedallastParameters): Promise<AxiosResponse<公共响应对象<持续天数>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/medal/last'
return request('post', host + path, body, $config)
}
export interface ProfitgetProfitListParameters {
profitRecordQuery: 车辆收益记录列表查询; // profitRecordQuery
}
/**
* @name: ProfitgetProfitList
* @date: 2022/1/21
* @description: 获取收益明细记录
* @param: {profitRecordQuery} [车辆收益记录列表查询]
* @return: Promise<AxiosResponse<公共响应对象<Array<车辆收益记录查询<车辆收益详细记录>>>>>
*/
export function ProfitgetProfitList(parameters: Config & ProfitgetProfitListParameters): Promise<AxiosResponse<公共响应对象<Array<车辆收益记录查询<车辆收益详细记录>>>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/profit/getProfitList'
return request('post', host + path, body, $config)
}
export interface ProfitgetAvgTopNParameters {
baseCheck: 基础校验; // baseCheck
}
/**
* @name: ProfitgetAvgTopN
* @date: 2022/1/21
* @description: 获取优驾之星排行榜
* @param: {baseCheck} [基础校验]
* @return: Promise<AxiosResponse<公共响应对象<Array<排行榜>>>>
*/
export function ProfitgetAvgTopN(parameters: Config & ProfitgetAvgTopNParameters): Promise<AxiosResponse<公共响应对象<Array<排行榜>>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/profit/getTopN'
return request('post', host + path, body, $config)
}
export interface ProfitgetTotalTopNParameters {
baseCheck: 基础校验; // baseCheck
}
/**
* @name: ProfitgetTotalTopN
* @date: 2022/1/21
* @description: 获取月度累积排行榜
* @param: {baseCheck} [基础校验]
* @return: Promise<AxiosResponse<公共响应对象<Array<排行榜>>>>
*/
export function ProfitgetTotalTopN(parameters: Config & ProfitgetTotalTopNParameters): Promise<AxiosResponse<公共响应对象<Array<排行榜>>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/profit/getTotalTopN'
return request('post', host + path, body, $config)
}
export interface ProfitgetVehicleProfitParameters {
vehicleProfitQuery: 车辆收益查询请求; // vehicleProfitQuery
}
/**
* @name: ProfitgetVehicleProfit
* @date: 2022/1/21
* @description: 获取车辆收益信息(首页)
* @param: {vehicleProfitQuery} [车辆收益查询请求]
* @return: Promise<AxiosResponse<公共响应对象<车辆收益查询实体>>>
*/
export function ProfitgetVehicleProfit(parameters: Config & ProfitgetVehicleProfitParameters): Promise<AxiosResponse<公共响应对象<车辆收益查询实体>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/profit/getVehicleProfit'
return request('post', host + path, body, $config)
}
export interface RightdrawParameters {
drawRights: 领取权益; // drawRights
}
/**
* @name: Rightdraw
* @date: 2022/1/21
* @description: 领取权益
* @param: {drawRights} [领取权益]
* @return: Promise<AxiosResponse<公共响应对象<Array<权益明细>>>>
*/
export function Rightdraw(parameters: Config & RightdrawParameters): Promise<AxiosResponse<公共响应对象<Array<权益明细>>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/rights/draw'
return request('post', host + path, body, $config)
}
export interface RightgetRightsParameters {
vehicleRightsQuery: 车辆权益查询; // vehicleRightsQuery
}
/**
* @name: RightgetRights
* @date: 2022/1/21
* @description: 获取权益列表
* @param: {vehicleRightsQuery} [车辆权益查询]
* @return: Promise<AxiosResponse<公共响应对象<Array<权益信息>>>>
*/
export function RightgetRights(parameters: Config & RightgetRightsParameters): Promise<AxiosResponse<公共响应对象<Array<权益信息>>>> {
const { $config, $domain, ...body} = parameters
const host = $domain ? $domain : getDomain()
let path = '/public/api/v1/rights/getRights'
return request('post', host + path, body, $config)
}