-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5805a5
commit 445d1f8
Showing
2 changed files
with
55 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.tb.auth; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.Table; | ||
import java.time.LocalDate; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.tb.common.AuditedEntity; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "user_role") | ||
public class UserRole extends AuditedEntity { | ||
|
||
public enum Role { ADMIN, MANAGER } | ||
|
||
public enum ObjectType { ORDER, EMPLOYEE } | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(name = "role", columnDefinition = "varchar") | ||
private Role role; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(name = "object_type", columnDefinition = "varchar") | ||
private ObjectType objectType; | ||
|
||
@Column(name = "user_id") | ||
private String userId; | ||
|
||
@Column(name = "object_id") | ||
private String objectId; | ||
|
||
@Column(name = "valid_from") | ||
private LocalDate validFrom; | ||
|
||
@Column(name = "valid_until") | ||
private LocalDate validUntil; | ||
|
||
} |
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,12 @@ | ||
package org.tb.auth; | ||
|
||
import java.util.Set; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface UserRoleRepository extends CrudRepository<UserRole, Long> { | ||
|
||
Set<UserRole> findAllByUserId(String userId); | ||
|
||
} |