package com.supersavedriving.driver.modular.system.service.impl;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.supersavedriving.driver.modular.system.dao.BranchOfficeMapper;
|
import com.supersavedriving.driver.modular.system.model.BranchOffice;
|
import com.supersavedriving.driver.modular.system.service.IBranchOfficeService;
|
import com.supersavedriving.driver.modular.system.warpper.OpenCityWarpper;
|
import org.springframework.stereotype.Service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
|
/**
|
* 分公司逻辑类
|
* @author pzb
|
* @Date 2023/2/3 14:48
|
*/
|
@Service
|
public class BranchOfficeServiceImpl extends ServiceImpl<BranchOfficeMapper, BranchOffice> implements IBranchOfficeService {
|
|
|
|
/**
|
* 根据城市code获取开通区域
|
* @param cityCode 城市code
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public List<OpenCityWarpper> queryOpenDistrict(String cityCode) throws Exception {
|
List<BranchOffice> branchOffices = this.selectList(new EntityWrapper<BranchOffice>().eq("cityCode", cityCode).eq("status", 1));
|
List<OpenCityWarpper> district = new ArrayList<>();
|
for (BranchOffice branchOffice : branchOffices) {
|
OpenCityWarpper openCityWarpper = new OpenCityWarpper();
|
openCityWarpper.setCode(null != branchOffice.getDistrictCode() ? branchOffice.getDistrictCode() : branchOffice.getCityCode());
|
openCityWarpper.setName(null != branchOffice.getDistrictName() ? branchOffice.getDistrictName() : branchOffice.getCityName());
|
district.add(openCityWarpper);
|
}
|
return district;
|
}
|
}
|