BusPatientController.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package com.coffee.bus.controller;
  2. import com.baomidou.mybatisplus.core.mapper.Mapper;
  3. import com.coffee.bus.entity.BusDoctorEntity;
  4. import com.coffee.bus.entity.BusPatientEntity;
  5. import com.coffee.bus.service.LocalBusDoctorService;
  6. import com.coffee.bus.service.LocalBusPatientService;
  7. import com.coffee.common.crud.BaseService;
  8. import com.coffee.common.crud.controller.BaseCrudController;
  9. import com.coffee.common.result.R;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.v3.oas.annotations.Operation;
  12. import lombok.AllArgsConstructor;
  13. import org.springframework.scheduling.annotation.Async;
  14. import org.springframework.web.bind.annotation.PathVariable;
  15. import org.springframework.web.bind.annotation.PostMapping;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import org.springframework.web.context.request.async.DeferredResult;
  19. /**
  20. * @author lifang
  21. * @version 1.0.0
  22. * @ClassName BusHospitalController.java
  23. * @Description TODO
  24. * @createTime 2022年03月19日 09:28:00
  25. */
  26. @RestController
  27. @AllArgsConstructor
  28. @RequestMapping("/bus/patient")
  29. @Api(tags = "医院病人管理",description = "统一权限前缀(bus:patient),例如新增bus:patient:add")
  30. public class BusPatientController extends BaseCrudController<BusPatientEntity, String> {
  31. private final LocalBusPatientService patientService;
  32. /**
  33. * 权限控制前缀
  34. * @return
  35. */
  36. @Override
  37. public String getPermissionPrefix() {
  38. return "bus:patient";
  39. }
  40. @Override
  41. public BaseService<? extends Mapper<BusPatientEntity>, BusPatientEntity, String> getService() {
  42. return patientService;
  43. }
  44. //todo 使用
  45. @PostMapping("/syn/{hospitalId}/{patientCode}")
  46. @Operation(summary = "同步更新患者信息,即等待更新完成后返回更新结果")
  47. public DeferredResult<R> syn(@PathVariable("hospitalId") String hospitalId, @PathVariable("patientCode")String patientCode){
  48. DeferredResult<R> result = new DeferredResult<>();
  49. result.onCompletion(()->{
  50. });
  51. result.onTimeout(()->{
  52. R.fail("响应超时");
  53. });
  54. return result;
  55. }
  56. //todo
  57. @PostMapping("/async/{hospitalId}/{patientCode}")
  58. @Operation(summary = "异步更新患者信息,即立刻返回更新结果")
  59. public R async(@PathVariable("hospitalId") String hospitalId, @PathVariable("patientCode")String patientCode){
  60. return R.success();
  61. }
  62. }