slim admin backend image and remove compose config
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-07-14 13:15:21 +09:00
parent e811208773
commit 78f3578098
6 changed files with 68 additions and 36 deletions
+36 -3
View File
@@ -1,12 +1,23 @@
import { ConflictException, Injectable, NotFoundException } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { Prisma } from '@prisma/auth-client';
import { getAdminAvatarUrl } from '../admins/admin-avatar';
import { AuthPrismaService } from '../auth-prisma/auth-prisma.service';
import { CreateOrganizationDto, ListOrganizationsQuery, UpdateOrganizationDto, UpdateOrganizationLicenseDto } from './dto';
type AdminRequester = {
id: string;
name: string;
email: string;
};
@Injectable()
export class OrganizationsService {
constructor(private readonly authPrisma: AuthPrismaService) {}
constructor(
private readonly authPrisma: AuthPrismaService,
private readonly configService: ConfigService,
) {}
async list(query: ListOrganizationsQuery = {}) {
const page = toPositiveInt(query.page, 1);
@@ -37,6 +48,9 @@ export class OrganizationsService {
type: true,
domain: true,
defaultLicenseCode: true,
createdById: true,
createdByName: true,
createdByEmail: true,
createdAt: true,
},
}),
@@ -51,6 +65,7 @@ export class OrganizationsService {
organizations: organizations.map((organization, index) => ({
...organization,
defaultLicenseName: organization.defaultLicenseCode ? licenseNameByCode.get(organization.defaultLicenseCode) ?? organization.defaultLicenseCode : null,
createdByAvatarUrl: getAdminAvatarUrl(organization.createdById, this.configService),
no: total - ((page - 1) * limit + index),
})),
total,
@@ -59,13 +74,20 @@ export class OrganizationsService {
};
}
async create(body: CreateOrganizationDto) {
async create(body: CreateOrganizationDto, requester?: AdminRequester) {
try {
const organization = await this.authPrisma.organization.create({
data: {
name: body.name.trim(),
type: body.type,
domain: body.domain?.trim() || null,
...(requester
? {
createdById: requester.id,
createdByName: requester.name,
createdByEmail: requester.email,
}
: {}),
},
select: {
id: true,
@@ -73,11 +95,19 @@ export class OrganizationsService {
type: true,
domain: true,
defaultLicenseCode: true,
createdById: true,
createdByName: true,
createdByEmail: true,
createdAt: true,
},
});
return { organization };
return {
organization: {
...organization,
createdByAvatarUrl: getAdminAvatarUrl(organization.createdById, this.configService),
},
};
} catch (error) {
if (
error instanceof Prisma.PrismaClientKnownRequestError &&
@@ -105,6 +135,9 @@ export class OrganizationsService {
type: true,
domain: true,
defaultLicenseCode: true,
createdById: true,
createdByName: true,
createdByEmail: true,
createdAt: true,
},
});