Skip to content

Commit

Permalink
feat: #7/공고 수정 Usecase 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Younggun-Kim committed Oct 23, 2024
1 parent 5552435 commit 9bbb887
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/feature/job_posting/domain/usecases/usecases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ abstract class JobPostingUseCase {
});

/// 공고 등록
Future<bool> createJobPosting(JobPostingRequestEntity entity);
Future<bool> createJobPosting({
required JobPostingRequestEntity entity,
});

/// 공고 수정
Future<bool> updateJobPosting({
required String jobPostingId,
required JobPostingRequestEntity entity,
});

/// 공고 상세 조회
Future<Either<JobPostingDetailEntity>> getJobPosting({
Expand Down
28 changes: 27 additions & 1 deletion lib/feature/job_posting/domain/usecases/usecases_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class JobPostingUseCaseImpl implements JobPostingUseCase {

/// 공고 등록
@override
Future<bool> createJobPosting(JobPostingRequestEntity entity) async {
Future<bool> createJobPosting({
required JobPostingRequestEntity entity,
}) async {
if (!isValidEntity(entity)) {
return false;
}
Expand All @@ -45,6 +47,30 @@ class JobPostingUseCaseImpl implements JobPostingUseCase {
return result.maybeWhen<bool>(success: (_) => true, orElse: () => false);
}

/// 공고 수정
@override
Future<bool> updateJobPosting({
required String jobPostingId,
required JobPostingRequestEntity entity,
}) async {
if (!isValidEntity(entity)) {
return false;
}

final dto = entity.toDto();

if (dto == null) {
return false;
}

final result = await repository.updateJobPosting(
jobPostingId: jobPostingId,
dto: dto,
);

return result.maybeWhen<bool>(success: (_) => true, orElse: () => false);
}

/// 공고 상세 조회
@override
Future<Either<JobPostingDetailEntity>> getJobPosting({
Expand Down

0 comments on commit 9bbb887

Please sign in to comment.