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