提交 | 用户 | 时间
|
e7c126
|
1 |
import request from '@/config/axios' |
H |
2 |
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") |
|
3 |
|
|
4 |
// ${table.classComment} VO |
|
5 |
export interface ${simpleClassName}VO { |
|
6 |
#foreach ($column in $columns) |
|
7 |
#if ($column.createOperation || $column.updateOperation) |
|
8 |
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal") |
|
9 |
${column.javaField}: number // ${column.columnComment} |
|
10 |
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime") |
|
11 |
${column.javaField}: Date // ${column.columnComment} |
|
12 |
#else |
|
13 |
${column.javaField}: ${column.javaType.toLowerCase()} // ${column.columnComment} |
|
14 |
#end |
|
15 |
#end |
|
16 |
#end |
|
17 |
} |
|
18 |
|
|
19 |
// ${table.classComment} API |
|
20 |
export const ${simpleClassName}Api = { |
|
21 |
#if ( $table.templateType != 2 ) |
|
22 |
// 查询${table.classComment}分页 |
|
23 |
get${simpleClassName}Page: async (params: any) => { |
|
24 |
return await request.get({ url: `${baseURL}/page`, params }) |
|
25 |
}, |
|
26 |
#else |
|
27 |
// 查询${table.classComment}列表 |
|
28 |
get${simpleClassName}List: async (params) => { |
|
29 |
return await request.get({ url: `${baseURL}/list`, params }) |
|
30 |
}, |
|
31 |
#end |
|
32 |
|
|
33 |
// 查询${table.classComment}详情 |
|
34 |
get${simpleClassName}: async (id: number) => { |
|
35 |
return await request.get({ url: `${baseURL}/get?id=` + id }) |
|
36 |
}, |
|
37 |
|
|
38 |
// 新增${table.classComment} |
|
39 |
create${simpleClassName}: async (data: ${simpleClassName}VO) => { |
|
40 |
return await request.post({ url: `${baseURL}/create`, data }) |
|
41 |
}, |
|
42 |
|
|
43 |
// 修改${table.classComment} |
|
44 |
update${simpleClassName}: async (data: ${simpleClassName}VO) => { |
|
45 |
return await request.put({ url: `${baseURL}/update`, data }) |
|
46 |
}, |
|
47 |
|
|
48 |
// 删除${table.classComment} |
|
49 |
delete${simpleClassName}: async (id: number) => { |
|
50 |
return await request.delete({ url: `${baseURL}/delete?id=` + id }) |
|
51 |
}, |
|
52 |
|
|
53 |
// 导出${table.classComment} Excel |
|
54 |
export${simpleClassName}: async (params) => { |
|
55 |
return await request.download({ url: `${baseURL}/export-excel`, params }) |
|
56 |
}, |
|
57 |
## 特殊:主子表专属逻辑 |
|
58 |
#foreach ($subTable in $subTables) |
|
59 |
#set ($index = $foreach.count - 1) |
|
60 |
#set ($subSimpleClassName = $subSimpleClassNames.get($index)) |
|
61 |
#set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段 |
|
62 |
#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 |
|
63 |
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 |
|
64 |
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) |
|
65 |
#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index)) |
|
66 |
#set ($subClassNameVar = $subClassNameVars.get($index)) |
|
67 |
|
|
68 |
// ==================== 子表($subTable.classComment) ==================== |
|
69 |
## 情况一:MASTER_ERP 时,需要分查询页子表 |
|
70 |
#if ( $table.templateType == 11 ) |
|
71 |
|
|
72 |
// 获得${subTable.classComment}分页 |
|
73 |
get${subSimpleClassName}Page: async (params) => { |
|
74 |
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/page`, params }) |
|
75 |
}, |
|
76 |
## 情况二:非 MASTER_ERP 时,需要列表查询子表 |
|
77 |
#else |
|
78 |
#if ( $subTable.subJoinMany ) |
|
79 |
|
|
80 |
// 获得${subTable.classComment}列表 |
|
81 |
get${subSimpleClassName}ListBy${SubJoinColumnName}: async (${subJoinColumn.javaField}) => { |
|
82 |
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} }) |
|
83 |
}, |
|
84 |
#else |
|
85 |
|
|
86 |
// 获得${subTable.classComment} |
|
87 |
get${subSimpleClassName}By${SubJoinColumnName}: async (${subJoinColumn.javaField}) => { |
|
88 |
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} }) |
|
89 |
}, |
|
90 |
#end |
|
91 |
#end |
|
92 |
## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作 |
|
93 |
#if ( $table.templateType == 11 ) |
|
94 |
// 新增${subTable.classComment} |
|
95 |
create${subSimpleClassName}: async (data) => { |
|
96 |
return await request.post({ url: `${baseURL}/${subSimpleClassName_strikeCase}/create`, data }) |
|
97 |
}, |
|
98 |
|
|
99 |
// 修改${subTable.classComment} |
|
100 |
update${subSimpleClassName}: async (data) => { |
|
101 |
return await request.put({ url: `${baseURL}/${subSimpleClassName_strikeCase}/update`, data }) |
|
102 |
}, |
|
103 |
|
|
104 |
// 删除${subTable.classComment} |
|
105 |
delete${subSimpleClassName}: async (id: number) => { |
|
106 |
return await request.delete({ url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id }) |
|
107 |
}, |
|
108 |
|
|
109 |
// 获得${subTable.classComment} |
|
110 |
get${subSimpleClassName}: async (id: number) => { |
|
111 |
return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id }) |
|
112 |
}, |
|
113 |
#end |
|
114 |
#end |
|
115 |
} |