Changeset 3f5e485


Ignore:
Timestamp:
02/13/23 14:34:36 (21 months ago)
Author:
SazdovaEkaterina <sazdovaekaterina@…>
Branches:
main
Children:
a762b3a
Parents:
a2060cb (diff), 04e4f54 (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.
Message:

merge create-post and login branches

resolved merge conflicts

Location:
Prototype Application/Paw5/src/main
Files:
10 added
8 edited

Legend:

Unmodified
Added
Removed
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Pet.java

    ra2060cb r3f5e485  
    4343
    4444    @Column(name = "id_adoption")
    45     private int adoptionId;
     45    private Integer adoptionId;
    4646
    4747    @Column(name = "id_shelter")
    48     private int shelterId;
     48    private Integer shelterId;
    4949
    50     public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, String name, Species species, Gender gender, boolean canBeFostered, int adoptionId, int shelterId) {
     50    public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, String name, Species species, Gender gender, boolean canBeFostered, Integer adoptionId, Integer shelterId) {
    5151        this.imageUrl = imageUrl;
    5252        this.ageGroup = ageGroup;
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Post.java

    ra2060cb r3f5e485  
    55
    66import java.time.LocalDate;
    7 import java.util.Date;
    87
    98@Data
     
    2423
    2524    @Column(name="id_pet", nullable = false)
    26     private int petId;
     25    private Integer petId;
    2726
    2827    @Column(name="id_surendee")
    29     private int surendeeId;
     28    private Integer surendeeId;
    3029
    3130    @Column(name="id_employee")
    32     private int employeeId;
     31    private Integer employeeId;
    3332
    34     public Post(LocalDate dateCreated, String thumbnailUrl, int petId, int surendeeId, int employeeId) {
     33    public Post(LocalDate dateCreated, String thumbnailUrl, Integer petId, Integer surendeeId, Integer employeeId) {
    3534        this.dateCreated = dateCreated;
    3635        this.thumbnailUrl = thumbnailUrl;
  • Prototype Application/Paw5/src/main/java/finki/paw5/repository/UserRepository.java

    ra2060cb r3f5e485  
    55import org.springframework.stereotype.Repository;
    66
     7
    78@Repository
    89public interface UserRepository extends JpaRepository<User, Integer> {
     10        User findByEmailAndPassword(String email, String password);
     11        User findByEmail(String email);
    912}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/PetService.java

    ra2060cb r3f5e485  
    11package finki.paw5.service;
    22
     3import finki.paw5.model.entities.Pet;
     4
    35public interface PetService {
     6
     7    void save (Pet pet);
    48}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/PostService.java

    ra2060cb r3f5e485  
    11package finki.paw5.service;
    22
     3import finki.paw5.model.entities.Post;
     4import finki.paw5.model.enumerations.AgeGroup;
     5import finki.paw5.model.enumerations.Gender;
     6import finki.paw5.model.enumerations.Size;
     7import finki.paw5.model.enumerations.Species;
     8
    39public interface PostService {
     10
     11    void save (Post post);
     12
    413}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PetServiceImplementation.java

    ra2060cb r3f5e485  
    11package finki.paw5.service.implementation;
    22
     3import finki.paw5.model.entities.Pet;
    34import finki.paw5.repository.PetRepository;
    45import finki.paw5.service.PetService;
     
    1415    }
    1516
     17    @Override
     18    public void save(Pet pet) {
     19        this.petRepository.save(pet);
     20    }
    1621}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PostServiceImplementation.java

    ra2060cb r3f5e485  
    11package finki.paw5.service.implementation;
    22
     3import finki.paw5.model.entities.Post;
    34import finki.paw5.repository.PostRepository;
    45import finki.paw5.service.PostService;
     
    1415    }
    1516
     17    @Override
     18    public void save(Post post) {
     19        this.postRepository.save(post);
     20    }
     21
    1622}
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java

    ra2060cb r3f5e485  
    11package finki.paw5.web.controllers;
    22
     3import finki.paw5.model.entities.Pet;
     4import finki.paw5.model.entities.Post;
     5import finki.paw5.model.enumerations.AgeGroup;
     6import finki.paw5.model.enumerations.Gender;
     7import finki.paw5.model.enumerations.Size;
     8import finki.paw5.model.enumerations.Species;
     9import finki.paw5.service.PetService;
    310import finki.paw5.service.PostService;
    411import org.springframework.stereotype.Controller;
     12import org.springframework.ui.Model;
     13import org.springframework.web.bind.annotation.GetMapping;
     14import org.springframework.web.bind.annotation.PostMapping;
     15import org.springframework.web.bind.annotation.RequestParam;
     16
     17import java.time.LocalDate;
    518
    619@Controller
     
    821
    922    private final PostService postService;
     23    private final PetService petService;
    1024
    11     public PostController(PostService postService) {
     25    public PostController(PostService postService, PetService petService) {
    1226        this.postService = postService;
     27        this.petService = petService;
    1328    }
    1429
     30    @GetMapping("create-post")
     31    public String get(Model model) {
     32        //TODO: vakvo ama za lista so pets
     33        //        List<Manufacturer> manufacturers = this.manufacturerService.findAll();
     34        //        model.addAttribute("manufacturers", manufacturers);
     35        return "create-post";
     36    }
     37
     38    @PostMapping("submit-post")
     39    public String savePost(@RequestParam(required = false) String name,
     40                           @RequestParam String gender,
     41                           @RequestParam String ageGroup,
     42                           @RequestParam String size,
     43                           @RequestParam String species,
     44                           @RequestParam(required = false) String breed,
     45                           @RequestParam(required = false) String imageUrl,
     46                           @RequestParam(required = false) boolean canBeFostered) {
     47
     48        Pet pet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, 1);
     49        this.petService.save(pet);
     50
     51        Post post = new Post(LocalDate.now(), imageUrl, pet.getId(), null, 10);//TODO: employee id da se zeme preku session user getid
     52        this.postService.save(post);
     53
     54        return "redirect:/home";
     55    }
    1556}
Note: See TracChangeset for help on using the changeset viewer.