|
@@ -69,7 +69,8 @@ export class AsyncExportService {
|
|
// 抛出异常: 该数据未经过导出设置,无法导出
|
|
// 抛出异常: 该数据未经过导出设置,无法导出
|
|
if (!model) throw new ServiceError(ErrorCode.NO_EXPORT_SETTING);
|
|
if (!model) throw new ServiceError(ErrorCode.NO_EXPORT_SETTING);
|
|
const builder = model.createQueryBuilder();
|
|
const builder = model.createQueryBuilder();
|
|
- completeBuilderCondition(builder, query);
|
|
|
|
|
|
+ const nq = this.checkColumnInTable(model, query);
|
|
|
|
+ completeBuilderCondition(builder, nq);
|
|
const total = await builder.getCount();
|
|
const total = await builder.getCount();
|
|
// 抛出异常: 未查询到可导出的数据
|
|
// 抛出异常: 未查询到可导出的数据
|
|
if (total <= 0) throw new ServiceError(ErrorCode.NO_DATA_IN_EXPORT_QUERY);
|
|
if (total <= 0) throw new ServiceError(ErrorCode.NO_DATA_IN_EXPORT_QUERY);
|
|
@@ -107,7 +108,8 @@ export class AsyncExportService {
|
|
// 没找到model,不需要执行
|
|
// 没找到model,不需要执行
|
|
if (!model) return;
|
|
if (!model) return;
|
|
const builder = model.createQueryBuilder();
|
|
const builder = model.createQueryBuilder();
|
|
- completeBuilderCondition(builder, query);
|
|
|
|
|
|
+ const nq = this.checkColumnInTable(model, query);
|
|
|
|
+ completeBuilderCondition(builder, nq);
|
|
/**数据总数,计算进度用 */
|
|
/**数据总数,计算进度用 */
|
|
const total = await builder.getCount();
|
|
const total = await builder.getCount();
|
|
// 找数据,处理数据,写入数据
|
|
// 找数据,处理数据,写入数据
|
|
@@ -242,7 +244,17 @@ export class AsyncExportService {
|
|
getModelName(name) {
|
|
getModelName(name) {
|
|
const model = this[`_model_${upperFirst(name)}`];
|
|
const model = this[`_model_${upperFirst(name)}`];
|
|
if (!model) return;
|
|
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')
|
|
@Config('PathConfig.path')
|
|
@@ -283,6 +295,18 @@ export class AsyncExportService {
|
|
return true;
|
|
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)
|
|
@InjectEntityModel(Admin)
|
|
_model_Admin: Repository<Admin>;
|
|
_model_Admin: Repository<Admin>;
|