0

I use micro service in spring boot with Restful services so i have

  1. Authentication Service app
  2. Main Service app

The entity that I have in Authentication Service

public class User implements Serializable {
   private int userId;
   private String firstname;
   private String lastname;
   private String email;
   private String password;
}

I need to display username in my UI page using userId.

For every UI in Main Service app i can not make a one rest call to get user firstname.

so in this case i would like to have User entity in both service and it will point to same database user table and Authentication Service app has full access to user table like add user, login, delete user but in Main Service app i want fetch user firstname alone using userId.

Here i confused in designing user entity in Main Service app.

  1. What are the field that i need to have in user entity of Main Service app
  2. Can I have Id field(I feel it is not required)?
1
  • You can have full functionality in the Dao layer or through JPA repository calls, and just not provide implementation for add/login/delete in MainService. Commented Dec 6, 2018 at 17:51

2 Answers 2

1

I think, you should implement User entity class same like user table in the database. You think, it is not necessary right now but probably you will need it in the future.

By the way, You want to permit write, read, delete, update ops. in authentication app and just want to permit read operation in Main Service. I think, you should implement auth mechanism both of your app.

Sign up to request clarification or add additional context in comments.

Comments

0

Expose a Rest service from Authentication Service app to get the user data from Main Service App, in the Main Service app create a new DTO (Data Transfer Object) Class UserDTO that contains the fields that you actually need, then convert UserEnitity class to UserDTO Class

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.