|
@@ -1,12 +1,57 @@
|
|
|
package edu.travel.commodity.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import edu.travel.commodity.dto.BaseCountryDto;
|
|
|
import edu.travel.commodity.entity.BaseCountry;
|
|
|
import edu.travel.commodity.mapper.BaseCountryMapper;
|
|
|
import edu.travel.commodity.service.BaseCountryService;
|
|
|
+import edu.travel.commodity.vo.BaseCountryVo;
|
|
|
+import edu.travel.rpc.RPCBaseResponse;
|
|
|
+import edu.travel.service.SysServiceImpl;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
@Service
|
|
|
-public class BaseCountryServiceImpl extends ServiceImpl<BaseCountryMapper, BaseCountry> implements BaseCountryService {
|
|
|
+public class BaseCountryServiceImpl extends SysServiceImpl<BaseCountryMapper, BaseCountry> implements BaseCountryService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RPCBaseResponse<IPage<BaseCountryVo>> getCountryPage(BaseCountryDto baseCountryDto) {
|
|
|
+ Page<BaseCountry> baseCountryPage = new Page<>(baseCountryDto.getCurrentPage(), baseCountryDto.getPageSize());
|
|
|
+ IPage<BaseCountry> pageLink = super.getPageLink(new LambdaQueryWrapper<BaseCountry>(), baseCountryPage);
|
|
|
+ IPage<BaseCountryVo> pageVoLink = new Page<>();
|
|
|
+ BeanUtils.copyProperties(pageLink,pageVoLink);
|
|
|
+ RPCBaseResponse<IPage<BaseCountryVo>> pageRPCPageResponse = new RPCBaseResponse<>(200,"SUCCESS",pageVoLink);
|
|
|
+ return pageRPCPageResponse;
|
|
|
+ }
|
|
|
+
|
|
|
+ //国家树
|
|
|
+ @Override
|
|
|
+ public RPCBaseResponse<List<BaseCountryVo>> getCountryTree() {
|
|
|
+ //查询所有国家数据
|
|
|
+ LambdaQueryWrapper<BaseCountry> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //获取所有国际家数据
|
|
|
+ List<BaseCountry> baseCountryList = super.getListLink(queryWrapper);
|
|
|
+
|
|
|
+ //构建树形结构
|
|
|
+ List<BaseCountryVo> BaseCountryTree = buildCountryTree(baseCountryList);
|
|
|
+
|
|
|
+ //返回结果
|
|
|
+ return new RPCBaseResponse<>(200,"SUCCESS",BaseCountryTree);
|
|
|
+ }
|
|
|
+
|
|
|
+ //树构建方法
|
|
|
+ private List<BaseCountryVo> buildCountryTree(List<BaseCountry> baseCountryList) {
|
|
|
+ //map,快速查找国家VO对象
|
|
|
+ Map<Long,BaseCountryVo> countryMap = new HashMap<>();
|
|
|
+ List<BaseCountryVo> rootCountries = new ArrayList<>();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
}
|