mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 01:24:54 +00:00
added success message
This commit is contained in:
@ -23,6 +23,7 @@ export class SuccessResponseDto<Type> implements BaseResponseDto {
|
||||
constructor(input: BaseResponseDto) {
|
||||
if (input.statusCode) this.statusCode = input.statusCode;
|
||||
else this.statusCode = 200;
|
||||
if (input.message) this.message = input.message;
|
||||
if (input.data) this.data = input.data;
|
||||
this.success = true;
|
||||
}
|
||||
|
||||
@ -109,15 +109,10 @@ export class CommunityService {
|
||||
try {
|
||||
const { name } = updateCommunityDto;
|
||||
|
||||
// Find the community by its UUID
|
||||
|
||||
// Update the community name
|
||||
community.name = name;
|
||||
|
||||
// Save the updated community back to the database
|
||||
const updatedCommunity = await this.communityRepository.save(community);
|
||||
|
||||
// Return a SuccessResponseDto with the updated community data
|
||||
return new SuccessResponseDto<CommunityDto>({
|
||||
message: 'Success update Community',
|
||||
data: updatedCommunity,
|
||||
@ -146,19 +141,14 @@ export class CommunityService {
|
||||
);
|
||||
}
|
||||
try {
|
||||
// Find the community by its uuid
|
||||
await this.communityRepository.remove(community);
|
||||
|
||||
// Remove the community from the database
|
||||
|
||||
// Return success response
|
||||
return new SuccessResponseDto({
|
||||
message: `Community with ID ${communityUuid} successfully deleted`,
|
||||
data: null,
|
||||
message: `Community with ID ${communityUuid} has been successfully deleted`,
|
||||
});
|
||||
} catch (err) {
|
||||
// Catch and handle any errors
|
||||
if (err instanceof HttpException) {
|
||||
throw err; // If it's an HttpException, rethrow it
|
||||
throw err;
|
||||
} else {
|
||||
throw new HttpException(
|
||||
'An error occurred while deleting the community',
|
||||
|
||||
Reference in New Issue
Block a user