package com.timtech.profile.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import com.timtech.profile.dto.ProfileDto; import com.timtech.profile.dto.ProfileDto.ProfileUpdate; import com.timtech.profile.service.ProfileService; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @RestController @RequestMapping("/profile") public class ProfileController { @Autowired private ProfileService profileService; @PostMapping @ResponseStatus(HttpStatus.CREATED) public Mono<ProfileDto> saveProfile(@RequestBody ProfileDto profileDto) { return profileService.save(profileDto); } @PutMapping @ResponseStatus(HttpStatus.ACCEPTED) public Mono<ProfileDto> updateProfile(@Validated(ProfileUpdate.class) @RequestBody ProfileDto profileDto) { return profileService.update(profileDto); } @GetMapping public Flux<ProfileDto> findAllProfiles(){ return profileService.findAll(); } @GetMapping("/{profileId}") public Mono<ProfileDto> findOneProfiles(@PathVariable String profileId){ return profileService.findOne(profileId); } @DeleteMapping("/{profileId}") public Mono<String> deleteOne(@PathVariable String profileId){ return profileService.deleteOne(profileId); } }