package com.xiaopeng.operation.controller;
|
|
import com.xiaopeng.api.model.operation.XpOpenCity;
|
import com.xiaopeng.common.core.domain.R;
|
import com.xiaopeng.common.core.web.controller.BaseController;
|
import com.xiaopeng.common.core.web.domain.AjaxResult;
|
import com.xiaopeng.operation.service.XpOpenCityService;
|
import com.xiaopeng.operation.vo.OpenCityListVO;
|
import com.xiaopeng.operation.vo.XpOpenCityVo;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.List;
|
|
@Slf4j
|
@RestController
|
@RequestMapping("/base/v1/mini-program")
|
@Api(tags = "开通城市模块")
|
public class XpOpenCityController extends BaseController {
|
|
private final XpOpenCityService xpOpenCityService;
|
|
public XpOpenCityController(XpOpenCityService xpOpenCityService) {
|
this.xpOpenCityService = xpOpenCityService;
|
}
|
|
|
|
/**
|
* 获取开通城市列表
|
* @return
|
*/
|
@ApiOperation(value = "获取开通城市列表",tags = {"小程序-开通城市列表"},response = XpOpenCityVo.class)
|
@GetMapping("/cities/list")
|
public R<XpOpenCityVo> citiesList() {
|
return R.ok(xpOpenCityService.citiesList());
|
}
|
|
/**
|
* 获取开通城市列表(管理后台使用)
|
* 用于路线规划配置的新增和编辑
|
*/
|
@ApiOperation(value = "获取开通城市列表(管理后台)", tags = {"管理后台-交易管理"}, response = OpenCityListVO.class)
|
@GetMapping("/api/v1/openCity/list")
|
public R<List<OpenCityListVO>> getOpenCityList() {
|
List<OpenCityListVO> list = xpOpenCityService.getOpenCityListForAdmin();
|
return R.ok(list);
|
}
|
|
|
/**
|
* 获取开通城市名称列表
|
*/
|
@GetMapping("/api/v1/openCity/nameList")
|
public R<List<String>> getOpenCityNameList(String openCityIds) {
|
List<XpOpenCity> list = xpOpenCityService.listByIds(Arrays.asList(openCityIds.split(",")));
|
ArrayList<String> nameLists = new ArrayList<>(list.size());
|
for (XpOpenCity xpOpenCity : list) {
|
if(xpOpenCity.getDistrictCode()!=null){
|
nameLists.add(xpOpenCity.getCityName() + "-" +xpOpenCity.getDistrictName());
|
}else {
|
nameLists.add(xpOpenCity.getCityName());
|
}
|
}
|
return R.ok(nameLists);
|
}
|
|
|
|
}
|