修改代码生成模板
This commit is contained in:
@@ -13,7 +13,7 @@ SELECT @TMP_PARENT_ID:=LAST_INSERT_ID();
|
||||
INSERT INTO system_menu
|
||||
(parent_id, name, type, sort, visible, status, cache, component)
|
||||
VALUES
|
||||
(@TMP_PARENT_ID, '$vue.comment', 2, 10, 1, 1, 1, '$vue.module$vue.featureFirstUpper');
|
||||
(@TMP_PARENT_ID, '$vue.comment', 2, 10, 1, 1, 1, '$vue.moduleEntityFirstLower$vue.featureEntity');
|
||||
|
||||
-- 设置临时子菜单id
|
||||
SELECT @TMP_SUB_ID:=LAST_INSERT_ID();
|
||||
|
||||
@@ -5,7 +5,7 @@ import { DataGrid, Pagination } from '@/types/global';
|
||||
/**
|
||||
* ${table.comment}创建请求
|
||||
*/
|
||||
export interface ${vue.featureFirstUpper}CreateRequest {
|
||||
export interface ${vue.featureEntity}CreateRequest {
|
||||
#foreach($field in ${table.fields})
|
||||
#if("$!field.propertyName" != "id")
|
||||
#if("$field.propertyType" == "String" || "$field.propertyType" == "Date")
|
||||
@@ -24,14 +24,14 @@ export interface ${vue.featureFirstUpper}CreateRequest {
|
||||
/**
|
||||
* ${table.comment}更新请求
|
||||
*/
|
||||
export interface ${vue.featureFirstUpper}UpdateRequest extends ${vue.featureFirstUpper}CreateRequest {
|
||||
export interface ${vue.featureEntity}UpdateRequest extends ${vue.featureEntity}CreateRequest {
|
||||
id: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ${table.comment}查询请求
|
||||
*/
|
||||
export interface ${vue.featureFirstUpper}QueryRequest extends Pagination {
|
||||
export interface ${vue.featureEntity}QueryRequest extends Pagination {
|
||||
#foreach($field in ${table.fields})
|
||||
#if("$field.propertyType" == "String" || "$field.propertyType" == "Date")
|
||||
${field.propertyName}?: string;
|
||||
@@ -48,7 +48,7 @@ export interface ${vue.featureFirstUpper}QueryRequest extends Pagination {
|
||||
/**
|
||||
* ${table.comment}查询响应
|
||||
*/
|
||||
export interface ${vue.featureFirstUpper}QueryResponse {
|
||||
export interface ${vue.featureEntity}QueryResponse {
|
||||
#foreach($field in ${table.fields})
|
||||
#if("$field.propertyType" == "String")
|
||||
${field.propertyName}?: string;
|
||||
@@ -69,29 +69,29 @@ export interface ${vue.featureFirstUpper}QueryResponse {
|
||||
/**
|
||||
* $apiComment.create
|
||||
*/
|
||||
export function create${vue.featureFirstUpper}(request: ${vue.featureFirstUpper}CreateRequest) {
|
||||
export function create${vue.featureEntity}(request: ${vue.featureEntity}CreateRequest) {
|
||||
return axios.post('/${package.ModuleName}/${typeHyphen}/create', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.updateById
|
||||
*/
|
||||
export function update${vue.featureFirstUpper}(request: ${vue.featureFirstUpper}UpdateRequest) {
|
||||
export function update${vue.featureEntity}(request: ${vue.featureEntity}UpdateRequest) {
|
||||
return axios.put('/${package.ModuleName}/${typeHyphen}/update', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.getById
|
||||
*/
|
||||
export function get${vue.featureFirstUpper}(id: number) {
|
||||
return axios.get<${vue.featureFirstUpper}QueryResponse>('/${package.ModuleName}/${typeHyphen}/get', { params: { id } });
|
||||
export function get${vue.featureEntity}(id: number) {
|
||||
return axios.get<${vue.featureEntity}QueryResponse>('/${package.ModuleName}/${typeHyphen}/get', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.listByIdList
|
||||
*/
|
||||
export function get${vue.featureFirstUpper}List(idList: Array<number>) {
|
||||
return axios.get<${vue.featureFirstUpper}QueryResponse[]>('/${package.ModuleName}/${typeHyphen}/list', {
|
||||
export function get${vue.featureEntity}List(idList: Array<number>) {
|
||||
return axios.get<${vue.featureEntity}QueryResponse[]>('/${package.ModuleName}/${typeHyphen}/list', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
@@ -102,28 +102,28 @@ export function get${vue.featureFirstUpper}List(idList: Array<number>) {
|
||||
/**
|
||||
* $apiComment.listAll
|
||||
*/
|
||||
export function get${vue.featureFirstUpper}ListAll(request: ${vue.featureFirstUpper}QueryRequest) {
|
||||
return axios.post<Array<${vue.featureFirstUpper}QueryResponse>>('/${package.ModuleName}/${typeHyphen}/list-all', request);
|
||||
export function get${vue.featureEntity}ListAll(request: ${vue.featureEntity}QueryRequest) {
|
||||
return axios.post<Array<${vue.featureEntity}QueryResponse>>('/${package.ModuleName}/${typeHyphen}/list-all', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.queryPage
|
||||
*/
|
||||
export function get${vue.featureFirstUpper}Page(request: ${vue.featureFirstUpper}QueryRequest) {
|
||||
return axios.post<DataGrid<${vue.featureFirstUpper}QueryResponse>>('/${package.ModuleName}/${typeHyphen}/query', request);
|
||||
export function get${vue.featureEntity}Page(request: ${vue.featureEntity}QueryRequest) {
|
||||
return axios.post<DataGrid<${vue.featureEntity}QueryResponse>>('/${package.ModuleName}/${typeHyphen}/query', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.deleteById
|
||||
*/
|
||||
export function delete${vue.featureFirstUpper}(id: number) {
|
||||
export function delete${vue.featureEntity}(id: number) {
|
||||
return axios.delete('/${package.ModuleName}/${typeHyphen}/delete', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.batchDeleteByIdList
|
||||
*/
|
||||
export function batchDelete${vue.featureFirstUpper}(idList: Array<number>) {
|
||||
export function batchDelete${vue.featureEntity}(idList: Array<number>) {
|
||||
return axios.delete('/${package.ModuleName}/${typeHyphen}/delete-batch', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
@@ -135,6 +135,6 @@ export function batchDelete${vue.featureFirstUpper}(idList: Array<number>) {
|
||||
/**
|
||||
* $apiComment.export
|
||||
*/
|
||||
export function export${vue.featureFirstUpper}(request: ${vue.featureFirstUpper}QueryRequest) {
|
||||
export function export${vue.featureEntity}(request: ${vue.featureEntity}QueryRequest) {
|
||||
return axios.post('/${package.ModuleName}/${typeHyphen}/export', request);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { DEFAULT_LAYOUT } from '../base';
|
||||
import { AppRouteRecordRaw } from '../types';
|
||||
|
||||
const $vue.featureAllUpper: AppRouteRecordRaw = {
|
||||
name: '$vue.module',
|
||||
const $vue.moduleConst: AppRouteRecordRaw = {
|
||||
name: '$vue.moduleEntityFirstLower',
|
||||
path: '/$vue.module',
|
||||
component: DEFAULT_LAYOUT,
|
||||
children: [
|
||||
{
|
||||
name: '$vue.module$vue.featureFirstUpper',
|
||||
name: '$vue.moduleEntityFirstLower$vue.featureEntity',
|
||||
path: '/$vue.module/$vue.feature',
|
||||
component: () => import('@/views/$vue.module/$vue.feature/index.vue'),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default $vue.featureAllUpper;
|
||||
export default $vue.moduleConst;
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import formRules from '../types/form.rules';
|
||||
import { create${vue.featureFirstUpper}, update${vue.featureFirstUpper} } from '@/api/${vue.module}/${vue.feature}';
|
||||
import { create${vue.featureEntity}, update${vue.featureEntity} } from '@/api/${vue.module}/${vue.feature}';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { } from '../types/enum.types';
|
||||
import { } from '../types/const';
|
||||
@@ -114,12 +114,12 @@
|
||||
}
|
||||
if (isAddHandle.value) {
|
||||
// 新增
|
||||
await create${vue.featureFirstUpper}(formModel as any);
|
||||
await create${vue.featureEntity}(formModel as any);
|
||||
Message.success('创建成功');
|
||||
emits('added');
|
||||
} else {
|
||||
// 修改
|
||||
await update${vue.featureFirstUpper}(formModel as any);
|
||||
await update${vue.featureEntity}(formModel as any);
|
||||
Message.success('修改成功');
|
||||
emits('updated');
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { batchDelete${vue.featureFirstUpper}, delete${vue.featureFirstUpper}, get${vue.featureFirstUpper}Page, ${vue.featureFirstUpper}QueryRequest, ${vue.featureFirstUpper}QueryResponse } from '@/api/${vue.module}/${vue.feature}';
|
||||
import { batchDelete${vue.featureEntity}, delete${vue.featureEntity}, get${vue.featureEntity}Page, ${vue.featureEntity}QueryRequest, ${vue.featureEntity}QueryResponse } from '@/api/${vue.module}/${vue.feature}';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
@@ -119,7 +119,7 @@
|
||||
import { } from '../types/const';
|
||||
import { toOptions } from '@/utils/enum';
|
||||
|
||||
const tableRenderData = ref<${vue.featureFirstUpper}QueryResponse[]>();
|
||||
const tableRenderData = ref<${vue.featureEntity}QueryResponse[]>();
|
||||
const { loading, setLoading } = useLoading();
|
||||
const emits = defineEmits(['openAdd', 'openUpdate']);
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
const selectedKeys = ref<number[]>([]);
|
||||
const rowSelection = reactive(defaultRowSelection());
|
||||
|
||||
const formModel = reactive<${vue.featureFirstUpper}QueryRequest>({
|
||||
const formModel = reactive<${vue.featureEntity}QueryRequest>({
|
||||
#foreach($field in ${table.fields})
|
||||
${field.propertyName}: undefined,
|
||||
#end
|
||||
@@ -138,7 +138,7 @@
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await batchDelete${vue.featureFirstUpper}(selectedKeys.value);
|
||||
await batchDelete${vue.featureEntity}(selectedKeys.value);
|
||||
Message.success(`成功删除${selectedKeys.value.length}条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
@@ -153,7 +153,7 @@
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await delete${vue.featureFirstUpper}(id);
|
||||
await delete${vue.featureEntity}(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
await fetchTableData();
|
||||
@@ -177,10 +177,10 @@
|
||||
});
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: ${vue.featureFirstUpper}QueryRequest) => {
|
||||
const doFetchTableData = async (request: ${vue.featureEntity}QueryRequest) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const { data } = await get${vue.featureFirstUpper}Page(request);
|
||||
const { data } = await get${vue.featureEntity}Page(request);
|
||||
tableRenderData.value = data.rows;
|
||||
pagination.total = data.total;
|
||||
pagination.current = request.page;
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: '${vue.module}${vue.featureFirstUpper}'
|
||||
name: '${vue.module}-${vue.feature}'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ${vue.featureFirstUpper}Table from './components/${vue.feature}-table.vue';
|
||||
import ${vue.featureFirstUpper}FormModal from './components/${vue.feature}-form-modal.vue';
|
||||
import ${vue.featureEntity}Table from './components/${vue.feature}-table.vue';
|
||||
import ${vue.featureEntity}FormModal from './components/${vue.feature}-form-modal.vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
const table = ref();
|
||||
|
||||
Reference in New Issue
Block a user