-
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 #42 from UdL-EPS-SoftArch/37-create-student-entity
Create Student entity and repository with role addition in user
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/cat/udl/eps/softarch/demo/domain/Student.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,30 @@ | ||
package cat.udl.eps.softarch.demo.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import jakarta.persistence.ElementCollection; | ||
import jakarta.persistence.Entity; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.authority.AuthorityUtils; | ||
|
||
import java.util.Collection; | ||
|
||
@Entity | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public class Student extends User { | ||
|
||
@NotEmpty | ||
private String phoneNumber; | ||
|
||
@NotEmpty | ||
private String name; | ||
@Override | ||
@ElementCollection | ||
public Collection<GrantedAuthority> getAuthorities(){ | ||
return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_STUDENT"); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/cat/udl/eps/softarch/demo/repository/StudentRepository.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,7 @@ | ||
package cat.udl.eps.softarch.demo.repository; | ||
|
||
import cat.udl.eps.softarch.demo.domain.Student; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface StudentRepository extends CrudRepository<Student, Long> { | ||
} |