-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-payment
- Loading branch information
Showing
18 changed files
with
313 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/project/carsharingapp/controller/AuthenticationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.project.carsharingapp.controller; | ||
|
||
import com.project.carsharingapp.dto.user.UserLoginRequestDto; | ||
import com.project.carsharingapp.dto.user.UserLoginResponseDto; | ||
import com.project.carsharingapp.dto.user.UserRegistrationRequestDto; | ||
import com.project.carsharingapp.dto.user.UserResponseDto; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
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; | ||
|
||
@RestController | ||
@RequestMapping("/auth") | ||
@Tag(name = "Authentication", description = "Endpoints for managing login and register user") | ||
public class AuthenticationController { | ||
|
||
@PostMapping("/login") | ||
@Operation(summary = "Login user") | ||
public UserLoginResponseDto login(@RequestBody @Valid UserLoginRequestDto requestDto) { | ||
return null; | ||
} | ||
|
||
@PostMapping("/register") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@Operation(summary = "Register user") | ||
public UserResponseDto register(@RequestBody @Valid UserRegistrationRequestDto requestDto) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/com/project/carsharingapp/controller/RentalController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.project.carsharingapp.controller; | ||
|
||
import com.project.carsharingapp.dto.rental.CreateRentalRequestDto; | ||
import com.project.carsharingapp.dto.rental.RentalDto; | ||
import com.project.carsharingapp.dto.rental.SetActualReturnDateRequestDto; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import org.springframework.http.HttpStatus; | ||
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.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "Rental management", | ||
description = "Endpoints for managing rentals") | ||
@RestController | ||
@RequestMapping(value = "/rentals") | ||
public class RentalController { | ||
@PostMapping | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@Operation(summary = "Save new rental", | ||
description = "Save new rental and decrease car inventory by 1") | ||
public RentalDto add(@RequestBody @Valid CreateRentalRequestDto requestDto) { | ||
return null; | ||
} | ||
|
||
@GetMapping("/{userId}/{isActive}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Get the rentals by user id and active status", | ||
description = "Retrieve rentals by user identification number" | ||
+ " and whether the rental is still active or not") | ||
public RentalDto getByUserIdAndActiveStatus(@PathVariable Long userId, | ||
@PathVariable boolean isActive) { | ||
return null; | ||
} | ||
|
||
@GetMapping("/{id}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Get the rental by id", | ||
description = "Get specific rental by identification number") | ||
public RentalDto getById(@PathVariable Long id) { | ||
return null; | ||
} | ||
|
||
@PostMapping("/{returnDate}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Set actual return date", | ||
description = "Set actual return date and increase car inventory by 1") | ||
public RentalDto setActualReturnDay(@RequestBody | ||
@Valid SetActualReturnDateRequestDto returnDate) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/project/carsharingapp/dto/rental/CreateRentalRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.project.carsharingapp.dto.rental; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class CreateRentalRequestDto { | ||
@NotNull | ||
private LocalDateTime rentalDate; | ||
@NotNull | ||
private LocalDateTime returnDate; | ||
@NotNull | ||
private LocalDateTime actualReturnDate; | ||
@NotNull | ||
private Long carId; | ||
@NotNull | ||
private Long userId; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/project/carsharingapp/dto/rental/RentalDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.project.carsharingapp.dto.rental; | ||
|
||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class RentalDto { | ||
private Long id; | ||
private LocalDateTime rentalDate; | ||
private LocalDateTime returnDate; | ||
private LocalDateTime actualReturnDate; | ||
private Long carId; | ||
private Long userId; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/project/carsharingapp/dto/rental/SetActualReturnDateRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.project.carsharingapp.dto.rental; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.format.annotation.DateTimeFormat; | ||
|
||
@Getter | ||
@Setter | ||
public class SetActualReturnDateRequestDto { | ||
@NotNull | ||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
private LocalDateTime actualReturnDate; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/project/carsharingapp/dto/user/UserLoginRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.project.carsharingapp.dto.user; | ||
|
||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public class UserLoginRequestDto { | ||
@NotEmpty | ||
@Size(min = 8, max = 20) | ||
private String email; | ||
|
||
private String password; | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/project/carsharingapp/dto/user/UserLoginResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.project.carsharingapp.dto.user; | ||
|
||
public class UserLoginResponseDto { | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/project/carsharingapp/dto/user/UserRegistrationRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.project.carsharingapp.dto.user; | ||
|
||
import jakarta.validation.constraints.NotEmpty; | ||
|
||
public class UserRegistrationRequestDto { | ||
|
||
private String email; | ||
@NotEmpty | ||
private String password; | ||
private String repeatPassword; | ||
@NotEmpty | ||
private String firstName; | ||
@NotEmpty | ||
private String lastName; | ||
@NotEmpty | ||
private String shippingAddress; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/project/carsharingapp/dto/user/UserResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.project.carsharingapp.dto.user; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class UserResponseDto { | ||
private Long id; | ||
private String email; | ||
private String firstName; | ||
private String lastName; | ||
private String shippingAddress; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/project/carsharingapp/mapper/CarMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.project.carsharingapp.mapper; | ||
|
||
import com.project.carsharingapp.config.MapperConfig; | ||
import com.project.carsharingapp.dto.car.CarDto; | ||
import com.project.carsharingapp.dto.car.CreateCarRequestDto; | ||
import com.project.carsharingapp.model.Car; | ||
import org.mapstruct.Mapper; | ||
|
||
@Mapper(config = MapperConfig.class) | ||
public interface CarMapper { | ||
Car toEntity(CreateCarRequestDto createCarRequestDto); | ||
|
||
CarDto toDto(Car car); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/project/carsharingapp/security/AuthenticationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.project.carsharingapp.security; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class AuthenticationService { | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/project/carsharingapp/service/CarService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.project.carsharingapp.service; | ||
|
||
import com.project.carsharingapp.dto.car.CarDto; | ||
import com.project.carsharingapp.dto.car.CreateCarRequestDto; | ||
import com.project.carsharingapp.dto.car.UpdateCarRequestDto; | ||
import java.util.List; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
public interface CarService { | ||
CarDto save(CreateCarRequestDto createCarRequestDto); | ||
|
||
CarDto get(Long id); | ||
|
||
List<CarDto> getAll(Pageable pageable); | ||
|
||
CarDto update(Long id, UpdateCarRequestDto updateCarRequestDto); | ||
|
||
void delete(Long id); | ||
} |
Oops, something went wrong.