mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 03:30:06 +08:00
基础设施:优化vue3标准版API生成(导出xxAPI,方便IDE识别接口)
This commit is contained in:
parent
de8f2800e5
commit
86a9c4bbf4
@ -1,12 +1,14 @@
|
|||||||
import request from '@/config/axios'
|
import request from '@/config/axios'
|
||||||
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
|
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
|
||||||
|
|
||||||
|
// ${table.classComment} VO
|
||||||
export interface ${simpleClassName}VO {
|
export interface ${simpleClassName}VO {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if ($column.createOperation || $column.updateOperation)
|
#if ($column.createOperation || $column.updateOperation)
|
||||||
|
// ${column.columnComment}
|
||||||
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
||||||
${column.javaField}: number
|
${column.javaField}: number
|
||||||
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdatetime")
|
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
|
||||||
${column.javaField}: Date
|
${column.javaField}: Date
|
||||||
#else
|
#else
|
||||||
${column.javaField}: ${column.javaType.toLowerCase()}
|
${column.javaField}: ${column.javaType.toLowerCase()}
|
||||||
@ -15,42 +17,44 @@ export interface ${simpleClassName}VO {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ${table.classComment} API
|
||||||
|
export const ${simpleClassName}Api = {
|
||||||
#if ( $table.templateType != 2 )
|
#if ( $table.templateType != 2 )
|
||||||
// 查询${table.classComment}分页
|
// 查询${table.classComment}分页
|
||||||
export const get${simpleClassName}Page = async (params) => {
|
get${simpleClassName}Page: async (params: any) => {
|
||||||
return await request.get({ url: `${baseURL}/page`, params })
|
return await request.get({ url: `${baseURL}/page`, params })
|
||||||
}
|
},
|
||||||
#else
|
#else
|
||||||
// 查询${table.classComment}列表
|
// 查询${table.classComment}列表
|
||||||
export const get${simpleClassName}List = async (params) => {
|
get${simpleClassName}List: async (params) => {
|
||||||
return await request.get({ url: `${baseURL}/list`, params })
|
return await request.get({ url: `${baseURL}/list`, params })
|
||||||
}
|
},
|
||||||
#end
|
#end
|
||||||
|
|
||||||
// 查询${table.classComment}详情
|
// 查询${table.classComment}详情
|
||||||
export const get${simpleClassName} = async (id: number) => {
|
get${simpleClassName}: async (id: number) => {
|
||||||
return await request.get({ url: `${baseURL}/get?id=` + id })
|
return await request.get({ url: `${baseURL}/get?id=` + id })
|
||||||
}
|
},
|
||||||
|
|
||||||
// 新增${table.classComment}
|
// 新增${table.classComment}
|
||||||
export const create${simpleClassName} = async (data: ${simpleClassName}VO) => {
|
create${simpleClassName}: async (data: ${simpleClassName}VO) => {
|
||||||
return await request.post({ url: `${baseURL}/create`, data })
|
return await request.post({ url: `${baseURL}/create`, data })
|
||||||
}
|
},
|
||||||
|
|
||||||
// 修改${table.classComment}
|
// 修改${table.classComment}
|
||||||
export const update${simpleClassName} = async (data: ${simpleClassName}VO) => {
|
update${simpleClassName}: async (data: ${simpleClassName}VO) => {
|
||||||
return await request.put({ url: `${baseURL}/update`, data })
|
return await request.put({ url: `${baseURL}/update`, data })
|
||||||
}
|
},
|
||||||
|
|
||||||
// 删除${table.classComment}
|
// 删除${table.classComment}
|
||||||
export const delete${simpleClassName} = async (id: number) => {
|
delete${simpleClassName}: async (id: number) => {
|
||||||
return await request.delete({ url: `${baseURL}/delete?id=` + id })
|
return await request.delete({ url: `${baseURL}/delete?id=` + id })
|
||||||
}
|
},
|
||||||
|
|
||||||
// 导出${table.classComment} Excel
|
// 导出${table.classComment} Excel
|
||||||
export const export${simpleClassName} = async (params) => {
|
export${simpleClassName}: async (params) => {
|
||||||
return await request.download({ url: `${baseURL}/export-excel`, params })
|
return await request.download({ url: `${baseURL}/export-excel`, params })
|
||||||
}
|
},
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#foreach ($subTable in $subTables)
|
#foreach ($subTable in $subTables)
|
||||||
#set ($index = $foreach.count - 1)
|
#set ($index = $foreach.count - 1)
|
||||||
@ -66,46 +70,47 @@ export const export${simpleClassName} = async (params) => {
|
|||||||
## 情况一:MASTER_ERP 时,需要分查询页子表
|
## 情况一:MASTER_ERP 时,需要分查询页子表
|
||||||
#if ( $table.templateType == 11 )
|
#if ( $table.templateType == 11 )
|
||||||
|
|
||||||
// 获得${subTable.classComment}分页
|
// 获得${subTable.classComment}分页
|
||||||
export const get${subSimpleClassName}Page = async (params) => {
|
get${subSimpleClassName}Page: async (params) => {
|
||||||
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/page`, params })
|
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/page`, params })
|
||||||
}
|
},
|
||||||
## 情况二:非 MASTER_ERP 时,需要列表查询子表
|
## 情况二:非 MASTER_ERP 时,需要列表查询子表
|
||||||
#else
|
#else
|
||||||
#if ( $subTable.subJoinMany )
|
#if ( $subTable.subJoinMany )
|
||||||
|
|
||||||
// 获得${subTable.classComment}列表
|
// 获得${subTable.classComment}列表
|
||||||
export const get${subSimpleClassName}ListBy${SubJoinColumnName} = async (${subJoinColumn.javaField}) => {
|
get${subSimpleClassName}ListBy${SubJoinColumnName}: async (${subJoinColumn.javaField}) => {
|
||||||
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} })
|
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} })
|
||||||
}
|
},
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// 获得${subTable.classComment}
|
// 获得${subTable.classComment}
|
||||||
export const get${subSimpleClassName}By${SubJoinColumnName} = async (${subJoinColumn.javaField}) => {
|
get${subSimpleClassName}By${SubJoinColumnName}: async (${subJoinColumn.javaField}) => {
|
||||||
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} })
|
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} })
|
||||||
}
|
},
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作
|
## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作
|
||||||
#if ( $table.templateType == 11 )
|
#if ( $table.templateType == 11 )
|
||||||
// 新增${subTable.classComment}
|
// 新增${subTable.classComment}
|
||||||
export const create${subSimpleClassName} = async (data) => {
|
create${subSimpleClassName}: async (data) => {
|
||||||
return await request.post({ url: `${baseURL}/${subSimpleClassName_strikeCase}/create`, data })
|
return await request.post({ url: `${baseURL}/${subSimpleClassName_strikeCase}/create`, data })
|
||||||
}
|
},
|
||||||
|
|
||||||
// 修改${subTable.classComment}
|
// 修改${subTable.classComment}
|
||||||
export const update${subSimpleClassName} = async (data) => {
|
update${subSimpleClassName}: async (data) => {
|
||||||
return await request.put({ url: `${baseURL}/${subSimpleClassName_strikeCase}/update`, data })
|
return await request.put({ url: `${baseURL}/${subSimpleClassName_strikeCase}/update`, data })
|
||||||
}
|
},
|
||||||
|
|
||||||
// 删除${subTable.classComment}
|
// 删除${subTable.classComment}
|
||||||
export const delete${subSimpleClassName} = async (id: number) => {
|
delete${subSimpleClassName}: async (id: number) => {
|
||||||
return await request.delete({ url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id })
|
return await request.delete({ url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id })
|
||||||
}
|
},
|
||||||
|
|
||||||
// 获得${subTable.classComment}
|
// 获得${subTable.classComment}
|
||||||
export const get${subSimpleClassName} = async (id: number) => {
|
get${subSimpleClassName}: async (id: number) => {
|
||||||
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id })
|
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id })
|
||||||
|
},
|
||||||
|
#end
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
#end
|
|
||||||
#end
|
|
@ -114,7 +114,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
import { ${simpleClassName}Api } from '@/api/${table.moduleName}/${table.businessName}'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
@ -265,7 +265,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
import { ${simpleClassName}Api } from '@/api/${table.moduleName}/${table.businessName}'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
${subJoinColumn.javaField}: undefined // ${subJoinColumn.columnComment}(主表的关联字段)
|
${subJoinColumn.javaField}: undefined // ${subJoinColumn.columnComment}(主表的关联字段)
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
import { ${simpleClassName}Api } from '@/api/${table.moduleName}/${table.businessName}'
|
||||||
#if ($table.templateType == 11)
|
#if ($table.templateType == 11)
|
||||||
import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue'
|
import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue'
|
||||||
#end
|
#end
|
||||||
|
@ -140,7 +140,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
import { ${simpleClassName}Api, ${simpleClassName}VO } from '@/api/${table.moduleName}/${table.businessName}'
|
||||||
## 特殊:树表专属逻辑
|
## 特殊:树表专属逻辑
|
||||||
#if ( $table.templateType == 2 )
|
#if ( $table.templateType == 2 )
|
||||||
import { defaultProps, handleTree } from '@/utils/tree'
|
import { defaultProps, handleTree } from '@/utils/tree'
|
||||||
@ -152,6 +152,9 @@ import ${subSimpleClassName}Form from './components/${subSimpleClassName}Form.vu
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
/** ${table.classComment} 表单 */
|
||||||
|
defineOptions({ name: '${simpleClassName}Form' })
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ import { dateFormatter } from '@/utils/formatTime'
|
|||||||
import { handleTree } from '@/utils/tree'
|
import { handleTree } from '@/utils/tree'
|
||||||
#end
|
#end
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
import { ${simpleClassName}Api, ${simpleClassName}VO } from '@/api/${table.moduleName}/${table.businessName}'
|
||||||
import ${simpleClassName}Form from './${simpleClassName}Form.vue'
|
import ${simpleClassName}Form from './${simpleClassName}Form.vue'
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType != 10 )
|
#if ( $table.templateType != 10 )
|
||||||
@ -249,16 +249,22 @@ import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vu
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
/** ${table.classComment} 列表 */
|
||||||
defineOptions({ name: '${table.className}' })
|
defineOptions({ name: '${table.className}' })
|
||||||
|
|
||||||
const message = useMessage() // 消息弹窗
|
// 消息弹窗
|
||||||
const { t } = useI18n() // 国际化
|
const message = useMessage()
|
||||||
|
// 国际化
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
// 列表的加载中
|
||||||
const list = ref([]) // 列表的数据
|
const loading = ref(true)
|
||||||
|
// 列表的数据
|
||||||
|
const list = ref<${simpleClassName}VO[]>([])
|
||||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||||
#if ( $table.templateType != 2 )
|
#if ( $table.templateType != 2 )
|
||||||
const total = ref(0) // 列表的总页数
|
// 列表的总页数
|
||||||
|
const total = ref(0)
|
||||||
#end
|
#end
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||||
@ -277,8 +283,10 @@ const queryParams = reactive({
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
})
|
})
|
||||||
const queryFormRef = ref() // 搜索的表单
|
// 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const queryFormRef = ref()
|
||||||
|
// 导出的加载中
|
||||||
|
const exportLoading = ref(false)
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user