feat: 测试代码生成

This commit is contained in:
xlsea
2024-09-09 15:40:38 +08:00
parent 74529144aa
commit 07e30bd591
26 changed files with 673 additions and 143 deletions

View File

@ -71,10 +71,10 @@ public class VelocityUtils {
velocityContext.put("pkColumn", genTable.getPkColumn());
velocityContext.put("importList", getImportList(genTable));
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
velocityContext.put("columns", getColumns(genTable));
velocityContext.put("table", genTable);
velocityContext.put("dicts", getDicts(genTable));
velocityContext.put("dictList", getDictList(genTable));
velocityContext.put("columns", getColumns(genTable));
velocityContext.put("table", genTable);
setMenuVelocityContext(velocityContext, genTable);
if (GenConstants.TPL_TREE.equals(tplCategory)) {
setTreeVelocityContext(velocityContext, genTable);
@ -178,7 +178,7 @@ public class VelocityUtils {
if (template.contains("soy.index.vue.vm")) {
fileName = StringUtils.format("soybean/views/{}/{}/index.vue", moduleName, businessName);
} else if (template.contains("soy.api.d.ts.vm")) {
fileName = StringUtils.format("soybean/typings/api/{}.d.ts", moduleName);
fileName = StringUtils.format("soybean/typings/api/{}.api.d.ts", moduleName);
} else if (template.contains("soy.api.ts.vm")) {
fileName = StringUtils.format("soybean/api/{}/{}.ts", moduleName, businessName);
} else if (template.contains("soy.search.vue.vm")) {

View File

@ -28,7 +28,7 @@ export function fetchUpdate${BusinessName} (data: Api.${ModuleName}.${BusinessNa
}
/** 批量删除${functionName} */
export function fetchDelete${BusinessName} (${pkColumn.javaField}s: CommonType.IdType[]) {
export function fetchBatchDelete${BusinessName} (${pkColumn.javaField}s: CommonType.IdType[]) {
return request<boolean>({
url: `/${moduleName}/${businessName}/${${pkColumn.javaField}s.join(',')}`,
method: 'delete'

View File

@ -3,6 +3,7 @@ import { computed, reactive, watch } from 'vue';
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import { $t } from '@/locales';
import { fetchCreate${BusinessName}, fetchUpdate${BusinessName} } from '@/service/api/${moduleName}/${businessName}';
#if($dictList && $dictList.size() > 0)import { useDict } from '@/hooks/business/dict';#end
defineOptions({
name: '${BusinessName}OperateDrawer'

View File

@ -3,6 +3,7 @@
import { ref } from 'vue';
import { $t } from '@/locales';
import { useNaiveForm } from '@/hooks/common/form';
#if($dictList && $dictList.size() > 0)import { useDict } from '@/hooks/business/dict';#end
defineOptions({
name: '${BusinessName}Search'
@ -27,14 +28,14 @@ const model = defineModel<Api.$ModuleName.${BusinessName}SearchParams>('model',
#if($dictList && $dictList.size() > 0)
#foreach($dict in $dictList)
const { options: ${dict.name}Options } = useDict(${dict.type}#if($dict.immediate), false#end);
const { options: ${dict.name}Options } = useDict('${dict.type}#if($dict.immediate)', false#end);
#end#end
async function reset() {
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
const dateRange${AttrName}.value = undefined;
dateRange${AttrName}.value = undefined;
#end
#end
await restoreValidation();

View File

@ -26,8 +26,8 @@ const {
} = useTable({
apiFn: fetchGet${BusinessName}List,
apiParams: {
current: 1,
size: 10,
pageNum: 1,
pageSize: 10,
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null
// the value can not be undefined, otherwise the property in Form will not be reactive
#foreach ($column in $columns)
@ -109,7 +109,7 @@ async function handleDelete(#foreach($column in $columns)#if($column.isPk == '1'
onDeleted();
}
async function edit(id: CommonType.IdType) {
async function edit(#foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end: CommonType.IdType) {
handleEdit('#foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end', #foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end);
}
</script>