|
|
@@ -0,0 +1,42 @@
|
|
|
+package com.travel.service.impl;
|
|
|
+
|
|
|
+import com.travel.mapper.LatLngMapper;
|
|
|
+import com.travel.model.LatLng;
|
|
|
+import com.travel.service.LatLngService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class LatLngServiceImpl implements LatLngService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LatLngMapper latLngMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Map<String, Object> addCodeLatLng(LatLng latLng) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ try{
|
|
|
+ if(latLng.getType().equals("get")){
|
|
|
+ map.put("data", latLngMapper.getCodeLatLng(latLng));
|
|
|
+ } else {
|
|
|
+ int count = latLngMapper.getCodeIsNotExist(latLng);
|
|
|
+ if(count == 0){
|
|
|
+ latLngMapper.addCodeLatLng(latLng);
|
|
|
+ } else {
|
|
|
+ latLngMapper.updateCodeLatLng(latLng);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("msg", "200");
|
|
|
+ } catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ map.put("msg", "500");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+}
|