From fdb10aeced87df8fdb8d31cb4812898a4a499b48 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 2 Oct 2023 18:30:14 +0800 Subject: [PATCH] =?UTF-8?q?trade=EF=BC=9A=E4=BC=98=E5=8C=96=E8=BF=90?= =?UTF-8?q?=E8=B4=B9=E6=A8=A1=E7=89=88=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... DeliveryExpressTemplateChargeBaseVO.java} | 5 +- .../DeliveryExpressTemplateCreateReqVO.java | 5 +- .../DeliveryExpressTemplateDetailRespVO.java | 4 +- ...=> DeliveryExpressTemplateFreeBaseVO.java} | 2 +- .../DeliveryExpressTemplateUpdateReqVO.java | 30 +---- .../DeliveryExpressTemplateConvert.java | 21 ++- .../DeliveryExpressTemplateServiceImpl.java | 125 +++++++----------- .../controller/admin/ip/AreaController.java | 30 +---- .../admin/ip/vo/AreaNodeSimpleRespVO.java | 19 --- .../module/system/convert/ip/AreaConvert.java | 13 -- 10 files changed, 70 insertions(+), 184 deletions(-) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/{ExpressTemplateChargeBaseVO.java => DeliveryExpressTemplateChargeBaseVO.java} (85%) rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/{ExpressTemplateFreeBaseVO.java => DeliveryExpressTemplateFreeBaseVO.java} (95%) delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeSimpleRespVO.java diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateChargeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java similarity index 85% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateChargeBaseVO.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java index 7fb1111d57..efb15c894a 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateChargeBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java @@ -11,7 +11,10 @@ import java.util.List; * 快递运费模板运费设置 Base VO,提供给添加运费模板使用 */ @Data -public class ExpressTemplateChargeBaseVO { +public class DeliveryExpressTemplateChargeBaseVO { + + @Schema(description = "编号", example = "6592", hidden = true) // 由于想简单一点,复用这个 VO 在更新操作,所以 hidden 为 false + private Long id; @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") @NotEmpty(message = "区域编号列表不能为空") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java index 26173a9771..c5eeaebc98 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java @@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import javax.validation.Valid; -import java.util.Collections; import java.util.List; @Schema(description = "管理后台 - 快递运费模板创建 Request VO") @@ -17,10 +16,10 @@ public class DeliveryExpressTemplateCreateReqVO extends DeliveryExpressTemplateB @Schema(description = "区域运费列表") @Valid - private List templateCharge; + private List charges; @Schema(description = "包邮区域列表") @Valid - private List templateFree; + private List frees; } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java index 44cb042f96..272ab59a0a 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java @@ -17,9 +17,9 @@ public class DeliveryExpressTemplateDetailRespVO extends DeliveryExpressTemplate private Long id; @Schema(description = "运费模板运费设置", requiredMode = Schema.RequiredMode.REQUIRED) - private List templateCharge; + private List charges; @Schema(description = "运费模板包邮区域", requiredMode = Schema.RequiredMode.REQUIRED) - private List templateFree; + private List frees; } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateFreeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java similarity index 95% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateFreeBaseVO.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java index 9334abf072..b3e0f12b55 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateFreeBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java @@ -11,7 +11,7 @@ import java.util.List; * 快递运费模板包邮 Base VO,提供给添加运费模板使用 */ @Data -public class ExpressTemplateFreeBaseVO { +public class DeliveryExpressTemplateFreeBaseVO { @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") @NotEmpty(message = "区域编号列表不能为空") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java index b8b3722714..4c17745243 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java @@ -21,36 +21,10 @@ public class DeliveryExpressTemplateUpdateReqVO extends DeliveryExpressTemplateB @Schema(description = "区域运费列表") @Valid - private List templateCharge; + private List charges; @Schema(description = "包邮区域列表") @Valid - private List templateFree; + private List frees; - @Schema(description = "管理后台 - 快递运费模板区域运费更新 Request VO") - @Data - public static class ExpressTemplateChargeUpdateVO extends ExpressTemplateChargeBaseVO { - - @Schema(description = "编号", example = "6592") - private Long id; - - // TODO @jason:这几个字段,应该不通过前端传递,而是后端查询后去赋值的 - @Schema(description = "配送模板编号", example = "1") - private Long templateId; - - @Schema(description = "配送计费方式", example = "1") - private Integer chargeMode; - - } - - @Schema(description = "管理后台 - 快递运费模板包邮区域更新 Request VO") - @Data - public static class ExpressTemplateFreeUpdateVO extends ExpressTemplateFreeBaseVO { - - @Schema(description = "编号", example = "6592") - private Long id; - - @Schema(description = "配送模板编号", example = "1") - private Long templateId; - } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java index 665dc787df..b917d874bb 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java @@ -42,36 +42,32 @@ public interface DeliveryExpressTemplateConvert { List chargeList, List freeList) { DeliveryExpressTemplateDetailRespVO respVO = convert2(bean); - respVO.setTemplateCharge(convertTemplateChargeList(chargeList)); - respVO.setTemplateFree(convertTemplateFreeList(freeList)); + respVO.setCharges(convertTemplateChargeList(chargeList)); + respVO.setFrees(convertTemplateFreeList(freeList)); return respVO; } // ========== Template Charge ========== - DeliveryExpressTemplateChargeDO convertTemplateCharge(Long templateId, Integer chargeMode, ExpressTemplateChargeBaseVO vo); - - DeliveryExpressTemplateChargeDO convertTemplateCharge(DeliveryExpressTemplateUpdateReqVO.ExpressTemplateChargeUpdateVO vo); + DeliveryExpressTemplateChargeDO convertTemplateCharge(Long templateId, Integer chargeMode, DeliveryExpressTemplateChargeBaseVO vo); DeliveryExpressTemplateRespBO.Charge convertTemplateCharge(DeliveryExpressTemplateChargeDO bean); - default List convertTemplateChargeList(Long templateId, Integer chargeMode, List list) { + default List convertTemplateChargeList(Long templateId, Integer chargeMode, List list) { return CollectionUtils.convertList(list, vo -> convertTemplateCharge(templateId, chargeMode, vo)); } // ========== Template Free ========== - DeliveryExpressTemplateFreeDO convertTemplateFree(Long templateId, ExpressTemplateFreeBaseVO vo); - - DeliveryExpressTemplateFreeDO convertTemplateFree(DeliveryExpressTemplateUpdateReqVO.ExpressTemplateFreeUpdateVO vo); + DeliveryExpressTemplateFreeDO convertTemplateFree(Long templateId, DeliveryExpressTemplateFreeBaseVO vo); DeliveryExpressTemplateRespBO.Free convertTemplateFree(DeliveryExpressTemplateFreeDO bean); - List convertTemplateChargeList(List list); + List convertTemplateChargeList(List list); - List convertTemplateFreeList(List list); + List convertTemplateFreeList(List list); - default List convertTemplateFreeList(Long templateId, List list) { + default List convertTemplateFreeList(Long templateId, List list) { return CollectionUtils.convertList(list, vo -> convertTemplateFree(templateId, vo)); } @@ -93,4 +89,5 @@ public interface DeliveryExpressTemplateConvert { }); return result; } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java index 0cfe5e8158..5dec5abcff 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java @@ -2,11 +2,10 @@ package cn.iocoder.yudao.module.trade.service.delivery; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplatePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateUpdateReqVO; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; @@ -50,21 +49,21 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla validateTemplateNameUnique(createReqVO.getName(), null); // 插入 - DeliveryExpressTemplateDO deliveryExpressTemplate = INSTANCE.convert(createReqVO); - expressTemplateMapper.insert(deliveryExpressTemplate); + DeliveryExpressTemplateDO template = INSTANCE.convert(createReqVO); + expressTemplateMapper.insert(template); // 插入运费模板计费表 - if (CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) { + if (CollUtil.isNotEmpty(createReqVO.getCharges())) { expressTemplateChargeMapper.insertBatch( - INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge()) + INSTANCE.convertTemplateChargeList(template.getId(), createReqVO.getChargeMode(), createReqVO.getCharges()) ); } // 插入运费模板包邮表 - if (CollUtil.isNotEmpty(createReqVO.getTemplateFree())) { + if (CollUtil.isNotEmpty(createReqVO.getFrees())) { expressTemplateFreeMapper.insertBatch( - INSTANCE.convertTemplateFreeList(deliveryExpressTemplate.getId(), createReqVO.getTemplateFree()) + INSTANCE.convertTemplateFreeList(template.getId(), createReqVO.getFrees()) ); } - return deliveryExpressTemplate.getId(); + return template.getId(); } @Override @@ -76,76 +75,54 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId()); // 更新运费从表 - updateExpressTemplateCharge(updateReqVO); + updateExpressTemplateCharge(updateReqVO.getId(), updateReqVO.getChargeMode(), updateReqVO.getCharges()); // 更新包邮从表 - updateExpressTemplateFree(updateReqVO); + updateExpressTemplateFree(updateReqVO.getId(), updateReqVO.getFrees()); // 更新模板主表 DeliveryExpressTemplateDO updateObj = INSTANCE.convert(updateReqVO); expressTemplateMapper.updateById(updateObj); } - private void updateExpressTemplateFree(DeliveryExpressTemplateUpdateReqVO updateReqVO) { - // 1.1 获得新增/修改的区域列表 - List oldFreeList = expressTemplateFreeMapper.selectListByTemplateId(updateReqVO.getId()); - List newFreeList = updateReqVO.getTemplateFree(); - List addFreeList = new ArrayList<>(newFreeList.size()); // 新增包邮区域列表 - List updateFreeList = new ArrayList<>(newFreeList.size()); // 更新包邮区域列表 - for (DeliveryExpressTemplateUpdateReqVO.ExpressTemplateFreeUpdateVO item : newFreeList) { - if (Objects.nonNull(item.getId())) { - updateFreeList.add(INSTANCE.convertTemplateFree(item)); - } else { - item.setTemplateId(updateReqVO.getId()); - addFreeList.add(INSTANCE.convertTemplateFree(item)); - } - } - // 1.2 新增 - if (CollUtil.isNotEmpty(addFreeList)) { - expressTemplateFreeMapper.insertBatch(addFreeList); - } - // 1.3 修改 - if (CollUtil.isNotEmpty(updateFreeList)) { - expressTemplateFreeMapper.updateBatch(updateFreeList); - } + private void updateExpressTemplateFree(Long templateId, List frees) { + // 第一步,对比新老数据,获得添加、修改、删除的列表 + List oldList = expressTemplateFreeMapper.selectListByTemplateId(templateId); + List newList = INSTANCE.convertTemplateFreeList(templateId, frees); + List> diffList = CollectionUtils.diffList(oldList, newList, + (oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getTemplateId())); - // 2. 删除 - Set deleteFreeIds = convertSet(oldFreeList, DeliveryExpressTemplateFreeDO::getId); - deleteFreeIds.removeAll(convertSet(updateFreeList, DeliveryExpressTemplateFreeDO::getId)); - if (CollUtil.isNotEmpty(deleteFreeIds)) { - expressTemplateFreeMapper.deleteBatchIds(deleteFreeIds); + // 第二步,批量添加、修改、删除 + if (CollUtil.isNotEmpty(diffList.get(0))) { + expressTemplateFreeMapper.insertBatch(diffList.get(0)); + } + if (CollUtil.isNotEmpty(diffList.get(1))) { + expressTemplateFreeMapper.updateBatch(diffList.get(1)); + } + if (CollUtil.isNotEmpty(diffList.get(2))) { + expressTemplateFreeMapper.deleteBatchIds(convertList(diffList.get(2), DeliveryExpressTemplateFreeDO::getId)); } } - private void updateExpressTemplateCharge(DeliveryExpressTemplateUpdateReqVO updateReqVO) { - // 1.1 获得新增/修改的区域列表 - List oldChargeList = expressTemplateChargeMapper.selectListByTemplateId(updateReqVO.getId()); - List newChargeList = updateReqVO.getTemplateCharge(); - List addList = new ArrayList<>(newChargeList.size()); // 新增运费区域列表 - List updateList = new ArrayList<>(newChargeList.size()); // 更新运费区域列表 - for (DeliveryExpressTemplateUpdateReqVO.ExpressTemplateChargeUpdateVO item : newChargeList) { - if (item.getId() != null) { - // 计费模式以主表为准 - item.setChargeMode(updateReqVO.getChargeMode()); - updateList.add(INSTANCE.convertTemplateCharge(item)); - } else { - item.setTemplateId(updateReqVO.getId()); - item.setChargeMode(updateReqVO.getChargeMode()); - addList.add(INSTANCE.convertTemplateCharge(item)); + private void updateExpressTemplateCharge(Long templateId, Integer chargeMode, List charges) { + // 第一步,对比新老数据,获得添加、修改、删除的列表 + List oldList = expressTemplateChargeMapper.selectListByTemplateId(templateId); + List newList = INSTANCE.convertTemplateChargeList(templateId, chargeMode, charges); + List> diffList = diffList(oldList, newList, (oldVal, newVal) -> { + boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId()); + if (same) { + newVal.setChargeMode(chargeMode); // 更新下收费模式 } - } - // 1.2 新增 - if (CollUtil.isNotEmpty(addList)) { - expressTemplateChargeMapper.insertBatch(addList); - } - // 1.3 修改 - if (CollUtil.isNotEmpty(updateList)) { - expressTemplateChargeMapper.updateBatch(updateList); - } + return same; + }); - // 2. 删除 - Set deleteChargeIds = convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId); - deleteChargeIds.removeAll(convertSet(updateList, DeliveryExpressTemplateChargeDO::getId)); - if (CollUtil.isNotEmpty(deleteChargeIds)) { - expressTemplateChargeMapper.deleteBatchIds(deleteChargeIds); + // 第二步,批量添加、修改、删除 + if (CollUtil.isNotEmpty(diffList.get(0))) { + expressTemplateChargeMapper.insertBatch(diffList.get(0)); + } + if (CollUtil.isNotEmpty(diffList.get(1))) { + expressTemplateChargeMapper.updateBatch(diffList.get(1)); + } + if (CollUtil.isNotEmpty(diffList.get(2))) { + expressTemplateChargeMapper.deleteBatchIds(convertList(diffList.get(2), DeliveryExpressTemplateChargeDO::getId)); } } @@ -238,14 +215,4 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla return INSTANCE.convertMap(areaId, templateList, chargeList, freeList); } - private DeliveryExpressTemplateRespBO.Charge findMatchExpressTemplateCharge( - List templateChargeList, Integer areaId) { - return INSTANCE.convertTemplateCharge(findFirst(templateChargeList, item -> item.getAreaIds().contains(areaId))); - } - - private DeliveryExpressTemplateRespBO.Free findMatchExpressTemplateFree( - List templateFreeList, Integer areaId) { - return INSTANCE.convertTemplateFree(findFirst(templateFreeList, item -> item.getAreaIds().contains(areaId))); - } - } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java index b3bc0c03c9..2d5c766fdb 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java @@ -6,17 +6,17 @@ import cn.iocoder.yudao.framework.ip.core.Area; import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.framework.ip.core.utils.IPUtils; import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; -import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeSimpleRespVO; import cn.iocoder.yudao.module.system.convert.ip.AreaConvert; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +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; -import java.util.ArrayList; import java.util.List; -import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -34,28 +34,6 @@ public class AreaController { return success(AreaConvert.INSTANCE.convertList(area.getChildren())); } - @GetMapping("/get-children") - @Operation(summary = "获得地区的下级区域") - @Parameter(name = "id", description = "区域编号", required = true, example = "150000") - public CommonResult> getChildren(@RequestParam("id") Integer id) { - Area area = AreaUtils.getArea(id); - Assert.notNull(area, String.format("获取不到 id : %d 的区域", id)); - return success(AreaConvert.INSTANCE.convertList2(area.getChildren())); - } - - // 4)方法改成 getAreaChildrenList 获得子节点们;5)url 可以已改成 children-list - //@芋艿 是不是叫 getAreaListByIds 更合适。 因为不一定是子节点。 用于前端树选择获取缓存数据。 见 - @GetMapping("/get-by-ids") - @Operation(summary = "通过区域 ids 获得地区列表") - @Parameter(name = "ids", description = "区域编号 ids", required = true, example = "1,150000") - public CommonResult> getAreaListByIds(@RequestParam("ids") Set ids) { - List areaList = new ArrayList<>(ids.size()); - for (Integer areaId : ids) { - areaList.add(AreaUtils.getArea(areaId)); - } - return success(AreaConvert.INSTANCE.convertList2(areaList)); - } - @GetMapping("/get-by-ip") @Operation(summary = "获得 IP 对应的地区名") @Parameter(name = "ip", description = "IP", required = true) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeSimpleRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeSimpleRespVO.java deleted file mode 100644 index b7bf8e8a86..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeSimpleRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.system.controller.admin.ip.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 简洁的地区节点 Response VO") -@Data -public class AreaNodeSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110000") - private Integer id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "北京") - private String name; - - @Schema(description = "是否叶子节点", example = "false") - private Boolean leaf; - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java index 4ffa374e79..ae98bd25d2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java @@ -1,16 +1,12 @@ package cn.iocoder.yudao.module.system.convert.ip; import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; -import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeSimpleRespVO; import cn.iocoder.yudao.module.system.controller.app.ip.vo.AppAreaNodeRespVO; import org.mapstruct.Mapper; -import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import java.util.List; -import java.util.Objects; @Mapper public interface AreaConvert { @@ -19,15 +15,6 @@ public interface AreaConvert { List convertList(List list); - List convertList2(List list); - - @Mapping(source = "type", target = "leaf") - AreaNodeSimpleRespVO convert(Area area); - - default Boolean convertAreaType(Integer type) { - return Objects.equals(AreaTypeEnum.DISTRICT.getType(), type); - } - List convertList3(List list); }