提交 e65252df 作者: 方治民

feat(api): openapi v3 初步适配

上级 b4a1225d
...@@ -13,12 +13,13 @@ VITE_PROXY = [["/basic-api","http://localhost:3000"],["/upload","http://localhos ...@@ -13,12 +13,13 @@ VITE_PROXY = [["/basic-api","http://localhost:3000"],["/upload","http://localhos
VITE_DROP_CONSOLE = false VITE_DROP_CONSOLE = false
# Basic interface address SPA # Basic interface address SPA
VITE_GLOB_API_URL=/basic-api # VITE_GLOB_API_URL=/basic-api
# VITE_GLOB_API_URL=http://192.168.0.156:8081 VITE_GLOB_API_URL=http://127.0.0.1:8081
# Interface prefix # Interface prefix
VITE_GLOB_API_URL_PREFIX= # VITE_GLOB_API_URL_PREFIX=
# VITE_GLOB_API_URL_PREFIX=/api VITE_GLOB_API_URL_PREFIX=/api
# File upload address, optional # File upload address, optional
VITE_GLOB_UPLOAD_URL=/upload # VITE_GLOB_UPLOAD_URL=/upload
VITE_GLOB_UPLOAD_URL=/common/file/upload
...@@ -60,10 +60,10 @@ ...@@ -60,10 +60,10 @@
"@logicflow/core": "^1.1.31", "@logicflow/core": "^1.1.31",
"@logicflow/extension": "^1.1.31", "@logicflow/extension": "^1.1.31",
"@stomp/stompjs": "^6.1.2", "@stomp/stompjs": "^6.1.2",
"@vue/runtime-core": "^3.2.45", "@vue/runtime-core": "^3.2.47",
"@vue/shared": "^3.2.45", "@vue/shared": "^3.2.47",
"@vueuse/core": "^9.11.1", "@vueuse/core": "^9.12.0",
"@vueuse/shared": "^9.11.1", "@vueuse/shared": "^9.12.0",
"@zxcvbn-ts/core": "^2.2.0", "@zxcvbn-ts/core": "^2.2.0",
"ant-design-vue": "^3.2.15", "ant-design-vue": "^3.2.15",
"axios": "^0.26.1", "axios": "^0.26.1",
...@@ -73,12 +73,13 @@ ...@@ -73,12 +73,13 @@
"dayjs": "^1.11.7", "dayjs": "^1.11.7",
"echarts": "^5.4.1", "echarts": "^5.4.1",
"intro.js": "^5.1.0", "intro.js": "^5.1.0",
"js-file-download": "^0.4.12",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"nanoid": "^4.0.0", "nanoid": "^4.0.0",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"path-to-regexp": "^6.2.1", "path-to-regexp": "^6.2.1",
"pinia": "^2.0.29", "pinia": "^2.0.30",
"print-js": "^1.6.0", "print-js": "^1.6.0",
"qrcode": "^1.5.1", "qrcode": "^1.5.1",
"qs": "^6.11.0", "qs": "^6.11.0",
...@@ -89,7 +90,7 @@ ...@@ -89,7 +90,7 @@
"stompjs": "^2.3.3", "stompjs": "^2.3.3",
"tinymce": "^5.10.7", "tinymce": "^5.10.7",
"vditor": "^3.9.0", "vditor": "^3.9.0",
"vue": "^3.2.45", "vue": "^3.2.47",
"vue-i18n": "^9.2.2", "vue-i18n": "^9.2.2",
"vue-json-pretty": "^2.2.3", "vue-json-pretty": "^2.2.3",
"vue-router": "^4.1.6", "vue-router": "^4.1.6",
...@@ -99,13 +100,14 @@ ...@@ -99,13 +100,14 @@
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^17.4.2", "@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2", "@commitlint/config-conventional": "^17.4.2",
"@iconify/json": "^2.2.13", "@iconify/json": "^2.2.15",
"@purge-icons/generated": "^0.8.1", "@purge-icons/generated": "^0.8.1",
"@types/codemirror": "^5.60.7", "@types/codemirror": "^5.60.7",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/inquirer": "^9.0.3", "@types/inquirer": "^9.0.3",
"@types/intro.js": "^3.0.2", "@types/intro.js": "^3.0.2",
"@types/lodash": "^4.14.191",
"@types/lodash-es": "^4.17.6", "@types/lodash-es": "^4.17.6",
"@types/mockjs": "^1.0.7", "@types/mockjs": "^1.0.7",
"@types/node": "^18.11.18", "@types/node": "^18.11.18",
...@@ -116,14 +118,14 @@ ...@@ -116,14 +118,14 @@
"@types/sockjs-client": "^1.5.1", "@types/sockjs-client": "^1.5.1",
"@types/sortablejs": "^1.15.0", "@types/sortablejs": "^1.15.0",
"@types/stompjs": "^2.3.5", "@types/stompjs": "^2.3.5",
"@typescript-eslint/eslint-plugin": "^5.49.0", "@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.49.0", "@typescript-eslint/parser": "^5.50.0",
"@vitejs/plugin-legacy": "^2.3.1", "@vitejs/plugin-legacy": "^2.3.1",
"@vitejs/plugin-vue": "^3.2.0", "@vitejs/plugin-vue": "^3.2.0",
"@vitejs/plugin-vue-jsx": "^1.3.10", "@vitejs/plugin-vue-jsx": "^1.3.10",
"@vue/compiler-dom": "^3.2.45", "@vue/compiler-dom": "^3.2.47",
"@vue/compiler-sfc": "3.2.31", "@vue/compiler-sfc": "3.2.31",
"@vue/test-utils": "^2.2.8", "@vue/test-utils": "^2.2.10",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.13",
"commitizen": "^4.3.0", "commitizen": "^4.3.0",
"conventional-changelog-cli": "^2.2.2", "conventional-changelog-cli": "^2.2.2",
...@@ -142,6 +144,7 @@ ...@@ -142,6 +144,7 @@
"inquirer": "^9.1.4", "inquirer": "^9.1.4",
"less": "^4.1.3", "less": "^4.1.3",
"lint-staged": "12.3.7", "lint-staged": "12.3.7",
"lodash": "^4.17.21",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"picocolors": "^1.0.0", "picocolors": "^1.0.0",
"pont-engine": "^1.5.5", "pont-engine": "^1.5.5",
...@@ -159,14 +162,14 @@ ...@@ -159,14 +162,14 @@
"stylelint-config-recommended-vue": "^1.4.0", "stylelint-config-recommended-vue": "^1.4.0",
"stylelint-config-standard": "^29.0.0", "stylelint-config-standard": "^29.0.0",
"stylelint-order": "^5.0.0", "stylelint-order": "^5.0.0",
"terser": "^5.16.1", "terser": "^5.16.2",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^4.9.4", "typescript": "^4.9.5",
"unplugin-auto-import": "^0.12.2", "unplugin-auto-import": "^0.12.2",
"vite": "^3.2.5", "vite": "^3.2.5",
"vite-plugin-compression": "^0.5.1", "vite-plugin-compression": "^0.5.1",
"vite-plugin-html": "^3.2.0", "vite-plugin-html": "^3.2.0",
"vite-plugin-mkcert": "^1.11.0", "vite-plugin-mkcert": "^1.12.0",
"vite-plugin-mock": "^2.9.6", "vite-plugin-mock": "^2.9.6",
"vite-plugin-purge-icons": "^0.9.2", "vite-plugin-purge-icons": "^0.9.2",
"vite-plugin-pwa": "^0.13.3", "vite-plugin-pwa": "^0.13.3",
......
{ {
"originType": "SwaggerV2", "originType": "SwaggerV3",
"originUrl": "http://127.0.0.1:8081/api/v2/api-docs", "originUrl": "http://127.0.0.1:8081/api/v3/api-docs",
"templateType": "fetch", "templateType": "fetch",
"templatePath": "./pont-template", "templatePath": "./pont-template",
"transformPath": "./pont-transform", "transformPath": "./pont-transform",
"outDir": "./src/api/services", "outDir": "./src/api/services",
"surrounding": "typeScript", "surrounding": "typeScript",
"usingOperationId": true,
"mocks": { "mocks": {
"enable": true, "enable": true,
"basePath": "", "basePath": "",
......
import * as Pont from 'pont-engine' // import * as Pont from 'pont-engine'
import { Interface, BaseClass, Property, CodeGenerator } from 'pont-engine' import { Interface, BaseClass, Property, CodeGenerator } from 'pont-engine'
// 接口 API 前缀 // 接口 API 前缀
// 通常与项目的 env 配置中的 VITE_GLOB_API_URL_PREFIX 相同 // 通常与项目的 env 配置中的 VITE_GLOB_API_URL_PREFIX 相同
const API_URL_PREFIX = '/api' const API_URL_PREFIX = '/api'
export class FileStructures extends Pont.FileStructures {
getModsDeclaration(originCode: string): string {
return originCode
}
}
export default class BasicGenerator extends CodeGenerator { export default class BasicGenerator extends CodeGenerator {
checkJsonParam(inter: Interface, paramsCode: string): boolean { isRequestBody(inter: Interface, paramsCode: string): boolean {
const prettier = require('prettier') const prettier = require('prettier')
const requestParams = inter.getRequestParams(this.surrounding) const requestParams = inter.getRequestParams(this.surrounding)
const code = prettier.format(paramsCode, { parser: 'typescript' }) const code = prettier.format(paramsCode, { parser: 'typescript' })
return code.includes('{}') && requestParams.includes('body') return code.includes('{}') && requestParams.includes('body')
} }
// 认为没有返回值的接口表示下载(通常是)
isDownload(inter: Interface): boolean {
return inter.responseType === 'any'
}
// 认为包含 form 参数的接口表示带有上传功能 // 认为包含 form 参数的接口表示带有上传功能
isUpload(inter: Interface): boolean { isUpload(inter: Interface): boolean {
return inter.getRequestParams(this.surrounding).includes('form') return inter.getRequestParams(this.surrounding).includes('form')
...@@ -40,8 +29,9 @@ export default class BasicGenerator extends CodeGenerator { ...@@ -40,8 +29,9 @@ export default class BasicGenerator extends CodeGenerator {
} }
if (requestParams.includes('body')) { if (requestParams.includes('body')) {
requestParams = requestParams.replace('params?: Params, ', '')
bodyTypeDef = requestParams.replace(/^.*body: (.*),.*$/gi, '$1') bodyTypeDef = requestParams.replace(/^.*body: (.*),.*$/gi, '$1')
requestParams = requestParams.replace('params?: Params, ', '')
requestParams = requestParams.replace('body:', 'body?:')
} }
} }
...@@ -56,11 +46,18 @@ export default class BasicGenerator extends CodeGenerator { ...@@ -56,11 +46,18 @@ export default class BasicGenerator extends CodeGenerator {
getInterfaceContentInDeclaration(inter: Interface) { getInterfaceContentInDeclaration(inter: Interface) {
const paramsCode = inter.getParamsCode('Params') const paramsCode = inter.getParamsCode('Params')
const requestParams = this.getParams(inter, paramsCode) 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 ` return `
export ${paramsCode} export ${paramsCode}
export type Response = ${inter.responseType.replace(/defs.Result\<(.*)\>/, '$1')}; export type Response = ${targetResponseType};
export const init: Response; export const init: Response;
...@@ -88,8 +85,10 @@ export default class BasicGenerator extends CodeGenerator { ...@@ -88,8 +85,10 @@ export default class BasicGenerator extends CodeGenerator {
const method = inter.method.toUpperCase() const method = inter.method.toUpperCase()
const paramsCode = inter.getParamsCode('Params', this.surrounding) const paramsCode = inter.getParamsCode('Params', this.surrounding)
const requestParams = this.getParams(inter, paramsCode) const requestParams = this.getParams(inter, paramsCode)
const isBody = this.checkJsonParam(inter, paramsCode) const initValue = inter.response.getInitialValue(true)
const responseType = `Promise<${inter.responseType.replace(/defs.Result\<(.*)\>/, '$1') || 'any'}>` const undef = initValue === 'undefined' || initValue === `''`
const isBody = this.isRequestBody(inter, paramsCode)
const isDownload = inter.responseType === 'File'
// TODO // TODO
// 扩展 hooks mode // 扩展 hooks mode
...@@ -99,11 +98,15 @@ export default class BasicGenerator extends CodeGenerator { ...@@ -99,11 +98,15 @@ export default class BasicGenerator extends CodeGenerator {
/** /**
* @desc ${inter.description} * @desc ${inter.description}
*/ */
${undef ? '' : `import * as defs from '../../baseClass';`}
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
${isBody ? '' : `export ${paramsCode}`} ${isBody ? '' : `export ${paramsCode}`}
export function request(${requestParams}): ${responseType} { ${undef ? '' : `export const init = ${initValue};`}
export function request(${requestParams}) {
return defHttp.request({ return defHttp.request({
url: "${inter.path.replace(API_URL_PREFIX, '')}", url: "${inter.path.replace(API_URL_PREFIX, '')}",
method: '${method}', method: '${method}',
...@@ -116,12 +119,24 @@ export default class BasicGenerator extends CodeGenerator { ...@@ -116,12 +119,24 @@ export default class BasicGenerator extends CodeGenerator {
requestParams.includes('form') requestParams.includes('form')
? `headers: { 'Content-Type': 'multipart/form-data;charset=UTF-8' },` ? `headers: { 'Content-Type': 'multipart/form-data;charset=UTF-8' },`
: isBody : isBody
? `headers: { 'Content-Type': 'application/json;charset=UTF-8' },` ? `headers: { 'Content-Type': 'application/json' },`
: ''
}
${
isDownload
? `
responseType: 'blob',
timeout: 0,
`
: '' : ''
} }
...config, ...config,
}, options); }, {
${isDownload ? `download: true,` : ''}
...options,
});
} }
` `
} }
......
import { StandardDataSource } from 'pont-engine' import { StandardDataSource } from 'pont-engine'
export default function (dataSource: StandardDataSource): StandardDataSource { export default function transform(dataSource: StandardDataSource): StandardDataSource {
console.log(dataSource)
return dataSource return dataSource
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
/** /**
* @desc 登录 * @desc 登录
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
...@@ -10,11 +12,9 @@ export class Params { ...@@ -10,11 +12,9 @@ export class Params {
password: string password: string
} }
export function request( export const init = new defs.ResultLoginVo()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<defs.LoginVo> {
return defHttp.request( return defHttp.request(
{ {
url: '/auth/login', url: '/auth/login',
...@@ -23,6 +23,8 @@ export function request( ...@@ -23,6 +23,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 登出 * @desc 登出
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export const init = new defs.ResultString()
params?: Params,
config?: http.RequestConfig<Params>, export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/auth/logout', url: '/auth/logout',
...@@ -18,6 +18,8 @@ export function request( ...@@ -18,6 +18,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 注册 * @desc 注册
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** 用户名 */
username: string
/** 密码 */
password: string
/** 真实姓名 */
realName: string
/** 手机号 */
mobile: string
/** 头像 */ /** 头像 */
avatar?: string avatar?: string
/** 邮箱 */ /** 邮箱 */
email?: string email?: string
/** 是否启用 */ /** 是否启用 */
enable?: boolean enable?: boolean
/** 简介 */
introduction?: string
/** 手机号 */
mobile: string
/** 密码 */
password: string
/** 真实姓名 */
realName: string
/** 用户名 */
username: string
} }
export function request( export const init = new defs.ResultString()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/auth/register', url: '/auth/register',
...@@ -35,6 +33,8 @@ export function request( ...@@ -35,6 +33,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 安全校验 * @desc 安全验证
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
...@@ -8,11 +10,9 @@ export class Params { ...@@ -8,11 +10,9 @@ export class Params {
password: string password: string
} }
export function request( export const init = new defs.ResultString()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/auth/safe', url: '/auth/safe',
...@@ -21,6 +21,8 @@ export function request( ...@@ -21,6 +21,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 检查登录 * @desc 检查登录
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export const init = new defs.ResultBoolean()
params?: Params,
config?: http.RequestConfig<Params>, export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<boolean> {
return defHttp.request( return defHttp.request(
{ {
url: '/auth/valid', url: '/auth/valid',
...@@ -18,6 +18,8 @@ export function request( ...@@ -18,6 +18,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/**
* @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,
},
)
}
/** /**
* @desc 删除 * @desc 删除
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
...@@ -8,19 +10,19 @@ export class Params { ...@@ -8,19 +10,19 @@ export class Params {
ids: string ids: string
} }
export function request( export const init = new defs.ResultString()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/role/deleted', url: '/sys/dict/remove',
method: 'POST', method: 'POST',
data: params, data: params,
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/**
* @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,
},
)
}
/** /**
* @desc 文件下载 * @desc 文件下载
*/ */
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
params?: Params,
config?: http.RequestConfig<Params>,
options?: http.RequestOptions,
): Promise<any> {
return defHttp.request( return defHttp.request(
{ {
url: '/example/download', url: '/example/download',
method: 'GET', method: 'GET',
params, params,
responseType: 'blob',
timeout: 0,
...config, ...config,
}, },
options, {
download: true,
...options,
},
) )
} }
/** /**
* @desc 测试失败 * @desc 测试失败
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export const init = new defs.ResultString()
params?: Params,
config?: http.RequestConfig<Params>, export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/example/fail', url: '/example/fail',
...@@ -18,6 +18,8 @@ export function request( ...@@ -18,6 +18,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 查询用户属性 * @desc 查询用户属性
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export const init = new defs.ResultUserExtensionVo()
params?: Params,
config?: http.RequestConfig<Params>, export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<defs.UserExtensionVo> {
return defHttp.request( return defHttp.request(
{ {
url: '/example/findUserExtensionInfo', url: '/example/findUserExtensionInfo',
...@@ -18,6 +18,8 @@ export function request( ...@@ -18,6 +18,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc Hello World * @desc Hello World
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export const init = new defs.ResultString()
params?: Params,
config?: http.RequestConfig<Params>, export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/example/', url: '/example/',
...@@ -18,6 +18,8 @@ export function request( ...@@ -18,6 +18,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
...@@ -7,5 +7,6 @@ import * as fail from './fail' ...@@ -7,5 +7,6 @@ import * as fail from './fail'
import * as findUserExtensionInfo from './findUserExtensionInfo' import * as findUserExtensionInfo from './findUserExtensionInfo'
import * as json from './json' import * as json from './json'
import * as page from './page' 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 }
/** /**
* @desc JSON 传参 * @desc JSON 传参
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export const init = new defs.ResultPageVoString()
export function request( export function request(
body: defs.PageParam, body?: defs.PageParam,
config?: http.RequestConfig<defs.PageParam>, config?: http.RequestConfig<defs.PageParam>,
options?: http.RequestOptions, options?: http.RequestOptions,
): Promise<defs.PageVo<string>> { ) {
return defHttp.request( return defHttp.request(
{ {
url: '/example/json', url: '/example/json',
...@@ -17,6 +21,8 @@ export function request( ...@@ -17,6 +21,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 分页条件查询 * @desc 分页条件查询
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** 当前页数 */
pageNo: number
/** 分页条数 */ /** 分页条数 */
pageSize: number pageSize: number
/** 当前页数 */
pageNo: number
/** 排序字段 */ /** 排序字段 */
sortField?: string sortField?: string
/** 排序方向(ASC|DESC) */ /** 排序方向(ASC|DESC) */
sortOrder?: 'ASC' | 'DESC' sortOrder?: string
} }
export function request( export const init = new defs.ResultPageVoString()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<defs.PageVo<string>> {
return defHttp.request( return defHttp.request(
{ {
url: '/example/page', url: '/example/page',
...@@ -27,6 +27,8 @@ export function request( ...@@ -27,6 +27,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/**
* @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,
},
)
}
/** /**
* @desc 文件下载 * @desc 文件下载
*/ */
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
...@@ -10,19 +11,22 @@ export class Params { ...@@ -10,19 +11,22 @@ export class Params {
object: string object: string
} }
export function request( export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
params: Params,
config?: http.RequestConfig<Params>,
options?: http.RequestOptions,
): Promise<any> {
return defHttp.request( return defHttp.request(
{ {
url: '/common/file/download', url: '/common/file/download',
method: 'GET', method: 'GET',
params, params,
responseType: 'blob',
timeout: 0,
...config, ...config,
}, },
options, {
download: true,
...options,
},
) )
} }
/** /**
* @desc 文件上传 * @desc 文件上传
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export const init = new defs.ResultString()
export function request( export function request(body?: object, config?: http.RequestConfig<object>, options?: http.RequestOptions) {
params: Params,
form: FormData,
config?: http.RequestConfig<Params | FormData>,
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/common/file/upload', url: '/common/file/upload',
method: 'POST', method: 'POST',
data: form || params, data: body,
headers: { 'Content-Type': 'multipart/form-data;charset=UTF-8' }, headers: { 'Content-Type': 'application/json' },
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc Base64 图片上传 * @desc Base64 图片上传
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export const init = new defs.ResultString()
/** Base64 图片信息 */
base64Image: string
}
export function request( export function request(body?: string, config?: http.RequestConfig<string>, options?: http.RequestOptions) {
params: Params,
config?: http.RequestConfig<Params>,
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/common/file/uploadBase64Image', url: '/common/file/uploadBase64Image',
method: 'POST', method: 'POST',
data: params, data: body,
headers: { 'Content-Type': 'application/json' },
...config, ...config,
}, },
options, {
...options,
},
) )
} }
import * as auth from './auth' import * as auth from './auth'
import * as dict from './dict'
import * as dictItem from './dictItem'
import * as example from './example' import * as example from './example'
import * as file from './file' import * as file from './file'
import * as permission from './permission' import * as permission from './permission'
...@@ -8,6 +10,8 @@ import * as userView from './userView' ...@@ -8,6 +10,8 @@ import * as userView from './userView'
export const API = { export const API = {
auth, auth,
dict,
dictItem,
example, example,
file, file,
permission, permission,
......
/** /**
* @desc 新增 * @desc 新增
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export const init = new defs.ResultString()
/** 组件 */
component?: string
/** 是否启用 */
enable?: boolean
/** 是否隐藏 */
hidden?: boolean
/** 图标 */
icon?: string
/** 元数据 */
meta?: string
/** 名称 */
name: string
/** 路径 */
path?: string
/** 父级ID */
pid?: string
/** 重定向 */
redirect?: string
/** 序号 */
serial?: number
/** 权限类型 */
type: 'DIR' | 'MENU' | 'BUTTON'
/** 标识 */
uid: string
}
export function request( export function request(
params: Params, body?: defs.PermissionParam,
config?: http.RequestConfig<Params>, config?: http.RequestConfig<defs.PermissionParam>,
options?: http.RequestOptions, options?: http.RequestOptions,
): Promise<string> { ) {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/permission/add', url: '/sys/permission/add',
method: 'POST', method: 'POST',
data: params, data: body,
headers: { 'Content-Type': 'application/json' },
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 查询 * @desc 查询
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
...@@ -8,11 +10,9 @@ export class Params { ...@@ -8,11 +10,9 @@ export class Params {
id: string id: string
} }
export function request( export const init = new defs.ResultPermissionVo()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<defs.PermissionVo> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/permission/find', url: '/sys/permission/find',
...@@ -21,6 +21,8 @@ export function request( ...@@ -21,6 +21,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
* @description 权限管理 * @description 权限管理
*/ */
import * as add from './add' import * as add from './add'
import * as deleted from './deleted'
import * as find from './find' import * as find from './find'
import * as modify from './modify' import * as modify from './modify'
import * as page from './page' import * as page from './page'
import * as remove from './remove'
import * as tree from './tree' import * as tree from './tree'
export { add, deleted, find, modify, page, tree } export { add, find, modify, page, remove, tree }
/** /**
* @desc 修改 * @desc 修改
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export const init = new defs.ResultString()
/** 组件 */
component?: string
/** 是否启用 */
enable?: boolean
/** 是否隐藏 */
hidden?: boolean
/** 图标 */
icon?: string
/** id */
id: string
/** 元数据 */
meta?: string
/** 名称 */
name: string
/** 路径 */
path?: string
/** 父级ID */
pid?: string
/** 重定向 */
redirect?: string
/** 序号 */
serial?: number
/** 权限类型 */
type: 'DIR' | 'MENU' | 'BUTTON'
/** 标识 */
uid: string
}
export function request( export function request(
params: Params, body?: defs.PermissionParam,
config?: http.RequestConfig<Params>, config?: http.RequestConfig<defs.PermissionParam>,
options?: http.RequestOptions, options?: http.RequestOptions,
): Promise<string> { ) {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/permission/modify', url: '/sys/permission/modify',
method: 'POST', method: 'POST',
data: params, data: body,
headers: { 'Content-Type': 'application/json' },
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 分页查询 * @desc 分页查询
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** 当前页数 */
pageNo: number
/** 分页条数 */ /** 分页条数 */
pageSize: number pageSize: number
/** 当前页数 */
pageNo: number
/** 排序字段 */ /** 排序字段 */
sortField?: string sortField?: string
/** 排序方向(ASC|DESC) */ /** 排序方向(ASC|DESC) */
sortOrder?: 'ASC' | 'DESC' sortOrder?: string
} }
export function request( export const init = new defs.ResultPageVoPermissionVo()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<defs.PageVo<defs.PermissionVo>> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/permission/page', url: '/sys/permission/page',
...@@ -27,6 +27,8 @@ export function request( ...@@ -27,6 +27,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 删除 * @desc 删除
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
...@@ -8,19 +10,19 @@ export class Params { ...@@ -8,19 +10,19 @@ export class Params {
id: string id: string
} }
export function request( export const init = new defs.ResultString()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/permission/deleted', url: '/sys/permission/remove',
method: 'POST', method: 'POST',
data: params, data: params,
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 树结构查询 * @desc 树结构查询
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** pid */ /** pid */
pid?: string pid: string
} }
export function request( export const init = new defs.ResultArrayListPermissionVo()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<Array<defs.PermissionVo>> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/permission/tree', url: '/sys/permission/tree',
...@@ -21,6 +21,8 @@ export function request( ...@@ -21,6 +21,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 新增 * @desc 新增
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** 名称 */ /** id */
name: string id: string
/** 标识 */ /** 标识 */
uid: string uid: string
/** 名称 */
name: string
} }
export function request( export const init = new defs.ResultString()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/role/add', url: '/sys/role/add',
...@@ -23,6 +25,8 @@ export function request( ...@@ -23,6 +25,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 分配权限 * @desc 分配权限
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
...@@ -10,11 +12,9 @@ export class Params { ...@@ -10,11 +12,9 @@ export class Params {
ids: string ids: string
} }
export function request( export const init = new defs.ResultString()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/role/assign', url: '/sys/role/assign',
...@@ -23,6 +23,8 @@ export function request( ...@@ -23,6 +23,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 查询 * @desc 查询
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
...@@ -8,11 +10,9 @@ export class Params { ...@@ -8,11 +10,9 @@ export class Params {
id: string id: string
} }
export function request( export const init = new defs.ResultRoleVo()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<defs.RoleVo> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/role/find', url: '/sys/role/find',
...@@ -21,6 +21,8 @@ export function request( ...@@ -21,6 +21,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
*/ */
import * as add from './add' import * as add from './add'
import * as assign from './assign' import * as assign from './assign'
import * as deleted from './deleted'
import * as find from './find' import * as find from './find'
import * as modify from './modify' import * as modify from './modify'
import * as page from './page' import * as page from './page'
import * as remove from './remove'
import * as selector from './selector' import * as selector from './selector'
export { add, assign, deleted, find, modify, page, selector } export { add, assign, find, modify, page, remove, selector }
/** /**
* @desc 修改 * @desc 修改
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** id */ /** id */
id: string id: string
/** 名称 */
name: string
/** 标识 */ /** 标识 */
uid: string uid: string
/** 名称 */
name: string
} }
export function request( export const init = new defs.ResultString()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/role/modify', url: '/sys/role/modify',
...@@ -25,6 +25,8 @@ export function request( ...@@ -25,6 +25,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 分页查询 * @desc 分页查询
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** 当前页数 */
pageNo: number
/** 分页条数 */ /** 分页条数 */
pageSize: number pageSize: number
/** 当前页数 */
pageNo: number
/** 排序字段 */ /** 排序字段 */
sortField?: string sortField?: string
/** 排序方向(ASC|DESC) */ /** 排序方向(ASC|DESC) */
sortOrder?: 'ASC' | 'DESC' sortOrder?: string
} }
export function request( export const init = new defs.ResultPageVoRoleVo()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<defs.PageVo<defs.RoleVo>> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/role/page', url: '/sys/role/page',
...@@ -27,6 +27,8 @@ export function request( ...@@ -27,6 +27,8 @@ export function request(
...config, ...config,
}, },
options, {
...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/role/remove',
method: 'POST',
data: params,
...config,
},
{
...options,
},
)
}
/** /**
* @desc 选项查询 * @desc 选项查询
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export const init = new defs.ResultArrayListRoleVo()
params?: Params,
config?: http.RequestConfig<Params>, export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<Array<defs.RoleVo>> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/role/selector', url: '/sys/role/selector',
...@@ -18,6 +18,8 @@ export function request( ...@@ -18,6 +18,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 分配角色 * @desc 分配角色
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
...@@ -10,11 +12,9 @@ export class Params { ...@@ -10,11 +12,9 @@ export class Params {
ids: string ids: string
} }
export function request( export const init = new defs.ResultString()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<string> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/user/assign', url: '/sys/user/assign',
...@@ -23,6 +23,8 @@ export function request( ...@@ -23,6 +23,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 分页查询 * @desc 分页查询
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params { export class Params {
/** 当前页数 */
pageNo: number
/** 分页条数 */ /** 分页条数 */
pageSize: number pageSize: number
/** 当前页数 */
pageNo: number
/** 排序字段 */ /** 排序字段 */
sortField?: string sortField?: string
/** 排序方向(ASC|DESC) */ /** 排序方向(ASC|DESC) */
sortOrder?: 'ASC' | 'DESC' sortOrder?: string
} }
export function request( export const init = new defs.ResultPageVoUserVo()
params: Params,
config?: http.RequestConfig<Params>, export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<defs.PageVo<defs.UserVo>> {
return defHttp.request( return defHttp.request(
{ {
url: '/sys/user/page', url: '/sys/user/page',
...@@ -27,6 +27,8 @@ export function request( ...@@ -27,6 +27,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 获取用户菜单 * @desc 获取用户菜单
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export const init = new defs.ResultArrayListMenuVo()
params?: Params,
config?: http.RequestConfig<Params>, export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<Array<defs.MenuVo>> {
return defHttp.request( return defHttp.request(
{ {
url: '/user/getMenuList', url: '/user/getMenuList',
...@@ -18,6 +18,8 @@ export function request( ...@@ -18,6 +18,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 获取用户权限 * @desc 获取用户权限
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export const init = new defs.ResultArrayListString()
params?: Params,
config?: http.RequestConfig<Params>, export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<Array<string>> {
return defHttp.request( return defHttp.request(
{ {
url: '/user/getPermCode', url: '/user/getPermCode',
...@@ -18,6 +18,8 @@ export function request( ...@@ -18,6 +18,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
/** /**
* @desc 获取登录用户信息 * @desc 获取登录用户信息
*/ */
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios' import { defHttp } from '/@/utils/http/axios'
export class Params {} export class Params {}
export function request( export const init = new defs.ResultUserInfo()
params?: Params,
config?: http.RequestConfig<Params>, export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
options?: http.RequestOptions,
): Promise<defs.UserInfo> {
return defHttp.request( return defHttp.request(
{ {
url: '/user/getUserInfo', url: '/user/getUserInfo',
...@@ -18,6 +18,8 @@ export function request( ...@@ -18,6 +18,8 @@ export function request(
...config, ...config,
}, },
options, {
...options,
},
) )
} }
const validColors = ['error', 'warning', 'success', ''] as const const validColors = ['error', 'warning', 'success', ''] as const
type ButtonColorType = typeof validColors[number] type ButtonColorType = (typeof validColors)[number]
export const buttonProps = { export const buttonProps = {
color: { color: {
......
...@@ -83,7 +83,7 @@ export default defineComponent({ ...@@ -83,7 +83,7 @@ export default defineComponent({
<> <>
<TypePicker <TypePicker
menuTypeList={menuTypeList} menuTypeList={menuTypeList}
handler={(item: typeof menuTypeList[0]) => { handler={(item: (typeof menuTypeList)[0]) => {
baseHandler(HandlerEnum.CHANGE_LAYOUT, { baseHandler(HandlerEnum.CHANGE_LAYOUT, {
mode: item.mode, mode: item.mode,
type: item.type, type: item.type,
......
...@@ -21,6 +21,7 @@ import { AxiosRetry } from '/@/utils/http/axios/axiosRetry' ...@@ -21,6 +21,7 @@ import { AxiosRetry } from '/@/utils/http/axios/axiosRetry'
import * as HTTP from '/@/api/types' import * as HTTP from '/@/api/types'
import { API_URL, API_URL_PREFIX } from '/@/utils/net' import { API_URL, API_URL_PREFIX } from '/@/utils/net'
import { handleResponseResource } from '/@/utils/proxy' import { handleResponseResource } from '/@/utils/proxy'
import fileDownload from 'js-file-download'
const GLOBAL_API_ERROR_MESSAGE_KEY = 'GLOBAL_MESSAGE_KEY' const GLOBAL_API_ERROR_MESSAGE_KEY = 'GLOBAL_MESSAGE_KEY'
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
...@@ -36,7 +37,16 @@ const transform: AxiosTransform = { ...@@ -36,7 +37,16 @@ const transform: AxiosTransform = {
*/ */
transformRequestHook: (res: AxiosResponse<Result>, options: RequestOptions) => { transformRequestHook: (res: AxiosResponse<Result>, options: RequestOptions) => {
const { t } = useI18n() const { t } = useI18n()
const { isTransformResponse, isReturnNativeResponse } = options const { isTransformResponse, isReturnNativeResponse, download } = options
// 判断是否为下载
const disposition = res.headers['content-disposition']
if (download && disposition) {
const fileName = decodeURIComponent(disposition.split('=')[1])
fileDownload(res.data, fileName)
return
}
// 是否返回原生响应头 比如:需要获取响应头时使用该属性 // 是否返回原生响应头 比如:需要获取响应头时使用该属性
if (isReturnNativeResponse) { if (isReturnNativeResponse) {
return res return res
......
...@@ -28,3 +28,7 @@ ...@@ -28,3 +28,7 @@
<div class="title">{{ text }}</div> <div class="title">{{ text }}</div>
</PageWrapper> </PageWrapper>
</template> </template>
<style lang="less" scoped>
/* ... */
</style>
...@@ -11,9 +11,9 @@ export interface RetryRequest { ...@@ -11,9 +11,9 @@ export interface RetryRequest {
export type Result<T = any> = defs.Result<T> export type Result<T = any> = defs.Result<T>
// multipart/form-data: upload file // multipart/form-data: upload file
export interface UploadFileParams { export interface UploadFileParams<T = any> {
// Other parameters // Other parameters
data?: Recordable data?: T | Recordable
// File parameter interface field name // File parameter interface field name
name?: string name?: string
// file name // file name
......
...@@ -122,6 +122,8 @@ declare global { ...@@ -122,6 +122,8 @@ declare global {
withToken?: boolean withToken?: boolean
// 请求重试机制 // 请求重试机制
retryRequest?: RetryRequest retryRequest?: RetryRequest
// 下载
download?: boolean
} }
type RequestConfig<T = any> = AxiosRequestConfig<T> type RequestConfig<T = any> = AxiosRequestConfig<T>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论