|
@@ -69,7 +69,8 @@ export class AsyncExportService {
|
|
|
|
|
|
if (!model) throw new ServiceError(ErrorCode.NO_EXPORT_SETTING);
|
|
|
const builder = model.createQueryBuilder();
|
|
|
- completeBuilderCondition(builder, query);
|
|
|
+ const nq = this.checkColumnInTable(model, query);
|
|
|
+ completeBuilderCondition(builder, nq);
|
|
|
const total = await builder.getCount();
|
|
|
|
|
|
if (total <= 0) throw new ServiceError(ErrorCode.NO_DATA_IN_EXPORT_QUERY);
|
|
@@ -107,7 +108,8 @@ export class AsyncExportService {
|
|
|
|
|
|
if (!model) return;
|
|
|
const builder = model.createQueryBuilder();
|
|
|
- completeBuilderCondition(builder, query);
|
|
|
+ const nq = this.checkColumnInTable(model, query);
|
|
|
+ completeBuilderCondition(builder, nq);
|
|
|
|
|
|
const total = await builder.getCount();
|
|
|
|
|
@@ -242,7 +244,17 @@ export class AsyncExportService {
|
|
|
getModelName(name) {
|
|
|
const model = this[`_model_${upperFirst(name)}`];
|
|
|
if (!model) return;
|
|
|
- return get(model,'metadata.comment')
|
|
|
+ return get(model, 'metadata.comment');
|
|
|
+ }
|
|
|
+ getDict_tables() {
|
|
|
+ const keys = Object.keys(this).filter(f => f.includes('_model_'));
|
|
|
+ const tableList = keys.map(i => {
|
|
|
+ const model = this[i];
|
|
|
+ const label = get(model, 'metadata.comment');
|
|
|
+ const table = get(model, 'metadata.name');
|
|
|
+ return { label, table };
|
|
|
+ });
|
|
|
+ return tableList;
|
|
|
}
|
|
|
|
|
|
@Config('PathConfig.path')
|
|
@@ -283,6 +295,18 @@ export class AsyncExportService {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ checkColumnInTable(model, query) {
|
|
|
+ const columns = get(model, 'metadata.columns', []);
|
|
|
+ const nq = {};
|
|
|
+ for (const key in query) {
|
|
|
+ const column = columns.find(f => get(f, 'propertyName') === key);
|
|
|
+ if (!column) continue;
|
|
|
+ const val = query[key];
|
|
|
+ nq[key] = val;
|
|
|
+ }
|
|
|
+ return nq;
|
|
|
+ }
|
|
|
|
|
|
@InjectEntityModel(Admin)
|
|
|
_model_Admin: Repository<Admin>;
|