提交 ac6234fc 作者: 方治民

feat(api): 优化 API 相关配置

上级 62a19309
# API 接口地址
VITE_GLOB_API_URL=http://192.168.0.156:17181
VITE_GLOB_API_URL=http://192.168.0.156:8081
# API 接口地址前缀
VITE_GLOB_API_URL_PREFIX=/api
{
"originType": "SwaggerV3",
"originUrl": "http://127.0.0.1:8081/api/v3/api-docs",
"originUrl": "http://192.168.0.156:8081/api/v3/api-docs",
"templateType": "fetch",
"templatePath": "./pont-template",
"transformPath": "./pont-transform",
......
......@@ -35,8 +35,9 @@ export default class BasicGenerator extends CodeGenerator {
}
if (requestParams.includes('body')) {
requestParams = requestParams.replace('params?: Params, ', '')
bodyTypeDef = requestParams.replace(/^.*body: (.*),.*$/gi, '$1')
requestParams = requestParams.replace('params?: Params, ', '')
requestParams = requestParams.replace('body:', 'body?:')
}
}
......@@ -51,11 +52,18 @@ export default class BasicGenerator extends CodeGenerator {
getInterfaceContentInDeclaration(inter: Interface) {
const paramsCode = inter.getParamsCode('Params')
const requestParams = this.getParams(inter, paramsCode)
const sourceResponseType = inter.responseType
const targetResponseType =
sourceResponseType === 'File'
? 'void'
: sourceResponseType === 'defs.ResultString'
? 'string'
: sourceResponseType.replace(/defs.Result(.*)/, 'defs.$1')
return `
export ${paramsCode}
export type Response = ${inter.responseType.replace(/defs.Result\<(.*)\>/, '$1')};
export type Response = ${targetResponseType};
export const init: Response;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
export class DictItemVo {
/** 字典选项描述 */
description = ''
/** 字典选项是否启用 */
enable = false
/** id */
id = ''
/** 字典选项名称 */
name = ''
/** 字典选项排序序号 */
serial = undefined
/** 字典选项值 */
value = ''
}
export class DictVo {
/** 字典编号 */
code = ''
/** 字典描述 */
description = ''
/** id */
id = ''
/** 字典名称 */
name = ''
}
export class KeyValueVo {
/** 是否启用 */
enable = ''
/** key */
key = ''
/** label */
label = ''
/** value */
value = ''
}
export class LoginVo {
/** token */
token = ''
......@@ -43,6 +91,28 @@ export class PageParam {
sortOrder = 'ASC'
}
export class PageVoDictItemVo {
/** 数据 */
data = []
/** 数据最新时间 */
latest = ''
/** 数据总数 */
total = undefined
}
export class PageVoDictVo {
/** 数据 */
data = []
/** 数据最新时间 */
latest = ''
/** 数据总数 */
total = undefined
}
export class PageVoPermissionVo {
/** 数据 */
data = []
......@@ -87,6 +157,47 @@ export class PageVoUserVo {
total = undefined
}
export class PermissionParam {
/** 组件 */
component = ''
/** 是否启用 */
enable = false
/** 是否隐藏 */
hidden = false
/** 图标 */
icon = ''
/** id */
id = ''
/** 元数据 */
meta = undefined
/** 名称 */
name = ''
/** 路径 */
path = ''
/** 父级ID */
pid = ''
/** 重定向 */
redirect = ''
/** 序号 */
serial = undefined
/** 权限类型 */
type = 'DIR'
/** 标识 */
uid = ''
}
export class PermissionVo {
/** children */
children = []
......@@ -128,6 +239,32 @@ export class PermissionVo {
uid = ''
}
export class ResultArrayListKeyValueVo {
/** 内容 */
body = []
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultArrayListMenuVo {
/** 内容 */
body = []
......@@ -258,6 +395,58 @@ export class ResultBoolean {
timestamp = ''
}
export class ResultDictItemVo {
/** body */
body = new DictItemVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultDictVo {
/** body */
body = new DictVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultLoginVo {
/** body */
body = new LoginVo()
......@@ -284,6 +473,58 @@ export class ResultLoginVo {
timestamp = ''
}
export class ResultPageVoDictItemVo {
/** body */
body = new PageVoDictItemVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultPageVoDictVo {
/** body */
body = new PageVoDictVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultPageVoPermissionVo {
/** body */
body = new PageVoPermissionVo()
......
......@@ -18,8 +18,6 @@ export class Params {
avatar?: string
/** 邮箱 */
email?: string
/** 简介 */
introduction?: string
/** 是否启用 */
enable?: boolean
}
......
/**
* @desc 新增
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** id */
id: string
/** 字典名称 */
name: string
/** 字典编号 */
code: string
/** 字典描述 */
description?: string
}
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/add',
method: 'POST',
data: params,
...config,
},
options,
)
}
/**
* @desc 查询
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** id */
id: string
}
export const init = new defs.ResultDictVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/find',
method: 'GET',
params,
...config,
},
options,
)
}
/**
* @description 字典管理
*/
import * as add from './add'
import * as find from './find'
import * as modify from './modify'
import * as page from './page'
import * as remove from './remove'
import * as selector from './selector'
export { add, find, modify, page, remove, selector }
/**
* @desc 修改
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** id */
id: string
/** 字典名称 */
name: string
/** 字典编号 */
code: string
/** 字典描述 */
description?: string
}
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/modify',
method: 'POST',
data: params,
...config,
},
options,
)
}
/**
* @desc 分页查询
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 分页条数 */
pageSize: number
/** 当前页数 */
pageNo: number
/** 排序字段 */
sortField?: string
/** 排序方向(ASC|DESC) */
sortOrder?: string
}
export const init = new defs.ResultPageVoDictVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/page',
method: 'GET',
params,
...config,
},
options,
)
}
......@@ -15,7 +15,7 @@ export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/role/deleted',
url: '/sys/dict/remove',
method: 'POST',
data: params,
......
/**
* @desc 选项查询
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.ResultArrayListKeyValueVo()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/selector',
method: 'GET',
params,
...config,
},
options,
)
}
/**
* @desc 新增
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** id */
id: string
/** 字典 ID */
dictId: string
/** 字典选项名称 */
name: string
/** 字典选项值 */
value: string
/** 字典选项描述 */
description?: string
/** 字典选项排序序号 */
serial?: number
/** 字典选项是否启用 */
enable: boolean
}
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/item/add',
method: 'POST',
data: params,
...config,
},
options,
)
}
/**
* @desc 查询
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** id */
id: string
}
export const init = new defs.ResultDictItemVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/item/find',
method: 'GET',
params,
...config,
},
options,
)
}
/**
* @description 字典选项管理
*/
import * as add from './add'
import * as find from './find'
import * as modify from './modify'
import * as page from './page'
import * as remove from './remove'
import * as selector from './selector'
export { add, find, modify, page, remove, selector }
/**
* @desc 修改
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** id */
id: string
/** 字典 ID */
dictId: string
/** 字典选项名称 */
name: string
/** 字典选项值 */
value: string
/** 字典选项描述 */
description?: string
/** 字典选项排序序号 */
serial?: number
/** 字典选项是否启用 */
enable: boolean
}
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/item/modify',
method: 'POST',
data: params,
...config,
},
options,
)
}
/**
* @desc 分页查询
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 分页条数 */
pageSize: number
/** 当前页数 */
pageNo: number
/** 排序字段 */
sortField?: string
/** 排序方向(ASC|DESC) */
sortOrder?: string
}
export const init = new defs.ResultPageVoDictItemVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/item/page',
method: 'GET',
params,
...config,
},
options,
)
}
/**
* @desc 删除
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** ids 多个以逗号分割 */
ids: string
}
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/item/remove',
method: 'POST',
data: params,
...config,
},
options,
)
}
/**
* @desc 选项查询
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 字典 ID */
dictId?: string
/** 字典 ID */
dictCode?: string
/** 字典选项是否启用 */
enable?: boolean
}
export const init = new defs.ResultArrayListKeyValueVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/dict/item/selector',
method: 'GET',
params,
...config,
},
options,
)
}
......@@ -7,5 +7,6 @@ import * as fail from './fail'
import * as findUserExtensionInfo from './findUserExtensionInfo'
import * as json from './json'
import * as page from './page'
import * as upload from './upload'
export { hello, download, fail, findUserExtensionInfo, json, page }
export { hello, download, fail, findUserExtensionInfo, json, page, upload }
......@@ -8,7 +8,7 @@ import { defHttp } from '/@/utils/http/axios'
export const init = new defs.ResultPageVoString()
export function request(
body: defs.PageParam,
body?: defs.PageParam,
config?: http.RequestConfig<defs.PageParam>,
options?: http.RequestOptions,
) {
......
......@@ -6,9 +6,9 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** pageSize */
/** 分页条数 */
pageSize: number
/** pageNo */
/** 当前页数 */
pageNo: number
/** 排序字段 */
sortField?: string
......
/**
* @desc 文件上传
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export const init = new defs.ResultString()
export function request(body?: object, config?: http.RequestConfig<object>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/example/upload',
method: 'POST',
data: body,
headers: { 'Content-Type': 'application/json' },
...config,
},
options,
)
}
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export const init = new defs.ResultString()
export function request(body: object, config?: http.RequestConfig<object>, options?: http.RequestOptions) {
export function request(body?: object, config?: http.RequestConfig<object>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/common/file/upload',
......
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export const init = new defs.ResultString()
export function request(body: string, config?: http.RequestConfig<string>, options?: http.RequestOptions) {
export function request(body?: string, config?: http.RequestConfig<string>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/common/file/uploadBase64Image',
......
import * as auth from './auth'
import * as dict from './dict'
import * as dictItem from './dictItem'
import * as example from './example'
import * as file from './file'
import * as permission from './permission'
......@@ -8,6 +10,8 @@ import * as userView from './userView'
export const API = {
auth,
dict,
dictItem,
example,
file,
permission,
......
......@@ -5,43 +5,19 @@
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** id */
id: string
/** 权限类型 */
type: 'DIR' | 'MENU' | 'BUTTON'
/** 序号 */
serial?: number
/** 标识 */
uid: string
/** 名称 */
name: string
/** 路径 */
path?: string
/** 重定向 */
redirect?: string
/** 组件 */
component?: string
/** 图标 */
icon?: string
/** 是否隐藏 */
hidden?: boolean
/** 是否启用 */
enable?: boolean
/** 父级ID */
pid?: string
/** 元数据 */
meta?: string
}
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
export function request(
body?: defs.PermissionParam,
config?: http.RequestConfig<defs.PermissionParam>,
options?: http.RequestOptions,
) {
return defHttp.request(
{
url: '/sys/permission/add',
method: 'POST',
data: params,
data: body,
headers: { 'Content-Type': 'application/json' },
...config,
},
......
......@@ -2,10 +2,10 @@
* @description 权限管理
*/
import * as add from './add'
import * as deleted from './deleted'
import * as find from './find'
import * as modify from './modify'
import * as page from './page'
import * as remove from './remove'
import * as tree from './tree'
export { add, deleted, find, modify, page, tree }
export { add, find, modify, page, remove, tree }
......@@ -5,43 +5,19 @@
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** id */
id: string
/** 权限类型 */
type: 'DIR' | 'MENU' | 'BUTTON'
/** 序号 */
serial?: number
/** 标识 */
uid: string
/** 名称 */
name: string
/** 路径 */
path?: string
/** 重定向 */
redirect?: string
/** 组件 */
component?: string
/** 图标 */
icon?: string
/** 是否隐藏 */
hidden?: boolean
/** 是否启用 */
enable?: boolean
/** 父级ID */
pid?: string
/** 元数据 */
meta?: string
}
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
export function request(
body?: defs.PermissionParam,
config?: http.RequestConfig<defs.PermissionParam>,
options?: http.RequestOptions,
) {
return defHttp.request(
{
url: '/sys/permission/modify',
method: 'POST',
data: params,
data: body,
headers: { 'Content-Type': 'application/json' },
...config,
},
......
......@@ -6,9 +6,9 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** pageSize */
/** 分页条数 */
pageSize: number
/** pageNo */
/** 当前页数 */
pageNo: number
/** 排序字段 */
sortField?: string
......
......@@ -15,7 +15,7 @@ export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/permission/deleted',
url: '/sys/permission/remove',
method: 'POST',
data: params,
......
......@@ -3,10 +3,10 @@
*/
import * as add from './add'
import * as assign from './assign'
import * as deleted from './deleted'
import * as find from './find'
import * as modify from './modify'
import * as page from './page'
import * as remove from './remove'
import * as selector from './selector'
export { add, assign, deleted, find, modify, page, selector }
export { add, assign, find, modify, page, remove, selector }
......@@ -6,9 +6,9 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** pageSize */
/** 分页条数 */
pageSize: number
/** pageNo */
/** 当前页数 */
pageNo: number
/** 排序字段 */
sortField?: string
......
/**
* @desc 删除
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** ids 多个以逗号分割 */
ids: string
}
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/sys/role/remove',
method: 'POST',
data: params,
...config,
},
options,
)
}
......@@ -6,9 +6,9 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** pageSize */
/** 分页条数 */
pageSize: number
/** pageNo */
/** 当前页数 */
pageNo: number
/** 排序字段 */
sortField?: string
......
import { useGlobSetting } from '/@/hooks/setting'
const globSetting = useGlobSetting()
let HOST = globSetting.apiUrl
let HOST = 'localhost'
let API_URL = `${HOST}`
let API_URL_PREFIX = globSetting.urlPrefix
......@@ -9,6 +9,7 @@ let API_URL_PREFIX = globSetting.urlPrefix
// ✨ 生产环境
// HOST = 'https://beta.app.yiring.com'
// API_URL = `${HOST}`
// API_URL_PREFIX = globSetting.urlPrefix
// 📖 开发环境
HOST = globSetting.apiUrl
......@@ -16,7 +17,10 @@ API_URL = `${HOST}`
API_URL_PREFIX = globSetting.urlPrefix
// 🔦 检查生产环境,使用对应 env 中的配置,保留原有方式方便开发中调试
API_URL = import.meta.env.MODE !== 'development' ? globSetting.apiUrl : API_URL
if (import.meta.env.MODE !== 'development') {
API_URL = globSetting.apiUrl
API_URL_PREFIX = globSetting.urlPrefix
}
// 📢 如果使用代理访问网站,则默认使用代理 API 地址
// API_URL = isProxy(window.location.host) ? `http://proxy.yiring.com` : API_URL
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论