|
|
@@ -1,33 +1,46 @@
|
|
|
package thyyxxk.wxservice_server.controller;
|
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.wxservice_server.dao.ImportDrugDao;
|
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
|
-import thyyxxk.wxservice_server.entity.importdrug.ImportDrugPurchase;
|
|
|
+import thyyxxk.wxservice_server.entity.drugconsult.ImportDrugPurchase;
|
|
|
+import thyyxxk.wxservice_server.entity.drugconsult.OnShelfDrug;
|
|
|
import thyyxxk.wxservice_server.utils.ResultVoUtil;
|
|
|
import thyyxxk.wxservice_server.utils.SnowFlakeId;
|
|
|
|
|
|
import java.util.Calendar;
|
|
|
+import java.util.List;
|
|
|
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
-@RequestMapping("/importDrug")
|
|
|
+@RequestMapping("/drugConsult")
|
|
|
public class ImportDrugController {
|
|
|
private final ImportDrugDao dao;
|
|
|
+ private static final String API = "http://172.16.32.167:9206/thyy/api/public/selfServiceMachine/drug?drugName=";
|
|
|
|
|
|
@Autowired
|
|
|
public ImportDrugController(ImportDrugDao dao) {
|
|
|
this.dao = dao;
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/submitNewItem")
|
|
|
- public ResultVo<String> submitNewItem(@RequestBody ImportDrugPurchase purchase) {
|
|
|
+ @PostMapping("/importDrugPurchase")
|
|
|
+ public ResultVo<String> importDrugPurchase(@RequestBody ImportDrugPurchase purchase) {
|
|
|
purchase.setId(SnowFlakeId.instance().nextId());
|
|
|
purchase.setCreateTime(Calendar.getInstance().getTime());
|
|
|
dao.insert(purchase);
|
|
|
return ResultVoUtil.success("我院近期将与您联系,请保持手机畅通,谢谢。");
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("/onShelfDrugInquiry")
|
|
|
+ public ResultVo<List<OnShelfDrug>> onShelfDrugInquiry(@RequestParam("name") String name) {
|
|
|
+ List<OnShelfDrug> list = new RestTemplate().getForObject(API+name, List.class);
|
|
|
+ if (null == list || list.isEmpty()) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到数据。");
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(list);
|
|
|
+ }
|
|
|
}
|