1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package org.develop.officialjournal.controllers;
- import java.util.List;
- import org.develop.officialjournal.services.Database;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import dao.DAOEntity;
- import dao.DAOJudge;
- import dao.DAOLawyer;
- import dao.DAOSearch;
- import entity.Entity;
- import entity.Info;
- import entity.Judge;
- import entity.Lawyer;
- @RestController
- public class SearchController {
- private DAOLawyer daoLawyer;
- private DAOJudge daoJudge;
- private DAOEntity daoEntity;
- private DAOSearch daoSearch;
-
-
- public SearchController() {
-
- daoLawyer = Database.get().getDaoLawyer();
- daoJudge = Database.get().getDaoJudge();
- daoEntity = Database.get().getDaoEntity();
- daoSearch = Database.get().getDaoSearch();
- }
-
-
-
-
- /**returns lawyer by id*/
- @RequestMapping("/search/autocomplete")
- public List<Entity> autoComplete(@RequestParam String text ) {
-
- return daoSearch.autoComplete(text);
-
- }
-
-
- /**returns lawyer by id*/
- @RequestMapping("/search")
- public Entity getEntity(@RequestParam String text ) {
- Lawyer lawyer = new Lawyer(text);
- Judge judge = new Judge(text);
- Entity entity = new Entity();
- entity.setName(text);
- if(daoLawyer.contains(lawyer))
- {
- lawyer = daoLawyer.get(lawyer);
- return lawyer;
- }
-
- if(daoJudge.contains(judge))
- {
- judge = daoJudge.get(judge);
- return judge;
- }
- if(daoEntity.contains(entity))
- {
- entity = daoEntity.get(entity);
- return entity;
- }
- return new Entity();
-
- }
-
-
- @RequestMapping("/search/info")
- public Info getEntityInfo(@RequestParam String type, @RequestParam Integer entityId ) {
-
- return daoSearch.getInfo(type, entityId);
-
- }
-
-
-
-
-
-
- }
|