In our web app, there's a page for user profile (if go to localhost:9000/#/profiles. But currently it shows nothing.)
The page is just a simple display of all profile information related to a user, we need to show:
username, email, phone, gender, registerAt, lastUpdateAt, Avatar image, Passport image, Insurance image (For images, provide the url of image on our server). If the user is a student, we also need to show credits, birthday, school name. (Note that we have two user types, student and tutor)
(For details of these fields, see Users.scala, Students.scala, Images.scala, UserImage.scala, Schools.scala)
We will need CRUD APIs for user profile.
Here are some of the steps you will need to consider:
proto files: in the protobuf folder, create proper *.proto files for data transfer. Use protobuf files to describe the shapes of our JSON requests and responses.
separated endpoints for image uploads (meaning that front-end will make several requests for a single profile update action): During user profile creation, since it is expensive to directly put image in JSON strings, I suggest you create several separate endpoints solely for the purposes of image uploads. These endpoints will require user logged in (so that we can find user id), and a image file. In the response, we should return the image id and user id.
You will need three such image endpoints, for avatar image, passport image, and insurance card image.
write DAO query classes for profile creation, read, update and delete(user delete account)
Need to handle file uploads: the web app will send the image file over using XHR, backend play server need to be able to receive and store the file (Ref: https://www.playframework.com/documentation/2.5.x/ScalaFileUpload). AND, you need to select a directory to store the file(I suggest for simplicity just create another folder under project root and then call it images. Don't forget to put the folder into .gitignore). We also need to think about how to generate unique file names for these files.
Need to handle file retrieval: when front-end makes a request for uploaded files, we just give it an url for the image. See the routes file for how we did static file serving for the web folder.
When you store the images, the UserImage table will require user id. You can get user data from AuthenticatedRequest (See AuthenticatedRequest.scala and AuthenticatedAction.scala)
Another helpful piece of info is that our user will initially register an account by giving just username, email and password, later they can give more info on their profile in a separate route.
Example JSON response:
{
email: example@gmail.com,
username: example,
avatar: /image/.jpg
}
In our web app, there's a page for user profile (if go to localhost:9000/#/profiles. But currently it shows nothing.) The page is just a simple display of all profile information related to a user, we need to show: username, email, phone, gender, registerAt, lastUpdateAt, Avatar image, Passport image, Insurance image (For images, provide the url of image on our server). If the user is a student, we also need to show credits, birthday, school name. (Note that we have two user types, student and tutor) (For details of these fields, see Users.scala, Students.scala, Images.scala, UserImage.scala, Schools.scala)
We will need CRUD APIs for user profile. Here are some of the steps you will need to consider:
Another helpful piece of info is that our user will initially register an account by giving just username, email and password, later they can give more info on their profile in a separate route.
Example JSON response: { email: example@gmail.com, username: example, avatar: /image/.jpg
}