Commit 55dbff7570caf069efe2495b6c048e90c12d51b0
1 parent
02fa6fc5
运费模板 review 修改. 运费模块可以选择多个区域
Showing
25 changed files
with
174 additions
and
235 deletions
sql/mysql/optional/mall.sql
| ... | ... | @@ -350,7 +350,7 @@ DROP TABLE IF EXISTS `trade_delivery_express_template_free`; |
| 350 | 350 | CREATE TABLE `trade_delivery_express_template_free` ( |
| 351 | 351 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', |
| 352 | 352 | `template_id` bigint NOT NULL COMMENT '快递运费模板编号', |
| 353 | - `area_id` int NOT NULL COMMENT '包邮区域 id', | |
| 353 | + `area_ids` varchar(100) NOT NULL COMMENT '包邮区域 ids', | |
| 354 | 354 | `free_price` int NOT NULL COMMENT '包邮金额,单位:分', |
| 355 | 355 | `free_count` int NOT NULL DEFAULT 0 COMMENT '包邮件数,', |
| 356 | 356 | `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`; |
| 369 | 369 | CREATE TABLE `trade_delivery_express_template_charge` ( |
| 370 | 370 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,自增', |
| 371 | 371 | `template_id` bigint NOT NULL COMMENT '快递运费模板编号', |
| 372 | - `area_id` int NOT NULL COMMENT '配送区域 id', | |
| 372 | + `area_ids` varchar(100) NOT NULL COMMENT '配送区域 ids', | |
| 373 | 373 | `charge_mode` tinyint NOT NULL COMMENT '配送计费方式', |
| 374 | 374 | `start_count` double NOT NULL COMMENT '首件数量', |
| 375 | 375 | `start_price` int NOT NULL COMMENT '起步价,单位:分', |
| ... | ... | @@ -501,7 +501,7 @@ INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, ` |
| 501 | 501 | 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'); |
| 502 | 502 | 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'); |
| 503 | 503 | 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'); |
| 504 | -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'); | |
| 504 | +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'); | |
| 505 | 505 | 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'); |
| 506 | 506 | 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'); |
| 507 | 507 | 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'); | ... | ... |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java
| ... | ... | @@ -45,4 +45,10 @@ public class StrUtils { |
| 45 | 45 | return Arrays.stream(longs).boxed().collect(Collectors.toList()); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | + public static List<Integer> splitToInteger(String value, CharSequence separator) { | |
| 49 | + int[] integers = StrUtil.splitToInt(value, separator); | |
| 50 | + return Arrays.stream(integers).boxed().collect(Collectors.toList()); | |
| 51 | + } | |
| 52 | + | |
| 53 | + | |
| 48 | 54 | } | ... | ... |
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<T> extends MPJBaseMapper<T> { |
| 113 | 113 | Db.saveBatch(entities, size); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | + // @芋艿 是不是叫 updateByDo 或者 updateByEntity 更合适 | |
| 116 | 117 | default void updateBatch(T update) { |
| 117 | 118 | update(update, new QueryWrapper<>()); |
| 118 | 119 | } |
| 119 | 120 | |
| 121 | + /** | |
| 122 | + * 根据ID 批量更新,适合大量数据更新 | |
| 123 | + * | |
| 124 | + * @param entities 实体们 | |
| 125 | + */ | |
| 126 | + default void updateBatch(Collection<T> entities) { | |
| 127 | + Db.updateBatchById(entities); | |
| 128 | + } | |
| 129 | + | |
| 120 | 130 | default void updateBatch(Collection<T> entities, int size) { |
| 121 | 131 | Db.updateBatchById(entities, size); |
| 122 | 132 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/IntegerListTypeHandler.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.mybatis.core.type; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.util.string.StrUtils; | |
| 5 | +import org.apache.ibatis.type.JdbcType; | |
| 6 | +import org.apache.ibatis.type.MappedJdbcTypes; | |
| 7 | +import org.apache.ibatis.type.MappedTypes; | |
| 8 | +import org.apache.ibatis.type.TypeHandler; | |
| 9 | + | |
| 10 | +import java.sql.CallableStatement; | |
| 11 | +import java.sql.PreparedStatement; | |
| 12 | +import java.sql.ResultSet; | |
| 13 | +import java.sql.SQLException; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * List<Integer> 的类型转换器实现类,对应数据库的 varchar 类型 | |
| 18 | + * | |
| 19 | + * @author jason | |
| 20 | + */ | |
| 21 | +@MappedJdbcTypes(JdbcType.VARCHAR) | |
| 22 | +@MappedTypes(List.class) | |
| 23 | +public class IntegerListTypeHandler implements TypeHandler<List<Integer>> { | |
| 24 | + | |
| 25 | + private static final String COMMA = ","; | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public void setParameter(PreparedStatement ps, int i, List<Integer> strings, JdbcType jdbcType) throws SQLException { | |
| 29 | + ps.setString(i, CollUtil.join(strings, COMMA)); | |
| 30 | + } | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public List<Integer> getResult(ResultSet rs, String columnName) throws SQLException { | |
| 34 | + String value = rs.getString(columnName); | |
| 35 | + return getResult(value); | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public List<Integer> getResult(ResultSet rs, int columnIndex) throws SQLException { | |
| 40 | + String value = rs.getString(columnIndex); | |
| 41 | + return getResult(value); | |
| 42 | + } | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + public List<Integer> getResult(CallableStatement cs, int columnIndex) throws SQLException { | |
| 46 | + String value = cs.getString(columnIndex); | |
| 47 | + return getResult(value); | |
| 48 | + } | |
| 49 | + | |
| 50 | + private List<Integer> getResult(String value) { | |
| 51 | + if (value == null) { | |
| 52 | + return null; | |
| 53 | + } | |
| 54 | + return StrUtils.splitToInteger(value, COMMA); | |
| 55 | + } | |
| 56 | +} | ... | ... |
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 { |
| 74 | 74 | return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult)); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - // TODO @jason:运费模版,可以去掉哈,没啥用; | |
| 77 | + // TODO @jason:运费模版,@芋艿 你的意思是运费模板导出没有必要吧。已经去掉了。这个是快递公司导出 | |
| 78 | 78 | @GetMapping("/export-excel") |
| 79 | 79 | @Operation(summary = "导出快递公司 Excel") |
| 80 | 80 | @PreAuthorize("@ss.hasPermission('trade:delivery:express:export')") | ... | ... |
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 { |
| 84 | 84 | PageResult<DeliveryExpressTemplateDO> pageResult = deliveryExpressTemplateService.getDeliveryExpressTemplatePage(pageVO); |
| 85 | 85 | return success(DeliveryExpressTemplateConvert.INSTANCE.convertPage(pageResult)); |
| 86 | 86 | } |
| 87 | - | |
| 88 | - @GetMapping("/export-excel") | |
| 89 | - @Operation(summary = "导出快递运费模板 Excel") | |
| 90 | - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:export')") | |
| 91 | - @OperateLog(type = EXPORT) | |
| 92 | - public void exportDeliveryExpressTemplateExcel(@Valid DeliveryExpressTemplateExportReqVO exportReqVO, | |
| 93 | - HttpServletResponse response) throws IOException { | |
| 94 | - List<DeliveryExpressTemplateDO> list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(exportReqVO); | |
| 95 | - // 导出 Excel | |
| 96 | - List<DeliveryExpressTemplateExcelVO> datas = DeliveryExpressTemplateConvert.INSTANCE.convertList02(list); | |
| 97 | - ExcelUtils.write(response, "快递运费模板.xls", "数据", DeliveryExpressTemplateExcelVO.class, datas); | |
| 98 | - } | |
| 99 | - | |
| 100 | 87 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressExcelVO.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; | |
| 3 | 6 | import com.alibaba.excel.annotation.ExcelProperty; |
| 4 | 7 | import lombok.Data; |
| 5 | 8 | |
| ... | ... | @@ -7,8 +10,6 @@ import java.time.LocalDateTime; |
| 7 | 10 | |
| 8 | 11 | /** |
| 9 | 12 | * 快递公司 Excel VO |
| 10 | - * | |
| 11 | - * @author jason | |
| 12 | 13 | */ |
| 13 | 14 | @Data |
| 14 | 15 | public class DeliveryExpressExcelVO { |
| ... | ... | @@ -28,9 +29,9 @@ public class DeliveryExpressExcelVO { |
| 28 | 29 | @ExcelProperty("排序") |
| 29 | 30 | private Integer sort; |
| 30 | 31 | |
| 31 | - @ExcelProperty("状态") | |
| 32 | - // TODO @jason:可以使用 @DictFormat(DictTypeConstants.COMMON_STATUS) | |
| 33 | - private Byte status; | |
| 32 | + @ExcelProperty(value = "状态", converter = DictConvert.class) | |
| 33 | + @DictFormat(DictTypeConstants.COMMON_STATUS) | |
| 34 | + private Integer status; | |
| 34 | 35 | |
| 35 | 36 | @ExcelProperty("创建时间") |
| 36 | 37 | private LocalDateTime createTime; | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; | |
| 2 | - | |
| 3 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 6 | -import java.time.LocalDateTime; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * 快递运费模板 Excel VO | |
| 10 | - * | |
| 11 | - * @author jason | |
| 12 | - */ | |
| 13 | -@Data | |
| 14 | -public class DeliveryExpressTemplateExcelVO { | |
| 15 | - | |
| 16 | - @ExcelProperty("编号,自增") | |
| 17 | - private Long id; | |
| 18 | - | |
| 19 | - @ExcelProperty("模板名称") | |
| 20 | - private String name; | |
| 21 | - | |
| 22 | - @ExcelProperty("配送计费方式 1:按件 2:按重量 3:按体积") | |
| 23 | - private Integer chargeMode; | |
| 24 | - | |
| 25 | - @ExcelProperty("排序") | |
| 26 | - private Integer sort; | |
| 27 | - | |
| 28 | - @ExcelProperty("创建时间") | |
| 29 | - private LocalDateTime createTime; | |
| 30 | - | |
| 31 | -} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; | |
| 2 | - | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | -import java.time.LocalDateTime; | |
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | - | |
| 10 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | - | |
| 12 | -@Schema(description = "管理后台 - 快递运费模板 Excel 导出 Request VO,参数和 DeliveryExpressTemplatePageReqVO 是一致的") | |
| 13 | -@Data | |
| 14 | -public class DeliveryExpressTemplateExportReqVO { | |
| 15 | - | |
| 16 | - @Schema(description = "模板名称", example = "王五") | |
| 17 | - private String name; | |
| 18 | - | |
| 19 | - @Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积") | |
| 20 | - private Integer chargeMode; | |
| 21 | - | |
| 22 | - @Schema(description = "创建时间") | |
| 23 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 24 | - private LocalDateTime[] createTime; | |
| 25 | - | |
| 26 | -} |
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; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | +import javax.validation.constraints.NotEmpty; | |
| 6 | 7 | import javax.validation.constraints.NotNull; |
| 8 | +import java.util.List; | |
| 7 | 9 | |
| 8 | 10 | /** |
| 9 | 11 | * 快递运费模板运费设置 Base VO,提供给添加运费模板使用 |
| 10 | - * | |
| 11 | - * @author jason | |
| 12 | 12 | */ |
| 13 | 13 | @Data |
| 14 | 14 | public class ExpressTemplateChargeBaseVO { |
| 15 | 15 | |
| 16 | - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 17 | - @NotNull(message = "区域编号不能为空") | |
| 18 | - private Integer areaId; | |
| 16 | + @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") | |
| 17 | + @NotEmpty(message = "区域编号列表不能为空") | |
| 18 | + private List<Integer> areaIds; | |
| 19 | 19 | |
| 20 | 20 | @Schema(description = "首件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") |
| 21 | 21 | @NotNull(message = "首件数量不能为空") | ... | ... |
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; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | -/** | |
| 7 | - * @author jason | |
| 8 | - */ | |
| 6 | + | |
| 9 | 7 | @Data |
| 10 | 8 | public class ExpressTemplateChargeUpdateVO extends ExpressTemplateChargeBaseVO { |
| 11 | 9 | ... | ... |
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; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | +import javax.validation.constraints.NotEmpty; | |
| 6 | 7 | import javax.validation.constraints.NotNull; |
| 8 | +import java.util.List; | |
| 7 | 9 | |
| 8 | 10 | /** |
| 9 | 11 | * 快递运费模板包邮 Base VO,提供给添加运费模板使用 |
| 10 | - * | |
| 11 | - * @author jason | |
| 12 | 12 | */ |
| 13 | 13 | @Data |
| 14 | 14 | public class ExpressTemplateFreeBaseVO { |
| 15 | 15 | |
| 16 | - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 17 | - @NotNull(message = "区域编号不能为空") | |
| 18 | - private Integer areaId; | |
| 16 | + @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") | |
| 17 | + @NotEmpty(message = "区域编号列表不能为空") | |
| 18 | + private List<Integer> areaIds; | |
| 19 | 19 | |
| 20 | 20 | @Schema(description = "包邮金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "5000") |
| 21 | 21 | @NotNull(message = "包邮金额不能为空") | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeUpdateVO.java
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java
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; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 5 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.*; |
| 6 | 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; |
| 7 | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; |
| ... | ... | @@ -16,7 +17,7 @@ import java.util.List; |
| 16 | 17 | /** |
| 17 | 18 | * 快递运费模板 Convert |
| 18 | 19 | * |
| 19 | - * @author 芋道源码 | |
| 20 | + * @author jason | |
| 20 | 21 | */ |
| 21 | 22 | @Mapper |
| 22 | 23 | public interface DeliveryExpressTemplateConvert { |
| ... | ... | @@ -37,8 +38,6 @@ public interface DeliveryExpressTemplateConvert { |
| 37 | 38 | |
| 38 | 39 | PageResult<DeliveryExpressTemplateSimpleRespVO> convertPage(PageResult<DeliveryExpressTemplateDO> page); |
| 39 | 40 | |
| 40 | - List<DeliveryExpressTemplateExcelVO> convertList02(List<DeliveryExpressTemplateDO> list); | |
| 41 | - | |
| 42 | 41 | default DeliveryExpressTemplateRespVO convert(DeliveryExpressTemplateDO bean, |
| 43 | 42 | List<DeliveryExpressTemplateChargeDO> chargeList, |
| 44 | 43 | List<DeliveryExpressTemplateFreeDO> freeList){ |
| ... | ... | @@ -55,15 +54,7 @@ public interface DeliveryExpressTemplateConvert { |
| 55 | 54 | DeliveryExpressTemplateChargeDO convertTemplateCharge(ExpressTemplateChargeUpdateVO vo); |
| 56 | 55 | |
| 57 | 56 | default List<DeliveryExpressTemplateChargeDO> convertTemplateChargeList(Long templateId, Integer chargeMode, List<ExpressTemplateChargeBaseVO> list) { |
| 58 | - // TODO @jason:可以使用 CollectionUtils.convertList,本质上就是 stream convert list | |
| 59 | - if(CollUtil.isEmpty(list)){ | |
| 60 | - return Collections.emptyList(); | |
| 61 | - } | |
| 62 | - List<DeliveryExpressTemplateChargeDO> templateChargeList = new ArrayList<>(list.size()); | |
| 63 | - for (ExpressTemplateChargeBaseVO item : list) { | |
| 64 | - templateChargeList.add(convertTemplateCharge(templateId, chargeMode, item)); | |
| 65 | - } | |
| 66 | - return templateChargeList; | |
| 57 | + return CollectionUtils.convertList(list, vo -> convertTemplateCharge(templateId, chargeMode, vo)); | |
| 67 | 58 | } |
| 68 | 59 | |
| 69 | 60 | // ========== Template Free ========== |
| ... | ... | @@ -76,17 +67,8 @@ public interface DeliveryExpressTemplateConvert { |
| 76 | 67 | |
| 77 | 68 | List<ExpressTemplateFreeBaseVO> convertTemplateFreeList(List<DeliveryExpressTemplateFreeDO> list); |
| 78 | 69 | |
| 79 | - // TODO @jason:, List,中间一个空格哈。代码的空格和空行要注意,嘿嘿~ | |
| 80 | - default List<DeliveryExpressTemplateFreeDO> convertTemplateFreeList(Long templateId, List<ExpressTemplateFreeBaseVO> list) { | |
| 81 | - // TODO @jason:可以使用 CollectionUtils.convertList,本质上就是 stream convert list | |
| 82 | - if (CollUtil.isEmpty(list)) { | |
| 83 | - return Collections.emptyList(); | |
| 84 | - } | |
| 85 | - List<DeliveryExpressTemplateFreeDO> templateFreeList = new ArrayList<>(list.size()); | |
| 86 | - for (ExpressTemplateFreeBaseVO item : list) { | |
| 87 | - templateFreeList.add(convertTemplateFree(templateId, item)); | |
| 88 | - } | |
| 89 | - return templateFreeList; | |
| 70 | + default List<DeliveryExpressTemplateFreeDO> convertTemplateFreeList(Long templateId, List<ExpressTemplateFreeBaseVO> list) { | |
| 71 | + return CollectionUtils.convertList(list, vo -> convertTemplateFree(templateId, vo)); | |
| 90 | 72 | } |
| 91 | 73 | |
| 92 | 74 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; | |
| 4 | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 6 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 5 | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
| 6 | 8 | import com.baomidou.mybatisplus.annotation.TableName; |
| 7 | 9 | import lombok.Data; |
| 8 | 10 | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 9 | 13 | /** |
| 10 | 14 | * 快递运费模板计费配置 DO |
| 11 | 15 | * |
| 12 | 16 | * @author jason |
| 13 | 17 | */ |
| 14 | -@TableName(value ="trade_delivery_express_template_charge") | |
| 18 | +@TableName(value ="trade_delivery_express_template_charge", autoResultMap = true) | |
| 15 | 19 | @KeySequence("trade_delivery_express_template_charge_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 16 | 20 | @Data |
| 17 | 21 | public class DeliveryExpressTemplateChargeDO extends BaseDO { |
| ... | ... | @@ -30,9 +34,10 @@ public class DeliveryExpressTemplateChargeDO extends BaseDO { |
| 30 | 34 | private Long templateId; |
| 31 | 35 | |
| 32 | 36 | /** |
| 33 | - * 配送区域 | |
| 37 | + * 配送区域编号列表 | |
| 34 | 38 | */ |
| 35 | - private Integer areaId; | |
| 39 | + @TableField(typeHandler = IntegerListTypeHandler.class) | |
| 40 | + private List<Integer> areaIds; | |
| 36 | 41 | |
| 37 | 42 | /** |
| 38 | 43 | * 配送计费方式 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; | |
| 4 | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 6 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 5 | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
| 6 | 8 | import com.baomidou.mybatisplus.annotation.TableName; |
| 7 | 9 | import lombok.Data; |
| 8 | 10 | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 9 | 13 | /** |
| 10 | 14 | * 快递运费模板包邮配置 DO |
| 11 | 15 | * |
| 12 | 16 | * @author jason |
| 13 | 17 | */ |
| 14 | -@TableName(value ="trade_delivery_express_template_free") | |
| 18 | +@TableName(value ="trade_delivery_express_template_free", autoResultMap = true) | |
| 15 | 19 | @KeySequence("trade_delivery_express_template_free_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 16 | 20 | @Data |
| 17 | 21 | public class DeliveryExpressTemplateFreeDO extends BaseDO { |
| ... | ... | @@ -29,10 +33,12 @@ public class DeliveryExpressTemplateFreeDO extends BaseDO { |
| 29 | 33 | */ |
| 30 | 34 | private Long templateId; |
| 31 | 35 | |
| 36 | + | |
| 32 | 37 | /** |
| 33 | - * 包邮区域id | |
| 38 | + * 配送区域编号列表 | |
| 34 | 39 | */ |
| 35 | - private Integer areaId; | |
| 40 | + @TableField(typeHandler = IntegerListTypeHandler.class) | |
| 41 | + private List<Integer> areaIds; | |
| 36 | 42 | |
| 37 | 43 | /** |
| 38 | 44 | * 包邮金额,单位:分 | ... | ... |
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; |
| 14 | 14 | @Mapper |
| 15 | 15 | public interface DeliveryExpressTemplateChargeMapper extends BaseMapperX<DeliveryExpressTemplateChargeDO> { |
| 16 | 16 | |
| 17 | - @Repository | |
| 18 | - class BatchInsertMapper extends ServiceImpl<DeliveryExpressTemplateChargeMapper, DeliveryExpressTemplateChargeDO> { | |
| 19 | - } | |
| 20 | - | |
| 21 | 17 | default List<DeliveryExpressTemplateChargeDO> selectListByTemplateId(Long templateId){ |
| 22 | 18 | return selectList(new LambdaQueryWrapper<DeliveryExpressTemplateChargeDO>() |
| 23 | 19 | .eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId)); | ... | ... |
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; |
| 14 | 14 | @Mapper |
| 15 | 15 | public interface DeliveryExpressTemplateFreeMapper extends BaseMapperX<DeliveryExpressTemplateFreeDO> { |
| 16 | 16 | |
| 17 | - @Repository | |
| 18 | - class BatchInsertMapper extends ServiceImpl<DeliveryExpressTemplateFreeMapper, DeliveryExpressTemplateFreeDO> { | |
| 19 | - } | |
| 20 | - | |
| 21 | 17 | default List<DeliveryExpressTemplateFreeDO> selectListByTemplateId(Long templateId) { |
| 22 | 18 | return selectList(new LambdaQueryWrapper<DeliveryExpressTemplateFreeDO>() |
| 23 | 19 | .eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId)); | ... | ... |
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; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressTemplateExportReqVO; | |
| 8 | 7 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressTemplatePageReqVO; |
| 9 | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; |
| 10 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
| 11 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 12 | 10 | |
| 13 | -import java.util.List; | |
| 14 | - | |
| 15 | 11 | @Mapper |
| 16 | 12 | public interface DeliveryExpressTemplateMapper extends BaseMapperX<DeliveryExpressTemplateDO> { |
| 17 | 13 | |
| ... | ... | @@ -23,18 +19,8 @@ public interface DeliveryExpressTemplateMapper extends BaseMapperX<DeliveryExpre |
| 23 | 19 | .orderByAsc(DeliveryExpressTemplateDO::getSort)); |
| 24 | 20 | } |
| 25 | 21 | |
| 26 | - default List<DeliveryExpressTemplateDO> selectList(DeliveryExpressTemplateExportReqVO reqVO) { | |
| 27 | - return selectList(new LambdaQueryWrapperX<DeliveryExpressTemplateDO>() | |
| 28 | - .likeIfPresent(DeliveryExpressTemplateDO::getName, reqVO.getName()) | |
| 29 | - .eqIfPresent(DeliveryExpressTemplateDO::getChargeMode, reqVO.getChargeMode()) | |
| 30 | - .betweenIfPresent(DeliveryExpressTemplateDO::getCreateTime, reqVO.getCreateTime()) | |
| 31 | - .orderByAsc(DeliveryExpressTemplateDO::getSort)); | |
| 32 | - } | |
| 33 | - | |
| 34 | - // TODO @jason:可以用 selectOne(DeliveryExpressTemplateDO::getName, name),常用的我封装了哈。简洁一点~ | |
| 35 | 22 | default DeliveryExpressTemplateDO selectByName(String name) { |
| 36 | - return selectOne(new LambdaQueryWrapper<DeliveryExpressTemplateDO>() | |
| 37 | - .eq(DeliveryExpressTemplateDO::getName, name)); | |
| 23 | + return selectOne(DeliveryExpressTemplateDO::getName,name); | |
| 38 | 24 | } |
| 39 | 25 | |
| 40 | 26 | } | ... | ... |
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 { |
| 58 | 58 | * @return 快递运费模板分页 |
| 59 | 59 | */ |
| 60 | 60 | PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO); |
| 61 | - | |
| 62 | - /** | |
| 63 | - * 获得快递运费模板列表, 用于 Excel 导出 | |
| 64 | - * | |
| 65 | - * @param exportReqVO 查询条件 | |
| 66 | - * @return 快递运费模板列表 | |
| 67 | - */ | |
| 68 | - List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO); | |
| 69 | - | |
| 70 | 61 | } | ... | ... |
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 |
| 36 | 36 | private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper; |
| 37 | 37 | @Resource |
| 38 | 38 | private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper; |
| 39 | - // TODO @jason:应该不用 BatchInsertMapper 拉,直接走 expressTemplateChargeMapper.insertBatch | |
| 40 | - @Resource | |
| 41 | - private DeliveryExpressTemplateChargeMapper.BatchInsertMapper expressTemplateChargeBatchMapper; | |
| 42 | - @Resource | |
| 43 | - private DeliveryExpressTemplateFreeMapper.BatchInsertMapper expressTemplateFreeBatchMapper; | |
| 44 | 39 | |
| 45 | 40 | @Override |
| 46 | 41 | @Transactional(rollbackFor = Exception.class) |
| 47 | 42 | public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) { |
| 48 | - // TODO @jason:中英文之间,要有空格哈。例如说, // 校验模板名是否唯一 | |
| 49 | - //校验模板名是否唯一 | |
| 43 | + // 校验模板名是否唯一 | |
| 50 | 44 | validateTemplateNameUnique(createReqVO.getName(), null); |
| 51 | - | |
| 52 | 45 | // 插入 |
| 53 | 46 | DeliveryExpressTemplateDO deliveryExpressTemplate = INSTANCE.convert(createReqVO); |
| 54 | 47 | expressTemplateMapper.insert(deliveryExpressTemplate); |
| 55 | - //插入运费模板计费表 | |
| 56 | - // TODO @jason:if (,中间要有空格 | |
| 57 | - if(CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) { | |
| 58 | - expressTemplateChargeBatchMapper.saveBatch( | |
| 59 | - INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge()) | |
| 48 | + // 插入运费模板计费表 | |
| 49 | + if (CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) { | |
| 50 | + expressTemplateChargeMapper.insertBatch( | |
| 51 | + INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge()) | |
| 60 | 52 | ); |
| 61 | 53 | } |
| 62 | - //插入运费模板包邮表 | |
| 63 | - if(CollUtil.isNotEmpty(createReqVO.getTemplateFree())) { | |
| 64 | - expressTemplateFreeBatchMapper.saveBatch( | |
| 54 | + // 插入运费模板包邮表 | |
| 55 | + if (CollUtil.isNotEmpty(createReqVO.getTemplateFree())) { | |
| 56 | + expressTemplateFreeMapper.insertBatch( | |
| 65 | 57 | INSTANCE.convertTemplateFreeList(deliveryExpressTemplate.getId(), createReqVO.getTemplateFree()) |
| 66 | 58 | ); |
| 67 | 59 | } |
| ... | ... | @@ -73,14 +65,13 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla |
| 73 | 65 | public void updateDeliveryExpressTemplate(DeliveryExpressTemplateUpdateReqVO updateReqVO) { |
| 74 | 66 | // 校验存在 |
| 75 | 67 | validateDeliveryExpressTemplateExists(updateReqVO.getId()); |
| 76 | - //校验模板名是否唯一 | |
| 68 | + // 校验模板名是否唯一 | |
| 77 | 69 | validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId()); |
| 78 | - | |
| 79 | - //更新运费从表 | |
| 70 | + // 更新运费从表 | |
| 80 | 71 | updateExpressTemplateCharge(updateReqVO); |
| 81 | - //更新包邮从表 | |
| 72 | + // 更新包邮从表 | |
| 82 | 73 | updateExpressTemplateFree(updateReqVO); |
| 83 | - //更新模板主表 | |
| 74 | + // 更新模板主表 | |
| 84 | 75 | DeliveryExpressTemplateDO updateObj = INSTANCE.convert(updateReqVO); |
| 85 | 76 | expressTemplateMapper.updateById(updateObj); |
| 86 | 77 | } |
| ... | ... | @@ -88,29 +79,29 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla |
| 88 | 79 | private void updateExpressTemplateFree(DeliveryExpressTemplateUpdateReqVO updateReqVO) { |
| 89 | 80 | List<DeliveryExpressTemplateFreeDO> oldFreeList = expressTemplateFreeMapper.selectListByTemplateId(updateReqVO.getId()); |
| 90 | 81 | List<ExpressTemplateFreeUpdateVO> newFreeList = updateReqVO.getTemplateFree(); |
| 91 | - //新增包邮区域列表 | |
| 82 | + // 新增包邮区域列表 | |
| 92 | 83 | List<DeliveryExpressTemplateFreeDO> addFreeList = new ArrayList<>(newFreeList.size()); |
| 93 | - //更新包邮区域列表 | |
| 84 | + // 更新包邮区域列表 | |
| 94 | 85 | List<DeliveryExpressTemplateFreeDO> updateFreeList = new ArrayList<>(newFreeList.size()); |
| 95 | 86 | for (ExpressTemplateFreeUpdateVO item : newFreeList) { |
| 96 | 87 | if (Objects.nonNull(item.getId())) { |
| 97 | 88 | updateFreeList.add(INSTANCE.convertTemplateFree(item)); |
| 98 | - }else{ | |
| 89 | + } else { | |
| 99 | 90 | item.setTemplateId(updateReqVO.getId()); |
| 100 | 91 | addFreeList.add(INSTANCE.convertTemplateFree(item)); |
| 101 | 92 | } |
| 102 | 93 | } |
| 103 | - //删除的包邮区域id | |
| 104 | - Set<Long> deleteFreeIds = CollectionUtils.convertSet(oldFreeList, DeliveryExpressTemplateFreeDO::getId); | |
| 105 | - deleteFreeIds.removeAll(CollectionUtils.convertSet(updateFreeList, DeliveryExpressTemplateFreeDO::getId)); | |
| 106 | - //新增 | |
| 94 | + // 新增 | |
| 107 | 95 | if (CollUtil.isNotEmpty(addFreeList)) { |
| 108 | - expressTemplateFreeBatchMapper.saveBatch(addFreeList); | |
| 96 | + expressTemplateFreeMapper.insertBatch(addFreeList); | |
| 109 | 97 | } |
| 110 | - //修改 | |
| 98 | + // 修改 | |
| 111 | 99 | if (CollUtil.isNotEmpty(updateFreeList)) { |
| 112 | - expressTemplateFreeBatchMapper.saveOrUpdateBatch(updateFreeList); | |
| 100 | + expressTemplateFreeMapper.updateBatch(updateFreeList); | |
| 113 | 101 | } |
| 102 | + // 得到删除ids | |
| 103 | + Set<Long> deleteFreeIds = CollectionUtils.convertSet(oldFreeList, DeliveryExpressTemplateFreeDO::getId); | |
| 104 | + deleteFreeIds.removeAll(CollectionUtils.convertSet(updateFreeList, DeliveryExpressTemplateFreeDO::getId)); | |
| 114 | 105 | //删除 |
| 115 | 106 | if (CollUtil.isNotEmpty(deleteFreeIds)) { |
| 116 | 107 | expressTemplateFreeMapper.deleteBatchIds(deleteFreeIds); |
| ... | ... | @@ -120,33 +111,33 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla |
| 120 | 111 | private void updateExpressTemplateCharge(DeliveryExpressTemplateUpdateReqVO updateReqVO) { |
| 121 | 112 | List<DeliveryExpressTemplateChargeDO> oldChargeList = expressTemplateChargeMapper.selectListByTemplateId(updateReqVO.getId()); |
| 122 | 113 | List<ExpressTemplateChargeUpdateVO> newChargeList = updateReqVO.getTemplateCharge(); |
| 123 | - //新增运费区域列表 | |
| 114 | + // 新增运费区域列表 | |
| 124 | 115 | List<DeliveryExpressTemplateChargeDO> addList = new ArrayList<>(newChargeList.size()); |
| 125 | - //更新运费区域列表 | |
| 116 | + // 更新运费区域列表 | |
| 126 | 117 | List<DeliveryExpressTemplateChargeDO> updateList = new ArrayList<>(newChargeList.size()); |
| 127 | 118 | for (ExpressTemplateChargeUpdateVO item : newChargeList) { |
| 128 | - if (Objects.nonNull(item.getId())) { // TODO @jason:null 的判断,还是用 item.getId() != null 好一点。一般数组用方法,主要考虑 null + length = 0; | |
| 129 | - //计费模式以主表为准 | |
| 119 | + if (item.getId() != null) { | |
| 120 | + // 计费模式以主表为准 | |
| 130 | 121 | item.setChargeMode(updateReqVO.getChargeMode()); |
| 131 | 122 | updateList.add(INSTANCE.convertTemplateCharge(item)); |
| 132 | - }else{ | |
| 123 | + } else { | |
| 133 | 124 | item.setTemplateId(updateReqVO.getId()); |
| 134 | 125 | item.setChargeMode(updateReqVO.getChargeMode()); |
| 135 | 126 | addList.add(INSTANCE.convertTemplateCharge(item)); |
| 136 | 127 | } |
| 137 | 128 | } |
| 138 | - //删除的运费区域id TODO @jason:这块放到删除部分的那块逻辑会好点(149 - 152 行),主要变量要贴相应的逻辑近一点哈。 | |
| 139 | - Set<Long> deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId); | |
| 140 | - deleteChargeIds.removeAll(CollectionUtils.convertSet(updateList, DeliveryExpressTemplateChargeDO::getId)); | |
| 141 | - //新增 | |
| 129 | + // 新增 | |
| 142 | 130 | if (CollUtil.isNotEmpty(addList)) { |
| 143 | - expressTemplateChargeBatchMapper.saveBatch(addList); | |
| 131 | + expressTemplateChargeMapper.insertBatch(addList); | |
| 144 | 132 | } |
| 145 | - //修改 | |
| 133 | + // 修改 | |
| 146 | 134 | if (CollUtil.isNotEmpty(updateList)) { |
| 147 | - expressTemplateChargeBatchMapper.saveOrUpdateBatch(updateList); | |
| 135 | + expressTemplateChargeMapper.updateBatch(updateList); | |
| 148 | 136 | } |
| 149 | - //删除 | |
| 137 | + // 得到删除的ids | |
| 138 | + Set<Long> deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId); | |
| 139 | + deleteChargeIds.removeAll(CollectionUtils.convertSet(updateList, DeliveryExpressTemplateChargeDO::getId)); | |
| 140 | + // 删除 | |
| 150 | 141 | if (CollUtil.isNotEmpty(deleteChargeIds)) { |
| 151 | 142 | expressTemplateChargeMapper.deleteBatchIds(deleteChargeIds); |
| 152 | 143 | } |
| ... | ... | @@ -157,7 +148,6 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla |
| 157 | 148 | public void deleteDeliveryExpressTemplate(Long id) { |
| 158 | 149 | // 校验存在 |
| 159 | 150 | validateDeliveryExpressTemplateExists(id); |
| 160 | - | |
| 161 | 151 | // 删除主表 |
| 162 | 152 | expressTemplateMapper.deleteById(id); |
| 163 | 153 | // 删除运费从表 |
| ... | ... | @@ -167,9 +157,10 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla |
| 167 | 157 | } |
| 168 | 158 | |
| 169 | 159 | /** |
| 170 | - * 校验运费模板名是否唯一 // TODO @jason:方法注释,和参数,要空一行。 | |
| 160 | + * 校验运费模板名是否唯一 | |
| 161 | + * | |
| 171 | 162 | * @param name 模板名称 |
| 172 | - * @param id 运费模板编号, 可以为null // TODO @jason:中英文之间,要空一行;其它地方也看看哈 | |
| 163 | + * @param id 运费模板编号,可以为 null | |
| 173 | 164 | */ |
| 174 | 165 | private void validateTemplateNameUnique(String name, Long id) { |
| 175 | 166 | DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name); |
| ... | ... | @@ -196,7 +187,7 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla |
| 196 | 187 | List<DeliveryExpressTemplateChargeDO> chargeList = expressTemplateChargeMapper.selectListByTemplateId(id); |
| 197 | 188 | List<DeliveryExpressTemplateFreeDO> freeList = expressTemplateFreeMapper.selectListByTemplateId(id); |
| 198 | 189 | DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(id); |
| 199 | - return INSTANCE.convert(template, chargeList,freeList); | |
| 190 | + return INSTANCE.convert(template, chargeList, freeList); | |
| 200 | 191 | } |
| 201 | 192 | |
| 202 | 193 | @Override |
| ... | ... | @@ -208,10 +199,4 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla |
| 208 | 199 | public PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO) { |
| 209 | 200 | return expressTemplateMapper.selectPage(pageReqVO); |
| 210 | 201 | } |
| 211 | - | |
| 212 | - @Override | |
| 213 | - public List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO) { | |
| 214 | - return expressTemplateMapper.selectList(exportReqVO); | |
| 215 | - } | |
| 216 | - | |
| 217 | 202 | } | ... | ... |
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; |
| 6 | 6 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.ip.core.utils.IPUtils; |
| 8 | 8 | import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; |
| 9 | -import cn.iocoder.yudao.module.system.controller.admin.ip.vo.LazyAreaNodeRespVO; | |
| 9 | +import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeSimpleRespVO; | |
| 10 | 10 | import cn.iocoder.yudao.module.system.convert.ip.AreaConvert; |
| 11 | 11 | import io.swagger.v3.oas.annotations.Operation; |
| 12 | 12 | import io.swagger.v3.oas.annotations.Parameter; |
| ... | ... | @@ -34,23 +34,23 @@ public class AreaController { |
| 34 | 34 | return success(AreaConvert.INSTANCE.convertList(area.getChildren())); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - // TODO @jason:1)url 使用中划线分隔哈,然后可以改成 children;2)id 需要添加 @RequestParam,因为可能会混淆编译; | |
| 38 | - // 3) swagger 注解要写下哈; | |
| 39 | - @GetMapping("/getChildrenArea") | |
| 37 | + @GetMapping("/get-children") | |
| 40 | 38 | @Operation(summary = "获得地区的下级区域") |
| 41 | - public CommonResult<List<LazyAreaNodeRespVO>> getChildrenArea(Integer id) { | |
| 39 | + @Parameter(name = "id", description = "区域编号", required = true, example = "150000") | |
| 40 | + public CommonResult<List<AreaNodeSimpleRespVO>> getChildren(@RequestParam("id") Integer id) { | |
| 42 | 41 | Area area = AreaUtils.getArea(id); |
| 43 | - Assert.notNull(area, String.format("获取不到 id : %d的区域", id)); | |
| 42 | + Assert.notNull(area, String.format("获取不到 id : %d 的区域", id)); | |
| 44 | 43 | return success(AreaConvert.INSTANCE.convertList2(area.getChildren())); |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | - // TODO @jason:1)读请求,使用 get 哈。2)然后参数不应该使用 @RequestBody;3)areaIds 改成 ids 更合适; | |
| 48 | 46 | // 4)方法改成 getAreaChildrenList 获得子节点们;5)url 可以已改成 children-list |
| 49 | - @PostMapping("/list") | |
| 47 | + //@芋艿 是不是叫 getAreaListByIds 更合适。 因为不一定是子节点。 用于前端树选择获取缓存数据。 见 <el-tree-select :cache-data="areaCache"> | |
| 48 | + @GetMapping("/get-by-ids") | |
| 50 | 49 | @Operation(summary = "通过区域 ids 获得地区列表") |
| 51 | - public CommonResult<List<LazyAreaNodeRespVO>> list(@RequestBody Set<Integer> areaIds) { | |
| 52 | - List<Area> areaList = new ArrayList<>(areaIds.size()); | |
| 53 | - for (Integer areaId : areaIds) { | |
| 50 | + @Parameter(name = "ids", description = "区域编号 ids", required = true, example = "1,150000") | |
| 51 | + public CommonResult<List<AreaNodeSimpleRespVO>> getAreaListByIds(@RequestParam("ids") Set<Integer> ids) { | |
| 52 | + List<Area> areaList = new ArrayList<>(ids.size()); | |
| 53 | + for (Integer areaId : ids) { | |
| 54 | 54 | areaList.add(AreaUtils.getArea(areaId)); |
| 55 | 55 | } |
| 56 | 56 | return success(AreaConvert.INSTANCE.convertList2(areaList)); | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/LazyAreaNodeRespVO.java renamed to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeSimpleRespVO.java
| ... | ... | @@ -3,13 +3,9 @@ package cn.iocoder.yudao.module.system.controller.admin.ip.vo; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | -// TODO @jason:1)VO 不添加注释作者哈。2)是不是改成 AreaNodeSimpleRespVO,它其实是返回一个简洁的地区,懒加载只是它的使用场景; | |
| 7 | -/** | |
| 8 | - * @author jason | |
| 9 | - */ | |
| 10 | -@Schema(description = "管理后台 - 懒加载地区节点 Response VO") | |
| 6 | +@Schema(description = "管理后台 - 简洁的地区节点 Response VO") | |
| 11 | 7 | @Data |
| 12 | -public class LazyAreaNodeRespVO { | |
| 8 | +public class AreaNodeSimpleRespVO { | |
| 13 | 9 | |
| 14 | 10 | @Schema(description = "编号", required = true, example = "110000") |
| 15 | 11 | private Integer id; |
| ... | ... | @@ -17,8 +13,7 @@ public class LazyAreaNodeRespVO { |
| 17 | 13 | @Schema(description = "名字", required = true, example = "北京") |
| 18 | 14 | private String name; |
| 19 | 15 | |
| 20 | - // TODO @jason:1)不设置默认值,交给业务逻辑那写入;2)这个字段必须返回哇? | |
| 21 | - @Schema(description = "是否叶子节点", required = true, example = "false") | |
| 22 | - private Boolean leaf = Boolean.FALSE; | |
| 16 | + @Schema(description = "是否叶子节点", required = false, example = "false") | |
| 17 | + private Boolean leaf; | |
| 23 | 18 | |
| 24 | 19 | } | ... | ... |
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; |
| 3 | 3 | import cn.iocoder.yudao.framework.ip.core.Area; |
| 4 | 4 | import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; |
| 5 | 5 | import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.ip.vo.LazyAreaNodeRespVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeSimpleRespVO; | |
| 7 | 7 | import org.mapstruct.Mapper; |
| 8 | 8 | import org.mapstruct.Mapping; |
| 9 | -import org.mapstruct.Named; | |
| 10 | 9 | import org.mapstruct.factory.Mappers; |
| 11 | -import org.springframework.context.annotation.Lazy; | |
| 12 | 10 | |
| 13 | 11 | import java.util.List; |
| 14 | 12 | import java.util.Objects; |
| ... | ... | @@ -20,10 +18,10 @@ public interface AreaConvert { |
| 20 | 18 | |
| 21 | 19 | List<AreaNodeRespVO> convertList(List<Area> list); |
| 22 | 20 | |
| 23 | - List<LazyAreaNodeRespVO> convertList2(List<Area> list); | |
| 21 | + List<AreaNodeSimpleRespVO> convertList2(List<Area> list); | |
| 24 | 22 | |
| 25 | 23 | @Mapping(source = "type", target = "leaf") |
| 26 | - LazyAreaNodeRespVO convert(Area area); | |
| 24 | + AreaNodeSimpleRespVO convert(Area area); | |
| 27 | 25 | |
| 28 | 26 | default Boolean convertAreaType(Integer type){ |
| 29 | 27 | return Objects.equals(AreaTypeEnum.DISTRICT.getType(),type); | ... | ... |