nsgm-cli 2.1.38 → 2.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,16 +11,12 @@ class ResolverGenerator extends base_generator_1.BaseGenerator {
11
11
  return `\`${this.controller}\``;
12
12
  }
13
13
  generate() {
14
- // @ts-ignore - Used in string concatenation for generated code
15
- const _selectFields = this.fields.map((f) => f.name).join(", ");
14
+ const selectFields = this.fields.map((f) => f.name).join(", ");
16
15
  const insertFields = this.getFormFields();
17
16
  const searchableFields = this.getSearchableFields();
18
- // @ts-ignore - Used in string concatenation for generated code
19
- const _quotedTableName = this.getQuotedTableName();
20
- // @ts-ignore - Used in string concatenation for generated code
21
- const _insertFieldNames = insertFields.map((f) => f.name).join(", ");
22
- // @ts-ignore - Used in string concatenation for generated code
23
- const _insertPlaceholders = insertFields.map(() => "?").join(", ");
17
+ const quotedTableName = this.getQuotedTableName();
18
+ const insertFieldNames = insertFields.map((f) => f.name).join(", ");
19
+ const insertPlaceholders = insertFields.map(() => "?").join(", ");
24
20
  const insertValues = insertFields
25
21
  .map((f) => {
26
22
  if (f.type === "integer") {
@@ -30,266 +26,267 @@ class ResolverGenerator extends base_generator_1.BaseGenerator {
30
26
  })
31
27
  .join(", ");
32
28
  const searchConditions = this.generateSearchConditions(searchableFields);
33
- // @ts-ignore - Used in string concatenation for generated code
34
- const _updateFields = insertFields.map((f) => `${f.name} = ?`).join(", ");
35
- return `const { executeQuery, executePaginatedQuery } = require('../../utils/common')
36
- const { validateInteger, validatePagination, validateId } = require('../../utils/validation')
37
-
38
- module.exports = {
39
- // 获取${this.controller}列表(分页)
40
- ${this.controller}: async ({ page = 0, pageSize = 10 }) => {
41
- try {
42
- const { page: validPage, pageSize: validPageSize } = validatePagination(page, pageSize);
43
-
44
- const sql = 'SELECT ' + _selectFields + ' FROM ' + _quotedTableName + ' LIMIT ? OFFSET ?';
45
- const countSql = 'SELECT COUNT(*) as counts FROM ' + _quotedTableName;
46
- const values = [validPageSize, validPage * validPageSize];
47
-
48
- console.log('执行分页查询:', { sql, values, countSql });
49
-
50
- return await executePaginatedQuery(sql, countSql, values);
51
- } catch (error) {
52
- console.error('获取${this.controller}列表失败:', error.message);
53
- throw error;
54
- }
55
- },
56
-
57
- // 根据ID获取${this.controller} - 使用 DataLoader 优化
58
- ${this.controller}Get: async ({ id }, context) => {
59
- try {
60
- const validId = validateId(id);
61
-
62
- console.log('🚀 使用 DataLoader 根据ID查询${this.controller}:', { id: validId });
63
-
64
- // 使用 DataLoader 批量加载,自动去重和缓存
65
- const result = await context.dataloaders.${this.controller}.byId.load(validId);
66
-
67
- if (!result) {
68
- throw new Error(\`ID为 \${validId} 的${this.controller}不存在\`);
69
- }
70
-
71
- return result;
72
- } catch (error) {
73
- console.error('获取${this.controller}失败:', error.message);
74
- throw error;
75
- }
76
- },
77
-
78
- // 批量获取${this.controller} - 新增方法,展示 DataLoader 批量能力
79
- ${this.controller}BatchGet: async ({ ids }, context) => {
80
- try {
81
- if (!Array.isArray(ids) || ids.length === 0) {
82
- throw new Error('ID列表不能为空');
83
- }
84
-
85
- // 验证所有ID
86
- const validIds = ids.map(id => validateId(id));
87
-
88
- console.log('🚀 使用 DataLoader 批量查询${this.controller}:', { ids: validIds });
89
-
90
- // DataLoader 自动批量处理,一次查询获取所有数据
91
- const results = await context.dataloaders.${this.controller}.byId.loadMany(validIds);
92
-
93
- // 过滤掉 null 结果(未找到的记录)
94
- return results.filter(result => result !== null && !(result instanceof Error));
95
- } catch (error) {
96
- console.error('批量获取${this.controller}失败:', error.message);
97
- throw error;
98
- }
99
- },
100
-
101
- // 搜索${this.controller}(分页)- 使用 DataLoader 优化搜索
102
- ${this.controller}Search: async ({ page = 0, pageSize = 10, data = {} }, context) => {
103
- try {
104
- const { page: validPage, pageSize: validPageSize } = validatePagination(page, pageSize);
105
-
106
- ${this.generateDataLoaderSearchLogic(searchableFields)}
107
-
108
- // 原始查询方式(作为备用)
109
- const values = [];
110
- const countValues = [];
111
-
112
- let whereSql = '';
113
- ${searchConditions}
114
-
115
- const sql = 'SELECT ' + _selectFields + ' FROM ' + _quotedTableName + ' WHERE 1=1' + whereSql + ' LIMIT ? OFFSET ?';
116
- const countSql = 'SELECT COUNT(*) as counts FROM ' + _quotedTableName + ' WHERE 1=1' + whereSql;
117
-
118
- values.push(validPageSize, validPage * validPageSize);
119
-
120
- console.log('搜索${this.controller}(备用查询):', { sql, values, countSql, countValues });
121
-
122
- return await executePaginatedQuery(sql, countSql, values, countValues);
123
- } catch (error) {
124
- console.error('搜索${this.controller}失败:', error.message);
125
- throw error;
126
- }
127
- },
128
-
129
- // 添加${this.controller} - 添加 DataLoader 缓存预加载
130
- ${this.controller}Add: async ({ data }, context) => {
131
- try {
132
- ${this.generateNewValidationCalls(insertFields)}
133
-
134
- const sql = 'INSERT INTO ' + _quotedTableName + ' (' + _insertFieldNames + ') VALUES (' + _insertPlaceholders + ')';
135
- const values = [${insertValues}];
136
-
137
- console.log('添加${this.controller}:', { sql, values });
138
-
139
- const results = await executeQuery(sql, values);
140
- const insertId = results.insertId;
141
-
142
- // 预加载新数据到 DataLoader 缓存
143
- if (insertId && context?.dataloaders?.${this.controller}) {
144
- const newRecord = { id: insertId, ${this.generateNewRecordObject(insertFields)} };
145
- context.dataloaders.${this.controller}.prime(insertId, newRecord);
146
- console.log('🚀 新${this.controller}已预加载到 DataLoader 缓存:', newRecord);
147
- }
148
-
149
- return insertId;
150
- } catch (error) {
151
- console.error('添加${this.controller}失败:', error.message);
152
- throw error;
153
- }
154
- },
155
-
156
- // 批量添加${this.controller}
157
- ${this.controller}BatchAdd: async ({ datas }) => {
158
- try {
159
- if (!Array.isArray(datas) || datas.length === 0) {
160
- throw new Error('批量添加数据不能为空');
161
- }
162
-
163
- // 验证所有数据并转换
164
- const validatedDatas = datas.map((data, index) => {
165
- try {
166
- ${this.generateBatchValidation(insertFields)}
167
- return { ${this.generateBatchReturnObject(insertFields)} };
168
- } catch (error) {
169
- throw new Error(\`第 \${index + 1} 条数据验证失败: \${error.message}\`);
170
- }
171
- });
172
-
173
- const placeholders = validatedDatas.map(() => '(' + _insertPlaceholders + ')').join(',');
174
- const sql = 'INSERT INTO ' + _quotedTableName + ' (' + _insertFieldNames + ') VALUES ' + placeholders;
175
- const values = validatedDatas.flatMap(data => [${this.generateBatchInsertValues(insertFields)}]);
176
-
177
- console.log('批量添加${this.controller}:', { sql, values });
178
-
179
- const results = await executeQuery(sql, values);
180
- return results.insertId;
181
- } catch (error) {
182
- console.error('批量添加${this.controller}失败:', error.message);
183
- throw error;
184
- }
185
- },
186
-
187
- // 更新${this.controller} - 添加 DataLoader 缓存清理
188
- ${this.controller}Update: async ({ id, data }, context) => {
189
- try {
190
- const validId = validateId(id);
191
-
192
- if (!data) {
193
- throw new Error('更新数据不能为空');
194
- }
195
-
196
- ${this.generateUpdateValidation(insertFields)}
197
-
198
- const sql = 'UPDATE ' + _quotedTableName + ' SET ' + _updateFields + ' WHERE id = ?';
199
- const values = [${this.generateUpdateValues(insertFields)}, validId];
200
-
201
- console.log('更新${this.controller}:', { sql, values });
202
-
203
- const results = await executeQuery(sql, values);
204
-
205
- if (results.affectedRows === 0) {
206
- throw new Error(\`ID为 \${validId} 的${this.controller}不存在\`);
207
- }
208
-
209
- // 清除 DataLoader 缓存,确保下次查询获取最新数据
210
- if (context?.dataloaders?.${this.controller}) {
211
- context.dataloaders.${this.controller}.clearById(validId);
212
- console.log('🧹 已清除 DataLoader 缓存:', { id: validId });
213
- }
214
-
215
- return true;
216
- } catch (error) {
217
- console.error('更新${this.controller}失败:', error.message);
218
- throw error;
219
- }
220
- },
221
-
222
- // 删除${this.controller} - 添加 DataLoader 缓存清理
223
- ${this.controller}Delete: async ({ id }, context) => {
224
- try {
225
- const validId = validateId(id);
226
-
227
- const sql = 'DELETE FROM ' + _quotedTableName + ' WHERE id = ?';
228
- const values = [validId];
229
-
230
- console.log('删除${this.controller}:', { sql, values });
231
-
232
- const results = await executeQuery(sql, values);
233
-
234
- if (results.affectedRows === 0) {
235
- throw new Error(\`ID为 \${validId} 的${this.controller}不存在\`);
236
- }
237
-
238
- // 清除 DataLoader 缓存
239
- if (context?.dataloaders?.${this.controller}) {
240
- context.dataloaders.${this.controller}.clearById(validId);
241
- console.log('🧹 已清除 DataLoader 缓存:', { id: validId });
242
- }
243
-
244
- return true;
245
- } catch (error) {
246
- console.error('删除${this.controller}失败:', error.message);
247
- throw error;
248
- }
249
- },
250
-
251
- // 批量删除${this.controller} - 添加 DataLoader 缓存清理
252
- ${this.controller}BatchDelete: async ({ ids }, context) => {
253
- try {
254
- if (!Array.isArray(ids) || ids.length === 0) {
255
- throw new Error('批量删除的ID列表不能为空');
256
- }
257
-
258
- // 验证所有ID
259
- const validIds = ids.map((id, index) => {
260
- try {
261
- return validateId(id, \`第\${index + 1}个ID\`);
262
- } catch (error) {
263
- throw new Error(\`第 \${index + 1} 个ID验证失败: \${error.message}\`);
264
- }
265
- });
266
-
267
- const placeholders = validIds.map(() => '?').join(',');
268
- const sql = 'DELETE FROM ' + _quotedTableName + ' WHERE id IN (' + placeholders + ')';
269
-
270
- console.log('批量删除${this.controller}:', { sql, values: validIds });
271
-
272
- const results = await executeQuery(sql, validIds);
273
-
274
- if (results.affectedRows === 0) {
275
- throw new Error('没有找到要删除的${this.controller}');
276
- }
277
-
278
- // 批量清除 DataLoader 缓存
279
- if (context?.dataloaders?.${this.controller}) {
280
- validIds.forEach(id => {
281
- context.dataloaders.${this.controller}.clearById(id);
282
- });
283
- console.log('🧹 已批量清除 DataLoader 缓存:', { ids: validIds });
284
- }
285
-
286
- return true;
287
- } catch (error) {
288
- console.error('批量删除${this.controller}失败:', error.message);
289
- throw error;
290
- }
291
- }
292
- }`;
29
+ const updateFields = insertFields.map((f) => `${f.name} = ?`).join(", ");
30
+ return [
31
+ "const { executeQuery, executePaginatedQuery } = require('../../utils/common')",
32
+ "const { validateInteger, validatePagination, validateId } = require('../../utils/validation')",
33
+ "",
34
+ "module.exports = {",
35
+ ` // 获取${this.controller}列表(分页)`,
36
+ ` ${this.controller}: async ({ page = 0, pageSize = 10 }) => {`,
37
+ ` try {`,
38
+ ` const { page: validPage, pageSize: validPageSize } = validatePagination(page, pageSize);`,
39
+ ``,
40
+ ` const sql = 'SELECT ${selectFields} FROM ${quotedTableName} LIMIT ? OFFSET ?';`,
41
+ ` const countSql = 'SELECT COUNT(*) as counts FROM ${quotedTableName}';`,
42
+ ` const values = [validPageSize, validPage * validPageSize];`,
43
+ ``,
44
+ ` console.log('执行分页查询:', { sql, values, countSql });`,
45
+ ``,
46
+ ` return await executePaginatedQuery(sql, countSql, values);`,
47
+ ` } catch (error) {`,
48
+ ` console.error('获取${this.controller}列表失败:', error.message);`,
49
+ ` throw error;`,
50
+ ` }`,
51
+ ` },`,
52
+ ``,
53
+ ` // 根据ID获取${this.controller} - 使用 DataLoader 优化`,
54
+ ` ${this.controller}Get: async ({ id }, context) => {`,
55
+ ` try {`,
56
+ ` const validId = validateId(id);`,
57
+ ``,
58
+ ` console.log('🚀 使用 DataLoader 根据ID查询${this.controller}:', { id: validId });`,
59
+ ``,
60
+ ` // 使用 DataLoader 批量加载,自动去重和缓存`,
61
+ ` const result = await context.dataloaders.${this.controller}.byId.load(validId);`,
62
+ ``,
63
+ ` if (!result) {`,
64
+ ` throw new Error(\`ID为 \${validId} 的${this.controller}不存在\`);`,
65
+ ` }`,
66
+ ``,
67
+ ` return result;`,
68
+ ` } catch (error) {`,
69
+ ` console.error('获取${this.controller}失败:', error.message);`,
70
+ ` throw error;`,
71
+ ` }`,
72
+ ` },`,
73
+ ``,
74
+ ` // 批量获取${this.controller} - 新增方法,展示 DataLoader 批量能力`,
75
+ ` ${this.controller}BatchGet: async ({ ids }, context) => {`,
76
+ ` try {`,
77
+ ` if (!Array.isArray(ids) || ids.length === 0) {`,
78
+ ` throw new Error('ID列表不能为空');`,
79
+ ` }`,
80
+ ``,
81
+ ` // 验证所有ID`,
82
+ ` const validIds = ids.map(id => validateId(id));`,
83
+ ``,
84
+ ` console.log('🚀 使用 DataLoader 批量查询${this.controller}:', { ids: validIds });`,
85
+ ``,
86
+ ` // DataLoader 自动批量处理,一次查询获取所有数据`,
87
+ ` const results = await context.dataloaders.${this.controller}.byId.loadMany(validIds);`,
88
+ ``,
89
+ ` // 过滤掉 null 结果(未找到的记录)`,
90
+ ` return results.filter(result => result !== null && !(result instanceof Error));`,
91
+ ` } catch (error) {`,
92
+ ` console.error('批量获取${this.controller}失败:', error.message);`,
93
+ ` throw error;`,
94
+ ` }`,
95
+ ` },`,
96
+ ``,
97
+ ` // 搜索${this.controller}(分页)- 使用 DataLoader 优化搜索`,
98
+ ` ${this.controller}Search: async ({ page = 0, pageSize = 10, data = {} }, context) => {`,
99
+ ` try {`,
100
+ ` const { page: validPage, pageSize: validPageSize } = validatePagination(page, pageSize);`,
101
+ ``,
102
+ this.generateDataLoaderSearchLogic(searchableFields),
103
+ ``,
104
+ ` // 原始查询方式(作为备用)`,
105
+ ` const values = [];`,
106
+ ` const countValues = [];`,
107
+ ``,
108
+ ` let whereSql = '';`,
109
+ searchConditions,
110
+ ``,
111
+ ` const sql = 'SELECT ${selectFields} FROM ${quotedTableName} WHERE 1=1' + whereSql + ' LIMIT ? OFFSET ?';`,
112
+ ` const countSql = 'SELECT COUNT(*) as counts FROM ${quotedTableName} WHERE 1=1' + whereSql;`,
113
+ ``,
114
+ ` values.push(validPageSize, validPage * validPageSize);`,
115
+ ``,
116
+ ` console.log('搜索${this.controller}(备用查询):', { sql, values, countSql, countValues });`,
117
+ ``,
118
+ ` return await executePaginatedQuery(sql, countSql, values, countValues);`,
119
+ ` } catch (error) {`,
120
+ ` console.error('搜索${this.controller}失败:', error.message);`,
121
+ ` throw error;`,
122
+ ` }`,
123
+ ` },`,
124
+ ``,
125
+ ` // 添加${this.controller} - 添加 DataLoader 缓存预加载`,
126
+ ` ${this.controller}Add: async ({ data }, context) => {`,
127
+ ` try {`,
128
+ this.generateNewValidationCalls(insertFields),
129
+ ``,
130
+ ` const sql = 'INSERT INTO ${quotedTableName} (${insertFieldNames}) VALUES (${insertPlaceholders})';`,
131
+ ` const values = [${insertValues}];`,
132
+ ``,
133
+ ` console.log('添加${this.controller}:', { sql, values });`,
134
+ ``,
135
+ ` const results = await executeQuery(sql, values);`,
136
+ ` const insertId = results.insertId;`,
137
+ ``,
138
+ ` // 预加载新数据到 DataLoader 缓存`,
139
+ ` if (insertId && context?.dataloaders?.${this.controller}) {`,
140
+ ` const newRecord = { id: insertId, ${this.generateNewRecordObject(insertFields)} };`,
141
+ ` context.dataloaders.${this.controller}.prime(insertId, newRecord);`,
142
+ ` console.log('🚀 新${this.controller}已预加载到 DataLoader 缓存:', newRecord);`,
143
+ ` }`,
144
+ ``,
145
+ ` return insertId;`,
146
+ ` } catch (error) {`,
147
+ ` console.error('添加${this.controller}失败:', error.message);`,
148
+ ` throw error;`,
149
+ ` }`,
150
+ ` },`,
151
+ ``,
152
+ ` // 批量添加${this.controller}`,
153
+ ` ${this.controller}BatchAdd: async ({ datas }) => {`,
154
+ ` try {`,
155
+ ` if (!Array.isArray(datas) || datas.length === 0) {`,
156
+ ` throw new Error('批量添加数据不能为空');`,
157
+ ` }`,
158
+ ``,
159
+ ` // 验证所有数据并转换`,
160
+ ` const validatedDatas = datas.map((data, index) => {`,
161
+ ` try {`,
162
+ this.generateBatchValidation(insertFields),
163
+ ` return { ${this.generateBatchReturnObject(insertFields)} };`,
164
+ ` } catch (error) {`,
165
+ ` throw new Error(\`第 \${index + 1} 条数据验证失败: \${error.message}\`);`,
166
+ ` }`,
167
+ ` });`,
168
+ ``,
169
+ ` const placeholders = validatedDatas.map(() => '(${insertPlaceholders})').join(',');`,
170
+ ` const sql = 'INSERT INTO ${quotedTableName} (${insertFieldNames}) VALUES ' + placeholders;`,
171
+ ` const values = validatedDatas.flatMap(data => [${this.generateBatchInsertValues(insertFields)}]);`,
172
+ ` `,
173
+ ` console.log('批量添加${this.controller}:', { sql, values });`,
174
+ ` `,
175
+ ` const results = await executeQuery(sql, values);`,
176
+ ` return results.insertId;`,
177
+ ` } catch (error) {`,
178
+ ` console.error('批量添加${this.controller}失败:', error.message);`,
179
+ ` throw error;`,
180
+ ` }`,
181
+ ` },`,
182
+ ``,
183
+ ` // 更新${this.controller} - 添加 DataLoader 缓存清理`,
184
+ ` ${this.controller}Update: async ({ id, data }, context) => {`,
185
+ ` try {`,
186
+ ` const validId = validateId(id);`,
187
+ ` `,
188
+ ` if (!data) {`,
189
+ ` throw new Error('更新数据不能为空');`,
190
+ ` }`,
191
+ ` `,
192
+ this.generateUpdateValidation(insertFields),
193
+ ` `,
194
+ ` const sql = 'UPDATE ${quotedTableName} SET ${updateFields} WHERE id = ?';`,
195
+ ` const values = [${this.generateUpdateValues(insertFields)}, validId];`,
196
+ ` `,
197
+ ` console.log('更新${this.controller}:', { sql, values });`,
198
+ ` `,
199
+ ` const results = await executeQuery(sql, values);`,
200
+ ` `,
201
+ ` if (results.affectedRows === 0) {`,
202
+ ` throw new Error(\`ID为 \${validId} 的${this.controller}不存在\`);`,
203
+ ` }`,
204
+ ` `,
205
+ ` // 清除 DataLoader 缓存,确保下次查询获取最新数据`,
206
+ ` if (context?.dataloaders?.${this.controller}) {`,
207
+ ` context.dataloaders.${this.controller}.clearById(validId);`,
208
+ ` console.log('🧹 已清除 DataLoader 缓存:', { id: validId });`,
209
+ ` }`,
210
+ ` `,
211
+ ` return true;`,
212
+ ` } catch (error) {`,
213
+ ` console.error('更新${this.controller}失败:', error.message);`,
214
+ ` throw error;`,
215
+ ` }`,
216
+ ` },`,
217
+ ``,
218
+ ` // 删除${this.controller} - 添加 DataLoader 缓存清理`,
219
+ ` ${this.controller}Delete: async ({ id }, context) => {`,
220
+ ` try {`,
221
+ ` const validId = validateId(id);`,
222
+ ` `,
223
+ ` const sql = 'DELETE FROM ${quotedTableName} WHERE id = ?';`,
224
+ ` const values = [validId];`,
225
+ ` `,
226
+ ` console.log('删除${this.controller}:', { sql, values });`,
227
+ ` `,
228
+ ` const results = await executeQuery(sql, values);`,
229
+ ` `,
230
+ ` if (results.affectedRows === 0) {`,
231
+ ` throw new Error(\`ID为 \${validId} 的${this.controller}不存在\`);`,
232
+ ` }`,
233
+ ` `,
234
+ ` // 清除 DataLoader 缓存`,
235
+ ` if (context?.dataloaders?.${this.controller}) {`,
236
+ ` context.dataloaders.${this.controller}.clearById(validId);`,
237
+ ` console.log('🧹 已清除 DataLoader 缓存:', { id: validId });`,
238
+ ` }`,
239
+ ` `,
240
+ ` return true;`,
241
+ ` } catch (error) {`,
242
+ ` console.error('删除${this.controller}失败:', error.message);`,
243
+ ` throw error;`,
244
+ ` }`,
245
+ ` },`,
246
+ ``,
247
+ ` // 批量删除${this.controller} - 添加 DataLoader 缓存清理`,
248
+ ` ${this.controller}BatchDelete: async ({ ids }, context) => {`,
249
+ ` try {`,
250
+ ` if (!Array.isArray(ids) || ids.length === 0) {`,
251
+ ` throw new Error('批量删除的ID列表不能为空');`,
252
+ ` }`,
253
+ ` `,
254
+ ` // 验证所有ID`,
255
+ ` const validIds = ids.map((id, index) => {`,
256
+ ` try {`,
257
+ ` return validateId(id, \`第\${index + 1}个ID\`);`,
258
+ ` } catch (error) {`,
259
+ ` throw new Error(\`第 \${index + 1} 个ID验证失败: \${error.message}\`);`,
260
+ ` }`,
261
+ ` });`,
262
+ ` `,
263
+ ` const placeholders = validIds.map(() => '?').join(',');`,
264
+ ` const sql = 'DELETE FROM ${quotedTableName} WHERE id IN (' + placeholders + ')';`,
265
+ ` `,
266
+ ` console.log('批量删除${this.controller}:', { sql, values: validIds });`,
267
+ ` `,
268
+ ` const results = await executeQuery(sql, validIds);`,
269
+ ` `,
270
+ ` if (results.affectedRows === 0) {`,
271
+ ` throw new Error('没有找到要删除的${this.controller}');`,
272
+ ` }`,
273
+ ` `,
274
+ ` // 批量清除 DataLoader 缓存`,
275
+ ` if (context?.dataloaders?.${this.controller}) {`,
276
+ ` validIds.forEach(id => {`,
277
+ ` context.dataloaders.${this.controller}.clearById(id);`,
278
+ ` });`,
279
+ ` console.log('🧹 已批量清除 DataLoader 缓存:', { ids: validIds });`,
280
+ ` }`,
281
+ ` `,
282
+ ` return true;`,
283
+ ` } catch (error) {`,
284
+ ` console.error('批量删除${this.controller}失败:', error.message);`,
285
+ ` throw error;`,
286
+ ` }`,
287
+ ` }`,
288
+ `};`,
289
+ ].join("\n");
293
290
  }
294
291
  generateSearchConditions(searchableFields) {
295
292
  if (searchableFields.length === 0)