nsgm-cli 2.1.36 → 2.1.37

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,17 @@ class ResolverGenerator extends base_generator_1.BaseGenerator {
11
11
  return `\`${this.controller}\``;
12
12
  }
13
13
  generate() {
14
+ // Variables used in generated template string (prefixed with _ to satisfy ESLint)
14
15
  // @ts-ignore - Variable is used in generated template string
15
- const selectFields = this.fields.map((f) => f.name).join(", ");
16
+ const _selectFields = this.fields.map((f) => f.name).join(", ");
16
17
  const insertFields = this.getFormFields();
17
18
  const searchableFields = this.getSearchableFields();
18
19
  // @ts-ignore - Variable is used in generated template string
19
- const quotedTableName = this.getQuotedTableName();
20
+ const _quotedTableName = this.getQuotedTableName();
20
21
  // @ts-ignore - Variable is used in generated template string
21
- const insertFieldNames = insertFields.map((f) => f.name).join(", ");
22
+ const _insertFieldNames = insertFields.map((f) => f.name).join(", ");
22
23
  // @ts-ignore - Variable is used in generated template string
23
- const insertPlaceholders = insertFields.map(() => "?").join(", ");
24
+ const _insertPlaceholders = insertFields.map(() => "?").join(", ");
24
25
  const insertValues = insertFields
25
26
  .map((f) => {
26
27
  if (f.type === "integer") {
@@ -31,7 +32,7 @@ class ResolverGenerator extends base_generator_1.BaseGenerator {
31
32
  .join(", ");
32
33
  const searchConditions = this.generateSearchConditions(searchableFields);
33
34
  // @ts-ignore - Variable is used in generated template string
34
- const updateFields = insertFields.map((f) => `${f.name} = ?`).join(", ");
35
+ const _updateFields = insertFields.map((f) => `${f.name} = ?`).join(", ");
35
36
  return `const { executeQuery, executePaginatedQuery } = require('../../utils/common')
36
37
  const { validateInteger, validatePagination, validateId } = require('../../utils/validation')
37
38
 
@@ -41,8 +42,8 @@ module.exports = {
41
42
  try {
42
43
  const { page: validPage, pageSize: validPageSize } = validatePagination(page, pageSize);
43
44
 
44
- const sql = \`SELECT \${selectFields} FROM \${quotedTableName} LIMIT ? OFFSET ?\`;
45
- const countSql = \`SELECT COUNT(*) as counts FROM \${quotedTableName}\`;
45
+ const sql = \`SELECT \${_selectFields} FROM \${_quotedTableName} LIMIT ? OFFSET ?\`;
46
+ const countSql = \`SELECT COUNT(*) as counts FROM \${_quotedTableName}\`;
46
47
  const values = [validPageSize, validPage * validPageSize];
47
48
 
48
49
  console.log('执行分页查询:', { sql, values, countSql });
@@ -112,8 +113,8 @@ module.exports = {
112
113
  let whereSql = '';
113
114
  ${searchConditions}
114
115
 
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}\`;
116
+ const sql = \`SELECT \${_selectFields} FROM \${_quotedTableName} WHERE 1=1\${whereSql} LIMIT ? OFFSET ?\`;
117
+ const countSql = \`SELECT COUNT(*) as counts FROM \${_quotedTableName} WHERE 1=1\${whereSql}\`;
117
118
 
118
119
  values.push(validPageSize, validPage * validPageSize);
119
120
 
@@ -131,7 +132,7 @@ ${searchConditions}
131
132
  try {
132
133
  ${this.generateNewValidationCalls(insertFields)}
133
134
 
134
- const sql = \`INSERT INTO \${quotedTableName} (\${insertFieldNames}) VALUES (\${insertPlaceholders})\`;
135
+ const sql = \`INSERT INTO \${_quotedTableName} (\${_insertFieldNames}) VALUES (\${_insertPlaceholders})\`;
135
136
  const values = [${insertValues}];
136
137
 
137
138
  console.log('添加${this.controller}:', { sql, values });
@@ -170,8 +171,8 @@ ${this.generateBatchValidation(insertFields)}
170
171
  }
171
172
  });
172
173
 
173
- const placeholders = validatedDatas.map(() => \`(\${insertPlaceholders})\`).join(',');
174
- const sql = \`INSERT INTO \${quotedTableName} (\${insertFieldNames}) VALUES \${placeholders}\`;
174
+ const placeholders = validatedDatas.map(() => \`(\${_insertPlaceholders})\`).join(',');
175
+ const sql = \`INSERT INTO \${_quotedTableName} (\${_insertFieldNames}) VALUES \${placeholders}\`;
175
176
  const values = validatedDatas.flatMap(data => [${this.generateBatchInsertValues(insertFields)}]);
176
177
 
177
178
  console.log('批量添加${this.controller}:', { sql, values });
@@ -195,7 +196,7 @@ ${this.generateBatchValidation(insertFields)}
195
196
 
196
197
  ${this.generateUpdateValidation(insertFields)}
197
198
 
198
- const sql = \`UPDATE \${quotedTableName} SET \${updateFields} WHERE id = ?\`;
199
+ const sql = \`UPDATE \${_quotedTableName} SET \${_updateFields} WHERE id = ?\`;
199
200
  const values = [${this.generateUpdateValues(insertFields)}, validId];
200
201
 
201
202
  console.log('更新${this.controller}:', { sql, values });
@@ -224,7 +225,7 @@ ${this.generateUpdateValidation(insertFields)}
224
225
  try {
225
226
  const validId = validateId(id);
226
227
 
227
- const sql = \`DELETE FROM \${quotedTableName} WHERE id = ?\`;
228
+ const sql = \`DELETE FROM \${_quotedTableName} WHERE id = ?\`;
228
229
  const values = [validId];
229
230
 
230
231
  console.log('删除${this.controller}:', { sql, values });
@@ -265,7 +266,7 @@ ${this.generateUpdateValidation(insertFields)}
265
266
  });
266
267
 
267
268
  const placeholders = validIds.map(() => '?').join(',');
268
- const sql = \`DELETE FROM \${quotedTableName} WHERE id IN (\${placeholders})\`;
269
+ const sql = \`DELETE FROM \${_quotedTableName} WHERE id IN (\${placeholders})\`;
269
270
 
270
271
  console.log('批量删除${this.controller}:', { sql, values: validIds });
271
272