|
|
@@ -0,0 +1,69 @@
|
|
|
+package com.fs.app.controller;
|
|
|
+
|
|
|
+import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.his.domain.FsCity;
|
|
|
+import com.fs.his.service.IFsCityService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 城市Controller
|
|
|
+ *
|
|
|
+ * @author fs
|
|
|
+ * @date 2023-06-02
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/app/city")
|
|
|
+public class FsCityController extends AppBaseController
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private IFsCityService fsCityService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取城市详细信息
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/cityId")
|
|
|
+ public R getInfo(@RequestParam("cityName") String cityName)
|
|
|
+ {
|
|
|
+ String key = "city:citySName:" + cityName;
|
|
|
+ String cityId = redisCache.getCacheObject(key);
|
|
|
+ if (StringUtils.isEmpty(cityId)) {
|
|
|
+ FsCity fsCity = new FsCity();
|
|
|
+ fsCity.setCitySname(cityName);
|
|
|
+ cityId = fsCityService.selectByFsCity(fsCity);
|
|
|
+ redisCache.setCacheObject(key, cityId);
|
|
|
+ }
|
|
|
+ return R.ok().put("cityId",cityId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取城市详细信息
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/process")
|
|
|
+ public R getInfo(@RequestParam("province") String province,@RequestParam("city") String city,@RequestParam("district") String district)
|
|
|
+ {
|
|
|
+ String sName = province + city + district;
|
|
|
+ String key = "city:citySName:" + province + ":" + city + ":" + district;
|
|
|
+ String cityId = redisCache.getCacheObject(key);
|
|
|
+ if (StringUtils.isEmpty(cityId)) {
|
|
|
+ FsCity fsCity = new FsCity();
|
|
|
+ fsCity.setCitySname(sName);
|
|
|
+ cityId = fsCityService.selectByFsCity(fsCity);
|
|
|
+ if (StringUtils.isEmpty(cityId)) {
|
|
|
+ cityId = fsCityService.likeByCityDistrict(city, district);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(cityId)) {
|
|
|
+ return R.error("获取城市信息失败!");
|
|
|
+ }
|
|
|
+ redisCache.setCacheObject(key, cityId);
|
|
|
+ }
|
|
|
+ return R.ok().put("cityId",cityId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|