From b13a6c471528d0165b4c94877c067befca7f9bad Mon Sep 17 00:00:00 2001 From: lakefish <3488815871@qq.com> Date: Fri, 28 Jan 2022 00:27:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=85=B3=E4=BA=8E?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E8=A7=84=E5=88=92=E7=9A=84=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HospitalController.java | 79 +++++++++++++++++++ .../java/com/peteralbus/entity/Distance.java | 18 +++++ .../java/com/peteralbus/entity/Hospital.java | 19 +++++ .../com/peteralbus/mapper/HospitalMapper.java | 15 ++++ .../peteralbus/service/HospitalService.java | 9 +++ .../service/impl/HospitalServiceImpl.java | 19 +++++ src/main/resources/mapper/HospitalMapper.xml | 13 +++ 7 files changed, 172 insertions(+) create mode 100644 src/main/java/com/peteralbus/controller/HospitalController.java create mode 100644 src/main/java/com/peteralbus/entity/Distance.java create mode 100644 src/main/java/com/peteralbus/entity/Hospital.java create mode 100644 src/main/java/com/peteralbus/mapper/HospitalMapper.java create mode 100644 src/main/java/com/peteralbus/service/HospitalService.java create mode 100644 src/main/java/com/peteralbus/service/impl/HospitalServiceImpl.java create mode 100644 src/main/resources/mapper/HospitalMapper.xml diff --git a/src/main/java/com/peteralbus/controller/HospitalController.java b/src/main/java/com/peteralbus/controller/HospitalController.java new file mode 100644 index 0000000..dbf3e59 --- /dev/null +++ b/src/main/java/com/peteralbus/controller/HospitalController.java @@ -0,0 +1,79 @@ +package com.peteralbus.controller; + +import com.peteralbus.entity.Distance; +import com.peteralbus.entity.Hospital; +import com.peteralbus.service.HospitalService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@CrossOrigin +@RestController +public class HospitalController { + @Autowired + HospitalService hospitalService; + @RequestMapping("/findAllHospital") + public List findAllHospital(){ + return hospitalService.findAllHospital(); + } + @RequestMapping("/calculateDistance") + public Distance calculateDistance(double lng, double lat){//输入经纬度的值,遍历所有Hosiptai的经纬度并比较其距离 +// return getDistance(121.446014,31.215937,121.446028464238,31.2158502442799 ); + System.out.print("进入函数calculate"); + List hospitals=hospitalService.findAllHospital(); + double minDistance=Double.MAX_VALUE; + Distance distance=new Distance(); + for(int i=0;i findAllHospital(); + +} diff --git a/src/main/java/com/peteralbus/service/HospitalService.java b/src/main/java/com/peteralbus/service/HospitalService.java new file mode 100644 index 0000000..23f6f42 --- /dev/null +++ b/src/main/java/com/peteralbus/service/HospitalService.java @@ -0,0 +1,9 @@ +package com.peteralbus.service; + +import com.peteralbus.entity.Hospital; + +import java.util.List; + +public interface HospitalService { + public List findAllHospital(); +} diff --git a/src/main/java/com/peteralbus/service/impl/HospitalServiceImpl.java b/src/main/java/com/peteralbus/service/impl/HospitalServiceImpl.java new file mode 100644 index 0000000..eaab3f4 --- /dev/null +++ b/src/main/java/com/peteralbus/service/impl/HospitalServiceImpl.java @@ -0,0 +1,19 @@ +package com.peteralbus.service.impl; + +import com.peteralbus.entity.Hospital; +import com.peteralbus.mapper.HospitalMapper; +import com.peteralbus.service.HospitalService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class HospitalServiceImpl implements HospitalService { + @Autowired + private HospitalMapper hospitalMapper; + @Override + public List findAllHospital() { + return hospitalMapper.findAllHospital(); + } +} diff --git a/src/main/resources/mapper/HospitalMapper.xml b/src/main/resources/mapper/HospitalMapper.xml new file mode 100644 index 0000000..e6db5c1 --- /dev/null +++ b/src/main/resources/mapper/HospitalMapper.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file