Changeset 6729ba5 for src


Ignore:
Timestamp:
01/15/21 16:39:45 (4 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
81c9e25
Parents:
ed3f5c4
Message:

finished work edit

Location:
src/main/java/it/finki/tinki
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/tinki/model/dto/response/work/WorkResponseDTO.java

    red3f5c4 r6729ba5  
    1313    String accountEmail;
    1414    String accountName;
     15    Long accountId;
    1516    AccountType accountType;
    1617    String error;
     
    2829        this.description = description;
    2930        this.salary = salary;
     31        this.accountId = account.getId();
    3032        this.accountEmail = account.getEmail();
    3133        this.accountName = account.getName();
  • src/main/java/it/finki/tinki/service/impl/WorkServiceImpl.java

    red3f5c4 r6729ba5  
    131131        j.setDescription(description);
    132132        j.setSalary(salary);
     133        j.setOpenSpots(openSpots);
    133134
    134135        return this.internshipRepository.save(j);
  • src/main/java/it/finki/tinki/web/controller/WorkEditController.java

    red3f5c4 r6729ba5  
    44import it.finki.tinki.model.Work.Job;
    55import it.finki.tinki.model.Work.Project;
     6import it.finki.tinki.model.dto.edit.work.InternshipEditDTO;
     7import it.finki.tinki.model.dto.edit.work.WorkEditDTO;
    68import it.finki.tinki.model.dto.register.work.InternshipRegisterDTO;
    79import it.finki.tinki.model.dto.register.work.JobRegisterDTO;
     
    2931
    3032    @PostMapping("/job/{id}")
    31     public Map<String, String> editJob(@PathVariable Long id,
    32                                        @RequestBody JobRegisterDTO body){
     33    public JobResponseDTO editJob(@PathVariable Long id,
     34                                  @RequestBody WorkEditDTO body){
    3335
    34         Map<String, String> response = new HashMap<>();
     36        Job j = this.workService.getJobById(id);
    3537
    36         if(body.getAccountId().equals(this.workService.getJobById(id).getAccount().getId())) {
     38        if(body.getAccountId().equals(j.getAccount().getId())) {
    3739            Job k = this.workService.editJob(id, body.getTitle(), body.getDescription(), body.getSalary());
    3840            if(k!=null){
    39                 response.put("success", "Job edited successfully!");
    40                 return response;
     41                return new JobResponseDTO(k);
    4142            }
    4243        }
    4344
    44         response.put("error", "Internship edit failed!");
    45         return response;
     45        return new JobResponseDTO();
    4646    }
    4747
    4848    @PostMapping("/internship/{id}")
    49     public Map<String, String> editInternship(@PathVariable Long id,
    50                                                 @RequestBody InternshipRegisterDTO body){
     49    public InternshipResponseDTO editInternship(@PathVariable Long id,
     50                                                @RequestBody InternshipEditDTO body){
    5151
    52         Map<String, String> response = new HashMap<>();
     52        Internship i = this.workService.getInternshipById(id);
    5353
    54         if(body.getAccountId().equals(this.workService.getInternshipById(id).getAccount().getId())){
     54        if(body.getAccountId().equals(i.getAccount().getId())){
    5555            Internship k = this.workService.editInternship(id, body.getTitle(), body.getDescription(), body.getSalary(), body.getOpenSpots());
    5656            if(k!=null){
    57                 response.put("success", "Internship edited successfully!");
    58                 return response;
     57                return new InternshipResponseDTO(k);
    5958            }
    6059        }
    6160
    62         response.put("error", "Internship edit failed!");
    63         return response;
     61        return new InternshipResponseDTO();
    6462    }
    6563
    6664    @PostMapping("/project/{id}")
    67     public Map<String, String> editProject(@PathVariable Long id,
    68                                           @RequestBody ProjectRegisterDTO body){
     65    public ProjectResponseDTO editProject(@PathVariable Long id,
     66                                          @RequestBody WorkEditDTO body){
    6967
    70         Map<String, String> response = new HashMap<>();
     68        Project p = this.workService.getProjectById(id);
    7169
    72         if(body.getAccountId().equals(this.workService.getProjectById(id).getAccount().getId())) {
     70        if(body.getAccountId().equals(p.getAccount().getId())) {
    7371            Project k = this.workService.editProject(id, body.getTitle(), body.getDescription(), body.getSalary());
    7472            if(k!=null){
    75                 response.put("success", "Project edited successfully!");
    76                 return response;
     73                return new ProjectResponseDTO(k);
    7774            }
    7875        }
    7976
    80         response.put("error", "Project edit failed!");
    81         return response;
     77        return new ProjectResponseDTO();
    8278    }
    8379}
Note: See TracChangeset for help on using the changeset viewer.