Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RID-440][#197][feat] : frontoffice launchedmodule complete #199

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public ResponseEntity<LaunchedModuleWithContent> getLaunchedModuleWithContent(@P
return ResponseEntity.ok(module);
}

@PostMapping("/{frontOfficeId}/launched-modules/{launchedModuleId}/complete")
public ResponseEntity<LaunchedModuleWithContent> completeModule(@PathVariable UUID frontOfficeId, @PathVariable Long launchedModuleId){
LaunchedModuleWithContent module = frontofficeService.completeLaunchedModuleWithContent(launchedModuleId);
return ResponseEntity.ok(module);
}



@PostMapping("/{frontOfficeId}/oauth")
public ResponseEntity<OAuthV2AccessResponse> oauthMember(@PathVariable UUID frontOfficeId, @Valid @RequestBody OAuthRequest oAuthRequest) throws SlackApiException, IOException {
FrontOfficeResponse frontofficeResponse = frontofficeService.getFrontOffice(frontOfficeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.backend.curi.launched.controller.dto.LaunchedModuleResponse;
import com.backend.curi.launched.repository.entity.LaunchedModule;
import com.backend.curi.launched.repository.entity.LaunchedSequence;
import com.backend.curi.launched.repository.entity.LaunchedStatus;
import com.backend.curi.launched.service.LaunchedModuleService;
import com.backend.curi.slack.controller.dto.OAuthRequest;

Expand Down Expand Up @@ -47,6 +48,14 @@ public LaunchedModuleWithContent getLaunchedModuleWithContent(Long launchedModul
return LaunchedModuleWithContent.of(LaunchedModuleResponse.of(launchedModule), ContentResponse.of(content, launchedModule));
}

public LaunchedModuleWithContent completeLaunchedModuleWithContent(Long launchedModuleId) {
LaunchedModule launchedModule = launchedModuleService.getLaunchedModuleEntity(launchedModuleId);
ObjectId contentId = launchedModule.getContentId();
Content content = contentService.getContent(contentId);
LaunchedModule completedModule = launchedModuleService.completeLaunchedModule(launchedModule);
return LaunchedModuleWithContent.of(LaunchedModuleResponse.of(completedModule), ContentResponse.of(content, launchedModule));
}

public void checkAuth(UUID frontOfficeId, UUID accessToken) {
FrontOffice frontOffice = frontOfficeRepository.findById(frontOfficeId).orElseThrow(() -> new CuriException(HttpStatus.NOT_FOUND, ErrorType.FRONTOFFICE_NOT_EXISTS));
if (!frontOffice.getAccessToken().equals(accessToken)) throw new CuriException(HttpStatus.UNAUTHORIZED, ErrorType.FRONTOFFICE_UNAUTHORIZED);
Expand All @@ -73,4 +82,5 @@ public OAuthV2AccessResponse oauthSlack (OAuthRequest oAuthRequest, UUID frontof
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.backend.curi.launched.repository.entity.LaunchedModule;
import com.backend.curi.launched.repository.entity.LaunchedSequence;
import com.backend.curi.launched.repository.LaunchedModuleRepository;
import com.backend.curi.launched.repository.entity.LaunchedStatus;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -35,6 +36,12 @@ public LaunchedModuleResponse createLaunchedModule(LaunchedModuleRequest launche
return LaunchedModuleResponse.of(savedLaunchedModule);
}

public LaunchedModule completeLaunchedModule (LaunchedModule launchedModule){
launchedModule.setStatus(LaunchedStatus.COMPLETED);
LaunchedModule savedModule = launchedModuleRepository.save(launchedModule);
return savedModule;
}

@Transactional
public LaunchedModuleResponse updateLaunchedModule(LaunchedModuleRequest launchedModuleRequest, Long moduleId){
LaunchedModule launchedModule = getLaunchedModuleEntity(moduleId);
Expand Down