mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-20 02:49:09 +00:00
FEAT: image upload in theme
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||
import { IdResponse } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Inject,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
UseFilters,
|
||||
@@ -22,11 +19,10 @@ import {
|
||||
} from 'src/decorators/authentication.decorator';
|
||||
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||
import { CustomersService } from './customers.service';
|
||||
import { CustomerLinkRequest, CustomerLinksResponse, CustomerThemeRequest, CustomerThemeResponse } from './dtos/customers';
|
||||
import { CustomerLinkRequest, CustomerLinksResponse } from './dtos/customers';
|
||||
import { RequestUser, User } from 'src/decorators/user.decorator';
|
||||
import type { StringValue } from 'ms';
|
||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||
import ErrorCodes from 'src/utils/errorCodes';
|
||||
|
||||
@ApiTags('Customers')
|
||||
@Controller('customers')
|
||||
@@ -51,51 +47,6 @@ export class CustomersController {
|
||||
return { links };
|
||||
}
|
||||
|
||||
@Post(':id/theme')
|
||||
@Authenticated()
|
||||
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({ type: CustomerThemeResponse })
|
||||
async saveCustomertheme(@Param('id') id: string, @Body() data: CustomerThemeRequest) {
|
||||
this.logger.info('saveCustomertheme', JSON.stringify({
|
||||
id, theme: data
|
||||
}));
|
||||
|
||||
try {
|
||||
// const theme = await this.customersService.createThemeByCustomer(id, data);
|
||||
this.logger.info('saveCustomertheme', JSON.stringify(data));
|
||||
return { theme: null };
|
||||
} catch (err) {
|
||||
if (err.details === ErrorCodes.CUSTOMER.NOT_FOUND) {
|
||||
this.logger.error('Error - saveCustomertheme - Expect CUSTOMER.NOT_FOUND');
|
||||
throw new HttpException(err.details, HttpStatus.NOT_FOUND);
|
||||
} else {
|
||||
this.logger.error('Error - saveCustomertheme Unknown Error:' + err?.message);
|
||||
return { theme: null };
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Get(':id/theme')
|
||||
@ApiOkResponse({ type: CustomerThemeResponse })
|
||||
async getCustomerTheme(@Param('id') id: string) {
|
||||
this.logger.info('getCustomerTheme with id' + id);
|
||||
|
||||
try {
|
||||
const data = await this.customersService.getThemeByCustomer(id);
|
||||
this.logger.info('Success - getCustomerTheme with id'+ id);
|
||||
return data;
|
||||
}catch (err) {
|
||||
if (err.details === ErrorCodes.CUSTOMER.NOT_FOUND) {
|
||||
this.logger.error('Error - getCustomerTheme - Expect CUSTOMER.NOT_FOUND');
|
||||
throw new HttpException(err.details, HttpStatus.NOT_FOUND);
|
||||
} else {
|
||||
this.logger.error('Error - getCustomerTheme Unknown Error:' + err?.message);
|
||||
return { theme: null };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Put(':id/links')
|
||||
@Authenticated()
|
||||
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
|
||||
|
||||
Reference in New Issue
Block a user