Changeset ac25203
- Timestamp:
- 02/03/23 23:11:04 (22 months ago)
- Branches:
- master
- Children:
- eb226b2
- Parents:
- 1b248e4
- Files:
-
- 7 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pom.xml
r1b248e4 rac25203 48 48 <artifactId>spring-boot-starter-data-jpa</artifactId> 49 49 </dependency> 50 <dependency> 51 <groupId>org.springframework.security</groupId> 52 <artifactId>spring-security-core</artifactId> 53 </dependency> 54 <dependency> 55 <groupId>org.springframework.security</groupId> 56 <artifactId>spring-security-config</artifactId> 57 <version>5.7.3</version> 58 <scope>compile</scope> 59 60 </dependency> 50 61 </dependencies> 51 62 -
src/main/java/com/example/moviezone/model/Customer.java
r1b248e4 rac25203 7 7 import lombok.Setter; 8 8 import lombok.ToString; 9 import org.springframework.security.core.GrantedAuthority; 10 11 import java.util.Collection; 12 import java.util.Collections; 9 13 10 14 @Entity … … 19 23 Integer points; 20 24 25 @Override 26 public Collection<? extends GrantedAuthority> getAuthorities() { 27 return Collections.singletonList(Role.ROLE_ADMIN); 28 } 21 29 22 30 } -
src/main/java/com/example/moviezone/model/User.java
r1b248e4 rac25203 5 5 import lombok.Setter; 6 6 import lombok.ToString; 7 import org.springframework.security.core.GrantedAuthority; 8 import org.springframework.security.core.userdetails.UserDetails; 7 9 10 import javax.management.relation.Role; 8 11 import java.time.LocalDateTime; 12 import java.util.Collection; 9 13 10 14 @Entity … … 14 18 @Table(name = "users") 15 19 @Inheritance(strategy = InheritanceType.JOINED) 16 public class User {20 public class User implements UserDetails { 17 21 18 22 @Id … … 24 28 String address; 25 29 String contact_number; 30 String username; 26 31 LocalDateTime date_created; 27 32 33 private boolean isAccountNonExpired = true; 34 private boolean isAccountNonLocked = true; 35 private boolean isCredentialsNonExpired = true; 36 private boolean isEnabled = true; 28 37 29 public User(Integer id_user, String password, String first_name, String last_name, String address, String contact_number, LocalDateTime date_created) { 38 @Enumerated(value = EnumType.STRING) 39 private Role role; 40 41 public User(Integer id_user, String password, String first_name, String last_name, String address, String contact_number, String username, LocalDateTime date_created, Role role) { 30 42 this.id_user = id_user; 31 43 this.password = password; … … 34 46 this.address = address; 35 47 this.contact_number = contact_number; 48 this.username = username; 36 49 this.date_created = date_created; 50 this.role = role; 37 51 } 38 52 … … 40 54 41 55 } 56 57 @Override 58 public Collection<? extends GrantedAuthority> getAuthorities() { 59 return null; 60 } 61 62 63 @Override 64 public boolean isAccountNonExpired() { 65 return isAccountNonExpired; 66 } 67 68 @Override 69 public boolean isAccountNonLocked() { 70 return isAccountNonLocked; 71 } 72 73 @Override 74 public boolean isCredentialsNonExpired() { 75 return isCredentialsNonExpired; 76 } 77 78 @Override 79 public boolean isEnabled() { 80 return isEnabled; 81 } 82 42 83 } -
src/main/java/com/example/moviezone/model/Worker.java
r1b248e4 rac25203 5 5 import lombok.Setter; 6 6 import lombok.ToString; 7 import org.springframework.security.core.GrantedAuthority; 8 9 import java.util.Collection; 10 import java.util.Collections; 7 11 8 12 @Entity … … 21 25 @ManyToOne() 22 26 Cinema cinema; 27 @Override 28 public Collection<? extends GrantedAuthority> getAuthorities() { 29 return Collections.singletonList(Role.ROLE_ADMIN); 30 } 23 31 24 32 } -
src/main/java/com/example/moviezone/repository/UserRepository.java
r1b248e4 rac25203 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 6 7 import java.util.List; 8 7 9 public interface UserRepository extends JpaRepository<User,Integer> { 10 User findByUsername(String username); 11 List<User> findAllByUsernameAndPassword(String username, String password); 8 12 } -
src/main/java/com/example/moviezone/service/Impl/UserServiceImpl.java
r1b248e4 rac25203 27 27 return userRepository.findById(id).orElseThrow(UserNotFoundException::new); 28 28 } 29 30 @Override 31 public User findByUsername(String username) { 32 return userRepository.findByUsername(username); 33 } 34 35 29 36 } -
src/main/java/com/example/moviezone/service/UserService.java
r1b248e4 rac25203 8 8 List<User> findAllUsers(); 9 9 User findById(Integer user_id); 10 User findByUsername(String username); 10 11 }
Note:
See TracChangeset
for help on using the changeset viewer.