PatientController.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.yihu.jw.controller;
  2. import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
  3. import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
  4. import com.yihu.jw.fegin.PatientFegin;
  5. import io.swagger.annotations.Api;
  6. import io.swagger.annotations.ApiOperation;
  7. import io.swagger.annotations.ApiParam;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.http.ResponseEntity;
  10. import org.springframework.web.bind.annotation.*;
  11. import org.springframework.web.client.RestTemplate;
  12. import org.springframework.web.context.annotation.SessionScope;
  13. /**
  14. * Created by chenweida on 2017/5/10.
  15. */
  16. @RestController
  17. @RequestMapping("/rest/patient")
  18. @Api(description = "患者")
  19. public class PatientController {
  20. @Autowired
  21. private PatientFegin patientFegin;
  22. @ApiOperation(value = "根据code查找患者")
  23. @GetMapping(value = "findByCode")
  24. //配置HystrixProperty 则调用的方法和fallback是同一个线程 否则就不是
  25. //@HystrixCommand(fallbackMethod = "findByCodeFallback",commandProperties = @HystrixProperty(name = "execution.isolation.strategy",value = "SEMAPHORE"))
  26. @HystrixCommand(fallbackMethod = "findByCodeFallback" )
  27. public String findByCode(
  28. @ApiParam(name = "code", value = "患者code", required = true) @RequestParam(value = "code", required = true) String code) {
  29. return patientFegin.findByCode(code);
  30. }
  31. // /**
  32. // * 参数要一致 返回值类型也要一致
  33. // *
  34. // * @param code
  35. // * @return
  36. // */
  37. // public String findByCodeFallback(String code) {
  38. // return "";
  39. // }
  40. }