daily pastebin goal
21%
SHARE
TWEET

Untitled

dave5595 Dec 11th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @RestController
  2. @Transactional(timeout = 90)
  3. public class JobCategoryController extends AbstractRestController {
  4.  
  5.     @Autowired JobCategoryRepo jobCategoryRepo;
  6.     @Autowired JobPostingRepo jobPostingRepo;
  7.     @Autowired ObjectMapper mapper;
  8.  
  9.     @RequestMapping(method = RequestMethod.GET, value = {"/api/jobCategory", "/admin/api/jobCategory"})
  10.     public ResponseEntity getAllJobCategories(){
  11.         List<JobCategory> jobCategoryList = jobCategoryRepo.findAll();
  12.  
  13.         List<ObjectNode> results = jobCategoryList
  14.                 .stream()
  15.                 .map(EntityUtils::toJson)
  16.                 .collect(Collectors.toList());
  17.         return ResponseUtils.responseOk().data(results).buildEntity();
  18.     }
  19.  
  20.     @RequestMapping(method = RequestMethod.GET, value = "/api/jobCategory/{jobCategoryId}/job")
  21.     public ResponseEntity getJobPostingByCategoryId(@PathVariable Integer jobCategoryId){
  22.         List<JobPosting> jobPostingList = Lists.newArrayList(jobPostingRepo.findAll(
  23.                 QJobPosting.jobPosting.jobCategory.id.eq(jobCategoryId)));
  24.         List<ObjectNode> results = jobPostingList
  25.                 .stream()
  26.                 .map(EntityUtils::toJson)
  27.                 .collect(Collectors.toList());
  28.         return ResponseUtils.responseOk().data(results).buildEntity();
  29.     }
  30.  
  31.     @RequestMapping(method = RequestMethod.GET, value = "/api/jobCategory/{jobCategoryId}/job/{id}")
  32.     public ResponseEntity getJob(@PathVariable Integer id){
  33.         JobPosting jobPosting = jobPostingRepo.findOne(id);
  34.         if (jobPosting == null){
  35.             return ResponseUtils.responseErr("Error, job id of {} does not exist", id).buildEntity();
  36.         }
  37.         return ResponseUtils.responseOk().data(EntityUtils.toJson(jobPosting)).buildEntity();
  38.     }
  39.  
  40.     @RequestMapping(value = {"/api/jobCategory/{jobCategoryId}/job/save", "/admin/api/jobCategory/{jobCategoryId}/job/save"})
  41.     public ResponseEntity saveJob(@RequestBody JsonNode json, @PathVariable Integer jobCategoryId) throws JsonProcessingException {
  42.         JobCategory category = jobCategoryRepo.findOne(jobCategoryId);
  43.         if (category == null){
  44.             return ResponseUtils.responseErr("Error, category id of {} does not exist", jobCategoryId).buildEntity();
  45.         }
  46.         JobPosting jobPosting = mapper.treeToValue(json, JobPosting.class);
  47.         jobPosting.setJobCategory(category);
  48.  
  49.         List<Requirement> requirementList = new ArrayList<Requirement>();
  50.         List<Responsibility> responsibilityList = new ArrayList<Responsibility>();
  51. //
  52.         JsonNode requirements = json.get("requirement");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top