Ignore:
Timestamp:
01/12/21 02:42:18 (3 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
a70db1a
Parents:
8f1f460
Message:

bugfixes and refactoring

File:
1 edited

Legend:

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

    r8f1f460 r33d4f5d  
    11package it.finki.tinki.web.controller;
    22
     3import it.finki.tinki.model.Users.Account;
    34import it.finki.tinki.model.Work.Internship;
    45import it.finki.tinki.model.Work.Job;
     
    1011import it.finki.tinki.model.dto.response.work.JobResponseDTO;
    1112import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;
     13import it.finki.tinki.model.enumerator.AccountType;
    1214import it.finki.tinki.service.WorkService;
    1315import org.springframework.web.bind.annotation.*;
     
    2628    @PostMapping("/job")
    2729    public JobResponseDTO registerJob(@RequestBody JobRegisterDTO body){
    28         Job j = this.workService.insertJob(body.getTitle(),
    29                 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getType());
    30         return new JobResponseDTO(j);
     30
     31        if(body.getType() != AccountType.USER){
     32            Job j = this.workService.insertJob(body.getTitle(),
     33                    body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getType());
     34            return new JobResponseDTO(j);
     35        }
     36
     37        return new JobResponseDTO();
    3138    }
    3239
    3340    @PostMapping("/internship")
    3441    public InternshipResponseDTO registerInternship(@RequestBody InternshipRegisterDTO body){
    35         Internship j = this.workService.insertInternship(body.getTitle(),
    36                 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsTrained(), body.getOpenSpots(), body.getType());
    37         return new InternshipResponseDTO(j);
     42        if(body.getType() == AccountType.COMPANY){
     43            Internship j = this.workService.insertInternship(body.getTitle(),
     44                    body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsTrained(), body.getOpenSpots(), body.getType());
     45            return new InternshipResponseDTO(j);
     46        }
     47
     48        return new InternshipResponseDTO();
    3849    }
    3950
    4051    @PostMapping("/project")
    4152    public ProjectResponseDTO registerProject(@RequestBody ProjectRegisterDTO body){
    42         Project j = this.workService.insertProject(body.getTitle(),
    43                 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getValidUntil(), body.getType());
    44         return new ProjectResponseDTO(j);
     53
     54        if(body.getType() == AccountType.TEAM){
     55            Project j = this.workService.insertProject(body.getTitle(),
     56                    body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getValidUntil(), body.getType());
     57            return new ProjectResponseDTO(j);
     58        }
     59
     60        return new ProjectResponseDTO();
    4561    }
    4662}
Note: See TracChangeset for help on using the changeset viewer.