@RequestMapping(value = USERACCOUNT + "/{name}/jobs", method = RequestMethod.POST) @PreAuthorize("hasAuthority(#name)") public ResponseEntity<JobResponseDTO> createJob( @PathVariable String name, @RequestBody JobRequestDTO newJob) throws ServiceException { newJob.setAccountName(name); Job job = JobConverter.fromRequest(validator, newJob); job = jobService.create(newJob.getAccountName(), newJob.getCategory().getCategory(), job); return new ResponseEntity<JobResponseDTO>(JobConverter.toResponse(job), HttpStatus.CREATED); }
@RequestMapping(value = USERACCOUNT + "/{name}/jobs/{jobId}/bids", method = RequestMethod.POST) @PreAuthorize("hasAuthority(#name)") public ResponseEntity<BidResponseDTO> createBid( @PathVariable String name, @PathVariable Long jobId, @RequestBody BidRequestDTO newBid) throws ServiceException { newBid.setAccountName(name); Bid bid = BidConverter.fromRequest(validator, newBid); bid = jobService.createBid(name, jobId, bid); return new ResponseEntity<BidResponseDTO>(BidConverter.toResponse(bid), HttpStatus.CREATED); }
@RequestMapping(value = USERACCOUNT + "/{name}/jobs", method = RequestMethod.GET) @PreAuthorize("hasAuthority(#name)") public ResponseEntity<JobPageResponseDTO> getMyJobs( @PathVariable String name, @RequestParam int page, @RequestParam int size, @RequestParam(required = false) String where) throws ServiceException, BadSearchStringException { // TODO - move it to some class if (!StringUtils.isEmpty(where)) { where += SearchCriteria.AND + "userName:"******"userName:" + name; } Page<Job> jobList = jobService.getAll(where, new PageRequest(page, size)); return new ResponseEntity<JobPageResponseDTO>(JobConverter.toResponse(jobList), HttpStatus.OK); }