Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

Commit

Permalink
fix: rerun CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexZ7000 committed Oct 15, 2024
1 parent 33ec935 commit 7bb08b4
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.example.comerce.core.entities.LoginResponse;
import com.example.comerce.core.entities.User;
import com.example.comerce.core.services.UserService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -16,7 +15,7 @@

@RestController
@RequestMapping("/api/users")
public final class UserController {
public class UserController {

private final UserService userService;

Expand All @@ -25,33 +24,33 @@ public UserController(final UserService userService) {
this.userService = userService;
}

@PostMapping("/login")
public ResponseEntity<LoginResponse> login(@RequestBody LoginRequest loginRequest) throws Exception {
LoginResponse loginResponse = userService.login(loginRequest.getEmail(), loginRequest.getPassword());
return ResponseEntity.ok(loginResponse);
}

@GetMapping
public ResponseEntity<List<User>> getAllUsers() {
final List<User> users = userService.findAll();
List<User> users = userService.findAll();
return ResponseEntity.ok(users);
}

@GetMapping("/{id}")
public ResponseEntity<User> getUserById(@PathVariable final UUID id) {
final Optional<User> user = userService.findById(id);
public ResponseEntity<User> getUserById(@PathVariable UUID id) {
Optional<User> user = userService.findById(id);
return user.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
}

@PostMapping
public ResponseEntity<User> createUser(@Valid @RequestBody final UserDTO userDTO) {
final User savedUser = userService.save(userDTO);
return ResponseEntity.ok(savedUser);
}

@PostMapping("/login")
public LoginResponse login(@RequestBody final LoginRequest request) throws Exception {
return userService.login(request.getEmail(), request.getPassword());
public ResponseEntity<User> createUser(@RequestBody UserDTO userDTO) {
User user = userService.save(userDTO);
return ResponseEntity.ok(user);
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteUser(@PathVariable final UUID id) {
public ResponseEntity<Void> deleteUser(@PathVariable UUID id) {
userService.delete(id);
return ResponseEntity.noContent().build();
}
}

}

0 comments on commit 7bb08b4

Please sign in to comment.