-
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 pull request #26 from gyda13/lulu
register User endpoint, db fixes
- Loading branch information
Showing
19 changed files
with
100 additions
and
27 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/lulugyda/controllers/UsersController.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,42 @@ | ||
package com.lulugyda.controllers; | ||
|
||
import com.lulugyda.models.entities.PhoneNumberEntity; | ||
import com.lulugyda.models.entities.UserEntity; | ||
import com.lulugyda.services.MovieService; | ||
import io.micronaut.http.HttpResponse; | ||
import io.micronaut.http.annotation.Body; | ||
import io.micronaut.http.annotation.Controller; | ||
import io.micronaut.http.annotation.Header; | ||
import io.micronaut.http.annotation.Post; | ||
import io.micronaut.scheduling.TaskExecutors; | ||
import io.micronaut.scheduling.annotation.ExecuteOn; | ||
import io.micronaut.validation.Validated; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static com.lulugyda.utils.Constants.USER_ID; | ||
import static io.micronaut.http.MediaType.APPLICATION_JSON; | ||
|
||
@Controller("v1/users") | ||
@Validated | ||
@RequiredArgsConstructor | ||
public class UsersController { | ||
|
||
private final MovieService movieService; | ||
@Post(produces = APPLICATION_JSON) | ||
@ExecuteOn(TaskExecutors.IO) | ||
public HttpResponse<?> registerUser(@Body UserEntity user) { | ||
movieService.registerUser(user); | ||
return HttpResponse.ok(); | ||
} | ||
|
||
// @Post(value = "/phone-numbers", produces = APPLICATION_JSON) | ||
// @ExecuteOn(TaskExecutors.IO) | ||
// public HttpResponse<?> addPhoneNumbers(@Body ArrayList<PhoneNumberEntity> numbers, | ||
// @Header(USER_ID) Integer userId) { | ||
// movieService.addPhoneNumbers(numbers,userId); | ||
// return HttpResponse.ok(); | ||
// } | ||
|
||
} |
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
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
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
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
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
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
package com.lulugyda.services; | ||
|
||
import com.lulugyda.models.entities.PhoneNumberEntity; | ||
import com.lulugyda.models.entities.UserEntity; | ||
import com.lulugyda.models.responses.MovieDetailsResponse; | ||
import com.lulugyda.models.responses.MovieListResponse; | ||
|
||
import java.util.ArrayList; | ||
|
||
public interface MovieService { | ||
MovieListResponse getMovieList(String page); | ||
|
||
MovieDetailsResponse getMovieDetails(String movieId); | ||
|
||
void saveUserMovies(String userId); | ||
void saveUserMovies(Integer userId); | ||
|
||
void registerUser (UserEntity userEntity); | ||
|
||
void addPhoneNumbers (ArrayList<PhoneNumberEntity> numbers, Integer userّId); | ||
|
||
} |
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
4 changes: 2 additions & 2 deletions
4
src/main/resources/db/migration/V2__Create-Phone-Numbers-Table.sql
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
CREATE TABLE Phone_Numbers ( | ||
id varchar(255) PRIMARY KEY, | ||
user_id varchar(255) NOT NULL, | ||
id serial PRIMARY KEY, | ||
user_id INTEGER NOT NULL, | ||
mobile_number varchar NOT NULL, | ||
CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES Users(id) | ||
); |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CREATE TABLE Movies ( | ||
movie_id varchar(255) PRIMARY KEY, | ||
movie_id INTEGER PRIMARY KEY, | ||
movie_title varchar(255) NOT NULL | ||
); |
5 changes: 2 additions & 3 deletions
5
src/main/resources/db/migration/V4__Create-Users-Movies-Table.sql
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
CREATE TABLE Users_Movies ( | ||
|
||
user_id varchar(255) NOT NULL, | ||
movie_id varchar(255) NOT NULL, | ||
user_id INTEGER NOT NULL, | ||
movie_id INTEGER NOT NULL, | ||
FOREIGN KEY (user_id) REFERENCES Users (id), | ||
FOREIGN KEY (movie_id) REFERENCES Movies (movie_id) | ||
); |