package com.coffee.bus.controller; import com.baomidou.mybatisplus.core.mapper.Mapper; import com.coffee.bus.entity.BusDoctorEntity; import com.coffee.bus.entity.BusPatientEntity; import com.coffee.bus.service.LocalBusDoctorService; import com.coffee.bus.service.LocalBusPatientService; import com.coffee.common.crud.BaseService; import com.coffee.common.crud.controller.BaseCrudController; import com.coffee.common.result.R; import io.swagger.annotations.Api; import io.swagger.v3.oas.annotations.Operation; import lombok.AllArgsConstructor; import org.springframework.scheduling.annotation.Async; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.request.async.DeferredResult; /** * @author lifang * @version 1.0.0 * @ClassName BusHospitalController.java * @Description TODO * @createTime 2022年03月19日 09:28:00 */ @RestController @AllArgsConstructor @RequestMapping("/bus/patient") @Api(tags = "医院病人管理",description = "统一权限前缀(bus:patient),例如新增bus:patient:add") public class BusPatientController extends BaseCrudController { private final LocalBusPatientService patientService; /** * 权限控制前缀 * @return */ @Override public String getPermissionPrefix() { return "bus:patient"; } @Override public BaseService, BusPatientEntity, String> getService() { return patientService; } //todo 使用 @PostMapping("/syn/{hospitalId}/{patientCode}") @Operation(summary = "同步更新患者信息,即等待更新完成后返回更新结果") public DeferredResult syn(@PathVariable("hospitalId") String hospitalId, @PathVariable("patientCode")String patientCode){ DeferredResult result = new DeferredResult<>(); result.onCompletion(()->{ }); result.onTimeout(()->{ R.fail("响应超时"); }); return result; } //todo @PostMapping("/async/{hospitalId}/{patientCode}") @Operation(summary = "异步更新患者信息,即立刻返回更新结果") public R async(@PathVariable("hospitalId") String hospitalId, @PathVariable("patientCode")String patientCode){ return R.success(); } }