Ignore:
Timestamp:
01/11/21 18:57:03 (3 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
8f1f460
Parents:
fc8421e
Message:

refactoring controllers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/tinki/web/controller/WorkEditController.java

    rfc8421e r5f9d25a  
    2525    }
    2626
    27     @PostMapping("/job/{userId}/{id}")
    28     public JobResponseDTO editJob(@PathVariable Long userId,
    29                                   @PathVariable Long id,
     27    @PostMapping("/job/{id}")
     28    public JobResponseDTO editJob(@PathVariable Long id,
    3029                                  @RequestBody JobRegisterDTO body){
    3130
    32         if(userId.equals(this.workService.getJobById(id).getAccount().getId())) {
     31        if(body.getAccountId().equals(this.workService.getJobById(id).getAccount().getId())) {
    3332            Job k = this.workService.editJob(id, body.getTitle(), body.getDescription(), body.getSalary());
    34 
    3533            return new JobResponseDTO(k);
    3634        }
    37 
    3835        return null;
    3936    }
    4037
    41     @PostMapping("/internship/{userId}/{id}")
    42     public InternshipResponseDTO editInternship(@PathVariable Long userId,
    43                                                 @PathVariable Long id,
     38    @PostMapping("/internship/{id}")
     39    public InternshipResponseDTO editInternship(@PathVariable Long id,
    4440                                                @RequestBody InternshipRegisterDTO body){
    4541
    46         if(userId.equals(this.workService.getJobById(id).getAccount().getId())){
     42        if(body.getAccountId().equals(this.workService.getJobById(id).getAccount().getId())){
    4743            Internship k = this.workService.editInternship(id, body.getTitle(), body.getDescription(), body.getSalary(), body.getOpenSpots());
    48 
    4944            return new InternshipResponseDTO(k);
    5045        }
    51 
    5246        return null;
    5347    }
    5448
    55     @PostMapping("/project/{userId}/{id}")
    56     public ProjectResponseDTO editProject(@PathVariable Long userId,
    57                                           @PathVariable Long id,
     49    @PostMapping("/project/{id}")
     50    public ProjectResponseDTO editProject(@PathVariable Long id,
    5851                                          @RequestBody ProjectRegisterDTO body){
    5952
    60         if(userId.equals(this.workService.getJobById(id).getAccount().getId())) {
     53        if(body.getAccountId().equals(this.workService.getJobById(id).getAccount().getId())) {
    6154            Project k = this.workService.editProject(id, body.getTitle(), body.getDescription(), body.getSalary());
    62 
    6355            return new ProjectResponseDTO(k);
    6456        }
    65 
    6657        return null;
    6758    }
Note: See TracChangeset for help on using the changeset viewer.