feat: 新增推广等级激励功能

This commit is contained in:
xiaojunnuo
2026-05-31 01:01:30 +08:00
parent 3c2d450aa8
commit 5096df5cc0
20 changed files with 236 additions and 53 deletions
@@ -1,5 +1,5 @@
import { PermissionException, ValidateException } from './exception/index.js';
import { FindOneOptions, In, Repository, SelectQueryBuilder } from 'typeorm';
import { EntityTarget, FindOneOptions, In, Repository, SelectQueryBuilder } from 'typeorm';
import { Inject } from '@midwayjs/core';
import { TypeORMDataSourceManager } from '@midwayjs/typeorm';
import { EntityManager } from 'typeorm/entity-manager/EntityManager.js';
@@ -20,6 +20,10 @@ export type ListReq<T = any> = {
select?: any;
};
export type ServiceContext = {
manager?: EntityManager;
};
/**
* 服务基类
*/
@@ -34,6 +38,14 @@ export abstract class BaseService<T> {
return await dataSource.transaction(callback as any);
}
protected getRepo<E>(ctx: ServiceContext, entity: EntityTarget<E>): Repository<E> {
if (ctx.manager) {
return ctx.manager.getRepository(entity);
}
const dataSource = this.dataSourceManager.getDataSource('default');
return dataSource.getRepository(entity);
}
/**
* 获得单个ID
* @param id ID
@@ -81,7 +93,7 @@ export abstract class BaseService<T> {
if (idArr.length === 0) {
return;
}
await this.getRepository().delete({
id: In(idArr),
...where,
@@ -283,4 +295,4 @@ export function checkUserProjectParam(userId: number, projectId: number) {
}
throw new ValidateException('userId不能为空');
}
}
}