Home System of User-Role and mapping with the other entities issue Spring boot
Reply: 0

System of User-Role and mapping with the other entities issue Spring boot

user2520
1#
user2520 Published in April 25, 2018, 6:15 pm

I was trying to set up role-user system in my application using spring boot, spring security, Hibernate/JPA and JWT, so i've created two entites the first one:

AppUser Entity:

@Entity
@Data
@AllArgsConstructor @NoArgsConstructor

public class AppUser implements Serializable {

    @Id @GeneratedValue
    private Long id;

    @Column(unique = true)
    private String username;

    private String password;

    @ManyToMany(fetch = FetchType.EAGER)
    private Collection<AppRole> roles = new ArrayList<>();

}

AppRole Entity:

@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AppRole implements Serializable {

    @Id @GeneratedValue
    private Long id;
    private String roleName;

}

So everything goes well with the authentication of the different users (admin, client) using the jwt and spring security.

Before doing this system i created two entities: admin and client, but as you see now with this new implementation i have only one entity called AppUser (as admin and client have the same attributes).

The problem that i'm fascing now for this application is that the Admin should manage some entities including 'Client' (it doesn't exist now), 'Projects', and the Client should manage the Entity 'Intervention'.

Projects Entity :

 @Entity
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
   public class Project implements Serializable{

    @Id @GeneratedValue
    private long id;
    private String description;


      }

Following the old UML_Classes Exemple : project + admin before the new implementation :

UML classe

So how i'm going to implement the relation between those entities together? how i'm going to say that the entity AppUser will manage the entity Projects for exemple if he is an admin?

And so on

Please if there any useful link thank you for redirecting me to it , i didn't know what to search for to get what i want .

PS : this App is considered as an API Rest with spring boot as backend , and angular4 Client as front end , and in the Client i can get which user is authenticated and the roles he gets , i wantto know how i'm going to implement the other entities , for exemple Project that the admin manage , ORM Side so i can see all this entites in the database Mysql, should i add any roles or what ?

Thank you in advance.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.328086 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO