Skip to content

Commit

Permalink
feat: #6/공고 삭제 Usecase 추가
Browse files Browse the repository at this point in the history
1. deleteJobPosting 메소드 추가
  • Loading branch information
Younggun-Kim committed Oct 23, 2024
1 parent 02a11e4 commit 46acf6d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/feature/job_posting/domain/usecases/usecases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:withu_app/core/core.dart';
import 'package:withu_app/feature/job_posting/data/data.dart';
import 'package:withu_app/feature/job_posting/domain/domain.dart';
import 'package:withu_app/feature/job_posting/domain/entities/job_posting_detail_entity.dart';
import 'package:withu_app/shared/data/data.dart';

part 'usecases_impl.dart';

Expand All @@ -24,4 +25,9 @@ abstract class JobPostingUseCase {
Future<Either<JobPostingDetailEntity>> closeJobPosting({
required String jobPostingId,
});

/// 공고 삭제
Future<Either<bool>> deleteJobPosting({
required String jobPostingId,
});
}
23 changes: 23 additions & 0 deletions lib/feature/job_posting/domain/usecases/usecases_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,29 @@ class JobPostingUseCaseImpl implements JobPostingUseCase {
},
);
}

/// 공고 삭제
@override
Future<Either<bool>> deleteJobPosting({
required String jobPostingId,
}) async {
final result =
await repository.deleteJobPosting(jobPostingId: jobPostingId);

return result.when(
success: (DeleteResponseDto dto) {
return dto.deleted
? const Either.success(true)
: Either.fail(dto.message ?? '');
},
fail: (FailResponse fail) {
return Either.fail(fail.message);
},
error: () {
return Either.fail(StringRes.serverError.tr);
},
);
}
}

extension on JobPostingUseCase {
Expand Down

0 comments on commit 46acf6d

Please sign in to comment.