新增快递公司功能

This commit is contained in:
jason 2023-05-18 23:37:56 +08:00
parent f129eab36f
commit 3da2eb89b2
15 changed files with 535 additions and 4 deletions

View File

@ -433,7 +433,7 @@ CREATE TABLE `trade_delivery_pick_up_store_staff` (
DROP TABLE IF EXISTS `trade_delivery_express`; DROP TABLE IF EXISTS `trade_delivery_express`;
CREATE TABLE `trade_delivery_express` ( CREATE TABLE `trade_delivery_express` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号自增', `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号自增',
`code` varchar(64) NOT NULL COMMENT '快递公司 code', `code` varchar(64) NOT NULL COMMENT '快递公司编号',
`name` varchar(64) NOT NULL COMMENT '快递公司名称', `name` varchar(64) NOT NULL COMMENT '快递公司名称',
`logo` varchar(256) COMMENT '快递公司logo', `logo` varchar(256) COMMENT '快递公司logo',
`sort` int NOT NULL DEFAULT 0 COMMENT '排序', `sort` int NOT NULL DEFAULT 0 COMMENT '排序',
@ -445,7 +445,7 @@ CREATE TABLE `trade_delivery_express` (
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='配送快递公司'; ) ENGINE=InnoDB COMMENT='快递公司';
SET FOREIGN_KEY_CHECKS = 1; SET FOREIGN_KEY_CHECKS = 1;
@ -478,6 +478,15 @@ 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 (2027, 'Banner创建', 'market:banner:create', 3, 2, 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 (2027, 'Banner创建', 'market:banner:create', 3, 2, 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 (2028, 'Banner更新', 'market:banner:update', 3, 3, 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 (2028, 'Banner更新', 'market:banner:update', 3, 3, 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`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2029, 'Banner删除', 'market:banner:delete', 3, 4, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2164, '配送管理', '', 1, 0, 2072, 'delivery', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:18:02', '1', '2023-05-18 09:48:48', b'0');
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2165, '快递发货', '', 1, 0, 2164, 'express', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:22:06', '1', '2023-05-18 09:22:06', b'0');
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2166, '门店自提', '', 1, 1, 2164, 'pick-up-store', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:23:14', '1', '2023-05-18 09:23:14', b'0');
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2167, '快递公司', '', 2, 0, 2165, 'express', '', 'mall/trade/delivery/express/index', 'Express', 0, b'1', b'1', b'1', '1', '2023-05-18 09:27:21', '1', '2023-05-18 22:11:14', b'0');
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2168, '快递公司查询', 'trade:delivery:express:query', 3, 1, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0');
INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2169, '快递公司创建', 'trade:delivery:express:create', 3, 2, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0');
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 (2170, '快递公司更新', 'trade:delivery:express:update', 3, 3, 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 (2171, '快递公司删除', 'trade:delivery:express:delete', 3, 4, 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 (2172, '快递公司导出', 'trade:delivery:express:export', 3, 5, 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 `system_dict_data`(`sort`,`label`,`value`,`dict_type`,`status`,`color_type`,`css_class`,`remark`,`creator`,`create_time`,`updater`,`update_time`,`deleted`) VALUES INSERT INTO `system_dict_data`(`sort`,`label`,`value`,`dict_type`,`status`,`color_type`,`css_class`,`remark`,`creator`,`create_time`,`updater`,`update_time`,`deleted`) VALUES
(1,'打',2,'product_unit',0,'','','',1, NOW(),1, NOW(),0), (1,'打',2,'product_unit',0,'','','',1, NOW(),1, NOW(),0),

View File

@ -42,7 +42,11 @@ public interface ErrorCodeConstants {
ErrorCode AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND = new ErrorCode(1011000110, "退款失败,售后单状态不是【待退款】"); ErrorCode AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND = new ErrorCode(1011000110, "退款失败,售后单状态不是【待退款】");
ErrorCode AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE = new ErrorCode(1011000111, "取消售后单失败,售后单状态不是【待审核】或【卖家同意】"); ErrorCode AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE = new ErrorCode(1011000111, "取消售后单失败,售后单状态不是【待审核】或【卖家同意】");
// ========== Cart 模块 1-011-001-000 ========== // ========== Cart 模块 1-011-002-000 ==========
ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1011002000, "购物车项不存在"); ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1011002000, "购物车项不存在");
// ========== 物流配送模块 1-011-003-000 ==========
ErrorCode DELIVERY_EXPRESS_NOT_EXISTS = new ErrorCode(1011003000, "快递公司不存在");
ErrorCode EXPRESS_CODE_DUPLICATE = new ErrorCode(1011003001, "已经存在该编码的快递公司");
} }

View File

@ -0,0 +1,92 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.*;
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 快递公司")
@RestController
@RequestMapping("/trade/delivery/express")
@Validated
public class DeliveryExpressController {
@Resource
private DeliveryExpressService deliveryExpressService;
@PostMapping("/create")
@Operation(summary = "创建快递公司")
@PreAuthorize("@ss.hasPermission('trade:delivery:express:create')")
public CommonResult<Long> createDeliveryExpress(@Valid @RequestBody DeliveryExpressCreateReqVO createReqVO) {
return success(deliveryExpressService.createDeliveryExpress(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新快递公司")
@PreAuthorize("@ss.hasPermission('trade:delivery:express:update')")
public CommonResult<Boolean> updateDeliveryExpress(@Valid @RequestBody DeliveryExpressUpdateReqVO updateReqVO) {
deliveryExpressService.updateDeliveryExpress(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除快递公司")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('trade:delivery:express:delete')")
public CommonResult<Boolean> deleteDeliveryExpress(@RequestParam("id") Long id) {
deliveryExpressService.deleteDeliveryExpress(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得快递公司")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('trade:delivery:express:query')")
public CommonResult<DeliveryExpressRespVO> getDeliveryExpress(@RequestParam("id") Long id) {
DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(id);
return success(DeliveryExpressConvert.INSTANCE.convert(deliveryExpress));
}
@GetMapping("/page")
@Operation(summary = "获得快递公司分页")
@PreAuthorize("@ss.hasPermission('trade:delivery-express:query')")
public CommonResult<PageResult<DeliveryExpressRespVO>> getDeliveryExpressPage(@Valid DeliveryExpressPageReqVO pageVO) {
PageResult<DeliveryExpressDO> pageResult = deliveryExpressService.getDeliveryExpressPage(pageVO);
return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出快递公司 Excel")
@PreAuthorize("@ss.hasPermission('trade:delivery:express:export')")
@OperateLog(type = EXPORT)
public void exportDeliveryExpressExcel(@Valid DeliveryExpressExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<DeliveryExpressDO> list = deliveryExpressService.getDeliveryExpressList(exportReqVO);
// 导出 Excel
List<DeliveryExpressExcelVO> dataList = DeliveryExpressConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "快递公司.xls", "数据", DeliveryExpressExcelVO.class, dataList);
}
}

View File

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
/**
* 快递公司 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class DeliveryExpressBaseVO {
@Schema(description = "快递公司编号", required = true)
@NotNull(message = "快递公司编号不能为空")
private String code;
@Schema(description = "快递公司名称", required = true, example = "李四")
@NotNull(message = "快递公司名称不能为空")
private String name;
@Schema(description = "快递公司logo")
private String logo;
@Schema(description = "排序", required = true)
@NotNull(message = "排序不能为空")
private Integer sort;
@Schema(description = "状态0正常 1停用", required = true, example = "1")
@NotNull(message = "状态0正常 1停用不能为空")
private Integer status;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 快递公司创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class DeliveryExpressCreateReqVO extends DeliveryExpressBaseVO {
}

View File

@ -0,0 +1,37 @@
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 DeliveryExpressExcelVO {
@ExcelProperty("编号")
private Long id;
@ExcelProperty("快递公司编号")
private String code;
@ExcelProperty("快递公司名称")
private String name;
@ExcelProperty("快递公司logo")
private String logo;
@ExcelProperty("排序")
private Integer sort;
@ExcelProperty("状态0正常 1停用")
private Byte status;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 快递公司 Excel 导出 Request VO")
@Data
public class DeliveryExpressExportReqVO {
@Schema(description = "快递公司编号")
private String code;
@Schema(description = "快递公司名称", example = "李四")
private String name;
@Schema(description = "状态0正常 1停用", example = "1")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,31 @@
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 org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 快递公司分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class DeliveryExpressPageReqVO extends PageParam {
@Schema(description = "快递公司编号")
private String code;
@Schema(description = "快递公司名称", example = "李四")
private String name;
@Schema(description = "状态0正常 1停用", example = "1")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 快递公司 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class DeliveryExpressRespVO extends DeliveryExpressBaseVO {
@Schema(description = "编号", required = true, example = "6592")
private Long id;
@Schema(description = "创建时间", required = true)
private LocalDateTime createTime;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 快递公司更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class DeliveryExpressUpdateReqVO extends DeliveryExpressBaseVO {
@Schema(description = "编号", required = true, example = "6592")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.trade.convert.delivery;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressExcelVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressRespVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressUpdateReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 快递公司 Convert
*
* @author 芋道源码
*/
@Mapper
public interface DeliveryExpressConvert {
DeliveryExpressConvert INSTANCE = Mappers.getMapper(DeliveryExpressConvert.class);
DeliveryExpressDO convert(DeliveryExpressCreateReqVO bean);
DeliveryExpressDO convert(DeliveryExpressUpdateReqVO bean);
DeliveryExpressRespVO convert(DeliveryExpressDO bean);
List<DeliveryExpressRespVO> convertList(List<DeliveryExpressDO> list);
PageResult<DeliveryExpressRespVO> convertPage(PageResult<DeliveryExpressDO> page);
List<DeliveryExpressExcelVO> convertList02(List<DeliveryExpressDO> list);
}

View File

@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
/** /**
* 配送快递公司 DO * 快递公司 DO
* *
* @author jason * @author jason
*/ */

View File

@ -1,12 +1,41 @@
package cn.iocoder.yudao.module.trade.dal.mysql.delivery; package cn.iocoder.yudao.module.trade.dal.mysql.delivery;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressExportReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressPageReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
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 DeliveryExpressMapper extends BaseMapperX<DeliveryExpressDO> { public interface DeliveryExpressMapper extends BaseMapperX<DeliveryExpressDO> {
default PageResult<DeliveryExpressDO> selectPage(DeliveryExpressPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<DeliveryExpressDO>()
.likeIfPresent(DeliveryExpressDO::getCode, reqVO.getCode())
.likeIfPresent(DeliveryExpressDO::getName, reqVO.getName())
.eqIfPresent(DeliveryExpressDO::getStatus, reqVO.getStatus())
.betweenIfPresent(DeliveryExpressDO::getCreateTime, reqVO.getCreateTime())
.orderByAsc(DeliveryExpressDO::getSort));
}
default List<DeliveryExpressDO> selectList(DeliveryExpressExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<DeliveryExpressDO>()
.likeIfPresent(DeliveryExpressDO::getCode, reqVO.getCode())
.likeIfPresent(DeliveryExpressDO::getName, reqVO.getName())
.eqIfPresent(DeliveryExpressDO::getStatus, reqVO.getStatus())
.betweenIfPresent(DeliveryExpressDO::getCreateTime, reqVO.getCreateTime())
.orderByAsc(DeliveryExpressDO::getSort));
}
default DeliveryExpressDO selectByCode(String code) {
return selectOne(new LambdaQueryWrapper<DeliveryExpressDO>()
.eq(DeliveryExpressDO::getCode, code));
}
} }

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.trade.service.delivery;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressExportReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressPageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressUpdateReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
/**
* 快递公司 Service 接口
*
* @author jason
*/
public interface DeliveryExpressService {
/**
* 创建快递公司
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createDeliveryExpress(@Valid DeliveryExpressCreateReqVO createReqVO);
/**
* 更新快递公司
*
* @param updateReqVO 更新信息
*/
void updateDeliveryExpress(@Valid DeliveryExpressUpdateReqVO updateReqVO);
/**
* 删除快递公司
*
* @param id 编号
*/
void deleteDeliveryExpress(Long id);
/**
* 获得快递公司
*
* @param id 编号
* @return 快递公司
*/
DeliveryExpressDO getDeliveryExpress(Long id);
/**
* 获得快递公司列表
*
* @param ids 编号
* @return 快递公司列表
*/
List<DeliveryExpressDO> getDeliveryExpressList(Collection<Long> ids);
/**
* 获得快递公司分页
*
* @param pageReqVO 分页查询
* @return 快递公司分页
*/
PageResult<DeliveryExpressDO> getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO);
/**
* 获得快递公司列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 快递公司列表
*/
List<DeliveryExpressDO> getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO);
}

View File

@ -0,0 +1,102 @@
package cn.iocoder.yudao.module.trade.service.delivery;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressExportReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressPageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.DeliveryExpressUpdateReqVO;
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
/**
* 快递公司 Service 实现类
*
* @author jason
*/
@Service
@Validated
public class DeliveryExpressServiceImpl implements DeliveryExpressService {
@Resource
private DeliveryExpressMapper deliveryExpressMapper;
@Override
public Long createDeliveryExpress(DeliveryExpressCreateReqVO createReqVO) {
//校验编码是否唯一
validateExpressCodeUnique(createReqVO.getCode(), null);
// 插入
DeliveryExpressDO deliveryExpress = DeliveryExpressConvert.INSTANCE.convert(createReqVO);
deliveryExpressMapper.insert(deliveryExpress);
// 返回
return deliveryExpress.getId();
}
@Override
public void updateDeliveryExpress(DeliveryExpressUpdateReqVO updateReqVO) {
// 校验存在
validateDeliveryExpressExists(updateReqVO.getId());
//校验编码是否唯一
validateExpressCodeUnique(updateReqVO.getCode(), updateReqVO.getId());
// 更新
DeliveryExpressDO updateObj = DeliveryExpressConvert.INSTANCE.convert(updateReqVO);
deliveryExpressMapper.updateById(updateObj);
}
@Override
public void deleteDeliveryExpress(Long id) {
// 校验存在
validateDeliveryExpressExists(id);
// 删除
deliveryExpressMapper.deleteById(id);
}
private void validateExpressCodeUnique(String code, Long id) {
DeliveryExpressDO express = deliveryExpressMapper.selectByCode(code);
if (express == null) {
return;
}
// 如果 id 为空说明不用比较是否为相同 id 的快递公司
if (id == null) {
throw exception(EXPRESS_CODE_DUPLICATE);
}
if (!express.getId().equals(id)) {
throw exception(EXPRESS_CODE_DUPLICATE);
}
}
private void validateDeliveryExpressExists(Long id) {
if (deliveryExpressMapper.selectById(id) == null) {
throw exception(DELIVERY_EXPRESS_NOT_EXISTS);
}
}
@Override
public DeliveryExpressDO getDeliveryExpress(Long id) {
return deliveryExpressMapper.selectById(id);
}
@Override
public List<DeliveryExpressDO> getDeliveryExpressList(Collection<Long> ids) {
return deliveryExpressMapper.selectBatchIds(ids);
}
@Override
public PageResult<DeliveryExpressDO> getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO) {
return deliveryExpressMapper.selectPage(pageReqVO);
}
@Override
public List<DeliveryExpressDO> getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO) {
return deliveryExpressMapper.selectList(exportReqVO);
}
}