-
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.
created user controller and user DTO
- Loading branch information
Showing
10 changed files
with
265 additions
and
4 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
68 changes: 68 additions & 0 deletions
68
src/main/java/com/project/carsharingapp/controller/CarController.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,68 @@ | ||
package com.project.carsharingapp.controller; | ||
|
||
import com.project.carsharingapp.dto.car.CarDto; | ||
import com.project.carsharingapp.dto.car.CreateCarRequestDto; | ||
import com.project.carsharingapp.dto.car.UpdateCarRequestDto; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.util.List; | ||
import javax.validation.Valid; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.http.HttpStatus; | ||
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; | ||
|
||
@Tag(name = "Car management", | ||
description = "Endpoints for managing cars") | ||
@RestController | ||
@RequestMapping(value = "/cars") | ||
public class CarController { | ||
|
||
@PostMapping | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@Operation(summary = "Save new car", | ||
description = "Save new car") | ||
public CarDto add(@RequestBody @Valid CreateCarRequestDto requestDto) { | ||
return null; | ||
} | ||
|
||
@GetMapping | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Get all cars", | ||
description = "Get list of all cars") | ||
public List<CarDto> getAll(Pageable pageable) { | ||
return null; | ||
} | ||
|
||
@GetMapping("/{id}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Get the car by id", | ||
description = "Get car's detailed information by identification number") | ||
public CarDto getById(@PathVariable Long id) { | ||
return null; | ||
} | ||
|
||
@PutMapping("/{id}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Update the car by id", | ||
description = "Update the car information by identification number") | ||
public CarDto update(@PathVariable Long id, | ||
@Valid @RequestBody UpdateCarRequestDto requestDto) { | ||
return null; | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@Operation(summary = "Delete the car by id", | ||
description = "Delete the car by identification number") | ||
public void deleteById(@PathVariable Long id) { | ||
|
||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/com/project/carsharingapp/controller/UserController.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,53 @@ | ||
package com.project.carsharingapp.controller; | ||
|
||
import com.project.carsharingapp.dto.user.UpdateUserProfileRequestDto; | ||
import com.project.carsharingapp.dto.user.UpdateUserRoleRequestDto; | ||
import com.project.carsharingapp.dto.user.UserDto; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import javax.validation.Valid; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
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; | ||
|
||
@Tag(name = "User management", | ||
description = "Endpoints for managing users") | ||
@RestController | ||
@RequestMapping(value = "/users") | ||
public class UserController { | ||
|
||
@GetMapping("/{id}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Get user profile info by user id", | ||
description = "Get user's detailed information about" | ||
+ " user profile by user identification number") | ||
public UserDto getById(@PathVariable Long id) { | ||
return null; | ||
} | ||
|
||
@PatchMapping("/{id}/role") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Update user role by user id", | ||
description = "Update user role by user identification number") | ||
public UserDto updateUserRole(@PathVariable Long id, | ||
@RequestBody @Valid | ||
UpdateUserRoleRequestDto requestDto) { | ||
return null; | ||
} | ||
|
||
@PutMapping("/{id}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@Operation(summary = "Update user info by id", | ||
description = "Update the user profile information " | ||
+ "by user identification number") | ||
public UserDto updateUserProfile(@PathVariable Long id, | ||
@Valid @RequestBody UpdateUserProfileRequestDto requestDto) { | ||
return null; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/project/carsharingapp/dto/car/CarDto.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.car; | ||
|
||
import com.project.carsharingapp.model.Car; | ||
import java.math.BigDecimal; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class CarDto { | ||
private Long id; | ||
private String model; | ||
private String brand; | ||
private Integer inventory; | ||
private Car.CarType carType; | ||
private BigDecimal dailyFee; | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/project/carsharingapp/dto/car/CreateCarRequestDto.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,31 @@ | ||
package com.project.carsharingapp.dto.car; | ||
|
||
import com.project.carsharingapp.model.Car; | ||
import java.math.BigDecimal; | ||
import javax.validation.constraints.Min; | ||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.hibernate.validator.constraints.Length; | ||
|
||
@Getter | ||
@Setter | ||
public class CreateCarRequestDto { | ||
@NotNull | ||
@Length(min = 1, max = 255) | ||
private String model; | ||
@NotNull | ||
@Length(min = 1, max = 255) | ||
private String brand; | ||
@NotBlank | ||
@NotNull | ||
@Min(0) | ||
private Integer inventory; | ||
@NotBlank | ||
@NotNull | ||
private Car.CarType carType; | ||
@NotBlank | ||
@Min(0) | ||
private BigDecimal dailyFee; | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/project/carsharingapp/dto/car/UpdateCarRequestDto.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,31 @@ | ||
package com.project.carsharingapp.dto.car; | ||
|
||
import com.project.carsharingapp.model.Car; | ||
import java.math.BigDecimal; | ||
import javax.validation.constraints.Min; | ||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.hibernate.validator.constraints.Length; | ||
|
||
@Getter | ||
@Setter | ||
public class UpdateCarRequestDto { | ||
@NotNull | ||
@Length(min = 1, max = 255) | ||
private String model; | ||
@NotNull | ||
@Length(min = 1, max = 255) | ||
private String brand; | ||
@NotBlank | ||
@NotNull | ||
@Min(0) | ||
private Integer inventory; | ||
@NotBlank | ||
@NotNull | ||
private Car.CarType carType; | ||
@NotBlank | ||
@Min(0) | ||
private BigDecimal dailyFee; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/project/carsharingapp/dto/user/UpdateUserProfileRequestDto.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,23 @@ | ||
package com.project.carsharingapp.dto.user; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.hibernate.validator.constraints.Length; | ||
|
||
@Getter | ||
@Setter | ||
public class UpdateUserProfileRequestDto { | ||
@NotBlank | ||
@Length(min = 4, max = 50) | ||
private String email; | ||
@NotBlank | ||
@Length(min = 1, max = 50) | ||
private String firstName; | ||
@NotBlank | ||
@Length(min = 1, max = 50) | ||
private String lastName; | ||
@NotBlank | ||
@Length(min = 6, max = 100) | ||
private String password; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/project/carsharingapp/dto/user/UpdateUserRoleRequestDto.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,13 @@ | ||
package com.project.carsharingapp.dto.user; | ||
|
||
import com.project.carsharingapp.model.RoleName; | ||
import javax.validation.constraints.NotNull; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class UpdateUserRoleRequestDto { | ||
@NotNull | ||
private RoleName role; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/project/carsharingapp/dto/user/UserDto.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 com.project.carsharingapp.model.Role; | ||
import java.util.Set; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class UserDto { | ||
private Long id; | ||
private String email; | ||
private String firstName; | ||
private String lastName; | ||
private Long telegramChatId; | ||
private Set<Role> roles; | ||
} |
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