mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-11-07 02:57:11 +08:00
feat: 新增代码生成
This commit is contained in:
@@ -3,9 +3,11 @@ export * from './auth'
|
||||
export * from './common'
|
||||
export * from './monitor'
|
||||
export * from './system'
|
||||
export * from './tool'
|
||||
|
||||
export * from './area/type'
|
||||
export * from './auth/type'
|
||||
export * from './common/type'
|
||||
export * from './monitor/type'
|
||||
export * from './system/type'
|
||||
export * from './tool/type'
|
||||
|
||||
38
src/apis/tool/generator.ts
Normal file
38
src/apis/tool/generator.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import http from '@/utils/http'
|
||||
import type * as Tool from './type'
|
||||
|
||||
const BASE_URL = '/generator'
|
||||
|
||||
/** @desc 查询代码生成列表 */
|
||||
export function listGenerator(query: Tool.TablePageQuery) {
|
||||
return http.get<PageRes<Tool.TableResp[]>>(`${BASE_URL}/table`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询字段配置列表 */
|
||||
export function listFieldConfig(tableName: string, requireSync: boolean) {
|
||||
return http.get<Tool.FieldConfigResp[]>(`${BASE_URL}/field/${tableName}?requireSync=${requireSync}`)
|
||||
}
|
||||
|
||||
/** @desc 查询生成配置信息 */
|
||||
export function getGenConfig(tableName: string) {
|
||||
return http.get<Tool.GenConfigResp>(`${BASE_URL}/config/${tableName}`)
|
||||
}
|
||||
|
||||
/** @desc 保存配置信息 */
|
||||
export function saveGenConfig(tableName: string, req: Tool.GeneratorConfigResp) {
|
||||
return http.post(`${BASE_URL}/config/${tableName}`, req)
|
||||
}
|
||||
|
||||
/** @desc 生成预览 */
|
||||
export function genPreview(tableName: string) {
|
||||
return http.get<Tool.GeneratePreviewResp[]>(`${BASE_URL}/preview/${tableName}`)
|
||||
}
|
||||
|
||||
/** @desc 生成代码 */
|
||||
export function generate(tableNames: Array<string>) {
|
||||
return http.requestNative({
|
||||
url: `${BASE_URL}/${tableNames}`,
|
||||
method: 'post',
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
1
src/apis/tool/index.ts
Normal file
1
src/apis/tool/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './generator'
|
||||
49
src/apis/tool/type.ts
Normal file
49
src/apis/tool/type.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/** 工具代码生成类型 */
|
||||
export interface TableResp {
|
||||
tableName: string
|
||||
comment?: string
|
||||
engine: string
|
||||
charset: string
|
||||
createTime?: string
|
||||
isConfiged: boolean
|
||||
disabled: boolean
|
||||
}
|
||||
export interface TableQuery {
|
||||
tableName?: string
|
||||
}
|
||||
export interface TablePageQuery extends PageQuery, TableQuery {}
|
||||
export interface FieldConfigResp {
|
||||
tableName: string
|
||||
columnName: string
|
||||
columnType: string
|
||||
fieldName: string
|
||||
fieldType: string
|
||||
fieldSort: number
|
||||
comment: string
|
||||
isRequired: boolean
|
||||
showInList: boolean
|
||||
showInForm: boolean
|
||||
showInQuery: boolean
|
||||
formType: string
|
||||
queryType: string
|
||||
createTime?: string
|
||||
}
|
||||
export interface GenConfigResp {
|
||||
tableName: string
|
||||
moduleName: string
|
||||
packageName: string
|
||||
businessName: string
|
||||
author: string
|
||||
tablePrefix: string
|
||||
isOverride: boolean
|
||||
createTime?: string
|
||||
updateTime?: string
|
||||
}
|
||||
export interface GeneratorConfigResp {
|
||||
genConfig: GenConfigResp
|
||||
fieldConfigs: FieldConfigResp[]
|
||||
}
|
||||
export interface GeneratePreviewResp {
|
||||
fileName: string
|
||||
content: string
|
||||
}
|
||||
Reference in New Issue
Block a user