Skip to content

Commit 68dcc0c

Browse files
committed
feat: 修改查询
1 parent 5f0784a commit 68dcc0c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/api/account/account.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class AccountController {
6969
async getAccountListApi(
7070
@CurrentUser('userInfo') currentInfo: ICurrentUserType,
7171
@Query('status') status: number
72-
): Promise<Pick<AccountEntity, 'id' | 'username'>[]> {
72+
): Promise<Pick<AccountEntity, 'id' | 'username' | 'parentId'>[]> {
7373
return await this.accountService.getAccountListApi(currentInfo, status);
7474
}
7575

src/api/account/account.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,22 +230,22 @@ export class AccountService {
230230
async getAccountListApi(
231231
currentInfo: ICurrentUserType,
232232
status: number
233-
): Promise<Pick<AccountEntity, 'id' | 'username'>[]> {
233+
): Promise<Pick<AccountEntity, 'id' | 'username' | 'parentId'>[]> {
234234
const { id, accountType } = currentInfo;
235235
console.log(status, '状态');
236236
const query = new Map<string, FindOperator<string>>();
237237
if (Object.is(accountType, AccountTypeEnum.SUPER_ACCOUNT)) {
238-
query.set('parentId', Equal(-1 + ''));
238+
query.set('parentId', In([-1, id]));
239239
} else {
240240
query.set('parentId', Equal(id + ''));
241241
}
242242
if ([StatusEnum.FORBIDDEN, StatusEnum.NORMAL].includes(status)) {
243243
query.set('status', Equal(status + ''));
244244
}
245-
const accountEntity: Pick<AccountEntity, 'id' | 'username'>[] =
245+
const accountEntity: Pick<AccountEntity, 'id' | 'username' | 'parentId'>[] =
246246
await this.accountRepository.find({
247247
where: mapToObj(query),
248-
select: ['id', 'username'],
248+
select: ['id', 'username', 'parentId'],
249249
});
250250
return accountEntity;
251251
}

src/api/department/department.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ export class DepartmentService {
204204
const { id, tenantId, accountType } = currentUser;
205205
const query = new Map<string, FindOperator<string>>();
206206
query.set('tenantId', Equal(tenantId + ''));
207-
if (accountType != AccountTypeEnum.SUPER_ACCOUNT) {
207+
if (accountType == AccountTypeEnum.SUPER_ACCOUNT) {
208+
query.set('parentId', In([-1, id]));
209+
} else {
208210
query.set('parentId', Equal(id + ''));
209211
}
210212
return await this.departmentRepository.find({

0 commit comments

Comments
 (0)