Changeset 0078d84
- Timestamp:
- 03/10/23 21:43:30 (21 months ago)
- Branches:
- main
- Children:
- 104185f
- Parents:
- b46d1f2 (diff), c3278ac (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- Prototype Application/Paw5/src/main
- Files:
-
- 14 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Admin.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 import java.time.LocalDate; … … 8 9 @Data 9 10 @Entity 11 @RequiredArgsConstructor 10 12 @Table(name = "admin_table") 11 13 @PrimaryKeyJoinColumn(name = "id_user") 12 14 public class Admin extends User { 13 15 14 public Admin(LocalDate dateCreated, String name, String email, String password, String telephone) { 16 public Admin(LocalDate dateCreated, String name, String email, 17 String password, String telephone) { 15 18 super(dateCreated, name, email, password, telephone); 16 19 } 17 18 public Admin() {19 }20 20 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Adopter.java
rb46d1f2 r0078d84 7 7 import jakarta.persistence.*; 8 8 import lombok.Data; 9 import lombok.RequiredArgsConstructor; 9 10 10 11 import java.time.LocalDate; … … 13 14 @Entity 14 15 @Table(name = "adopter") 16 @RequiredArgsConstructor 15 17 @PrimaryKeyJoinColumn(name = "id_user") 16 18 public class Adopter extends User { … … 40 42 private Boolean verified; 41 43 42 @Column(name = "verified_by_employee") 43 private Integer verifiedByEmployeeId; 44 @ManyToOne 45 @JoinColumn(name = "verified_by_employee") 46 Employee employeeVerificator; 44 47 45 48 public Adopter(LocalDate dateCreated, String name, String email, String password, String telephone, … … 57 60 } 58 61 59 public Adopter(FreeTime freeTime, Funds funds, boolean hasOtherPets, boolean hasKids, Housing housing,60 PhysicalActivity physicalActivity, boolean willFoster, boolean verified, int verifiedByEmployeeId) {61 this.freeTime = freeTime;62 this.funds = funds;63 this.hasOtherPets = hasOtherPets;64 this.hasKids = hasKids;65 this.housing = housing;66 this.physicalActivity = physicalActivity;67 this.willFoster = willFoster;68 this.verified = verified;69 this.verifiedByEmployeeId = verifiedByEmployeeId;70 }71 72 public Adopter() {73 }74 62 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Adoption.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 import java.time.LocalDate; 7 import java.util.Date;8 8 9 9 @Data 10 10 @Entity 11 @RequiredArgsConstructor 11 12 @Table(name = "adoption") 12 13 public class Adoption { … … 24 25 25 26 @Column(name = "approved", nullable = false) 26 private boolean approved;27 private Boolean approved; 27 28 28 @Column(name = "id_adopter", nullable = false) 29 private int adopterId; 29 @ManyToOne 30 @JoinColumn(name = "id_adopter", nullable = false) 31 private Adopter adopter; 30 32 31 public Adoption(LocalDate startDate, LocalDate endDateFoster, boolean approved, int adopterId) { 33 public Adoption(LocalDate startDate, LocalDate endDateFoster, Boolean approved, 34 Adopter adopter) { 32 35 this.startDate = startDate; 33 36 this.endDateFoster = endDateFoster; 34 37 this.approved = approved; 35 this.adopterId = adopterId; 36 } 37 38 public Adoption() { 38 this.adopter = adopter; 39 39 } 40 40 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Category.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 6 7 import java.util.List; 5 8 6 9 @Data 7 10 @Entity 11 @RequiredArgsConstructor 8 12 @Table(name = "category") 9 13 public class Category { … … 17 21 private String name; 18 22 23 @ManyToMany 24 @JoinTable(name = "pet_belongs_to_category", 25 joinColumns = @JoinColumn(name = "id_category"), 26 inverseJoinColumns = @JoinColumn(name = "id_pet")) 27 List<Pet> pets; 28 19 29 public Category(String name) { 20 30 this.name = name; 21 31 } 22 32 23 public Category() {24 }25 33 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Donor.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 import java.time.LocalDate; 8 import java.util.List; 7 9 8 10 @Data 9 11 @Entity 12 @RequiredArgsConstructor 10 13 @Table(name = "donor") 11 14 @PrimaryKeyJoinColumn(name = "id_user") … … 13 16 14 17 @Column(name = "is_from_organisation", nullable = false) 15 private boolean fromOrganisation;18 private Boolean fromOrganisation; 16 19 17 20 @Column(name = "name_organisation_donor", nullable = true, length = 100) 18 21 private String organisationName; 19 22 20 public Donor(LocalDate dateCreated, String name, String email, String password, String telephone, boolean fromOrganisation, String organisationName) { 23 @ManyToMany 24 @JoinTable(name = "donor_donates_to_organisation", 25 joinColumns = @JoinColumn(name = "id_user"), 26 inverseJoinColumns = @JoinColumn(name = "id_organisation")) 27 List<Organisation> donatedToOrganisations; 28 29 public Donor(LocalDate dateCreated, String name, String email, 30 String password, String telephone, Boolean fromOrganisation, 31 String organisationName) { 21 32 super(dateCreated, name, email, password, telephone); 22 33 this.fromOrganisation = fromOrganisation; … … 24 35 } 25 36 26 public Donor(boolean fromOrganisation, String organisationName) {27 this.fromOrganisation = fromOrganisation;28 this.organisationName = organisationName;29 }30 31 public Donor() {32 }33 34 37 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Employee.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 import java.time.LocalDate; … … 8 9 @Data 9 10 @Entity 11 @RequiredArgsConstructor 10 12 @Table(name = "employee") 11 13 @PrimaryKeyJoinColumn(name = "id_user") … … 15 17 private String position; 16 18 17 @Column(name = "id_shelter", nullable = false) 18 private Integer shelterId; 19 @ManyToOne 20 @JoinColumn(name = "id_shelter", nullable = false) 21 private Shelter shelter; 19 22 20 23 @Column(name = "is_verified", nullable = false) 21 private boolean verified;24 private Boolean verified; 22 25 23 @Column(name = "verified_by_admin") 24 private Integer verifiedByAdminId; 26 @ManyToOne 27 @JoinColumn(name = "verified_by_admin") 28 private Admin adminVerificator; 25 29 26 30 public Employee(LocalDate dateCreated, String name, String email, String password, String telephone, 27 String position, int shelterId, boolean verified) {31 String position, Shelter shelter, Boolean verified) { 28 32 super(dateCreated, name, email, password, telephone); 29 33 this.position = position; 30 this.shelter Id = shelterId;34 this.shelter = shelter; 31 35 this.verified = verified; 32 36 } 33 37 34 public Employee(String position, int shelterId, boolean verified, int verifiedByAdminId) {35 this.position = position;36 this.shelterId = shelterId;37 this.verified = verified;38 this.verifiedByAdminId = verifiedByAdminId;39 }40 41 public Employee() {42 43 }44 45 38 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Food.java
rb46d1f2 r0078d84 4 4 import jakarta.persistence.*; 5 5 import lombok.Data; 6 import lombok.RequiredArgsConstructor; 7 8 import java.util.List; 6 9 7 10 @Data 8 11 @Entity 12 @RequiredArgsConstructor 9 13 @Table(name = "food") 10 14 public class Food { … … 24 28 private FoodType type; 25 29 30 @ManyToMany 31 @JoinTable(name = "pet_preferably_eats_food", 32 joinColumns = @JoinColumn(name = "id_food"), 33 inverseJoinColumns = @JoinColumn(name = "id_pet")) 34 List<Pet> pets; 35 26 36 public Food(String manufacturer, String name, FoodType type) { 27 37 this.manufacturer = manufacturer; … … 29 39 this.type = type; 30 40 } 31 32 public Food() {33 }34 41 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Organisation.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 6 7 import java.util.List; 5 8 6 9 @Data 7 10 @Entity 11 @RequiredArgsConstructor 8 12 @Table(name = "organisation") 9 13 public class Organisation { … … 23 27 private String billingInformation; 24 28 29 @ManyToMany 30 @JoinTable(name = "donor_donates_to_organisation", 31 joinColumns = @JoinColumn(name = "id_organisation"), 32 inverseJoinColumns = @JoinColumn(name = "id_user")) 33 List<Donor> donors; 34 25 35 public Organisation(String name, String email, String billingInformation) { 26 36 this.name = name; … … 28 38 this.billingInformation = billingInformation; 29 39 } 30 31 public Organisation() {32 }33 40 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/PersonalProfile.java
rb46d1f2 r0078d84 2 2 3 3 import finki.paw5.model.enumerations.*; 4 import jakarta.persistence.Column; 5 import jakarta.persistence.Entity; 6 import jakarta.persistence.Id; 7 import jakarta.persistence.Table; 4 import jakarta.persistence.*; 8 5 import lombok.Data; 6 import lombok.RequiredArgsConstructor; 9 7 10 8 @Data 11 9 @Entity 10 @RequiredArgsConstructor 12 11 @Table(name = "personal_profile") 13 12 public class PersonalProfile { … … 16 15 @Column(name = "id_pet", nullable = false) 17 16 private Integer id; 17 18 @OneToOne 19 @JoinColumn(name = "id_pet", nullable = false) 20 private Pet pet; 18 21 19 22 @Column(name = "friendly_to_kids", nullable = false) … … 32 35 private GroomingNeed groomingNeed; 33 36 34 public PersonalProfile( int id, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) {37 public PersonalProfile(Integer id, Pet pet, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) { 35 38 this.id = id; 39 this.pet = pet; 36 40 this.friendlyToKids = friendlyToKids; 37 41 this.friendlyToPets = friendlyToPets; … … 40 44 this.groomingNeed = groomingNeed; 41 45 } 42 43 public PersonalProfile() {44 }45 46 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Pet.java
rb46d1f2 r0078d84 7 7 import jakarta.persistence.*; 8 8 import lombok.Data; 9 import lombok.RequiredArgsConstructor; 10 11 import java.util.List; 9 12 10 13 @Data 11 14 @Entity 15 @RequiredArgsConstructor 12 16 @Table(name = "pet") 13 17 public class Pet { … … 17 21 @Column(name = "id_pet") 18 22 private Integer id; 23 24 @OneToOne 25 @JoinColumn(name = "id_pet", nullable = false) 26 private PersonalProfile personalProfile; 19 27 20 28 @Column(name = "url_pet_image", length = 200) … … 40 48 41 49 @Column(name = "can_be_fostered", nullable = false) 42 private boolean canBeFostered;50 private Boolean canBeFostered; 43 51 44 @Column(name = "id_adoption") 45 private int adoptionId; 52 @ManyToOne 53 @JoinColumn(name = "id_adoption") 54 private Adoption adoption; 46 55 47 @Column(name = "id_shelter") 48 private int shelterId; 56 @ManyToOne 57 @JoinColumn(name = "id_shelter") 58 private Shelter shelter; 49 59 50 public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, String name, Species species, Gender gender, boolean canBeFostered, int adoptionId, int shelterId) { 60 @ManyToMany 61 @JoinTable(name = "pet_belongs_to_category", 62 joinColumns = @JoinColumn(name = "id_pet"), 63 inverseJoinColumns = @JoinColumn(name = "id_category")) 64 List<Category> categories; 65 66 @ManyToMany 67 @JoinTable(name = "pet_needs_intervention_in_vet_clinic", 68 joinColumns = @JoinColumn(name = "id_pet"), 69 inverseJoinColumns = @JoinColumn(name = "id_vet_clinic")) 70 List<VetClinic> vetClinicsTreatedIn; 71 72 @ManyToMany 73 @JoinTable(name = "pet_needs_therapy", 74 joinColumns = @JoinColumn(name = "id_pet"), 75 inverseJoinColumns = @JoinColumn(name = "id_therapy")) 76 List<Therapy> therapies; 77 78 @ManyToMany 79 @JoinTable(name = "pet_preferably_eats_food", 80 joinColumns = @JoinColumn(name = "id_pet"), 81 inverseJoinColumns = @JoinColumn(name = "id_food")) 82 List<Food> preferredFoods; 83 84 public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, 85 String name, Species species, Gender gender, Boolean canBeFostered, 86 Adoption adoption, Shelter shelter) { 51 87 this.imageUrl = imageUrl; 52 88 this.ageGroup = ageGroup; … … 57 93 this.gender = gender; 58 94 this.canBeFostered = canBeFostered; 59 this.adoptionId = adoptionId; 60 this.shelterId = shelterId; 61 } 62 63 public Pet() { 95 this.adoption = adoption; 96 this.shelter = shelter; 64 97 } 65 98 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Post.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 import java.time.LocalDate; 7 import java.util.Date;8 8 9 9 @Data 10 10 @Entity 11 @RequiredArgsConstructor 11 12 @Table(name = "post") 12 13 public class Post { … … 23 24 private String thumbnailUrl; 24 25 25 @Column(name="id_pet", nullable = false) 26 private int petId; 26 @OneToOne 27 @JoinColumn(name="id_pet", nullable = false) 28 private Pet pet; 27 29 28 @Column(name="id_surendee") 29 private int surendeeId; 30 @ManyToOne 31 @JoinColumn(name="id_surendee") 32 private Surendee surendeePoster; 30 33 31 @Column(name="id_employee") 32 private int employeeId; 34 @ManyToOne 35 @JoinColumn(name="id_employee") 36 private Employee employeePoster; 33 37 34 public Post(LocalDate dateCreated, String thumbnailUrl, int petId, int surendeeId, int employeeId) { 38 public Post(LocalDate dateCreated, String thumbnailUrl, 39 Pet pet, Surendee surendeePoster, Employee employeePoster) { 35 40 this.dateCreated = dateCreated; 36 41 this.thumbnailUrl = thumbnailUrl; 37 this.petId = petId; 38 this.surendeeId = surendeeId; 39 this.employeeId = employeeId; 40 } 41 42 public Post() { 42 this.pet = pet; 43 this.surendeePoster = surendeePoster; 44 this.employeePoster = employeePoster; 43 45 } 44 46 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Shelter.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 @Data 7 8 @Entity 9 @RequiredArgsConstructor 8 10 @Table(name = "shelter") 9 11 public class Shelter { … … 20 22 private String telephone; 21 23 22 @Column(name = "id_organisation") 23 private Integer organisationId; 24 @ManyToOne 25 @JoinColumn(name = "id_organisation") 26 private Organisation organisation; 24 27 25 28 @Column(name = "name_shelter", nullable = false, length = 100) … … 29 32 private String email; 30 33 31 public Shelter(String address, String telephone, Integer organisationId, String name, String email) { 34 public Shelter(String address, String telephone, Organisation organisation, 35 String name, String email) { 32 36 this.address = address; 33 37 this.telephone = telephone; 34 this.organisation Id = organisationId;38 this.organisation = organisation; 35 39 this.name = name; 36 40 this.email = email; 37 41 } 38 39 public Shelter() {40 }41 42 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Surendee.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 import java.time.LocalDate; … … 8 9 @Data 9 10 @Entity 11 @RequiredArgsConstructor 10 12 @Table(name = "surendee") 11 13 @PrimaryKeyJoinColumn(name = "id_user") … … 16 18 } 17 19 18 public Surendee() {19 }20 21 20 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Therapy.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 import java.time.LocalDate; 7 8 import java.util.Date; 9 import java.util.List; 8 10 9 11 @Data 10 12 @Entity 13 @RequiredArgsConstructor 11 14 @Table(name = "therapy") 12 15 public class Therapy { … … 26 29 private LocalDate endDate; 27 30 31 @ManyToMany 32 @JoinTable(name = "pet_needs_therapy", 33 joinColumns = @JoinColumn(name = "id_therapy"), 34 inverseJoinColumns = @JoinColumn(name = "id_pet")) 35 List<Pet> pets; 36 28 37 public Therapy(String healthProblem, LocalDate startDate, LocalDate endDate) { 29 38 this.healthProblem = healthProblem; … … 31 40 this.endDate = endDate; 32 41 } 33 34 public Therapy() {35 }36 42 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/User.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 import java.time.LocalDate; … … 9 10 @Data 10 11 @Entity 12 @RequiredArgsConstructor 11 13 @Table(name = "user_table") 12 14 @Inheritance(strategy = InheritanceType.JOINED) … … 40 42 this.telephone = telephone; 41 43 } 42 43 public User() {44 }45 44 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/VetClinic.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 6 7 import java.util.List; 5 8 6 9 @Data 7 10 @Entity 11 @RequiredArgsConstructor 8 12 @Table(name = "vet_clinic") 9 13 public class VetClinic { … … 23 27 private String name; 24 28 29 @ManyToMany 30 @JoinTable(name = "pet_needs_intervention_in_vet_clinic", 31 joinColumns = @JoinColumn(name = "id_vet_clinic"), 32 inverseJoinColumns = @JoinColumn(name = "id_pet")) 33 List<Pet> pets; 34 25 35 public VetClinic(String telephone, String address, String name) { 26 36 this.telephone = telephone; … … 28 38 this.name = name; 29 39 } 30 31 public VetClinic() {32 }33 40 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/DonorDonatesToOrganisation.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 @Data 7 8 @Entity 9 @RequiredArgsConstructor 8 10 @Table(name = "donor_donates_to_organisation") 9 11 @IdClass(DonorDonatesToOrganisationId.class) … … 22 24 this.organisationId = organisationId; 23 25 } 24 25 public DonorDonatesToOrganisation() {26 27 }28 26 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/PetBelongsToCategory.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 @Data 7 8 @Entity 9 @RequiredArgsConstructor 8 10 @Table(name = "pet_belongs_to_category") 9 11 @IdClass(PetBelongsToCategoryId.class) … … 22 24 this.categoryId = categoryId; 23 25 } 24 25 public PetBelongsToCategory() {26 27 }28 26 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/PetNeedsInterventionInVetClinic.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 import java.time.LocalDate; … … 9 10 @Data 10 11 @Entity 12 @RequiredArgsConstructor 11 13 @Table(name = "pet_needs_intervention_in_vet_clinic") 12 14 @IdClass(PetNeedsInterventionInVetClinicId.class) … … 33 35 this.description = description; 34 36 } 35 36 public PetNeedsInterventionInVetClinic() {37 38 }39 37 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/PetNeedsTherapy.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 @Data 7 8 @Entity 9 @RequiredArgsConstructor 8 10 @Table(name = "pet_needs_therapy") 9 11 @IdClass(PetNeedsTherapyId.class) … … 22 24 this.therapyId = therapyId; 23 25 } 24 25 public PetNeedsTherapy() {26 }27 26 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/PetPreferablyEatsFood.java
rb46d1f2 r0078d84 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor; 5 6 6 7 @Data 7 8 @Entity 9 @RequiredArgsConstructor 8 10 @Table(name = "pet_preferably_eats_food") 9 11 @IdClass(PetPreferablyEatsFoodId.class) … … 26 28 this.quantityPerDay = quantityPerDay; 27 29 } 28 29 public PetPreferablyEatsFood() {30 }31 30 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/ShelterService.java
rb46d1f2 r0078d84 4 4 5 5 import java.util.List; 6 import java.util.Optional; 6 7 7 8 public interface ShelterService { 9 Optional<Shelter> findById(Integer id); 8 10 List<Shelter> listShelters(); 9 11 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/AuthServiceImplementation.java
rb46d1f2 r0078d84 3 3 import finki.paw5.model.entities.Adopter; 4 4 import finki.paw5.model.entities.Employee; 5 import finki.paw5.model.entities.Shelter; 5 6 import finki.paw5.model.entities.User; 6 7 import finki.paw5.model.enumerations.FreeTime; … … 10 11 import finki.paw5.repository.AdopterRepository; 11 12 import finki.paw5.repository.EmployeeRepository; 13 import finki.paw5.repository.ShelterRepository; 12 14 import finki.paw5.repository.UserRepository; 13 15 import finki.paw5.service.AuthService; … … 22 24 private final AdopterRepository adopterRepository; 23 25 private final EmployeeRepository employeeRepository; 26 private final ShelterRepository shelterRepository; 24 27 25 public AuthServiceImplementation(UserRepository userRepository, AdopterRepository adopterRepository, EmployeeRepository employeeRepository ) {28 public AuthServiceImplementation(UserRepository userRepository, AdopterRepository adopterRepository, EmployeeRepository employeeRepository, ShelterRepository shelterRepository) { 26 29 this.userRepository = userRepository; 27 30 this.adopterRepository = adopterRepository; 28 31 this.employeeRepository = employeeRepository; 32 this.shelterRepository = shelterRepository; 29 33 } 30 34 … … 47 51 @Override 48 52 public Employee registerEmployee(String name, String email, String password, String telephone, String position, Integer shelterId) { 49 Employee employee = new Employee(LocalDate.now(),name, email,password,telephone,position,shelterId,false); 53 Shelter shelter = this.shelterRepository.findById(shelterId).get(); 54 Employee employee = new Employee(LocalDate.now(),name, email,password,telephone,position,shelter,false); 50 55 return employeeRepository.save(employee); 51 56 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/ShelterServiceImplementation.java
rb46d1f2 r0078d84 7 7 8 8 import java.util.List; 9 import java.util.Optional; 9 10 10 11 @Service 11 12 public class ShelterServiceImplementation implements ShelterService { 13 12 14 private final ShelterRepository shelterRepository; 13 15 … … 16 18 } 17 19 20 @Override 21 public Optional<Shelter> findById(Integer id) { 22 return this.shelterRepository.findById(id); 23 } 18 24 19 25 @Override … … 21 27 return shelterRepository.findAll(); 22 28 } 29 30 23 31 } -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/HomeController.java
rb46d1f2 r0078d84 1 1 package finki.paw5.web.controllers; 2 2 3 import jakarta.servlet.http.HttpServletRequest; 3 4 import org.springframework.stereotype.Controller; 4 5 import org.springframework.web.bind.annotation.GetMapping; … … 10 11 11 12 @GetMapping 12 public String getHomePage(){ 13 public String getHomePage(HttpServletRequest request) { 14 if(request.getSession().getAttribute("user")==null){ 15 return "redirect:/login"; 16 } 13 17 return "home"; 14 18 } 19 15 20 @GetMapping("/aboutUs") 16 21 public String getAboutUsPage(){ -
Prototype Application/Paw5/src/main/resources/templates/aboutUs.html
rb46d1f2 r0078d84 1 1 <!DOCTYPE html> 2 <html lang="en" >2 <html lang="en" xmlns:th="http://thymeleaf.org"> 3 3 <head> 4 4 <meta charset="UTF-8"> … … 46 46 <h5 class="text-center text-danger" th:if="${session.user != null}"> 47 47 You successfully logged in 48 <th:block th:text="${session.user .getId()}"></th:block>48 <th:block th:text="${session.user?.getId()}"></th:block> 49 49 </h5> 50 50 </div> -
Prototype Application/Paw5/src/main/resources/templates/home.html
rb46d1f2 r0078d84 1 1 <!DOCTYPE html> 2 <html lang="en" >2 <html lang="en" xmlns:th="http://thymeleaf.org"> 3 3 <head> 4 4 <meta charset="UTF-8"> … … 41 41 </nav> 42 42 </header> 43 44 43 <div> 45 44 <h1>Welcome to Paw 5</h1> … … 48 47 </h3> 49 48 </div> 50 49 <div> 50 <form method="get" th:action="@{'/create-post'}"> 51 <button id="createPost" 52 type="submit" 53 class="btn">Create an Adoption Post</button> 54 </form> 55 </div> 56 <div> 57 <form method="get" th:action="@{'/adoption-posts'}"> 58 <button id="submit" 59 type="submit" 60 class="btn">View Pet Posts</button> 61 </form> 62 </div> 51 63 </body> 52 64 </html> -
Prototype Application/Paw5/src/main/resources/templates/login.html
rb46d1f2 r0078d84 1 1 <!DOCTYPE html> 2 <html lang="en" >2 <html lang="en" xmlns:th="http://thymeleaf.org"> 3 3 <head> 4 4 <meta charset="UTF-8"> -
Prototype Application/Paw5/src/main/resources/templates/register.html
rb46d1f2 r0078d84 1 1 <!DOCTYPE html> 2 <html lang="en" xmlns:th="http:// www.thymeleaf.org">2 <html lang="en" xmlns:th="http://thymeleaf.org"> 3 3 <head> 4 4 <meta charset="UTF-8">
Note:
See TracChangeset
for help on using the changeset viewer.