增加额外的 api_build
增加选择生成接口模式
This commit is contained in:
parent
9946502355
commit
1186e6acf3
@ -122,4 +122,10 @@ public partial class SysCodeGen : EntityBase
|
||||
[SugarColumn(ColumnDescription = "打印模版名称", Length = 32)]
|
||||
[MaxLength(32)]
|
||||
public string? PrintName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用 Api Service
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "是否使用 Api Service")]
|
||||
public bool IsApiService { get; set; } = false;
|
||||
}
|
||||
@ -52,6 +52,8 @@ public class CustomViewEngine : ViewEngineModel
|
||||
|
||||
public string PrintName { get; set; }
|
||||
|
||||
public bool IsApiService { get; set; }
|
||||
|
||||
public List<CodeGenConfig> QueryWhetherList { get; set; }
|
||||
|
||||
public List<CodeGenConfig> TableField { get; set; }
|
||||
|
||||
@ -100,6 +100,11 @@ public class CodeGenInput : BasePageInput
|
||||
/// 打印模版名称
|
||||
/// </summary>
|
||||
public virtual string PrintName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用 Api Service
|
||||
/// </summary>
|
||||
public virtual bool IsApiService { get; set; }
|
||||
}
|
||||
|
||||
public class AddCodeGenInput : CodeGenInput
|
||||
@ -157,6 +162,11 @@ public class AddCodeGenInput : CodeGenInput
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "是否生成菜单不能为空")]
|
||||
public override bool GenerateMenu { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用 Api Service
|
||||
/// </summary>
|
||||
public override bool IsApiService { get; set; }
|
||||
}
|
||||
|
||||
public class DeleteCodeGenInput
|
||||
|
||||
@ -80,4 +80,9 @@ public class CodeGenOutput
|
||||
/// 打印模版名称
|
||||
/// </summary>
|
||||
public string PrintName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用 Api Service
|
||||
/// </summary>
|
||||
public bool IsApiService { get; set; }
|
||||
}
|
||||
@ -347,6 +347,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
IsUpload = joinTableList.Where(u => u.EffectType == "Upload").Any(),
|
||||
PrintType = input.PrintType,
|
||||
PrintName = input.PrintName,
|
||||
IsApiService = input.IsApiService
|
||||
};
|
||||
// 模板目录
|
||||
var templatePathList = GetTemplatePathList(input);
|
||||
@ -412,6 +413,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
IsUpload = joinTableList.Where(u => u.EffectType == "Upload").Any(),
|
||||
PrintType = input.PrintType,
|
||||
PrintName = input.PrintName,
|
||||
IsApiService = input.IsApiService
|
||||
};
|
||||
|
||||
// 获取模板文件并替换
|
||||
|
||||
@ -169,16 +169,24 @@
|
||||
import { ref,onMounted, reactive } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import type { FormRules } from "element-plus";
|
||||
|
||||
@if (@Model.IsApiService) {
|
||||
// 接口函数
|
||||
import { getAPI } from '/@@/utils/axios-utils';
|
||||
@:import { getAPI } from '/@@/utils/axios-utils';
|
||||
|
||||
// 接口
|
||||
import { @(@Model.ClassName)Api } from '/@@/api-services/api';
|
||||
@:import { @(@Model.ClassName)Api } from '/@@/api-services/api';
|
||||
|
||||
// 模型
|
||||
import { Update@(@Model.ClassName)Input } from '/@@/api-services/models';
|
||||
@:import { Update@(@Model.ClassName)Input } from '/@@/api-services/models';
|
||||
} else {
|
||||
@:import { add@(@Model.ClassName), update@(@Model.ClassName), detail@(@Model.ClassName) } from "/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)";
|
||||
|
||||
if(@Model.TableField.Any(x=>x.EffectType == "Upload")){
|
||||
@:import { Plus } from "@@element-plus/icons-vue";
|
||||
@:import { UploadRequestOptions } from "element-plus";
|
||||
@:import {@string.Join(",",Model.TableField.Where(x=>x.EffectType == "Upload").Select(x=>"upload"+x.PropertyName).ToList())} from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
|
||||
}
|
||||
}
|
||||
|
||||
@if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){
|
||||
@:import { getConstType } from "/@@/utils/constHelper";
|
||||
@ -244,8 +252,11 @@
|
||||
// 改用detail获取最新数据来编辑
|
||||
let rowData = JSON.parse(JSON.stringify(row));
|
||||
if (rowData.id)
|
||||
//state.ruleForm = (await detail@(@Model.ClassName)(rowData.id)).data.result;
|
||||
state.ruleForm = (await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)DetailGet(rowData.id)).data.result;
|
||||
@if (@Model.IsApiService) {
|
||||
@:state.ruleForm = (await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)DetailGet(rowData.id)).data.result;
|
||||
} else {
|
||||
@:state.ruleForm = (await detail@(@Model.ClassName)(rowData.id)).data.result;
|
||||
}
|
||||
else
|
||||
state.ruleForm = rowData;
|
||||
state.isShowDialog = true;
|
||||
@ -268,11 +279,17 @@
|
||||
if (isValid) {
|
||||
let values = state.ruleForm;
|
||||
if (state.ruleForm.@(@pkFieldName) == undefined || state.ruleForm.@(@pkFieldName) == null || state.ruleForm.@(@pkFieldName) == "" || state.ruleForm.@(@pkFieldName) == 0) {
|
||||
//await add@(@Model.ClassName)(values);
|
||||
await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)AddPost(state.ruleForm);
|
||||
@if (@Model.IsApiService) {
|
||||
@:await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)AddPost(state.ruleForm);
|
||||
} else {
|
||||
//await update@(@Model.ClassName)(values);
|
||||
await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)UpdatePost(state.ruleForm);
|
||||
@:await add@(@Model.ClassName)(values);
|
||||
}
|
||||
} else {
|
||||
@if (@Model.IsApiService) {
|
||||
@:await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)UpdatePost(state.ruleForm);
|
||||
} else {
|
||||
@:await update@(@Model.ClassName)(values);
|
||||
}
|
||||
}
|
||||
closeDialog();
|
||||
} else {
|
||||
@ -324,7 +341,11 @@
|
||||
if(column.WhetherAddUpdate=="N") continue;
|
||||
if(@column.EffectType == "Upload"){
|
||||
@:const upload@(@column.PropertyName)Handle = async (options: UploadRequestOptions) => {
|
||||
@if (@Model.IsApiService) {
|
||||
@:let list = await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)Upload@(@column.FkEntityName)PostForm(options);
|
||||
} else {
|
||||
@:let list = await upload@(@column.PropertyName)(options);
|
||||
}
|
||||
@:state.ruleForm.@(column.LowerPropertyName) = res.data.result?.url;
|
||||
@:};
|
||||
}
|
||||
|
||||
@ -225,6 +225,7 @@ import PrintDialog from '/@@/views/system/print/component/hiprint/preview.vue';
|
||||
import EditDialog from '/@@/views/@(@Model.PagePath)/@(@Model.LowerClassName)/component/editDialog.vue';
|
||||
import ModifyRecord from '/@@/components/table/modifyRecord.vue';
|
||||
|
||||
@if (@Model.IsApiService) {
|
||||
// 接口函数
|
||||
import { getAPI } from '/@@/utils/axios-utils';
|
||||
|
||||
@ -234,6 +235,15 @@ import { @(@Model.ClassName)Api } from '/@@/api-services/api';
|
||||
// 模型
|
||||
import { @(@Model.ClassName), @(@Model.ClassName)Input, @(@Model.ClassName)Output } from '/@@/api-services/models';
|
||||
|
||||
} else {
|
||||
@:import { page@(@Model.EntityName), delete@(@Model.EntityName) } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerEntityName)';
|
||||
foreach (var column in Model.QueryWhetherList){
|
||||
if(@column.EffectType == "fk"){
|
||||
@:import { get@(@column.FkEntityName)@(@column.PropertyName)Dropdown } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerEntityName)';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 子窗口对象
|
||||
const xGrid = ref<VxeGridInstance>();
|
||||
const printDialogRef = ref<InstanceType<typeof PrintDialog>>();
|
||||
@ -325,7 +335,11 @@ const handleQuery = async (reset = false) => {
|
||||
// 获取数据
|
||||
const fetchData = async (tableParams: any) => {
|
||||
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
|
||||
return getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)PagePost(params);
|
||||
@if (@Model.IsApiService) {
|
||||
@:return getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)PagePost(params);
|
||||
} else {
|
||||
@:return page@(@Model.ClassName)(params);
|
||||
}
|
||||
};
|
||||
|
||||
// 重置操作
|
||||
@ -369,7 +383,11 @@ const handleEdit = (row: any) => {
|
||||
const handlePrint = async (row: any) => {
|
||||
state.title = '打印@(@Model.BusName)';
|
||||
@if(@Model.PrintType == "custom"){
|
||||
if (@Model.IsApiService) {
|
||||
@:var res = await getAPI(SysPrintApi).apiSysPrintPrintNameGet('@Model.PrintName');
|
||||
} else {
|
||||
@:var res = await getPrint@(@Model.ClassName)(row);
|
||||
}
|
||||
@:var printTemplate = res.data.result as SysPrint;
|
||||
@:var template = JSON.parse(printTemplate.template);
|
||||
@:var width = template.panels[0].width;
|
||||
@ -390,7 +408,11 @@ const handleDelete = (row: any) => {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)DeletePost({ id: row.id });
|
||||
@if (@Model.IsApiService) {
|
||||
@:await getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)DeletePost({ id: row.id });
|
||||
} else {
|
||||
@:await delete@(@Model.ClassName)(row);
|
||||
}
|
||||
handleQuery();
|
||||
ElMessage.success('删除成功');
|
||||
})
|
||||
|
||||
@ -12,7 +12,7 @@ if exist %apiServicesPath% (
|
||||
|
||||
echo ================================ 开始生成 api-services ================================
|
||||
|
||||
java -jar %dir%swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/All%%20Groups/swagger.json -l typescript-axios -o %apiServicesPath%
|
||||
java -jar %dir%swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/Default/swagger.json -l typescript-axios -o %apiServicesPath%
|
||||
|
||||
@rem 删除不必要的文件和文件夹
|
||||
rd /s /q %apiServicesPath%.swagger-codegen
|
||||
|
||||
@ -14,7 +14,7 @@ fi
|
||||
|
||||
echo "================================ 开始生成 api-services ================================"
|
||||
|
||||
java -jar "${currPath}"/swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/All%20Groups/swagger.json -l typescript-axios -o "${apiServicesPath}"
|
||||
java -jar "${currPath}"/swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/Default/swagger.json -l typescript-axios -o "${apiServicesPath}"
|
||||
|
||||
rm -rf "${apiServicesPath}".swagger-codegen
|
||||
rm -f "${apiServicesPath}".gitignore
|
||||
|
||||
27
Web/api_build/build_approvalFlow.bat
Normal file
27
Web/api_build/build_approvalFlow.bat
Normal file
@ -0,0 +1,27 @@
|
||||
@echo off
|
||||
CHCP 65001
|
||||
|
||||
set dir=%~dp0
|
||||
|
||||
set apiServicesPath=%dir%..\src\api-services\_approvalFlow
|
||||
|
||||
if exist %apiServicesPath% (
|
||||
echo ================================ 删除目录 api-services ================================
|
||||
rd /s /q %apiServicesPath%
|
||||
)
|
||||
|
||||
echo ================================ 开始生成 api-services ================================
|
||||
|
||||
java -jar %dir%swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/ApprovalFlow/swagger.json -l typescript-axios -o %apiServicesPath%
|
||||
|
||||
@rem 删除不必要的文件和文件夹
|
||||
rd /s /q %apiServicesPath%.swagger-codegen
|
||||
del /q %apiServicesPath%.gitignore
|
||||
del /q %apiServicesPath%.npmignore
|
||||
del /q %apiServicesPath%.swagger-codegen-ignore
|
||||
del /q %apiServicesPath%git_push.sh
|
||||
del /q %apiServicesPath%package.json
|
||||
del /q %apiServicesPath%README.md
|
||||
del /q %apiServicesPath%tsconfig.json
|
||||
|
||||
echo ================================ 生成结束 ================================
|
||||
28
Web/api_build/build_approvalFlow.sh
Normal file
28
Web/api_build/build_approvalFlow.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
currPath=$(pwd)
|
||||
parentPath=$(dirname "$currPath")
|
||||
apiServicesPath=${parentPath}/src/api-services/_approvalFlow
|
||||
|
||||
echo "================================ 生成目录 ${apiServicesPath} ================================"
|
||||
|
||||
# 判断目录是否存在
|
||||
if test -d "$apiServicesPath"; then
|
||||
echo "================================ 删除目录 api-services ================================"
|
||||
rm -rf "${apiServicesPath}"
|
||||
fi
|
||||
|
||||
echo "================================ 开始生成 api-services ================================"
|
||||
|
||||
java -jar "${currPath}"/swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/ApprovalFlow/swagger.json -l typescript-axios -o "${apiServicesPath}"
|
||||
|
||||
rm -rf "${apiServicesPath}".swagger-codegen
|
||||
rm -f "${apiServicesPath}".gitignore
|
||||
rm -f "${apiServicesPath}".npmignore
|
||||
rm -f "${apiServicesPath}".swagger-codegen-ignore
|
||||
rm -f "${apiServicesPath}"git_push.sh
|
||||
rm -f "${apiServicesPath}"package.json
|
||||
rm -f "${apiServicesPath}"README.md
|
||||
rm -f "${apiServicesPath}"tsconfig.json
|
||||
|
||||
echo "================================ 生成结束 ================================"
|
||||
27
Web/api_build/build_dingTalk.bat
Normal file
27
Web/api_build/build_dingTalk.bat
Normal file
@ -0,0 +1,27 @@
|
||||
@echo off
|
||||
CHCP 65001
|
||||
|
||||
set dir=%~dp0
|
||||
|
||||
set apiServicesPath=%dir%..\src\api-services\_goView
|
||||
|
||||
if exist %apiServicesPath% (
|
||||
echo ================================ 删除目录 api-services ================================
|
||||
rd /s /q %apiServicesPath%
|
||||
)
|
||||
|
||||
echo ================================ 开始生成 api-services ================================
|
||||
|
||||
java -jar %dir%swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/GoView/swagger.json -l typescript-axios -o %apiServicesPath%
|
||||
|
||||
@rem 删除不必要的文件和文件夹
|
||||
rd /s /q %apiServicesPath%.swagger-codegen
|
||||
del /q %apiServicesPath%.gitignore
|
||||
del /q %apiServicesPath%.npmignore
|
||||
del /q %apiServicesPath%.swagger-codegen-ignore
|
||||
del /q %apiServicesPath%git_push.sh
|
||||
del /q %apiServicesPath%package.json
|
||||
del /q %apiServicesPath%README.md
|
||||
del /q %apiServicesPath%tsconfig.json
|
||||
|
||||
echo ================================ 生成结束 ================================
|
||||
28
Web/api_build/build_dingTalk.sh
Normal file
28
Web/api_build/build_dingTalk.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
currPath=$(pwd)
|
||||
parentPath=$(dirname "$currPath")
|
||||
apiServicesPath=${parentPath}/src/api-services/_goView
|
||||
|
||||
echo "================================ 生成目录 ${apiServicesPath} ================================"
|
||||
|
||||
# 判断目录是否存在
|
||||
if test -d "$apiServicesPath"; then
|
||||
echo "================================ 删除目录 api-services ================================"
|
||||
rm -rf "${apiServicesPath}"
|
||||
fi
|
||||
|
||||
echo "================================ 开始生成 api-services ================================"
|
||||
|
||||
java -jar "${currPath}"/swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/All%20Groups/swagger.json -l typescript-axios -o "${apiServicesPath}"
|
||||
|
||||
rm -rf "${apiServicesPath}".swagger-codegen
|
||||
rm -f "${apiServicesPath}".gitignore
|
||||
rm -f "${apiServicesPath}".npmignore
|
||||
rm -f "${apiServicesPath}".swagger-codegen-ignore
|
||||
rm -f "${apiServicesPath}"git_push.sh
|
||||
rm -f "${apiServicesPath}"package.json
|
||||
rm -f "${apiServicesPath}"README.md
|
||||
rm -f "${apiServicesPath}"tsconfig.json
|
||||
|
||||
echo "================================ 生成结束 ================================"
|
||||
27
Web/api_build/build_goView.bat
Normal file
27
Web/api_build/build_goView.bat
Normal file
@ -0,0 +1,27 @@
|
||||
@echo off
|
||||
CHCP 65001
|
||||
|
||||
set dir=%~dp0
|
||||
|
||||
set apiServicesPath=%dir%..\src\api-services\_goView
|
||||
|
||||
if exist %apiServicesPath% (
|
||||
echo ================================ 删除目录 api-services ================================
|
||||
rd /s /q %apiServicesPath%
|
||||
)
|
||||
|
||||
echo ================================ 开始生成 api-services ================================
|
||||
|
||||
java -jar %dir%swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/GoView/swagger.json -l typescript-axios -o %apiServicesPath%
|
||||
|
||||
@rem 删除不必要的文件和文件夹
|
||||
rd /s /q %apiServicesPath%.swagger-codegen
|
||||
del /q %apiServicesPath%.gitignore
|
||||
del /q %apiServicesPath%.npmignore
|
||||
del /q %apiServicesPath%.swagger-codegen-ignore
|
||||
del /q %apiServicesPath%git_push.sh
|
||||
del /q %apiServicesPath%package.json
|
||||
del /q %apiServicesPath%README.md
|
||||
del /q %apiServicesPath%tsconfig.json
|
||||
|
||||
echo ================================ 生成结束 ================================
|
||||
28
Web/api_build/build_goView.sh
Normal file
28
Web/api_build/build_goView.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
currPath=$(pwd)
|
||||
parentPath=$(dirname "$currPath")
|
||||
apiServicesPath=${parentPath}/src/api-services/_dingTalk
|
||||
|
||||
echo "================================ 生成目录 ${apiServicesPath} ================================"
|
||||
|
||||
# 判断目录是否存在
|
||||
if test -d "$apiServicesPath"; then
|
||||
echo "================================ 删除目录 api-services ================================"
|
||||
rm -rf "${apiServicesPath}"
|
||||
fi
|
||||
|
||||
echo "================================ 开始生成 api-services ================================"
|
||||
|
||||
java -jar "${currPath}"/swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/DingTalk/swagger.json -l typescript-axios -o "${apiServicesPath}"
|
||||
|
||||
rm -rf "${apiServicesPath}".swagger-codegen
|
||||
rm -f "${apiServicesPath}".gitignore
|
||||
rm -f "${apiServicesPath}".npmignore
|
||||
rm -f "${apiServicesPath}".swagger-codegen-ignore
|
||||
rm -f "${apiServicesPath}"git_push.sh
|
||||
rm -f "${apiServicesPath}"package.json
|
||||
rm -f "${apiServicesPath}"README.md
|
||||
rm -f "${apiServicesPath}"tsconfig.json
|
||||
|
||||
echo "================================ 生成结束 ================================"
|
||||
@ -135,6 +135,14 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item label="是否选择 Api Service 模式" prop="isApiService">
|
||||
<el-radio-group v-model="state.ruleForm.isApiService">
|
||||
<el-radio :value="true">是</el-radio>
|
||||
<el-radio :value="false">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user