| | |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.ReverseGeocodeVo; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private IUserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<BaseWarpper> queryOpenCity(Integer uid, Integer language) throws Exception { |
| | | if(null != uid){ |
| | | if(null == language && null != uid){ |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | language = userInfo.getLanguage(); |
| | | } |
| | |
| | | baseWarpper.setName(language == 1 ? city.getChineseName() : language == 2 ? city.getEnglishName() : language == 3 ? city.getFrenchName() : city.getEnglishName()); |
| | | baseWarpper.setLon(null != c.getLon() ? c.getLon() : 0); |
| | | baseWarpper.setLat(null != c.getLat() ? c.getLat() : 0); |
| | | baseWarpper.setContent(language == 1 ? city.getCountryChineseName() : language == 2 ? city.getCountryEnglishName() : language == 3 ? city.getCountryFrenchName() : city.getEnglishName()); |
| | | list.add(baseWarpper); |
| | | } |
| | | return list; |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public boolean openCity(Double lat, Double lnt) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt); |
| | | public City openCity(Integer uid, Double lat, Double lnt, Integer language) throws Exception { |
| | | if(null == language){ |
| | | language = 2; |
| | | } |
| | | String tripId = redisUtil.getValue("trip" + uid); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt, tripId); |
| | | if(null == reverseGeocode){ |
| | | return false; |
| | | return null; |
| | | } |
| | | AddressComponentsVo[] addressComponentsVos = reverseGeocode.getAddressComponentsVos(); |
| | | String[] city = new String[addressComponentsVos.length]; |
| | |
| | | } |
| | | List<OpenCity> openCities = openCityMapper.queryByCode(city); |
| | | if(openCities.size() == 0){ |
| | | return false; |
| | | return null; |
| | | } |
| | | return true; |
| | | City city1 = cityService.selectById(openCities.get(0).getCityId()); |
| | | return city1; |
| | | } |
| | | } |