运费模板 review 修改. 运费模块可以选择多个区域

This commit is contained in:
jason 2023-05-27 11:20:43 +08:00
parent 02fa6fc5c6
commit 55dbff7570
26 changed files with 193 additions and 254 deletions

View File

@ -350,7 +350,7 @@ DROP TABLE IF EXISTS `trade_delivery_express_template_free`;
CREATE TABLE `trade_delivery_express_template_free` ( CREATE TABLE `trade_delivery_express_template_free` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`template_id` bigint NOT NULL 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_price` int NOT NULL COMMENT '包邮金额单位',
`free_count` int NOT NULL DEFAULT 0 COMMENT '包邮件数,', `free_count` int NOT NULL DEFAULT 0 COMMENT '包邮件数,',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' 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` ( CREATE TABLE `trade_delivery_express_template_charge` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号自增', `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号自增',
`template_id` bigint NOT NULL 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 '配送计费方式', `charge_mode` tinyint NOT NULL COMMENT '配送计费方式',
`start_count` double NOT NULL COMMENT '首件数量', `start_count` double NOT NULL COMMENT '首件数量',
`start_price` int 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`, `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 (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 (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 (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 (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'); 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');

View File

@ -45,4 +45,10 @@ public class StrUtils {
return Arrays.stream(longs).boxed().collect(Collectors.toList()); return Arrays.stream(longs).boxed().collect(Collectors.toList());
} }
public static List<Integer> splitToInteger(String value, CharSequence separator) {
int[] integers = StrUtil.splitToInt(value, separator);
return Arrays.stream(integers).boxed().collect(Collectors.toList());
}
} }

View File

@ -113,10 +113,20 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
Db.saveBatch(entities, size); Db.saveBatch(entities, size);
} }
// @芋艿 是不是叫 updateByDo 或者 updateByEntity 更合适
default void updateBatch(T update) { default void updateBatch(T update) {
update(update, new QueryWrapper<>()); update(update, new QueryWrapper<>());
} }
/**
* 根据ID 批量更新适合大量数据更新
*
* @param entities 实体们
*/
default void updateBatch(Collection<T> entities) {
Db.updateBatchById(entities);
}
default void updateBatch(Collection<T> entities, int size) { default void updateBatch(Collection<T> entities, int size) {
Db.updateBatchById(entities, size); Db.updateBatchById(entities, size);
} }

View File

@ -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<Integer> 的类型转换器实现类对应数据库的 varchar 类型
*
* @author jason
*/
@MappedJdbcTypes(JdbcType.VARCHAR)
@MappedTypes(List.class)
public class IntegerListTypeHandler implements TypeHandler<List<Integer>> {
private static final String COMMA = ",";
@Override
public void setParameter(PreparedStatement ps, int i, List<Integer> strings, JdbcType jdbcType) throws SQLException {
ps.setString(i, CollUtil.join(strings, COMMA));
}
@Override
public List<Integer> getResult(ResultSet rs, String columnName) throws SQLException {
String value = rs.getString(columnName);
return getResult(value);
}
@Override
public List<Integer> getResult(ResultSet rs, int columnIndex) throws SQLException {
String value = rs.getString(columnIndex);
return getResult(value);
}
@Override
public List<Integer> getResult(CallableStatement cs, int columnIndex) throws SQLException {
String value = cs.getString(columnIndex);
return getResult(value);
}
private List<Integer> getResult(String value) {
if (value == null) {
return null;
}
return StrUtils.splitToInteger(value, COMMA);
}
}

View File

@ -74,7 +74,7 @@ public class DeliveryExpressController {
return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult)); return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult));
} }
// TODO @jason运费模版可以去掉哈没啥用 // TODO @jason运费模版@芋艿 你的意思是运费模板导出没有必要吧已经去掉了这个是快递公司导出
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出快递公司 Excel") @Operation(summary = "导出快递公司 Excel")
@PreAuthorize("@ss.hasPermission('trade:delivery:express:export')") @PreAuthorize("@ss.hasPermission('trade:delivery:express:export')")

View File

@ -84,17 +84,4 @@ public class DeliveryExpressTemplateController {
PageResult<DeliveryExpressTemplateDO> pageResult = deliveryExpressTemplateService.getDeliveryExpressTemplatePage(pageVO); PageResult<DeliveryExpressTemplateDO> pageResult = deliveryExpressTemplateService.getDeliveryExpressTemplatePage(pageVO);
return success(DeliveryExpressTemplateConvert.INSTANCE.convertPage(pageResult)); 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<DeliveryExpressTemplateDO> list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(exportReqVO);
// 导出 Excel
List<DeliveryExpressTemplateExcelVO> datas = DeliveryExpressTemplateConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "快递运费模板.xls", "数据", DeliveryExpressTemplateExcelVO.class, datas);
}
} }

View File

@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo; 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 com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data; import lombok.Data;
@ -7,8 +10,6 @@ import java.time.LocalDateTime;
/** /**
* 快递公司 Excel VO * 快递公司 Excel VO
*
* @author jason
*/ */
@Data @Data
public class DeliveryExpressExcelVO { public class DeliveryExpressExcelVO {
@ -28,9 +29,9 @@ public class DeliveryExpressExcelVO {
@ExcelProperty("排序") @ExcelProperty("排序")
private Integer sort; private Integer sort;
@ExcelProperty("状态") @ExcelProperty(value = "状态", converter = DictConvert.class)
// TODO @jason可以使用 @DictFormat(DictTypeConstants.COMMON_STATUS) @DictFormat(DictTypeConstants.COMMON_STATUS)
private Byte status; private Integer status;
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -3,19 +3,19 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
/** /**
* 快递运费模板运费设置 Base VO提供给添加运费模板使用 * 快递运费模板运费设置 Base VO提供给添加运费模板使用
*
* @author jason
*/ */
@Data @Data
public class ExpressTemplateChargeBaseVO { public class ExpressTemplateChargeBaseVO {
@Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]")
@NotNull(message = "区域编号不能为空") @NotEmpty(message = "区域编号列表不能为空")
private Integer areaId; private List<Integer> areaIds;
@Schema(description = "首件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") @Schema(description = "首件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "首件数量不能为空") @NotNull(message = "首件数量不能为空")

View File

@ -3,9 +3,7 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
/**
* @author jason
*/
@Data @Data
public class ExpressTemplateChargeUpdateVO extends ExpressTemplateChargeBaseVO { public class ExpressTemplateChargeUpdateVO extends ExpressTemplateChargeBaseVO {

View File

@ -3,19 +3,19 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
/** /**
* 快递运费模板包邮 Base VO提供给添加运费模板使用 * 快递运费模板包邮 Base VO提供给添加运费模板使用
*
* @author jason
*/ */
@Data @Data
public class ExpressTemplateFreeBaseVO { public class ExpressTemplateFreeBaseVO {
@Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]")
@NotNull(message = "区域编号不能为空") @NotEmpty(message = "区域编号列表不能为空")
private Integer areaId; private List<Integer> areaIds;
@Schema(description = "包邮金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "5000") @Schema(description = "包邮金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "5000")
@NotNull(message = "包邮金额不能为空") @NotNull(message = "包邮金额不能为空")

View File

@ -5,8 +5,6 @@ import lombok.Data;
/** /**
* 快递运费模板包邮 更新 VO * 快递运费模板包邮 更新 VO
*
* @author jason
*/ */
@Data @Data
public class ExpressTemplateFreeUpdateVO extends ExpressTemplateFreeBaseVO { public class ExpressTemplateFreeUpdateVO extends ExpressTemplateFreeBaseVO {

View File

@ -16,7 +16,7 @@ import org.mapstruct.factory.Mappers;
/** /**
* 快递公司 Convert * 快递公司 Convert
* *
* @author 芋道源码 * @author jason
*/ */
@Mapper @Mapper
public interface DeliveryExpressConvert { public interface DeliveryExpressConvert {

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.convert.delivery;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.controller.admin.delivery.vo.*;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO;
@ -16,7 +17,7 @@ import java.util.List;
/** /**
* 快递运费模板 Convert * 快递运费模板 Convert
* *
* @author 芋道源码 * @author jason
*/ */
@Mapper @Mapper
public interface DeliveryExpressTemplateConvert { public interface DeliveryExpressTemplateConvert {
@ -37,8 +38,6 @@ public interface DeliveryExpressTemplateConvert {
PageResult<DeliveryExpressTemplateSimpleRespVO> convertPage(PageResult<DeliveryExpressTemplateDO> page); PageResult<DeliveryExpressTemplateSimpleRespVO> convertPage(PageResult<DeliveryExpressTemplateDO> page);
List<DeliveryExpressTemplateExcelVO> convertList02(List<DeliveryExpressTemplateDO> list);
default DeliveryExpressTemplateRespVO convert(DeliveryExpressTemplateDO bean, default DeliveryExpressTemplateRespVO convert(DeliveryExpressTemplateDO bean,
List<DeliveryExpressTemplateChargeDO> chargeList, List<DeliveryExpressTemplateChargeDO> chargeList,
List<DeliveryExpressTemplateFreeDO> freeList){ List<DeliveryExpressTemplateFreeDO> freeList){
@ -55,15 +54,7 @@ public interface DeliveryExpressTemplateConvert {
DeliveryExpressTemplateChargeDO convertTemplateCharge(ExpressTemplateChargeUpdateVO vo); DeliveryExpressTemplateChargeDO convertTemplateCharge(ExpressTemplateChargeUpdateVO vo);
default List<DeliveryExpressTemplateChargeDO> convertTemplateChargeList(Long templateId, Integer chargeMode, List<ExpressTemplateChargeBaseVO> list) { default List<DeliveryExpressTemplateChargeDO> convertTemplateChargeList(Long templateId, Integer chargeMode, List<ExpressTemplateChargeBaseVO> list) {
// TODO @jason可以使用 CollectionUtils.convertList本质上就是 stream convert list return CollectionUtils.convertList(list, vo -> convertTemplateCharge(templateId, chargeMode, vo));
if(CollUtil.isEmpty(list)){
return Collections.emptyList();
}
List<DeliveryExpressTemplateChargeDO> templateChargeList = new ArrayList<>(list.size());
for (ExpressTemplateChargeBaseVO item : list) {
templateChargeList.add(convertTemplateCharge(templateId, chargeMode, item));
}
return templateChargeList;
} }
// ========== Template Free ========== // ========== Template Free ==========
@ -76,17 +67,8 @@ public interface DeliveryExpressTemplateConvert {
List<ExpressTemplateFreeBaseVO> convertTemplateFreeList(List<DeliveryExpressTemplateFreeDO> list); List<ExpressTemplateFreeBaseVO> convertTemplateFreeList(List<DeliveryExpressTemplateFreeDO> list);
// TODO @jason, List中间一个空格哈代码的空格和空行要注意嘿嘿~ default List<DeliveryExpressTemplateFreeDO> convertTemplateFreeList(Long templateId, List<ExpressTemplateFreeBaseVO> list) {
default List<DeliveryExpressTemplateFreeDO> convertTemplateFreeList(Long templateId, List<ExpressTemplateFreeBaseVO> list) { return CollectionUtils.convertList(list, vo -> convertTemplateFree(templateId, vo));
// TODO @jason可以使用 CollectionUtils.convertList本质上就是 stream convert list
if (CollUtil.isEmpty(list)) {
return Collections.emptyList();
}
List<DeliveryExpressTemplateFreeDO> templateFreeList = new ArrayList<>(list.size());
for (ExpressTemplateFreeBaseVO item : list) {
templateFreeList.add(convertTemplateFree(templateId, item));
}
return templateFreeList;
} }
} }

View File

@ -1,17 +1,21 @@
package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; 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.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* 快递运费模板计费配置 DO * 快递运费模板计费配置 DO
* *
* @author jason * @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") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写 @KeySequence("trade_delivery_express_template_charge_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data @Data
public class DeliveryExpressTemplateChargeDO extends BaseDO { public class DeliveryExpressTemplateChargeDO extends BaseDO {
@ -30,9 +34,10 @@ public class DeliveryExpressTemplateChargeDO extends BaseDO {
private Long templateId; private Long templateId;
/** /**
* 配送区域 * 配送区域编号列表
*/ */
private Integer areaId; @TableField(typeHandler = IntegerListTypeHandler.class)
private List<Integer> areaIds;
/** /**
* 配送计费方式 * 配送计费方式

View File

@ -1,17 +1,21 @@
package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; 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.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* 快递运费模板包邮配置 DO * 快递运费模板包邮配置 DO
* *
* @author jason * @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") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写 @KeySequence("trade_delivery_express_template_free_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data @Data
public class DeliveryExpressTemplateFreeDO extends BaseDO { public class DeliveryExpressTemplateFreeDO extends BaseDO {
@ -29,10 +33,12 @@ public class DeliveryExpressTemplateFreeDO extends BaseDO {
*/ */
private Long templateId; private Long templateId;
/** /**
* 包邮区域id * 配送区域编号列表
*/ */
private Integer areaId; @TableField(typeHandler = IntegerListTypeHandler.class)
private List<Integer> areaIds;
/** /**
* 包邮金额单位 * 包邮金额单位

View File

@ -14,10 +14,6 @@ import java.util.List;
@Mapper @Mapper
public interface DeliveryExpressTemplateChargeMapper extends BaseMapperX<DeliveryExpressTemplateChargeDO> { public interface DeliveryExpressTemplateChargeMapper extends BaseMapperX<DeliveryExpressTemplateChargeDO> {
@Repository
class BatchInsertMapper extends ServiceImpl<DeliveryExpressTemplateChargeMapper, DeliveryExpressTemplateChargeDO> {
}
default List<DeliveryExpressTemplateChargeDO> selectListByTemplateId(Long templateId){ default List<DeliveryExpressTemplateChargeDO> selectListByTemplateId(Long templateId){
return selectList(new LambdaQueryWrapper<DeliveryExpressTemplateChargeDO>() return selectList(new LambdaQueryWrapper<DeliveryExpressTemplateChargeDO>()
.eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId)); .eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId));

View File

@ -14,10 +14,6 @@ import java.util.List;
@Mapper @Mapper
public interface DeliveryExpressTemplateFreeMapper extends BaseMapperX<DeliveryExpressTemplateFreeDO> { public interface DeliveryExpressTemplateFreeMapper extends BaseMapperX<DeliveryExpressTemplateFreeDO> {
@Repository
class BatchInsertMapper extends ServiceImpl<DeliveryExpressTemplateFreeMapper, DeliveryExpressTemplateFreeDO> {
}
default List<DeliveryExpressTemplateFreeDO> selectListByTemplateId(Long templateId) { default List<DeliveryExpressTemplateFreeDO> selectListByTemplateId(Long templateId) {
return selectList(new LambdaQueryWrapper<DeliveryExpressTemplateFreeDO>() return selectList(new LambdaQueryWrapper<DeliveryExpressTemplateFreeDO>()
.eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId)); .eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId));

View File

@ -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.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 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.controller.admin.delivery.vo.DeliveryExpressTemplatePageReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; 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 org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper @Mapper
public interface DeliveryExpressTemplateMapper extends BaseMapperX<DeliveryExpressTemplateDO> { public interface DeliveryExpressTemplateMapper extends BaseMapperX<DeliveryExpressTemplateDO> {
@ -23,18 +19,8 @@ public interface DeliveryExpressTemplateMapper extends BaseMapperX<DeliveryExpre
.orderByAsc(DeliveryExpressTemplateDO::getSort)); .orderByAsc(DeliveryExpressTemplateDO::getSort));
} }
default List<DeliveryExpressTemplateDO> selectList(DeliveryExpressTemplateExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<DeliveryExpressTemplateDO>()
.likeIfPresent(DeliveryExpressTemplateDO::getName, reqVO.getName())
.eqIfPresent(DeliveryExpressTemplateDO::getChargeMode, reqVO.getChargeMode())
.betweenIfPresent(DeliveryExpressTemplateDO::getCreateTime, reqVO.getCreateTime())
.orderByAsc(DeliveryExpressTemplateDO::getSort));
}
// TODO @jason可以用 selectOneDeliveryExpressTemplateDO::getName, name常用的我封装了哈简洁一点~
default DeliveryExpressTemplateDO selectByName(String name) { default DeliveryExpressTemplateDO selectByName(String name) {
return selectOne(new LambdaQueryWrapper<DeliveryExpressTemplateDO>() return selectOne(DeliveryExpressTemplateDO::getName,name);
.eq(DeliveryExpressTemplateDO::getName, name));
} }
} }

View File

@ -58,13 +58,4 @@ public interface DeliveryExpressTemplateService {
* @return 快递运费模板分页 * @return 快递运费模板分页
*/ */
PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO); PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO);
/**
* 获得快递运费模板列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 快递运费模板列表
*/
List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO);
} }

View File

@ -36,32 +36,24 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper; private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper;
@Resource @Resource
private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper; private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper;
// TODO @jason应该不用 BatchInsertMapper 直接走 expressTemplateChargeMapper.insertBatch
@Resource
private DeliveryExpressTemplateChargeMapper.BatchInsertMapper expressTemplateChargeBatchMapper;
@Resource
private DeliveryExpressTemplateFreeMapper.BatchInsertMapper expressTemplateFreeBatchMapper;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) { public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) {
// TODO @jason中英文之间要有空格哈例如说 // 校验模板名是否唯一 // 校验模板名是否唯一
//校验模板名是否唯一
validateTemplateNameUnique(createReqVO.getName(), null); validateTemplateNameUnique(createReqVO.getName(), null);
// 插入 // 插入
DeliveryExpressTemplateDO deliveryExpressTemplate = INSTANCE.convert(createReqVO); DeliveryExpressTemplateDO deliveryExpressTemplate = INSTANCE.convert(createReqVO);
expressTemplateMapper.insert(deliveryExpressTemplate); expressTemplateMapper.insert(deliveryExpressTemplate);
//插入运费模板计费表 // 插入运费模板计费表
// TODO @jasonif (中间要有空格 if (CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) {
if(CollUtil.isNotEmpty(createReqVO.getTemplateCharge())) { expressTemplateChargeMapper.insertBatch(
expressTemplateChargeBatchMapper.saveBatch( INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge())
INSTANCE.convertTemplateChargeList(deliveryExpressTemplate.getId(), createReqVO.getChargeMode(), createReqVO.getTemplateCharge())
); );
} }
//插入运费模板包邮表 // 插入运费模板包邮表
if(CollUtil.isNotEmpty(createReqVO.getTemplateFree())) { if (CollUtil.isNotEmpty(createReqVO.getTemplateFree())) {
expressTemplateFreeBatchMapper.saveBatch( expressTemplateFreeMapper.insertBatch(
INSTANCE.convertTemplateFreeList(deliveryExpressTemplate.getId(), createReqVO.getTemplateFree()) INSTANCE.convertTemplateFreeList(deliveryExpressTemplate.getId(), createReqVO.getTemplateFree())
); );
} }
@ -73,14 +65,13 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
public void updateDeliveryExpressTemplate(DeliveryExpressTemplateUpdateReqVO updateReqVO) { public void updateDeliveryExpressTemplate(DeliveryExpressTemplateUpdateReqVO updateReqVO) {
// 校验存在 // 校验存在
validateDeliveryExpressTemplateExists(updateReqVO.getId()); validateDeliveryExpressTemplateExists(updateReqVO.getId());
//校验模板名是否唯一 // 校验模板名是否唯一
validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId()); validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId());
// 更新运费从表
//更新运费从表
updateExpressTemplateCharge(updateReqVO); updateExpressTemplateCharge(updateReqVO);
//更新包邮从表 // 更新包邮从表
updateExpressTemplateFree(updateReqVO); updateExpressTemplateFree(updateReqVO);
//更新模板主表 // 更新模板主表
DeliveryExpressTemplateDO updateObj = INSTANCE.convert(updateReqVO); DeliveryExpressTemplateDO updateObj = INSTANCE.convert(updateReqVO);
expressTemplateMapper.updateById(updateObj); expressTemplateMapper.updateById(updateObj);
} }
@ -88,29 +79,29 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
private void updateExpressTemplateFree(DeliveryExpressTemplateUpdateReqVO updateReqVO) { private void updateExpressTemplateFree(DeliveryExpressTemplateUpdateReqVO updateReqVO) {
List<DeliveryExpressTemplateFreeDO> oldFreeList = expressTemplateFreeMapper.selectListByTemplateId(updateReqVO.getId()); List<DeliveryExpressTemplateFreeDO> oldFreeList = expressTemplateFreeMapper.selectListByTemplateId(updateReqVO.getId());
List<ExpressTemplateFreeUpdateVO> newFreeList = updateReqVO.getTemplateFree(); List<ExpressTemplateFreeUpdateVO> newFreeList = updateReqVO.getTemplateFree();
//新增包邮区域列表 // 新增包邮区域列表
List<DeliveryExpressTemplateFreeDO> addFreeList = new ArrayList<>(newFreeList.size()); List<DeliveryExpressTemplateFreeDO> addFreeList = new ArrayList<>(newFreeList.size());
//更新包邮区域列表 // 更新包邮区域列表
List<DeliveryExpressTemplateFreeDO> updateFreeList = new ArrayList<>(newFreeList.size()); List<DeliveryExpressTemplateFreeDO> updateFreeList = new ArrayList<>(newFreeList.size());
for (ExpressTemplateFreeUpdateVO item : newFreeList) { for (ExpressTemplateFreeUpdateVO item : newFreeList) {
if (Objects.nonNull(item.getId())) { if (Objects.nonNull(item.getId())) {
updateFreeList.add(INSTANCE.convertTemplateFree(item)); updateFreeList.add(INSTANCE.convertTemplateFree(item));
}else{ } else {
item.setTemplateId(updateReqVO.getId()); item.setTemplateId(updateReqVO.getId());
addFreeList.add(INSTANCE.convertTemplateFree(item)); addFreeList.add(INSTANCE.convertTemplateFree(item));
} }
} }
//删除的包邮区域id // 新增
if (CollUtil.isNotEmpty(addFreeList)) {
expressTemplateFreeMapper.insertBatch(addFreeList);
}
// 修改
if (CollUtil.isNotEmpty(updateFreeList)) {
expressTemplateFreeMapper.updateBatch(updateFreeList);
}
// 得到删除ids
Set<Long> deleteFreeIds = CollectionUtils.convertSet(oldFreeList, DeliveryExpressTemplateFreeDO::getId); Set<Long> deleteFreeIds = CollectionUtils.convertSet(oldFreeList, DeliveryExpressTemplateFreeDO::getId);
deleteFreeIds.removeAll(CollectionUtils.convertSet(updateFreeList, 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)) { if (CollUtil.isNotEmpty(deleteFreeIds)) {
expressTemplateFreeMapper.deleteBatchIds(deleteFreeIds); expressTemplateFreeMapper.deleteBatchIds(deleteFreeIds);
@ -120,33 +111,33 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
private void updateExpressTemplateCharge(DeliveryExpressTemplateUpdateReqVO updateReqVO) { private void updateExpressTemplateCharge(DeliveryExpressTemplateUpdateReqVO updateReqVO) {
List<DeliveryExpressTemplateChargeDO> oldChargeList = expressTemplateChargeMapper.selectListByTemplateId(updateReqVO.getId()); List<DeliveryExpressTemplateChargeDO> oldChargeList = expressTemplateChargeMapper.selectListByTemplateId(updateReqVO.getId());
List<ExpressTemplateChargeUpdateVO> newChargeList = updateReqVO.getTemplateCharge(); List<ExpressTemplateChargeUpdateVO> newChargeList = updateReqVO.getTemplateCharge();
//新增运费区域列表 // 新增运费区域列表
List<DeliveryExpressTemplateChargeDO> addList = new ArrayList<>(newChargeList.size()); List<DeliveryExpressTemplateChargeDO> addList = new ArrayList<>(newChargeList.size());
//更新运费区域列表 // 更新运费区域列表
List<DeliveryExpressTemplateChargeDO> updateList = new ArrayList<>(newChargeList.size()); List<DeliveryExpressTemplateChargeDO> updateList = new ArrayList<>(newChargeList.size());
for (ExpressTemplateChargeUpdateVO item : newChargeList) { for (ExpressTemplateChargeUpdateVO item : newChargeList) {
if (Objects.nonNull(item.getId())) { // TODO @jasonnull 的判断还是用 item.getId() != null 好一点一般数组用方法主要考虑 null + length = 0 if (item.getId() != null) {
//计费模式以主表为准 // 计费模式以主表为准
item.setChargeMode(updateReqVO.getChargeMode()); item.setChargeMode(updateReqVO.getChargeMode());
updateList.add(INSTANCE.convertTemplateCharge(item)); updateList.add(INSTANCE.convertTemplateCharge(item));
}else{ } else {
item.setTemplateId(updateReqVO.getId()); item.setTemplateId(updateReqVO.getId());
item.setChargeMode(updateReqVO.getChargeMode()); item.setChargeMode(updateReqVO.getChargeMode());
addList.add(INSTANCE.convertTemplateCharge(item)); 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<Long> deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId); Set<Long> deleteChargeIds = CollectionUtils.convertSet(oldChargeList, DeliveryExpressTemplateChargeDO::getId);
deleteChargeIds.removeAll(CollectionUtils.convertSet(updateList, 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)) { if (CollUtil.isNotEmpty(deleteChargeIds)) {
expressTemplateChargeMapper.deleteBatchIds(deleteChargeIds); expressTemplateChargeMapper.deleteBatchIds(deleteChargeIds);
} }
@ -157,7 +148,6 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
public void deleteDeliveryExpressTemplate(Long id) { public void deleteDeliveryExpressTemplate(Long id) {
// 校验存在 // 校验存在
validateDeliveryExpressTemplateExists(id); validateDeliveryExpressTemplateExists(id);
// 删除主表 // 删除主表
expressTemplateMapper.deleteById(id); expressTemplateMapper.deleteById(id);
// 删除运费从表 // 删除运费从表
@ -167,9 +157,10 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
} }
/** /**
* 校验运费模板名是否唯一 // TODO @jason方法注释和参数要空一行 * 校验运费模板名是否唯一
*
* @param name 模板名称 * @param name 模板名称
* @param id 运费模板编号, 可以为null // TODO @jason中英文之间要空一行其它地方也看看哈 * @param id 运费模板编号,可以为 null
*/ */
private void validateTemplateNameUnique(String name, Long id) { private void validateTemplateNameUnique(String name, Long id) {
DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name); DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name);
@ -196,7 +187,7 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
List<DeliveryExpressTemplateChargeDO> chargeList = expressTemplateChargeMapper.selectListByTemplateId(id); List<DeliveryExpressTemplateChargeDO> chargeList = expressTemplateChargeMapper.selectListByTemplateId(id);
List<DeliveryExpressTemplateFreeDO> freeList = expressTemplateFreeMapper.selectListByTemplateId(id); List<DeliveryExpressTemplateFreeDO> freeList = expressTemplateFreeMapper.selectListByTemplateId(id);
DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(id); DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(id);
return INSTANCE.convert(template, chargeList,freeList); return INSTANCE.convert(template, chargeList, freeList);
} }
@Override @Override
@ -208,10 +199,4 @@ public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTempla
public PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO) { public PageResult<DeliveryExpressTemplateDO> getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO) {
return expressTemplateMapper.selectPage(pageReqVO); return expressTemplateMapper.selectPage(pageReqVO);
} }
@Override
public List<DeliveryExpressTemplateDO> getDeliveryExpressTemplateList(DeliveryExpressTemplateExportReqVO exportReqVO) {
return expressTemplateMapper.selectList(exportReqVO);
}
} }

View File

@ -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.AreaUtils;
import cn.iocoder.yudao.framework.ip.core.utils.IPUtils; 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.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 cn.iocoder.yudao.module.system.convert.ip.AreaConvert;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -34,23 +34,23 @@ public class AreaController {
return success(AreaConvert.INSTANCE.convertList(area.getChildren())); return success(AreaConvert.INSTANCE.convertList(area.getChildren()));
} }
// TODO @jason1url 使用中划线分隔哈然后可以改成 children2id 需要添加 @RequestParam因为可能会混淆编译 @GetMapping("/get-children")
// 3) swagger 注解要写下哈
@GetMapping("/getChildrenArea")
@Operation(summary = "获得地区的下级区域") @Operation(summary = "获得地区的下级区域")
public CommonResult<List<LazyAreaNodeRespVO>> getChildrenArea(Integer id) { @Parameter(name = "id", description = "区域编号", required = true, example = "150000")
public CommonResult<List<AreaNodeSimpleRespVO>> getChildren(@RequestParam("id") Integer id) {
Area area = AreaUtils.getArea(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())); return success(AreaConvert.INSTANCE.convertList2(area.getChildren()));
} }
// TODO @jason1读请求使用 get 2然后参数不应该使用 @RequestBody3areaIds 改成 ids 更合适
// 4)方法改成 getAreaChildrenList 获得子节点们5url 可以已改成 children-list // 4)方法改成 getAreaChildrenList 获得子节点们5url 可以已改成 children-list
@PostMapping("/list") //@芋艿 是不是叫 getAreaListByIds 更合适 因为不一定是子节点 用于前端树选择获取缓存数据 <el-tree-select :cache-data="areaCache">
@GetMapping("/get-by-ids")
@Operation(summary = "通过区域 ids 获得地区列表") @Operation(summary = "通过区域 ids 获得地区列表")
public CommonResult<List<LazyAreaNodeRespVO>> list(@RequestBody Set<Integer> areaIds) { @Parameter(name = "ids", description = "区域编号 ids", required = true, example = "1,150000")
List<Area> areaList = new ArrayList<>(areaIds.size()); public CommonResult<List<AreaNodeSimpleRespVO>> getAreaListByIds(@RequestParam("ids") Set<Integer> ids) {
for (Integer areaId : areaIds) { List<Area> areaList = new ArrayList<>(ids.size());
for (Integer areaId : ids) {
areaList.add(AreaUtils.getArea(areaId)); areaList.add(AreaUtils.getArea(areaId));
} }
return success(AreaConvert.INSTANCE.convertList2(areaList)); return success(AreaConvert.INSTANCE.convertList2(areaList));

View File

@ -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;
}

View File

@ -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 @jason1VO 不添加注释作者哈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 @jason1不设置默认值交给业务逻辑那写入2这个字段必须返回哇
@Schema(description = "是否叶子节点", required = true, example = "false")
private Boolean leaf = Boolean.FALSE;
}

View File

@ -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.Area;
import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; 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.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.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import org.springframework.context.annotation.Lazy;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -20,10 +18,10 @@ public interface AreaConvert {
List<AreaNodeRespVO> convertList(List<Area> list); List<AreaNodeRespVO> convertList(List<Area> list);
List<LazyAreaNodeRespVO> convertList2(List<Area> list); List<AreaNodeSimpleRespVO> convertList2(List<Area> list);
@Mapping(source = "type", target = "leaf") @Mapping(source = "type", target = "leaf")
LazyAreaNodeRespVO convert(Area area); AreaNodeSimpleRespVO convert(Area area);
default Boolean convertAreaType(Integer type){ default Boolean convertAreaType(Integer type){
return Objects.equals(AreaTypeEnum.DISTRICT.getType(),type); return Objects.equals(AreaTypeEnum.DISTRICT.getType(),type);