Skip to content

Commit

Permalink
Merge pull request #42 from UdL-EPS-SoftArch/37-create-student-entity
Browse files Browse the repository at this point in the history
Create Student entity and repository with role addition in user
  • Loading branch information
elskater98 authored Oct 9, 2024
2 parents dbc97f2 + 60d51cc commit 92c0d06
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Student.java
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");
}
}
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> {
}

0 comments on commit 92c0d06

Please sign in to comment.