diff --git a/sql/mysql/optional/mall.sql b/sql/mysql/optional/mall.sql index ca9f584b2..1cfda1722 100644 --- a/sql/mysql/optional/mall.sql +++ b/sql/mysql/optional/mall.sql @@ -350,7 +350,7 @@ DROP TABLE IF EXISTS `trade_delivery_express_template_free`; CREATE TABLE `trade_delivery_express_template_free` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `template_id` bigint NOT NULL COMMENT '快递运费模板编号', - `area_id` int NOT NULL COMMENT '包邮区域 id', + `area_ids` varchar(100) NOT NULL COMMENT '包邮区域 ids', `free_price` int NOT NULL COMMENT '包邮金额,单位:分', `free_count` int NOT NULL DEFAULT 0 COMMENT '包邮件数,', `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', @@ -369,7 +369,7 @@ DROP TABLE IF EXISTS `trade_delivery_express_template_charge`; CREATE TABLE `trade_delivery_express_template_charge` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,自增', `template_id` bigint NOT NULL COMMENT '快递运费模板编号', - `area_id` int NOT NULL COMMENT '配送区域 id', + `area_ids` varchar(100) NOT NULL COMMENT '配送区域 ids', `charge_mode` tinyint NOT NULL COMMENT '配送计费方式', `start_count` double NOT NULL COMMENT '首件数量', `start_price` int NOT NULL COMMENT '起步价,单位:分', @@ -501,7 +501,7 @@ INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, ` INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2029, 'Banner删除', 'market:banner:delete', 3, 4, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0'); INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2164, '配送管理', '', 1, 0, 2072, 'delivery', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:18:02', '1', '2023-05-18 09:48:48', b'0'); INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2165, '快递发货', '', 1, 0, 2164, 'express', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:22:06', '1', '2023-05-18 09:22:06', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2166, '门店自提', '', 1, 1, 2164, 'pick-up-store', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:23:14', '1', '2023-05-18 09:23:14', b'0'); +INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2166, '门店自提', '', 1, 1, 2164, 'pick-up', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:23:14', '1', '2023-05-18 09:23:14', b'0'); INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2167, '快递公司', '', 2, 0, 2165, 'express', '', 'mall/trade/delivery/express/index', 'Express', 0, b'1', b'1', b'1', '1', '2023-05-18 09:27:21', '1', '2023-05-18 22:11:14', b'0'); INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2168, '快递公司查询', 'trade:delivery:express:query', 3, 1, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0'); INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2169, '快递公司创建', 'trade:delivery:express:create', 3, 2, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0'); diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java index 88ba22d87..2ac7278a4 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java @@ -45,4 +45,10 @@ public class StrUtils { return Arrays.stream(longs).boxed().collect(Collectors.toList()); } + public static List splitToInteger(String value, CharSequence separator) { + int[] integers = StrUtil.splitToInt(value, separator); + return Arrays.stream(integers).boxed().collect(Collectors.toList()); + } + + } diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java index 87cf0dddc..7788d2895 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java @@ -113,10 +113,20 @@ public interface BaseMapperX extends MPJBaseMapper { Db.saveBatch(entities, size); } + // @芋艿 是不是叫 updateByDo 或者 updateByEntity 更合适 default void updateBatch(T update) { update(update, new QueryWrapper<>()); } + /** + * 根据ID 批量更新,适合大量数据更新 + * + * @param entities 实体们 + */ + default void updateBatch(Collection entities) { + Db.updateBatchById(entities); + } + default void updateBatch(Collection entities, int size) { Db.updateBatchById(entities, size); } diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/IntegerListTypeHandler.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/IntegerListTypeHandler.java new file mode 100644 index 000000000..18455ba11 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/IntegerListTypeHandler.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.framework.mybatis.core.type; + +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.common.util.string.StrUtils; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; +import org.apache.ibatis.type.TypeHandler; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; + +/** + * List 的类型转换器实现类,对应数据库的 varchar 类型 + * + * @author jason + */ +@MappedJdbcTypes(JdbcType.VARCHAR) +@MappedTypes(List.class) +public class IntegerListTypeHandler implements TypeHandler> { + + private static final String COMMA = ","; + + @Override + public void setParameter(PreparedStatement ps, int i, List strings, JdbcType jdbcType) throws SQLException { + ps.setString(i, CollUtil.join(strings, COMMA)); + } + + @Override + public List getResult(ResultSet rs, String columnName) throws SQLException { + String value = rs.getString(columnName); + return getResult(value); + } + + @Override + public List getResult(ResultSet rs, int columnIndex) throws SQLException { + String value = rs.getString(columnIndex); + return getResult(value); + } + + @Override + public List getResult(CallableStatement cs, int columnIndex) throws SQLException { + String value = cs.getString(columnIndex); + return getResult(value); + } + + private List getResult(String value) { + if (value == null) { + return null; + } + return StrUtils.splitToInteger(value, COMMA); + } +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java index b245ec860..5b3a84284 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java @@ -74,7 +74,7 @@ public class DeliveryExpressController { return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult)); } - // TODO @jason:运费模版,可以去掉哈,没啥用; + // TODO @jason:运费模版,@芋艿 你的意思是运费模板导出没有必要吧。已经去掉了。这个是快递公司导出 @GetMapping("/export-excel") @Operation(summary = "导出快递公司 Excel") @PreAuthorize("@ss.hasPermission('trade:delivery:express:export')") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java index 9ea4c4d1b..3471b2233 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java @@ -84,17 +84,4 @@ public class DeliveryExpressTemplateController { PageResult pageResult = deliveryExpressTemplateService.getDeliveryExpressTemplatePage(pageVO); return success(DeliveryExpressTemplateConvert.INSTANCE.convertPage(pageResult)); } - - @GetMapping("/export-excel") - @Operation(summary = "导出快递运费模板 Excel") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:export')") - @OperateLog(type = EXPORT) - public void exportDeliveryExpressTemplateExcel(@Valid DeliveryExpressTemplateExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(exportReqVO); - // 导出 Excel - List datas = DeliveryExpressTemplateConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "快递运费模板.xls", "数据", DeliveryExpressTemplateExcelVO.class, datas); - } - } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressExcelVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressExcelVO.java index 45d92aa43..4df6c0d7d 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressExcelVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressExcelVO.java @@ -1,5 +1,8 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; @@ -7,8 +10,6 @@ import java.time.LocalDateTime; /** * 快递公司 Excel VO - * - * @author jason */ @Data public class DeliveryExpressExcelVO { @@ -28,9 +29,9 @@ public class DeliveryExpressExcelVO { @ExcelProperty("排序") private Integer sort; - @ExcelProperty("状态") - // TODO @jason:可以使用 @DictFormat(DictTypeConstants.COMMON_STATUS) - private Byte status; + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat(DictTypeConstants.COMMON_STATUS) + private Integer status; @ExcelProperty("创建时间") private LocalDateTime createTime; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateExcelVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateExcelVO.java deleted file mode 100644 index 60ae499f0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateExcelVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递运费模板 Excel VO - * - * @author jason - */ -@Data -public class DeliveryExpressTemplateExcelVO { - - @ExcelProperty("编号,自增") - private Long id; - - @ExcelProperty("模板名称") - private String name; - - @ExcelProperty("配送计费方式 1:按件 2:按重量 3:按体积") - private Integer chargeMode; - - @ExcelProperty("排序") - private Integer sort; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateExportReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateExportReqVO.java deleted file mode 100644 index c02133165..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateExportReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import java.time.LocalDateTime; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递运费模板 Excel 导出 Request VO,参数和 DeliveryExpressTemplatePageReqVO 是一致的") -@Data -public class DeliveryExpressTemplateExportReqVO { - - @Schema(description = "模板名称", example = "王五") - private String name; - - @Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积") - private Integer chargeMode; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeBaseVO.java index 5da76845e..8bd2617b7 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeBaseVO.java @@ -3,19 +3,19 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.List; /** * 快递运费模板运费设置 Base VO,提供给添加运费模板使用 - * - * @author jason */ @Data public class ExpressTemplateChargeBaseVO { - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "区域编号不能为空") - private Integer areaId; + @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") + @NotEmpty(message = "区域编号列表不能为空") + private List areaIds; @Schema(description = "首件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") @NotNull(message = "首件数量不能为空") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeUpdateVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeUpdateVO.java index a0fb2315c..995ea4a18 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeUpdateVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeUpdateVO.java @@ -3,9 +3,7 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -/** - * @author jason - */ + @Data public class ExpressTemplateChargeUpdateVO extends ExpressTemplateChargeBaseVO { diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeBaseVO.java index ff6dbbcaa..7523b0f53 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeBaseVO.java @@ -3,19 +3,19 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.List; /** * 快递运费模板包邮 Base VO,提供给添加运费模板使用 - * - * @author jason */ @Data public class ExpressTemplateFreeBaseVO { - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "区域编号不能为空") - private Integer areaId; + @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") + @NotEmpty(message = "区域编号列表不能为空") + private List areaIds; @Schema(description = "包邮金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "5000") @NotNull(message = "包邮金额不能为空") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeUpdateVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeUpdateVO.java index 56485b579..e0c7e47b0 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeUpdateVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeUpdateVO.java @@ -5,8 +5,6 @@ import lombok.Data; /** * 快递运费模板包邮 更新 VO - * - * @author jason */ @Data public class ExpressTemplateFreeUpdateVO extends ExpressTemplateFreeBaseVO { diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java index 768530ace..e896962a2 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java @@ -16,7 +16,7 @@ import org.mapstruct.factory.Mappers; /** * 快递公司 Convert * - * @author 芋道源码 + * @author jason */ @Mapper public interface DeliveryExpressConvert { 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 d4d23cb0a..7e2a51cc1 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 @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.convert.delivery; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.*; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; @@ -16,7 +17,7 @@ import java.util.List; /** * 快递运费模板 Convert * - * @author 芋道源码 + * @author jason */ @Mapper public interface DeliveryExpressTemplateConvert { @@ -37,8 +38,6 @@ public interface DeliveryExpressTemplateConvert { PageResult convertPage(PageResult page); - List convertList02(List list); - default DeliveryExpressTemplateRespVO convert(DeliveryExpressTemplateDO bean, List chargeList, List freeList){ @@ -55,15 +54,7 @@ public interface DeliveryExpressTemplateConvert { DeliveryExpressTemplateChargeDO convertTemplateCharge(ExpressTemplateChargeUpdateVO vo); default List convertTemplateChargeList(Long templateId, Integer chargeMode, List list) { - // TODO @jason:可以使用 CollectionUtils.convertList,本质上就是 stream convert list - if(CollUtil.isEmpty(list)){ - return Collections.emptyList(); - } - List templateChargeList = new ArrayList<>(list.size()); - for (ExpressTemplateChargeBaseVO item : list) { - templateChargeList.add(convertTemplateCharge(templateId, chargeMode, item)); - } - return templateChargeList; + return CollectionUtils.convertList(list, vo -> convertTemplateCharge(templateId, chargeMode, vo)); } // ========== Template Free ========== @@ -76,17 +67,8 @@ public interface DeliveryExpressTemplateConvert { List convertTemplateFreeList(List list); - // TODO @jason:, List,中间一个空格哈。代码的空格和空行要注意,嘿嘿~ - default List convertTemplateFreeList(Long templateId, List list) { - // TODO @jason:可以使用 CollectionUtils.convertList,本质上就是 stream convert list - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - List templateFreeList = new ArrayList<>(list.size()); - for (ExpressTemplateFreeBaseVO item : list) { - templateFreeList.add(convertTemplateFree(templateId, item)); - } - return templateFreeList; + default List convertTemplateFreeList(Long templateId, List list) { + return CollectionUtils.convertList(list, vo -> convertTemplateFree(templateId, vo)); } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java index 803576503..c3bb30e9a 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java @@ -1,17 +1,21 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import java.util.List; + /** * 快递运费模板计费配置 DO * * @author jason */ -@TableName(value ="trade_delivery_express_template_charge") +@TableName(value ="trade_delivery_express_template_charge", autoResultMap = true) @KeySequence("trade_delivery_express_template_charge_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data public class DeliveryExpressTemplateChargeDO extends BaseDO { @@ -30,9 +34,10 @@ public class DeliveryExpressTemplateChargeDO extends BaseDO { private Long templateId; /** - * 配送区域 + * 配送区域编号列表 */ - private Integer areaId; + @TableField(typeHandler = IntegerListTypeHandler.class) + private List areaIds; /** * 配送计费方式 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java index 351a1dd24..07eef1be2 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java @@ -1,17 +1,21 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import java.util.List; + /** * 快递运费模板包邮配置 DO * * @author jason */ -@TableName(value ="trade_delivery_express_template_free") +@TableName(value ="trade_delivery_express_template_free", autoResultMap = true) @KeySequence("trade_delivery_express_template_free_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data public class DeliveryExpressTemplateFreeDO extends BaseDO { @@ -29,10 +33,12 @@ public class DeliveryExpressTemplateFreeDO extends BaseDO { */ private Long templateId; + /** - * 包邮区域id + * 配送区域编号列表 */ - private Integer areaId; + @TableField(typeHandler = IntegerListTypeHandler.class) + private List areaIds; /** * 包邮金额,单位:分 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java index ed0314018..dc96b24f2 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java @@ -14,10 +14,6 @@ import java.util.List; @Mapper public interface DeliveryExpressTemplateChargeMapper extends BaseMapperX { - @Repository - class BatchInsertMapper extends ServiceImpl { - } - default List selectListByTemplateId(Long templateId){ return selectList(new LambdaQueryWrapper() .eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId)); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java index 97a4d31d3..58caaf9af 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java @@ -14,10 +14,6 @@ import java.util.List; @Mapper public interface DeliveryExpressTemplateFreeMapper extends BaseMapperX { - @Repository - class BatchInsertMapper extends ServiceImpl { - } - default List selectListByTemplateId(Long templateId) { return selectList(new LambdaQueryWrapper() .eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId)); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java index 85b52851e..734298042 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java @@ -4,14 +4,10 @@ package cn.iocoder.yudao.module.trade.dal.mysql.delivery; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressTemplateExportReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressTemplatePageReqVO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.ibatis.annotations.Mapper; -import java.util.List; - @Mapper public interface DeliveryExpressTemplateMapper extends BaseMapperX { @@ -23,18 +19,8 @@ public interface DeliveryExpressTemplateMapper extends BaseMapperX selectList(DeliveryExpressTemplateExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressTemplateDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressTemplateDO::getChargeMode, reqVO.getChargeMode()) - .betweenIfPresent(DeliveryExpressTemplateDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressTemplateDO::getSort)); - } - - // TODO @jason:可以用 selectOne(DeliveryExpressTemplateDO::getName, name),常用的我封装了哈。简洁一点~ default DeliveryExpressTemplateDO selectByName(String name) { - return selectOne(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateDO::getName, name)); + return selectOne(DeliveryExpressTemplateDO::getName,name); } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java index 30cb85b75..71721fec2 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java @@ -58,13 +58,4 @@ public interface DeliveryExpressTemplateService { * @return 快递运费模板分页 */ PageResult getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO); - - /** - * 获得快递运费模板列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 快递运费模板列表 - */ - List getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO); - } 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 76182eed7..2bda89a91 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 @@ -36,32 +36,24 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper; @Resource private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper; - // TODO @jason:应该不用 BatchInsertMapper 拉,直接走 expressTemplateChargeMapper.insertBatch - @Resource - private DeliveryExpressTemplateChargeMapper.BatchInsertMapper expressTemplateChargeBatchMapper; - @Resource - private DeliveryExpressTemplateFreeMapper.BatchInsertMapper expressTemplateFreeBatchMapper; @Override @Transactional(rollbackFor = Exception.class) public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) { - // TODO @jason:中英文之间,要有空格哈。例如说, // 校验模板名是否唯一 - //校验模板名是否唯一 + // 校验模板名是否唯一 validateTemplateNameUnique(createReqVO.getName(), null); - // 插入 DeliveryExpressTemplateDO deliveryExpressTemplate = INSTANCE.convert(createReqVO); expressTemplateMapper.insert(deliveryExpressTemplate); - //插入运费模板计费表 - // TODO @jason:if (,中间要有空格 - if(CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) { - expressTemplateChargeBatchMapper.saveBatch( - INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge()) + // 插入运费模板计费表 + if (CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) { + expressTemplateChargeMapper.insertBatch( + INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge()) ); } - //插入运费模板包邮表 - if(CollUtil.isNotEmpty(createReqVO.getTemplateFree())) { - expressTemplateFreeBatchMapper.saveBatch( + // 插入运费模板包邮表 + if (CollUtil.isNotEmpty(createReqVO.getTemplateFree())) { + expressTemplateFreeMapper.insertBatch( INSTANCE.convertTemplateFreeList(deliveryExpressTemplate.getId(), createReqVO.getTemplateFree()) ); } @@ -73,14 +65,13 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla public void updateDeliveryExpressTemplate(DeliveryExpressTemplateUpdateReqVO updateReqVO) { // 校验存在 validateDeliveryExpressTemplateExists(updateReqVO.getId()); - //校验模板名是否唯一 + // 校验模板名是否唯一 validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId()); - - //更新运费从表 + // 更新运费从表 updateExpressTemplateCharge(updateReqVO); - //更新包邮从表 + // 更新包邮从表 updateExpressTemplateFree(updateReqVO); - //更新模板主表 + // 更新模板主表 DeliveryExpressTemplateDO updateObj = INSTANCE.convert(updateReqVO); expressTemplateMapper.updateById(updateObj); } @@ -88,29 +79,29 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla private void updateExpressTemplateFree(DeliveryExpressTemplateUpdateReqVO updateReqVO) { List oldFreeList = expressTemplateFreeMapper.selectListByTemplateId(updateReqVO.getId()); List newFreeList = updateReqVO.getTemplateFree(); - //新增包邮区域列表 + // 新增包邮区域列表 List addFreeList = new ArrayList<>(newFreeList.size()); - //更新包邮区域列表 + // 更新包邮区域列表 List updateFreeList = new ArrayList<>(newFreeList.size()); for (ExpressTemplateFreeUpdateVO item : newFreeList) { if (Objects.nonNull(item.getId())) { updateFreeList.add(INSTANCE.convertTemplateFree(item)); - }else{ + } else { item.setTemplateId(updateReqVO.getId()); addFreeList.add(INSTANCE.convertTemplateFree(item)); } } - //删除的包邮区域id + // 新增 + if (CollUtil.isNotEmpty(addFreeList)) { + expressTemplateFreeMapper.insertBatch(addFreeList); + } + // 修改 + if (CollUtil.isNotEmpty(updateFreeList)) { + expressTemplateFreeMapper.updateBatch(updateFreeList); + } + // 得到删除ids Set deleteFreeIds = CollectionUtils.convertSet(oldFreeList, DeliveryExpressTemplateFreeDO::getId); deleteFreeIds.removeAll(CollectionUtils.convertSet(updateFreeList, DeliveryExpressTemplateFreeDO::getId)); - //新增 - if (CollUtil.isNotEmpty(addFreeList)) { - expressTemplateFreeBatchMapper.saveBatch(addFreeList); - } - //修改 - if (CollUtil.isNotEmpty(updateFreeList)) { - expressTemplateFreeBatchMapper.saveOrUpdateBatch(updateFreeList); - } //删除 if (CollUtil.isNotEmpty(deleteFreeIds)) { expressTemplateFreeMapper.deleteBatchIds(deleteFreeIds); @@ -120,33 +111,33 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla private void updateExpressTemplateCharge(DeliveryExpressTemplateUpdateReqVO updateReqVO) { List oldChargeList = expressTemplateChargeMapper.selectListByTemplateId(updateReqVO.getId()); List newChargeList = updateReqVO.getTemplateCharge(); - //新增运费区域列表 + // 新增运费区域列表 List addList = new ArrayList<>(newChargeList.size()); - //更新运费区域列表 + // 更新运费区域列表 List updateList = new ArrayList<>(newChargeList.size()); for (ExpressTemplateChargeUpdateVO item : newChargeList) { - if (Objects.nonNull(item.getId())) { // TODO @jason:null 的判断,还是用 item.getId() != null 好一点。一般数组用方法,主要考虑 null + length = 0; - //计费模式以主表为准 + if (item.getId() != null) { + // 计费模式以主表为准 item.setChargeMode(updateReqVO.getChargeMode()); updateList.add(INSTANCE.convertTemplateCharge(item)); - }else{ + } else { item.setTemplateId(updateReqVO.getId()); item.setChargeMode(updateReqVO.getChargeMode()); addList.add(INSTANCE.convertTemplateCharge(item)); } } - //删除的运费区域id TODO @jason:这块放到删除部分的那块逻辑会好点(149 - 152 行),主要变量要贴相应的逻辑近一点哈。 + // 新增 + if (CollUtil.isNotEmpty(addList)) { + expressTemplateChargeMapper.insertBatch(addList); + } + // 修改 + if (CollUtil.isNotEmpty(updateList)) { + expressTemplateChargeMapper.updateBatch(updateList); + } + // 得到删除的ids Set deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId); deleteChargeIds.removeAll(CollectionUtils.convertSet(updateList, DeliveryExpressTemplateChargeDO::getId)); - //新增 - if (CollUtil.isNotEmpty(addList)) { - expressTemplateChargeBatchMapper.saveBatch(addList); - } - //修改 - if (CollUtil.isNotEmpty(updateList)) { - expressTemplateChargeBatchMapper.saveOrUpdateBatch(updateList); - } - //删除 + // 删除 if (CollUtil.isNotEmpty(deleteChargeIds)) { expressTemplateChargeMapper.deleteBatchIds(deleteChargeIds); } @@ -157,7 +148,6 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla public void deleteDeliveryExpressTemplate(Long id) { // 校验存在 validateDeliveryExpressTemplateExists(id); - // 删除主表 expressTemplateMapper.deleteById(id); // 删除运费从表 @@ -167,9 +157,10 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla } /** - * 校验运费模板名是否唯一 // TODO @jason:方法注释,和参数,要空一行。 + * 校验运费模板名是否唯一 + * * @param name 模板名称 - * @param id 运费模板编号, 可以为null // TODO @jason:中英文之间,要空一行;其它地方也看看哈 + * @param id 运费模板编号,可以为 null */ private void validateTemplateNameUnique(String name, Long id) { DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name); @@ -196,7 +187,7 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla List chargeList = expressTemplateChargeMapper.selectListByTemplateId(id); List freeList = expressTemplateFreeMapper.selectListByTemplateId(id); DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(id); - return INSTANCE.convert(template, chargeList,freeList); + return INSTANCE.convert(template, chargeList, freeList); } @Override @@ -208,10 +199,4 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla public PageResult getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO) { return expressTemplateMapper.selectPage(pageReqVO); } - - @Override - public List getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO) { - return expressTemplateMapper.selectList(exportReqVO); - } - } 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 0988cbe90..b3bc0c03c 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,7 +6,7 @@ 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.LazyAreaNodeRespVO; +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; @@ -34,23 +34,23 @@ public class AreaController { return success(AreaConvert.INSTANCE.convertList(area.getChildren())); } - // TODO @jason:1)url 使用中划线分隔哈,然后可以改成 children;2)id 需要添加 @RequestParam,因为可能会混淆编译; - // 3) swagger 注解要写下哈; - @GetMapping("/getChildrenArea") + @GetMapping("/get-children") @Operation(summary = "获得地区的下级区域") - public CommonResult> getChildrenArea(Integer id) { + @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)); + Assert.notNull(area, String.format("获取不到 id : %d 的区域", id)); return success(AreaConvert.INSTANCE.convertList2(area.getChildren())); } - // TODO @jason:1)读请求,使用 get 哈。2)然后参数不应该使用 @RequestBody;3)areaIds 改成 ids 更合适; // 4)方法改成 getAreaChildrenList 获得子节点们;5)url 可以已改成 children-list - @PostMapping("/list") + //@芋艿 是不是叫 getAreaListByIds 更合适。 因为不一定是子节点。 用于前端树选择获取缓存数据。 见 + @GetMapping("/get-by-ids") @Operation(summary = "通过区域 ids 获得地区列表") - public CommonResult> list(@RequestBody Set areaIds) { - List areaList = new ArrayList<>(areaIds.size()); - for (Integer areaId : areaIds) { + @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)); 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 new file mode 100644 index 000000000..a37430248 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeSimpleRespVO.java @@ -0,0 +1,19 @@ +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 = "编号", required = true, example = "110000") + private Integer id; + + @Schema(description = "名字", required = true, example = "北京") + private String name; + + @Schema(description = "是否叶子节点", required = false, example = "false") + private Boolean leaf; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/LazyAreaNodeRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/LazyAreaNodeRespVO.java deleted file mode 100644 index e95defb1c..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/LazyAreaNodeRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.system.controller.admin.ip.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -// TODO @jason:1)VO 不添加注释作者哈。2)是不是改成 AreaNodeSimpleRespVO,它其实是返回一个简洁的地区,懒加载只是它的使用场景; -/** - * @author jason - */ -@Schema(description = "管理后台 - 懒加载地区节点 Response VO") -@Data -public class LazyAreaNodeRespVO { - - @Schema(description = "编号", required = true, example = "110000") - private Integer id; - - @Schema(description = "名字", required = true, example = "北京") - private String name; - - // TODO @jason:1)不设置默认值,交给业务逻辑那写入;2)这个字段必须返回哇? - @Schema(description = "是否叶子节点", required = true, example = "false") - private Boolean leaf = Boolean.FALSE; - -} 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 540272e12..05d193717 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 @@ -3,12 +3,10 @@ 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.LazyAreaNodeRespVO; +import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeSimpleRespVO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; -import org.mapstruct.Named; import org.mapstruct.factory.Mappers; -import org.springframework.context.annotation.Lazy; import java.util.List; import java.util.Objects; @@ -20,10 +18,10 @@ public interface AreaConvert { List convertList(List list); - List convertList2(List list); + List convertList2(List list); @Mapping(source = "type", target = "leaf") - LazyAreaNodeRespVO convert(Area area); + AreaNodeSimpleRespVO convert(Area area); default Boolean convertAreaType(Integer type){ return Objects.equals(AreaTypeEnum.DISTRICT.getType(),type);