暂无描述

LawyerController.java 933B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package org.develop.officialjournal.controllers;
  2. import org.develop.officialjournal.services.Database;
  3. import org.springframework.web.bind.annotation.PathVariable;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RequestParam;
  6. import org.springframework.web.bind.annotation.RestController;
  7. import dao.entity.Lawyer;
  8. import dao.lucene.tables.DAOLawyer;
  9. @RestController
  10. public class LawyerController {
  11. private DAOLawyer daoLawyer;
  12. public LawyerController() {
  13. daoLawyer = Database.get().getDaoLawyer();
  14. }
  15. /**returns lawyer by id*/
  16. @RequestMapping("/lawyer/{id}")
  17. public Lawyer getById(@PathVariable Integer id ) {
  18. Lawyer lawyer = this.daoLawyer.get(id);
  19. return lawyer;
  20. }
  21. @RequestMapping("/lawyer/")
  22. public Lawyer getByName(@RequestParam (required = true) String name ) {
  23. Lawyer lawyer = new Lawyer(name);
  24. return daoLawyer.get(lawyer);
  25. }
  26. }