浏览代码

服务号添加在架药品查询,修改主页目录结构

lighter 10 月之前
父节点
当前提交
8b0c4119ba

+ 21 - 8
src/main/java/thyyxxk/wxservice_server/controller/ImportDrugController.java

@@ -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);
+    }
 }

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/dao/ImportDrugDao.java

@@ -2,7 +2,7 @@ package thyyxxk.wxservice_server.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
-import thyyxxk.wxservice_server.entity.importdrug.ImportDrugPurchase;
+import thyyxxk.wxservice_server.entity.drugconsult.ImportDrugPurchase;
 
 @Mapper
 public interface ImportDrugDao extends BaseMapper<ImportDrugPurchase> {

+ 3 - 1
src/main/java/thyyxxk/wxservice_server/entity/importdrug/ImportDrugPurchase.java → src/main/java/thyyxxk/wxservice_server/entity/drugconsult/ImportDrugPurchase.java

@@ -1,4 +1,4 @@
-package thyyxxk.wxservice_server.entity.importdrug;
+package thyyxxk.wxservice_server.entity.drugconsult;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -14,6 +14,8 @@ public class ImportDrugPurchase {
     private String id;
     private String phoneNo;
     private String drugName;
+    private Integer drugQuantity;
+    private String drugSpecification;
     private String drugFactory;
     private String expContent;
     private String drugImg;

+ 21 - 0
src/main/java/thyyxxk/wxservice_server/entity/drugconsult/OnShelfDrug.java

@@ -0,0 +1,21 @@
+package thyyxxk.wxservice_server.entity.drugconsult;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class OnShelfDrug {
+    // 类别
+    private String clazz;
+    // 生产厂家
+    private String manu;
+    // 药品名称
+    private String name;
+    // 医保编码
+    private String nationalCode;
+    // 药品单位
+    private String unit;
+    // 药品单价
+    private BigDecimal price;
+}

+ 1 - 1
src/main/resources/application.yml

@@ -1,3 +1,3 @@
 spring:
   profiles:
-    active: dev
+    active: prod