From d3a12b192afc54eb51f640a8050644d4fddd9100 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 28 七月 2023 15:16:08 +0800
Subject: [PATCH] 后台代码
---
cloud-server-other/src/main/java/com/dsh/other/service/impl/StoreServiceImpl.java | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 103 insertions(+), 0 deletions(-)
diff --git a/cloud-server-other/src/main/java/com/dsh/other/service/impl/StoreServiceImpl.java b/cloud-server-other/src/main/java/com/dsh/other/service/impl/StoreServiceImpl.java
index 55d882f..a450214 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/service/impl/StoreServiceImpl.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/service/impl/StoreServiceImpl.java
@@ -1,11 +1,22 @@
package com.dsh.other.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.other.entity.Store;
import com.dsh.other.mapper.StoreMapper;
+import com.dsh.other.model.BaseVo;
+import com.dsh.other.model.ProvinceAndCityVo;
import com.dsh.other.service.StoreService;
+import com.dsh.other.util.GDMapGeocodingUtil;
+import com.dsh.other.util.ToolUtil;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
/**
* <p>
@@ -18,4 +29,96 @@
@Service
public class StoreServiceImpl extends ServiceImpl<StoreMapper,Store> implements StoreService {
+ @Autowired
+ private GDMapGeocodingUtil gdMapGeocodingUtil;
+
+
+ /**
+ * 获取列表数据
+ * @param provinceCode
+ * @param cityCode
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public List<Store> queryStorsList(String provinceCode, String cityCode) throws Exception {
+ QueryWrapper objectQueryWrapper = new QueryWrapper<Store>().eq("state", 1);
+ if(ToolUtil.isNotEmpty(provinceCode)){
+ objectQueryWrapper.eq("provinceCode", provinceCode);
+ }
+ if(ToolUtil.isNotEmpty(cityCode)){
+ objectQueryWrapper.eq("cityCode", cityCode);
+ }
+ List<Store> list = this.list(objectQueryWrapper);
+ return list;
+ }
+
+
+ /**
+ * 获取列表数据
+ * @param lon
+ * @param lat
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public List<BaseVo> queryStoreLists(String lon, String lat) throws Exception {
+ List<BaseVo> list = new ArrayList<>();
+ if(ToolUtil.isEmpty(lon) || ToolUtil.isEmpty(lat)){
+ return list;
+ }
+ Map<String, String> geocode = gdMapGeocodingUtil.geocode(lon, lat);
+ if(null != geocode){
+ String provinceCode = geocode.get("provinceCode");
+ String cityCode = geocode.get("cityCode");
+ List<Store> stores = this.queryStorsList(provinceCode, cityCode);
+ for (Store store : stores) {
+ BaseVo baseVo = new BaseVo();
+ BeanUtils.copyProperties(store, baseVo);
+ list.add(baseVo);
+ }
+ }
+ return list;
+ }
+
+
+ /**
+ * 获取开通省市
+ * @param pcode
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public List<ProvinceAndCityVo> queryProvinceAndCity(String pcode) throws Exception {
+ if(ToolUtil.isEmpty(pcode)){
+ return this.baseMapper.queryProvince();
+ }
+ if(ToolUtil.isNotEmpty(pcode)){
+ return this.baseMapper.queryCity(pcode);
+ }
+ return null;
+ }
+
+
+ /**
+ * 获取所有开通城市
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public List<ProvinceAndCityVo> queryAllCity() throws Exception {
+ return this.baseMapper.queryCity(null);
+ }
+
+
+ /**
+ * 根据城市code获取城市列表
+ * @param cityCode
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public List<BaseVo> queryStoreByCityCode(String cityCode) throws Exception {
+ return this.baseMapper.queryStoreByCityCode(cityCode);
+ }
}
--
Gitblit v1.7.1