| package com.dsh.account.controller; | 
|   | 
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
| import com.dsh.account.entity.CityManager; | 
| import com.dsh.account.entity.TStoreStaff; | 
| import com.dsh.account.feignclient.other.model.Store; | 
| import com.dsh.account.service.ICityManagerService; | 
| import com.dsh.account.service.TStoreStaffService; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import javax.annotation.Resource; | 
| import java.util.ArrayList; | 
| import java.util.Comparator; | 
| import java.util.List; | 
| import java.util.TreeSet; | 
| import java.util.stream.Collectors; | 
|   | 
| /** | 
|  * @author zhibing.pu | 
|  * @Date 2023/8/1 17:06 | 
|  */ | 
| @RestController | 
| @RequestMapping("") | 
| public class CityManagerController { | 
|   | 
|     @Resource | 
|     private ICityManagerService cityManagerService; | 
|     @Autowired | 
|     private TStoreStaffService storeStaffService; | 
|   | 
|     /** | 
|      * 根据管理员id获取详情信息 | 
|      */ | 
|     @RequestMapping("/cityManager/getStoreById") | 
|     public CityManager getStoreById(@RequestParam Integer id) { | 
|         return cityManagerService.getOne(new QueryWrapper<CityManager>().eq("id", id)); | 
|     } | 
|   | 
|     /** | 
|      * 获取已有城市管理的省、市 | 
|      */ | 
|     @ResponseBody | 
|     @RequestMapping("/cityManager/listAll") | 
|     public List<CityManager> listAll() { | 
|         return cityManagerService.listAll(); | 
|     } | 
|   | 
|     /** | 
|      * 选择省 展示市 | 
|      */ | 
|     @RequestMapping("/cityManager/getCity") | 
|     @ResponseBody | 
|     public List<CityManager> getCity(@RequestBody String province) { | 
|         List<CityManager> province1 = cityManagerService.list(new QueryWrapper<CityManager>().eq("province", province)); | 
|         List<CityManager> distinctCities = province1.stream() | 
|                 .collect(Collectors.collectingAndThen( | 
|                         Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CityManager::getCity))), | 
|                         ArrayList::new | 
|                 )); | 
|   | 
|         return distinctCities; | 
|     } | 
|   | 
|     /** | 
|      * 选择市区 展示全部账号 | 
|      */ | 
|     @RequestMapping("/cityManager/getAccount") | 
|     @ResponseBody | 
|     public List<CityManager> getAccount(@RequestBody String city) { | 
|         return cityManagerService.list(new QueryWrapper<CityManager>().eq("city", city).ne("state", 2).ne("state", 3)); | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 根据id获取数据 | 
|      * | 
|      * @param id | 
|      * @return | 
|      */ | 
|     @ResponseBody | 
|     @PostMapping("/cityManager/queryCityManagerById") | 
|     public CityManager queryCityManagerById(@RequestBody Integer id) { | 
|         return cityManagerService.getById(id); | 
|     } | 
|   | 
| } |