mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 07:49:20 +08:00
feat: 新增电商平台管理模块(ec_platform),店铺表platform改为外键
后端: - 新增 ec_platform 表 + 10条初始平台数据(淘宝/京东/拼多多/抖音等) - ec_shop 表 platform varchar → platform_id bigint 外键 - 新增 Platform 模块:PO/VO/DTO/Mapper/Service/Controller - 修复 ShopServiceImpl/CompanyOverviewServiceImpl/ExportServiceImpl 中 platform 字段引用 前端: - 新增平台管理页面(列表 + 表单弹窗) - 路由注册 /data/platform - 店铺管理:平台选择改为下拉,字段 platform 字符串 → platformId 外键 - 同步更新 ShopVO/ShopDTO 类型定义 数据库: - V20260422__add_ec_platform.sql 迁移文件
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
-- =============================================================================
|
||||
-- 迁移 SQL:新增 ec_platform 表,增加 platform_id 外键,创建平台管理权限和菜单
|
||||
-- 执行时间:2026-04-22
|
||||
-- =============================================================================
|
||||
|
||||
-- =========================================
|
||||
-- Part 1: ec_platform 表结构 + 初始化数据
|
||||
-- =========================================
|
||||
|
||||
DROP TABLE IF EXISTS `ec_platform`;
|
||||
CREATE TABLE `ec_platform` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '平台ID',
|
||||
`platform_name` varchar(50) NOT NULL COMMENT '平台名称',
|
||||
`platform_code` varchar(20) NOT NULL COMMENT '平台代码',
|
||||
`logo_url` varchar(500) NULL DEFAULT NULL COMMENT '平台Logo URL',
|
||||
`sort_order` int NULL DEFAULT 0 COMMENT '排序',
|
||||
`is_active` tinyint NOT NULL DEFAULT 1 COMMENT '是否启用 0禁用 1启用',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `uk_platform_code` (`platform_code` ASC)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='电商-平台表';
|
||||
|
||||
INSERT INTO `ec_platform` (`platform_name`, `platform_code`, `sort_order`, `is_active`) VALUES
|
||||
('淘宝', 'taobao', 1, 1),
|
||||
('京东', 'jd', 2, 1),
|
||||
('拼多多', 'pdd', 3, 1),
|
||||
('抖音', 'douyin', 4, 1),
|
||||
('快手', 'kuaishou', 5, 1),
|
||||
('小红书', 'xiaohongshu', 6, 1),
|
||||
('天猫', 'tmall', 7, 1),
|
||||
('唯品会', 'vip', 8, 1),
|
||||
('苏宁', 'suning', 9, 1),
|
||||
('1688', '1688', 10, 1);
|
||||
|
||||
-- =========================================
|
||||
-- Part 2: ec_shop 表增加 platform_id 字段
|
||||
-- =========================================
|
||||
|
||||
SET @column_exists = (
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'ec_shop'
|
||||
AND COLUMN_NAME = 'platform_id'
|
||||
);
|
||||
SET @sql = IF(@column_exists = 0,
|
||||
'ALTER TABLE `ec_shop` ADD COLUMN `platform_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT ''平台ID'' AFTER `logo_image_id`,
|
||||
ADD INDEX `idx_platform_id`(`platform_id` ASC),
|
||||
ADD CONSTRAINT `fk_ec_shop_platform` FOREIGN KEY (`platform_id`) REFERENCES `ec_platform`(`id`) ON DELETE SET NULL ON UPDATE CASCADE',
|
||||
'SELECT ''Column platform_id already exists, skipping'' '
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- =========================================
|
||||
-- Part 3: 平台管理权限
|
||||
-- =========================================
|
||||
|
||||
-- 3.1 插入平台管理模块(parent_id=102 为电商业务顶级模块)
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `code`, `type`, `sort_order`, `status`, `create_time`)
|
||||
SELECT 133, 102, '平台管理', 'ecom:platform', 'module', 330, 1, NOW()
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE code = 'ecom:platform' AND parent_id = 102);
|
||||
|
||||
-- 3.2 插入平台查看和管理权限
|
||||
INSERT INTO `sys_permission` (`parent_id`, `name`, `code`, `type`, `sort_order`, `status`, `create_time`)
|
||||
SELECT 133, '平台查看', 'ecom:platform:read', 'api', 331, 1, NOW()
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE code = 'ecom:platform:read');
|
||||
|
||||
INSERT INTO `sys_permission` (`parent_id`, `name`, `code`, `type`, `sort_order`, `status`, `create_time`)
|
||||
SELECT 133, '平台管理', 'ecom:platform:manage', 'api', 332, 1, NOW()
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE code = 'ecom:platform:manage');
|
||||
|
||||
-- =========================================
|
||||
-- Part 4: 平台管理菜单
|
||||
-- 说明:请根据 sys_menu 实际情况调整 parent_id(电商父菜单的ID)
|
||||
-- 可以通过: SELECT id, name, parent_id FROM sys_menu WHERE name LIKE '%电商%' 来查找
|
||||
-- =========================================
|
||||
|
||||
-- 查找电商父菜单的ID(请手动确认后再执行下面的 INSERT)
|
||||
-- SELECT id, name, parent_id FROM sys_menu WHERE name LIKE '%电商%' OR name LIKE '%店铺%';
|
||||
|
||||
-- 示例: 如果电商菜单的 ID 是 28,则执行:
|
||||
-- INSERT INTO `sys_menu` (`parent_id`, `name`, `title`, `path`, `component`, `icon`, `type`, `visible`, `status`, `order`, `create_time`)
|
||||
-- VALUES (28, 'platform', '平台管理', '/ecommerce/platform', 'ecommerce/platform/index', 'appstore', 'menu', 1, 1, 330, NOW());
|
||||
@@ -350,6 +350,47 @@ CREATE TABLE `ec_promotion_fee_type` (
|
||||
CONSTRAINT `fk_ec_promotion_fee_type_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-推广费类型表' ;
|
||||
|
||||
-- ----------------------------
|
||||
-- 平台表
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `ec_platform`;
|
||||
CREATE TABLE `ec_platform` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '平台ID',
|
||||
`platform_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '平台名称(如淘宝、京东、拼多多、抖音)',
|
||||
`platform_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '平台代码(如 taobao、jd、pdd、douyin)',
|
||||
`logo_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '平台Logo URL',
|
||||
`sort_order` int NOT NULL DEFAULT 0 COMMENT '排序',
|
||||
`is_active` tinyint NOT NULL DEFAULT 1 COMMENT '是否启用 0禁用 1启用',
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_platform_name`(`platform_name` ASC) USING BTREE,
|
||||
UNIQUE INDEX `uk_platform_code`(`platform_code` ASC) USING BTREE,
|
||||
INDEX `idx_sort_order`(`sort_order` ASC) USING BTREE,
|
||||
INDEX `idx_is_active`(`is_active` ASC) USING BTREE,
|
||||
INDEX `fk_ec_platform_creator`(`create_by` ASC) USING BTREE,
|
||||
INDEX `fk_ec_platform_updater`(`update_by` ASC) USING BTREE,
|
||||
CONSTRAINT `fk_ec_platform_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_platform_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-平台表' ;
|
||||
|
||||
-- ----------------------------
|
||||
-- 平台数据初始化
|
||||
-- ----------------------------
|
||||
INSERT INTO `ec_platform` (`platform_name`, `platform_code`, `sort_order`, `is_active`) VALUES
|
||||
('淘宝', 'taobao', 1, 1),
|
||||
('京东', 'jd', 2, 1),
|
||||
('拼多多', 'pdd', 3, 1),
|
||||
('抖音', 'douyin', 4, 1),
|
||||
('快手', 'kuaishou', 5, 1),
|
||||
('小红书', 'xiaohongshu', 6, 1),
|
||||
('天猫', 'tmall', 7, 1),
|
||||
('唯品会', 'vip', 8, 1),
|
||||
('苏宁', 'suning', 9, 1),
|
||||
('1688', '1688', 10, 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- 店铺表
|
||||
-- ----------------------------
|
||||
@@ -359,19 +400,21 @@ CREATE TABLE `ec_shop` (
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '所属公司ID',
|
||||
`name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '店铺名称',
|
||||
`logo_image_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT 'logo图片ID',
|
||||
`platform` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '平台(如淘宝、京东、拼多多)',
|
||||
`platform_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '平台ID',
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_company_id`(`company_id` ASC) USING BTREE,
|
||||
INDEX `idx_platform_id`(`platform_id` ASC) USING BTREE,
|
||||
INDEX `fk_ec_shop_logo_image`(`logo_image_id` ASC) USING BTREE,
|
||||
INDEX `fk_ec_shop_creator`(`create_by` ASC) USING BTREE,
|
||||
INDEX `fk_ec_shop_updater`(`update_by` ASC) USING BTREE,
|
||||
CONSTRAINT `fk_ec_shop_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_shop_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_shop_logo_image` FOREIGN KEY (`logo_image_id`) REFERENCES `sys_file` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_shop_platform` FOREIGN KEY (`platform_id`) REFERENCES `ec_platform` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_shop_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-店铺表' ;
|
||||
|
||||
|
||||
+7
-2
@@ -5,6 +5,8 @@ import org.springframework.stereotype.Service;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.mapper.BrushOrderMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.dto.CompanyOverviewQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.model.po.BrushOrderPO;
|
||||
@@ -52,6 +54,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
private final OrderStatusService orderStatusService;
|
||||
private final ProductMapper productMapper;
|
||||
private final CategoryService categoryService;
|
||||
private final PlatformMapper platformMapper;
|
||||
|
||||
public CompanyOverviewServiceImpl(CurrentUserContext currentUserContext,
|
||||
OrderMapper orderMapper,
|
||||
@@ -61,7 +64,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
ShopService shopService,
|
||||
OrderStatusService orderStatusService,
|
||||
ProductMapper productMapper,
|
||||
CategoryService categoryService) {
|
||||
CategoryService categoryService,
|
||||
PlatformMapper platformMapper) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
this.orderMapper = orderMapper;
|
||||
this.promotionFeeMapper = promotionFeeMapper;
|
||||
@@ -71,6 +75,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
this.orderStatusService = orderStatusService;
|
||||
this.productMapper = productMapper;
|
||||
this.categoryService = categoryService;
|
||||
this.platformMapper = platformMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -582,7 +587,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
CompanyOverviewVO.ShopComparison comparison = new CompanyOverviewVO.ShopComparison();
|
||||
comparison.setShopId(shop.getId());
|
||||
comparison.setShopName(shop.getName());
|
||||
comparison.setPlatform(shop.getPlatform());
|
||||
comparison.setPlatform(shop.getPlatformId() != null ? platformMapper.selectById(shop.getPlatformId()).getPlatformName() : null);
|
||||
comparison.setTargetOrderCount(targetOrderCount);
|
||||
comparison.setOrderCountAchievementRate(orderCountAchievementRate);
|
||||
comparison.setTargetAmount(targetAmount);
|
||||
|
||||
+7
-2
@@ -8,6 +8,8 @@ import org.springframework.stereotype.Service;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.mapper.BrushOrderMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.dto.ShopOverviewQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.CompanyOverviewVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.ShopOverviewStatisticsVO;
|
||||
@@ -60,6 +62,7 @@ public class ExportServiceImpl implements ExportService {
|
||||
private final OrderStatusService orderStatusService;
|
||||
private final ShopOverviewStatisticsService shopOverviewStatisticsService;
|
||||
private final CategoryService categoryService;
|
||||
private final PlatformMapper platformMapper;
|
||||
|
||||
public ExportServiceImpl(CurrentUserContext currentUserContext,
|
||||
OrderMapper orderMapper,
|
||||
@@ -70,7 +73,8 @@ public class ExportServiceImpl implements ExportService {
|
||||
ProductService productService,
|
||||
OrderStatusService orderStatusService,
|
||||
ShopOverviewStatisticsService shopOverviewStatisticsService,
|
||||
CategoryService categoryService) {
|
||||
CategoryService categoryService,
|
||||
PlatformMapper platformMapper) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
this.orderMapper = orderMapper;
|
||||
this.promotionFeeMapper = promotionFeeMapper;
|
||||
@@ -81,6 +85,7 @@ public class ExportServiceImpl implements ExportService {
|
||||
this.orderStatusService = orderStatusService;
|
||||
this.shopOverviewStatisticsService = shopOverviewStatisticsService;
|
||||
this.categoryService = categoryService;
|
||||
this.platformMapper = platformMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1151,7 +1156,7 @@ public class ExportServiceImpl implements ExportService {
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("shopName", shop.getName());
|
||||
data.put("platform", shop.getPlatform());
|
||||
data.put("platform", shop.getPlatformId() != null ? platformMapper.selectById(shop.getPlatformId()).getPlatformName() : null);
|
||||
data.put("salesAmount", salesAmount);
|
||||
data.put("orderCount", orderCount);
|
||||
data.put("avgOrderValue", avgOrderValue);
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.platform.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.CreatePlatformDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.PlatformFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.UpdatePlatformDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.vo.PlatformVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.service.PlatformService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 平台管理控制器
|
||||
*/
|
||||
@Tag(name = "电商-平台管理", description = "平台的增删改查接口")
|
||||
@RestController
|
||||
@RequestMapping("/ec/platform")
|
||||
public class PlatformController {
|
||||
|
||||
private final PlatformService platformService;
|
||||
|
||||
public PlatformController(PlatformService platformService) {
|
||||
this.platformService = platformService;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建平台", description = "创建新的平台")
|
||||
@PostMapping("/create")
|
||||
@RequirePermission(value = "ecom:platform:manage", description = "创建平台", allowSuper = true)
|
||||
public ApiResponse<PlatformVO> createPlatform(@Valid @RequestBody CreatePlatformDTO createPlatformDTO) {
|
||||
PlatformVO platformVO = platformService.createPlatform(createPlatformDTO);
|
||||
return ApiResponse.success(platformVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新平台", description = "更新现有平台信息")
|
||||
@PutMapping("/update/{id}")
|
||||
@RequirePermission(value = "ecom:platform:manage", description = "更新平台", allowSuper = true)
|
||||
public ApiResponse<PlatformVO> updatePlatform(@Valid @RequestBody UpdatePlatformDTO updatePlatformDTO,
|
||||
@Parameter(description = "平台ID") @PathVariable Long id) {
|
||||
PlatformVO platformVO = platformService.updatePlatform(updatePlatformDTO, id);
|
||||
return ApiResponse.success(platformVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除平台", description = "删除指定平台")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequirePermission(value = "ecom:platform:manage", description = "删除平台", allowSuper = true)
|
||||
public ApiResponse<Void> deletePlatform(@Parameter(description = "平台ID") @PathVariable Long id) {
|
||||
platformService.deletePlatform(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取平台列表", description = "分页获取平台列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequirePermission(value = "ecom:platform:read", description = "查询平台列表", allowSuper = true)
|
||||
public ApiResponse<PageResultVO<PlatformVO>> getPlatformPage(
|
||||
@Valid @RequestBody PageQueryDTO<PlatformFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<PlatformVO> result = platformService.getPlatformPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有启用的平台", description = "获取所有已启用的平台列表,供下拉选择")
|
||||
@GetMapping("/active")
|
||||
@RequirePermission(value = "ecom:platform:read", description = "查询平台列表", allowSuper = true)
|
||||
public ApiResponse<List<PlatformVO>> getActivePlatforms() {
|
||||
List<PlatformVO> result = platformService.getActivePlatforms();
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||
|
||||
/**
|
||||
* 平台Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface PlatformMapper extends BaseMapper<PlatformPO> {
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 创建平台DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建平台DTO")
|
||||
public class CreatePlatformDTO {
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
*/
|
||||
@Schema(description = "平台名称", example = "淘宝", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "平台名称不能为空")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 平台代码
|
||||
*/
|
||||
@Schema(description = "平台代码", example = "taobao", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "平台代码不能为空")
|
||||
private String platformCode;
|
||||
|
||||
/**
|
||||
* Logo URL
|
||||
*/
|
||||
@Schema(description = "Logo URL")
|
||||
private String logoUrl;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "1")
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用 0禁用 1启用", example = "1")
|
||||
private Integer isActive;
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 平台过滤DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "平台过滤DTO")
|
||||
public class PlatformFilterDTO {
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
*/
|
||||
@Schema(description = "平台名称", example = "淘宝")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 平台代码
|
||||
*/
|
||||
@Schema(description = "平台代码", example = "taobao")
|
||||
private String platformCode;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用 0禁用 1启用", example = "1")
|
||||
private Integer isActive;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 更新平台DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "更新平台DTO")
|
||||
public class UpdatePlatformDTO {
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
*/
|
||||
@Schema(description = "平台名称", example = "淘宝", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "平台名称不能为空")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 平台代码
|
||||
*/
|
||||
@Schema(description = "平台代码", example = "taobao", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "平台代码不能为空")
|
||||
private String platformCode;
|
||||
|
||||
/**
|
||||
* Logo URL
|
||||
*/
|
||||
@Schema(description = "Logo URL")
|
||||
private String logoUrl;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用 0禁用 1启用", example = "1")
|
||||
@NotNull(message = "是否启用不能为空")
|
||||
private Integer isActive;
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 电商-平台实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_platform")
|
||||
public class PlatformPO {
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 平台名称(如淘宝、京东、拼多多、抖音)
|
||||
*/
|
||||
@TableField("platform_name")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 平台代码(如 taobao、jd、pdd、douyin)
|
||||
*/
|
||||
@TableField("platform_code")
|
||||
private String platformCode;
|
||||
|
||||
/**
|
||||
* 平台Logo URL
|
||||
*/
|
||||
@TableField("logo_url")
|
||||
private String logoUrl;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("sort_order")
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 是否启用 0禁用 1启用
|
||||
*/
|
||||
@TableField("is_active")
|
||||
private Integer isActive;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@TableField("create_by")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@TableField("update_by")
|
||||
private Long updateBy;
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 平台VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "平台VO")
|
||||
public class PlatformVO {
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
*/
|
||||
@Schema(description = "平台名称", example = "淘宝")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 平台代码
|
||||
*/
|
||||
@Schema(description = "平台代码", example = "taobao")
|
||||
private String platformCode;
|
||||
|
||||
/**
|
||||
* Logo URL
|
||||
*/
|
||||
@Schema(description = "Logo URL", example = "https://example.com/taobao.png")
|
||||
private String logoUrl;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "1")
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用 0禁用 1启用", example = "1")
|
||||
private Integer isActive;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.platform.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.CreatePlatformDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.PlatformFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.UpdatePlatformDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.vo.PlatformVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 平台服务接口
|
||||
*/
|
||||
public interface PlatformService extends IService<PlatformPO> {
|
||||
|
||||
/**
|
||||
* 创建平台
|
||||
*
|
||||
* @param createPlatformDTO 创建平台DTO
|
||||
* @return 平台VO
|
||||
*/
|
||||
PlatformVO createPlatform(CreatePlatformDTO createPlatformDTO);
|
||||
|
||||
/**
|
||||
* 更新平台
|
||||
*
|
||||
* @param updatePlatformDTO 更新平台DTO
|
||||
* @param id 平台ID
|
||||
* @return 平台VO
|
||||
*/
|
||||
PlatformVO updatePlatform(UpdatePlatformDTO updatePlatformDTO, Long id);
|
||||
|
||||
/**
|
||||
* 删除平台
|
||||
*
|
||||
* @param id 平台ID
|
||||
*/
|
||||
void deletePlatform(Long id);
|
||||
|
||||
/**
|
||||
* 分页获取平台列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<PlatformVO> getPlatformPage(PageQueryDTO<PlatformFilterDTO> pageQueryDTO);
|
||||
|
||||
/**
|
||||
* 获取所有启用的平台列表
|
||||
*
|
||||
* @return 平台列表
|
||||
*/
|
||||
List<PlatformVO> getActivePlatforms();
|
||||
}
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.platform.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.CreatePlatformDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.PlatformFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.UpdatePlatformDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.vo.PlatformVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.service.PlatformService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 平台服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class PlatformServiceImpl extends ServiceImpl<PlatformMapper, PlatformPO> implements PlatformService {
|
||||
|
||||
private final CurrentUserContext currentUserContext;
|
||||
|
||||
public PlatformServiceImpl(CurrentUserContext currentUserContext) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建平台
|
||||
*
|
||||
* @param createPlatformDTO 创建平台DTO
|
||||
* @return 平台VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public PlatformVO createPlatform(CreatePlatformDTO createPlatformDTO) {
|
||||
// 验证平台名称是否重复
|
||||
LambdaQueryWrapper<PlatformPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PlatformPO::getPlatformName, createPlatformDTO.getPlatformName());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("平台名称已存在");
|
||||
}
|
||||
|
||||
// 验证平台代码是否重复
|
||||
wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PlatformPO::getPlatformCode, createPlatformDTO.getPlatformCode());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("平台代码已存在");
|
||||
}
|
||||
|
||||
// 创建平台
|
||||
PlatformPO platform = new PlatformPO();
|
||||
BeanUtils.copyProperties(createPlatformDTO, platform);
|
||||
|
||||
// 设置默认值
|
||||
if (platform.getSortOrder() == null) {
|
||||
platform.setSortOrder(0);
|
||||
}
|
||||
if (platform.getIsActive() == null) {
|
||||
platform.setIsActive(1);
|
||||
}
|
||||
|
||||
// 设置创建人ID
|
||||
platform.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
// 保存平台
|
||||
this.save(platform);
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新平台
|
||||
*
|
||||
* @param updatePlatformDTO 更新平台DTO
|
||||
* @param id 平台ID
|
||||
* @return 平台VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public PlatformVO updatePlatform(UpdatePlatformDTO updatePlatformDTO, Long id) {
|
||||
// 验证平台是否存在
|
||||
PlatformPO existingPlatform = this.getById(id);
|
||||
if (existingPlatform == null) {
|
||||
throw new BusinessException("平台不存在");
|
||||
}
|
||||
|
||||
// 验证平台名称是否重复(排除当前平台)
|
||||
LambdaQueryWrapper<PlatformPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PlatformPO::getPlatformName, updatePlatformDTO.getPlatformName())
|
||||
.ne(PlatformPO::getId, id);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("平台名称已存在");
|
||||
}
|
||||
|
||||
// 验证平台代码是否重复(排除当前平台)
|
||||
wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PlatformPO::getPlatformCode, updatePlatformDTO.getPlatformCode())
|
||||
.ne(PlatformPO::getId, id);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("平台代码已存在");
|
||||
}
|
||||
|
||||
// 更新平台
|
||||
PlatformPO platform = new PlatformPO();
|
||||
BeanUtils.copyProperties(updatePlatformDTO, platform);
|
||||
platform.setId(id);
|
||||
|
||||
// 设置更新人ID
|
||||
platform.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
// 更新平台
|
||||
this.updateById(platform);
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除平台
|
||||
*
|
||||
* @param id 平台ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void deletePlatform(Long id) {
|
||||
// 验证平台是否存在
|
||||
PlatformPO existingPlatform = this.getById(id);
|
||||
if (existingPlatform == null) {
|
||||
throw new BusinessException("平台不存在");
|
||||
}
|
||||
|
||||
// 删除平台
|
||||
this.removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取平台列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<PlatformVO> getPlatformPage(PageQueryDTO<PlatformFilterDTO> pageQueryDTO) {
|
||||
PlatformFilterDTO filter = pageQueryDTO.getFilters() != null ? pageQueryDTO.getFilters() : new PlatformFilterDTO();
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<PlatformPO> wrapper = new LambdaQueryWrapper<>();
|
||||
if (filter.getPlatformName() != null && !filter.getPlatformName().isEmpty()) {
|
||||
wrapper.like(PlatformPO::getPlatformName, filter.getPlatformName());
|
||||
}
|
||||
if (filter.getPlatformCode() != null && !filter.getPlatformCode().isEmpty()) {
|
||||
wrapper.eq(PlatformPO::getPlatformCode, filter.getPlatformCode());
|
||||
}
|
||||
if (filter.getIsActive() != null) {
|
||||
wrapper.eq(PlatformPO::getIsActive, filter.getIsActive());
|
||||
}
|
||||
|
||||
// 按排序字段升序
|
||||
wrapper.orderByAsc(PlatformPO::getSortOrder)
|
||||
.orderByDesc(PlatformPO::getCreateTime);
|
||||
|
||||
// 分页查询
|
||||
IPage<PlatformPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<PlatformPO> result = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<PlatformVO> voList = result.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return PageResultVO.create(voList, result.getTotal(), (int) pageQueryDTO.getPage(), (int) pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有启用的平台列表
|
||||
*
|
||||
* @return 平台列表
|
||||
*/
|
||||
@Override
|
||||
public List<PlatformVO> getActivePlatforms() {
|
||||
LambdaQueryWrapper<PlatformPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PlatformPO::getIsActive, 1)
|
||||
.orderByAsc(PlatformPO::getSortOrder);
|
||||
|
||||
return this.list(wrapper).stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
*
|
||||
* @param platform 平台实体
|
||||
* @return 平台VO
|
||||
*/
|
||||
private PlatformVO convertToVO(PlatformPO platform) {
|
||||
PlatformVO vo = new PlatformVO();
|
||||
BeanUtils.copyProperties(platform, vo);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -25,8 +25,8 @@ public class CreateShopDTO {
|
||||
private Long logoImageId;
|
||||
|
||||
/**
|
||||
* 平台(如淘宝、京东、拼多多)
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"})
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
}
|
||||
|
||||
+3
-3
@@ -17,8 +17,8 @@ public class ShopFilterDTO {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 平台
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"})
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
}
|
||||
|
||||
+3
-3
@@ -25,8 +25,8 @@ public class UpdateShopDTO {
|
||||
private Long logoImageId;
|
||||
|
||||
/**
|
||||
* 平台(如淘宝、京东、拼多多)
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"})
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
}
|
||||
|
||||
+3
-3
@@ -39,10 +39,10 @@ public class ShopPO {
|
||||
private Long logoImageId;
|
||||
|
||||
/**
|
||||
* 平台(如淘宝、京东、拼多多)
|
||||
* 平台ID
|
||||
*/
|
||||
@TableField("platform")
|
||||
private String platform;
|
||||
@TableField("platform_id")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
|
||||
+9
-3
@@ -37,10 +37,16 @@ public class ShopVO {
|
||||
private String logo;
|
||||
|
||||
/**
|
||||
* 平台(如淘宝、京东、拼多多)
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝")
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
*/
|
||||
@Schema(description = "平台名称", example = "淘宝")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
|
||||
+15
-3
@@ -13,6 +13,8 @@ import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.product.mapper.ProductMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.mapper.ShopMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.mapper.ShopProductRelationMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.CreateShopDTO;
|
||||
@@ -68,12 +70,13 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
private final ShopProductRelationMapper shopProductRelationMapper;
|
||||
private final ProductSpecService productSpecService;
|
||||
private final OrderStatusService orderStatusService;
|
||||
private final PlatformMapper platformMapper;
|
||||
|
||||
public ShopServiceImpl(CurrentUserContext currentUserContext, SysFileMapper sysFileMapper, SysFileService sysFileService,
|
||||
OrderMapper orderMapper, PromotionFeeMapper promotionFeeMapper,
|
||||
ProductMapper productMapper,
|
||||
ShopProductRelationMapper shopProductRelationMapper, ProductSpecService productSpecService,
|
||||
OrderStatusService orderStatusService) {
|
||||
OrderStatusService orderStatusService, PlatformMapper platformMapper) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
this.sysFileMapper = sysFileMapper;
|
||||
this.sysFileService = sysFileService;
|
||||
@@ -83,6 +86,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
this.shopProductRelationMapper = shopProductRelationMapper;
|
||||
this.productSpecService = productSpecService;
|
||||
this.orderStatusService = orderStatusService;
|
||||
this.platformMapper = platformMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,8 +211,8 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
if (filter.getName() != null && !filter.getName().trim().isEmpty()) {
|
||||
wrapper.like(ShopPO::getName, filter.getName());
|
||||
}
|
||||
if (filter.getPlatform() != null && !filter.getPlatform().trim().isEmpty()) {
|
||||
wrapper.eq(ShopPO::getPlatform, filter.getPlatform());
|
||||
if (filter.getPlatformId() != null) {
|
||||
wrapper.eq(ShopPO::getPlatformId, filter.getPlatformId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,6 +270,14 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
shopVO.setLogo(sysFileService.getFileAccessUrl(shop.getLogoImageId()));
|
||||
}
|
||||
|
||||
// 获取平台名称
|
||||
if (shop.getPlatformId() != null) {
|
||||
PlatformPO platform = platformMapper.selectById(shop.getPlatformId());
|
||||
if (platform != null) {
|
||||
shopVO.setPlatformName(platform.getPlatformName());
|
||||
}
|
||||
}
|
||||
|
||||
return shopVO;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user