feat: add Jinshuju student sync
All checks were successful
CI / check (pull_request) Successful in 2m14s

This commit is contained in:
2026-07-22 11:37:20 +08:00
parent 1dc13274de
commit 393ee62168
18 changed files with 1378 additions and 12 deletions

View File

@@ -756,8 +756,8 @@ export class RbacService {
async getTeachers(query?: { search?: string; page?: number; pageSize?: number }) {
const page = query?.page || 1;
const pageSize = query?.pageSize || 20;
const teacherRoleCodes = ['teacher', 'super_admin'];
const teacherRoleNames = ['任课老师', '老师', '超级管理员', '超管'];
const teacherRoleCodes = ['teacher'];
const teacherRoleNames = ['任课老师', '老师'];
const qb = this.userRepo
.createQueryBuilder('u')

View File

@@ -0,0 +1,40 @@
import { RbacService } from './rbac.service';
describe('RbacService teacher listing', () => {
it('queries only teacher roles, excluding administrators', async () => {
const queryBuilder = {
leftJoinAndSelect: jest.fn(),
where: jest.fn(),
andWhere: jest.fn(),
getCount: jest.fn().mockResolvedValue(0),
orderBy: jest.fn(),
skip: jest.fn(),
take: jest.fn(),
getMany: jest.fn().mockResolvedValue([]),
};
for (const method of ['leftJoinAndSelect', 'where', 'andWhere', 'orderBy', 'skip', 'take'] as const) {
queryBuilder[method].mockReturnValue(queryBuilder);
}
const userRepo = { createQueryBuilder: jest.fn().mockReturnValue(queryBuilder) };
const service = new RbacService(
{} as never,
{} as never,
userRepo as never,
{} as never,
{} as never,
{} as never,
{} as never,
{} as never,
);
await service.getTeachers();
expect(queryBuilder.where).toHaveBeenCalledWith(
'(role.code IN (:...roleCodes) OR role.name IN (:...roleNames))',
{
roleCodes: ['teacher'],
roleNames: ['任课老师', '老师'],
},
);
});
});