|
@@ -19,7 +19,7 @@ export class CommonService {
|
|
|
* @returns total 总数
|
|
|
*/
|
|
|
async search(model: Repository<ObjectLiteral>, query: object = {}, page: object = {}, others: object = {}) {
|
|
|
- const data = await model.find({ ...query, ...page, ...others })
|
|
|
+ const data = await model.find({ where: query, ...page, ...others })
|
|
|
const total = await model.count(query)
|
|
|
return { data, total };
|
|
|
}
|
|
@@ -41,7 +41,7 @@ export class CommonService {
|
|
|
*/
|
|
|
getModel(tableName: string): Repository<ObjectLiteral> {
|
|
|
const entitys = this.defaultDataSource.entityMetadatas;
|
|
|
- const entity = entitys.find(f => replace(lowerCase(f.name), " ", '') === tableName)
|
|
|
+ const entity = entitys.find(f => replace(lowerCase(f.name), " ", '') === replace(lowerCase(tableName), " ", ''))
|
|
|
if (!entity) throw new ServiceError(ErrorCode.ENTITY_NOT_FOUND)
|
|
|
const entityClass = entity.target;
|
|
|
const model = this.defaultDataSource.getRepository(entityClass)
|