|
@@ -4,16 +4,19 @@ import { Team } from '../entities/team.entity'
|
|
|
import { PaginationResponse } from '../dto/common.dto'
|
|
import { PaginationResponse } from '../dto/common.dto'
|
|
|
import { CreateTeamBody, UpdateTeamBody, ListTeamQuery } from '../dto/team.dto'
|
|
import { CreateTeamBody, UpdateTeamBody, ListTeamQuery } from '../dto/team.dto'
|
|
|
import { UserService } from './user.service'
|
|
import { UserService } from './user.service'
|
|
|
|
|
+import { SysConfigService } from './sys-config.service'
|
|
|
import { UserRole } from '../entities/user.entity'
|
|
import { UserRole } from '../entities/user.entity'
|
|
|
import * as randomstring from 'randomstring'
|
|
import * as randomstring from 'randomstring'
|
|
|
|
|
|
|
|
export class TeamService {
|
|
export class TeamService {
|
|
|
private teamRepository: Repository<Team>
|
|
private teamRepository: Repository<Team>
|
|
|
private userService: UserService
|
|
private userService: UserService
|
|
|
|
|
+ private sysConfigService: SysConfigService
|
|
|
|
|
|
|
|
constructor(app: FastifyInstance) {
|
|
constructor(app: FastifyInstance) {
|
|
|
this.teamRepository = app.dataSource.getRepository(Team)
|
|
this.teamRepository = app.dataSource.getRepository(Team)
|
|
|
this.userService = new UserService(app)
|
|
this.userService = new UserService(app)
|
|
|
|
|
+ this.sysConfigService = new SysConfigService(app)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async create(data: CreateTeamBody, creatorId: number): Promise<Team> {
|
|
async create(data: CreateTeamBody, creatorId: number): Promise<Team> {
|
|
@@ -45,6 +48,9 @@ export class TeamService {
|
|
|
})
|
|
})
|
|
|
const savedTeam = await this.teamRepository.save(team)
|
|
const savedTeam = await this.teamRepository.save(team)
|
|
|
|
|
|
|
|
|
|
+ // 创建团队默认配置
|
|
|
|
|
+ await this.sysConfigService.createDefaultTeamConfigs(savedTeam.id)
|
|
|
|
|
+
|
|
|
return savedTeam
|
|
return savedTeam
|
|
|
}
|
|
}
|
|
|
|
|
|