mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 19:00:55 +00:00
feat(file-upload-settings): Add API endpoint and logic to retrieve settings by entity
This commit is contained in:
@@ -42,6 +42,12 @@ export class FileUploadSettingsController {
|
||||
return this.service.getByCode(code);
|
||||
}
|
||||
|
||||
@Get("by-entity/:entity")
|
||||
@ApiOperation({ summary: "Get all file upload settings for an entity type (customer, booking, etc.)" })
|
||||
getByEntity(@Param("entity") entity: string) {
|
||||
return this.service.getByEntity(entity);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: "Create a new file upload setting" })
|
||||
create(@Body() dto: CreateFileUploadSettingDto) {
|
||||
|
||||
@@ -21,6 +21,15 @@ export class FileUploadSettingsRepository
|
||||
super(repository);
|
||||
}
|
||||
|
||||
/** Look up all settings for a given entity (e.g. "customer", "booking"). */
|
||||
findByEntity(entity: string): Promise<FileUploadSetting[]> {
|
||||
return this.repository.find({
|
||||
where: { entity },
|
||||
order: { label: "ASC" },
|
||||
relations: { fields: true },
|
||||
});
|
||||
}
|
||||
|
||||
/** Look up a setting by its stable code. */
|
||||
findByCode(code: string): Promise<FileUploadSetting | null> {
|
||||
return this.repository.findOne({
|
||||
|
||||
@@ -33,6 +33,10 @@ export class FileUploadSettingsService {
|
||||
return setting;
|
||||
}
|
||||
|
||||
getByEntity(entity: string): Promise<FileUploadSetting[]> {
|
||||
return this.repository.findByEntity(entity);
|
||||
}
|
||||
|
||||
async getByCode(code: string): Promise<FileUploadSetting> {
|
||||
const setting = await this.repository.findByCode(code);
|
||||
if (!setting) throw new NotFoundException(`Setting "${code}" not found`);
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface IFileUploadSettingsRepository {
|
||||
findAll(): Promise<FileUploadSetting[]>;
|
||||
findById(id: string): Promise<FileUploadSetting | null>;
|
||||
findByCode(code: string): Promise<FileUploadSetting | null>;
|
||||
findByEntity(entity: string): Promise<FileUploadSetting[]>;
|
||||
|
||||
create(data: Partial<FileUploadSetting>): Promise<FileUploadSetting>;
|
||||
update(
|
||||
|
||||
Reference in New Issue
Block a user