mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 02:39:19 +08:00
feat: 增加redis作为消息队列
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
package top.xyquan.ecomdmbbackend.common.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* Redis配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
/**
|
||||
* 配置RedisTemplate
|
||||
*/
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
|
||||
// 使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
objectMapper.registerModule(new JavaTimeModule());
|
||||
|
||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer =
|
||||
new Jackson2JsonRedisSerializer<>(objectMapper, Object.class);
|
||||
|
||||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
|
||||
// key采用String的序列化方式
|
||||
template.setKeySerializer(stringRedisSerializer);
|
||||
// hash的key也采用String的序列化方式
|
||||
template.setHashKeySerializer(stringRedisSerializer);
|
||||
// value序列化方式采用jackson
|
||||
template.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
// hash的value序列化方式采用jackson
|
||||
template.setHashValueSerializer(jackson2JsonRedisSerializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.config;
|
||||
|
||||
/**
|
||||
* 导入任务队列配置
|
||||
* 定义队列相关的常量
|
||||
*/
|
||||
public class ImportTaskQueueConfig {
|
||||
|
||||
/**
|
||||
* 导入任务队列前缀
|
||||
*/
|
||||
public static final String IMPORT_TASK_QUEUE_PREFIX = "import:task:queue:";
|
||||
|
||||
/**
|
||||
* 商品导入任务队列
|
||||
*/
|
||||
public static final String IMPORT_TASK_QUEUE_PRODUCT = IMPORT_TASK_QUEUE_PREFIX + "product";
|
||||
|
||||
/**
|
||||
* 订单导入任务队列
|
||||
*/
|
||||
public static final String IMPORT_TASK_QUEUE_ORDER = IMPORT_TASK_QUEUE_PREFIX + "order";
|
||||
|
||||
/**
|
||||
* 根据类型获取队列名称
|
||||
*
|
||||
* @param type 导入类型(product/order)
|
||||
* @return 队列名称
|
||||
*/
|
||||
public static String getQueueName(String type) {
|
||||
return IMPORT_TASK_QUEUE_PREFIX + type;
|
||||
}
|
||||
}
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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.RequireRole;
|
||||
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.model.dto.importfielddef.CreateImportFieldDefDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef.ImportFieldDefFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef.UpdateImportFieldDefDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportFieldDefVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ImportFieldDefService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 导入字段定义管理控制器
|
||||
*/
|
||||
@Tag(name = "电商-导入字段定义管理", description = "导入字段定义的增删改查接口")
|
||||
@RestController
|
||||
@RequestMapping("/ec/import-field-def")
|
||||
public class ImportFieldDefController {
|
||||
|
||||
private final ImportFieldDefService importFieldDefService;
|
||||
|
||||
public ImportFieldDefController(ImportFieldDefService importFieldDefService) {
|
||||
this.importFieldDefService = importFieldDefService;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建导入字段定义", description = "创建新的导入字段定义")
|
||||
@PostMapping("/create")
|
||||
@RequireRole(description = "创建导入字段定义", allowUser = false)
|
||||
public ApiResponse<ImportFieldDefVO> createImportFieldDef(@Valid @RequestBody CreateImportFieldDefDTO createImportFieldDefDTO) {
|
||||
ImportFieldDefVO importFieldDefVO = importFieldDefService.createImportFieldDef(createImportFieldDefDTO);
|
||||
return ApiResponse.success(importFieldDefVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新导入字段定义", description = "更新现有导入字段定义")
|
||||
@PutMapping("/update/{id}")
|
||||
@RequireRole(description = "更新导入字段定义", allowUser = false)
|
||||
public ApiResponse<ImportFieldDefVO> updateImportFieldDef(
|
||||
@Valid @RequestBody UpdateImportFieldDefDTO updateImportFieldDefDTO,
|
||||
@Parameter(description = "字段定义ID") @PathVariable Long id) {
|
||||
ImportFieldDefVO importFieldDefVO = importFieldDefService.updateImportFieldDef(updateImportFieldDefDTO, id);
|
||||
return ApiResponse.success(importFieldDefVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除导入字段定义", description = "删除指定导入字段定义")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequireRole(description = "删除导入字段定义", allowUser = false)
|
||||
public ApiResponse<Void> deleteImportFieldDef(
|
||||
@Parameter(description = "字段定义ID") @PathVariable Long id) {
|
||||
importFieldDefService.deleteImportFieldDef(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "获取指定类型所有字段列表", description = "根据导入类型获取所有字段定义列表")
|
||||
@GetMapping("/list-by-type/all/{type}")
|
||||
@RequireRole(description = "获取字段定义列表", allowUser = true)
|
||||
public ApiResponse<List<ImportFieldDefVO>> getFieldDefsByType(
|
||||
@Parameter(description = "导入类型", example = "product") @PathVariable String type) {
|
||||
List<ImportFieldDefVO> fieldDefVOs = importFieldDefService.getFieldDefsByType(type);
|
||||
return ApiResponse.success(fieldDefVOs);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询导入字段定义", description = "分页查询导入字段定义,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询导入字段定义列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<ImportFieldDefVO>> getImportFieldDefPage(
|
||||
@Valid @RequestBody PageQueryDTO<ImportFieldDefFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<ImportFieldDefVO> result = importFieldDefService.getImportFieldDefPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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.RequireRole;
|
||||
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.model.dto.importmapping.CreateImportMappingDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping.ImportMappingFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping.UpdateImportMappingDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportMappingVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ImportMappingService;
|
||||
|
||||
/**
|
||||
* 导入映射管理控制器
|
||||
*/
|
||||
@Tag(name = "电商-导入映射管理", description = "导入映射的增删改查接口")
|
||||
@RestController
|
||||
@RequestMapping("/ec/import-mapping")
|
||||
public class ImportMappingController {
|
||||
|
||||
private final ImportMappingService importMappingService;
|
||||
|
||||
public ImportMappingController(ImportMappingService importMappingService) {
|
||||
this.importMappingService = importMappingService;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建导入映射模板", description = "创建新的导入映射模板")
|
||||
@PostMapping("/create")
|
||||
@RequireRole(description = "创建导入映射", allowUser = false)
|
||||
public ApiResponse<ImportMappingVO> createImportMapping(@Valid @RequestBody CreateImportMappingDTO createImportMappingDTO) {
|
||||
ImportMappingVO importMappingVO = importMappingService.createImportMapping(createImportMappingDTO);
|
||||
return ApiResponse.success(importMappingVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新导入映射模板", description = "更新现有导入映射模板")
|
||||
@PutMapping("/update/{id}")
|
||||
@RequireRole(description = "更新导入映射", allowUser = false)
|
||||
public ApiResponse<ImportMappingVO> updateImportMapping(
|
||||
@Valid @RequestBody UpdateImportMappingDTO updateImportMappingDTO,
|
||||
@Parameter(description = "映射ID") @PathVariable Long id) {
|
||||
ImportMappingVO importMappingVO = importMappingService.updateImportMapping(updateImportMappingDTO, id);
|
||||
return ApiResponse.success(importMappingVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除导入映射", description = "删除指定导入映射")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequireRole(description = "删除导入映射", allowUser = false)
|
||||
public ApiResponse<Void> deleteImportMapping(
|
||||
@Parameter(description = "映射ID") @PathVariable Long id) {
|
||||
importMappingService.deleteImportMapping(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取导入映射列表", description = "分页获取导入映射列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询导入映射列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<ImportMappingVO>> getImportMappingPage(
|
||||
@Valid @RequestBody PageQueryDTO<ImportMappingFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<ImportMappingVO> result = importMappingService.getImportMappingPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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 java.util.List;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
|
||||
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.model.dto.importrule.CreateImportRuleDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule.ImportRuleFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule.UpdateImportRuleDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportRuleVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ImportRuleService;
|
||||
|
||||
/**
|
||||
* 导入规则管理控制器
|
||||
*/
|
||||
@Tag(name = "电商-导入规则管理", description = "导入规则的增删改查接口")
|
||||
@RestController
|
||||
@RequestMapping("/ec/import-rule")
|
||||
public class ImportRuleController {
|
||||
|
||||
private final ImportRuleService importRuleService;
|
||||
|
||||
public ImportRuleController(ImportRuleService importRuleService) {
|
||||
this.importRuleService = importRuleService;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建导入规则", description = "创建新的导入规则")
|
||||
@PostMapping("/create")
|
||||
@RequireRole(description = "创建导入规则", allowUser = false)
|
||||
public ApiResponse<ImportRuleVO> createImportRule(@Valid @RequestBody CreateImportRuleDTO createImportRuleDTO) {
|
||||
ImportRuleVO importRuleVO = importRuleService.createImportRule(createImportRuleDTO);
|
||||
return ApiResponse.success(importRuleVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新导入规则", description = "更新现有导入规则信息")
|
||||
@PutMapping("/update/{id}")
|
||||
@RequireRole(description = "更新导入规则", allowUser = false)
|
||||
public ApiResponse<ImportRuleVO> updateImportRule(@Valid @RequestBody UpdateImportRuleDTO updateImportRuleDTO,
|
||||
@Parameter(description = "规则ID") @PathVariable Long id) {
|
||||
ImportRuleVO importRuleVO = importRuleService.updateImportRule(updateImportRuleDTO, id);
|
||||
return ApiResponse.success(importRuleVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除导入规则", description = "删除指定导入规则")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequireRole(description = "删除导入规则", allowUser = false)
|
||||
public ApiResponse<Void> deleteImportRule(
|
||||
@Parameter(description = "规则ID") @PathVariable Long id) {
|
||||
importRuleService.deleteImportRule(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "根据ID获取导入规则", description = "根据规则ID获取导入规则详情")
|
||||
@GetMapping("/get/{id}")
|
||||
@RequireRole(description = "查看导入规则", allowUser = true)
|
||||
public ApiResponse<ImportRuleVO> getImportRuleById(
|
||||
@Parameter(description = "规则ID") @PathVariable Long id) {
|
||||
ImportRuleVO importRuleVO = importRuleService.getImportRuleById(id);
|
||||
return ApiResponse.success(importRuleVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取导入规则列表", description = "分页获取导入规则列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询导入规则列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<ImportRuleVO>> getImportRulePage(
|
||||
@Valid @RequestBody PageQueryDTO<ImportRuleFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<ImportRuleVO> result = importRuleService.getImportRulePage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据规则类型获取导入规则列表", description = "根据规则类型获取导入规则列表")
|
||||
@GetMapping("/list-by-type/{ruleType}")
|
||||
@RequireRole(description = "根据类型查询导入规则", allowUser = true)
|
||||
public ApiResponse<List<ImportRuleVO>> getImportRulesByType(
|
||||
@Parameter(description = "规则类型") @PathVariable String ruleType) {
|
||||
List<ImportRuleVO> importRuleVOs = importRuleService.getImportRulesByType(ruleType);
|
||||
return ApiResponse.success(importRuleVOs);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取启用的导入规则列表", description = "获取所有启用的导入规则列表")
|
||||
@GetMapping("/active-list")
|
||||
@RequireRole(description = "查询启用的导入规则", allowUser = true)
|
||||
public ApiResponse<List<ImportRuleVO>> getActiveImportRules() {
|
||||
List<ImportRuleVO> importRuleVOs = importRuleService.getActiveImportRules();
|
||||
return ApiResponse.success(importRuleVOs);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据规则类型获取启用的导入规则", description = "根据规则类型获取启用的导入规则")
|
||||
@GetMapping("/active-by-type/{ruleType}")
|
||||
@RequireRole(description = "根据类型查询启用的导入规则", allowUser = true)
|
||||
public ApiResponse<ImportRuleVO> getActiveImportRuleByType(
|
||||
@Parameter(description = "规则类型") @PathVariable String ruleType) {
|
||||
ImportRuleVO importRuleVO = importRuleService.getActiveImportRuleByType(ruleType);
|
||||
return ApiResponse.success(importRuleVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "启用/禁用导入规则", description = "启用或禁用指定的导入规则")
|
||||
@PutMapping("/toggle-status/{id}")
|
||||
@RequireRole(description = "启用/禁用导入规则", allowUser = false)
|
||||
public ApiResponse<ImportRuleVO> toggleImportRuleStatus(
|
||||
@Parameter(description = "规则ID") @PathVariable Long id,
|
||||
@Parameter(description = "是否启用") @RequestParam Integer isActive) {
|
||||
ImportRuleVO importRuleVO = importRuleService.toggleImportRuleStatus(id, isActive);
|
||||
return ApiResponse.success(importRuleVO);
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
|
||||
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.model.dto.importtask.CreateImportTaskDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importtask.ImportTaskFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportTaskVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ImportTaskService;
|
||||
|
||||
/**
|
||||
* 导入任务管理控制器
|
||||
*/
|
||||
@Tag(name = "电商-导入任务管理", description = "导入任务的创建和查询接口")
|
||||
@RestController
|
||||
@RequestMapping("/ec/import-task")
|
||||
public class ImportTaskController {
|
||||
|
||||
private final ImportTaskService importTaskService;
|
||||
|
||||
public ImportTaskController(ImportTaskService importTaskService) {
|
||||
this.importTaskService = importTaskService;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建导入任务", description = "创建新的导入任务")
|
||||
@PostMapping("/create")
|
||||
@RequireRole(description = "创建导入任务", allowUser = false)
|
||||
public ApiResponse<ImportTaskVO> createImportTask(@Valid @RequestBody CreateImportTaskDTO createImportTaskDTO) {
|
||||
ImportTaskVO importTaskVO = importTaskService.createImportTask(createImportTaskDTO);
|
||||
return ApiResponse.success(importTaskVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取导入任务列表", description = "分页获取导入任务列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询导入任务列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<ImportTaskVO>> getImportTaskPage(
|
||||
@Valid @RequestBody PageQueryDTO<ImportTaskFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<ImportTaskVO> result = importTaskService.getImportTaskPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
|
||||
-9
@@ -12,7 +12,6 @@ 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.model.dto.product.CreateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.CreateProductWithSpecsDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.ProductFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.UpdateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ProductVO;
|
||||
@@ -67,14 +66,6 @@ public class ProductController {
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "一键创建商品和规格", description = "一次性创建商品和多个规格")
|
||||
@PostMapping("/create-with-specs")
|
||||
@RequireRole(description = "一键创建商品和规格", allowUser = false)
|
||||
public ApiResponse<ProductVO> createProductWithSpecs(@Valid @RequestBody CreateProductWithSpecsDTO createProductWithSpecsDTO) {
|
||||
ProductVO productVO = productService.createProductWithSpecs(createProductWithSpecsDTO);
|
||||
return ApiResponse.success(productVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据名称精准查询商品", description = "根据商品名称精准查询商品信息,用于数据导入")
|
||||
@GetMapping("/find-by-name/{name}")
|
||||
@RequireRole(description = "根据名称查询商品", allowUser = true)
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportFieldDefPO;
|
||||
|
||||
/**
|
||||
* 导入字段定义Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface ImportFieldDefMapper extends BaseMapper<ImportFieldDefPO> {
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportMappingPO;
|
||||
|
||||
/**
|
||||
* 导入映射Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface ImportMappingMapper extends BaseMapper<ImportMappingPO> {
|
||||
}
|
||||
|
||||
+4
-3
@@ -2,11 +2,12 @@ package top.xyquan.ecomdmbbackend.modules.ecom.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportRulePO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportTaskPO;
|
||||
|
||||
/**
|
||||
* 导入规则Mapper接口
|
||||
* 导入任务Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface ImportRuleMapper extends BaseMapper<ImportRulePO> {
|
||||
public interface ImportTaskMapper extends BaseMapper<ImportTaskPO> {
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 创建导入字段定义DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建导入字段定义DTO")
|
||||
public class CreateImportFieldDefDTO {
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product", required = true, allowableValues = {"product", "order"})
|
||||
@NotBlank(message = "导入类型不能为空")
|
||||
@Pattern(regexp = "^(product|order)$", message = "导入类型只能是product或order")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 数据库字段名,如 name
|
||||
*/
|
||||
@Schema(description = "数据库字段名", example = "name", required = true)
|
||||
@NotBlank(message = "字段名不能为空")
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 中文字段名,如 商品名称
|
||||
*/
|
||||
@Schema(description = "中文字段名", example = "商品名称", required = true)
|
||||
@NotBlank(message = "字段标签不能为空")
|
||||
private String fieldLabel;
|
||||
|
||||
/**
|
||||
* 是否必填
|
||||
*/
|
||||
@Schema(description = "是否必填", example = "true")
|
||||
@NotNull(message = "是否必填不能为空")
|
||||
private Boolean required;
|
||||
|
||||
/**
|
||||
* 数据类型(string, number, date等)
|
||||
*/
|
||||
@Schema(description = "数据类型", example = "string", defaultValue = "string")
|
||||
private String dataType;
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 导入字段定义过滤DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导入字段定义过滤DTO")
|
||||
public class ImportFieldDefFilterDTO {
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product", allowableValues = {"product", "order"})
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 字段名(模糊查询)
|
||||
*/
|
||||
@Schema(description = "字段名(模糊查询)", example = "name")
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 字段标签(模糊查询)
|
||||
*/
|
||||
@Schema(description = "字段标签(模糊查询)", example = "商品")
|
||||
private String fieldLabel;
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef;
|
||||
|
||||
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 UpdateImportFieldDefDTO {
|
||||
|
||||
/**
|
||||
* 中文字段名,如 商品名称
|
||||
*/
|
||||
@Schema(description = "中文字段名", example = "商品名称", required = true)
|
||||
@NotBlank(message = "字段标签不能为空")
|
||||
private String fieldLabel;
|
||||
|
||||
/**
|
||||
* 是否必填
|
||||
*/
|
||||
@Schema(description = "是否必填", example = "true")
|
||||
@NotNull(message = "是否必填不能为空")
|
||||
private Boolean required;
|
||||
|
||||
/**
|
||||
* 数据类型(string, number, date等)
|
||||
*/
|
||||
@Schema(description = "数据类型", example = "string")
|
||||
private String dataType;
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 创建导入映射DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建导入映射DTO")
|
||||
public class CreateImportMappingDTO {
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product", required = true, allowableValues = {"product", "order"})
|
||||
@NotBlank(message = "导入类型不能为空")
|
||||
@Pattern(regexp = "^(product|order)$", message = "导入类型只能是product或order")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 字段映射(JSON格式)
|
||||
*/
|
||||
@Schema(description = "字段映射(JSON格式)", example = "{\"商品名称\":\"name\",\"价格(元)\":\"price\"}", required = true)
|
||||
@NotBlank(message = "字段映射不能为空")
|
||||
private String mapping;
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 导入映射过滤DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导入映射过滤DTO")
|
||||
public class ImportMappingFilterDTO {
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product", allowableValues = {"product", "order"})
|
||||
private String type;
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 更新导入映射DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "更新导入映射DTO")
|
||||
public class UpdateImportMappingDTO {
|
||||
|
||||
/**
|
||||
* 字段映射(JSON格式)
|
||||
*/
|
||||
@Schema(description = "字段映射(JSON格式)", example = "{\"商品名称\":\"name\",\"价格(元)\":\"price\"}", required = true)
|
||||
@NotBlank(message = "字段映射不能为空")
|
||||
private String mapping;
|
||||
}
|
||||
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule;
|
||||
|
||||
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 CreateImportRuleDTO {
|
||||
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
@Schema(description = "规则名称", example = "订单导入规则", required = true)
|
||||
@NotBlank(message = "规则名称不能为空")
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 规则类型
|
||||
*/
|
||||
@Schema(description = "规则类型", example = "订单导入", required = true,
|
||||
allowableValues = {"订单导入", "商品导入", "推广费导入", "店铺导入"})
|
||||
@NotBlank(message = "规则类型不能为空")
|
||||
private String ruleType;
|
||||
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
@Schema(description = "规则描述", example = "用于处理订单数据的导入规则")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 字段映射规则(JSON格式)
|
||||
*/
|
||||
@Schema(description = "字段映射规则", example = "{\"excel_column_a\":\"product_name\",\"excel_column_b\":\"cost_price\"}", required = true)
|
||||
@NotBlank(message = "字段映射规则不能为空")
|
||||
private String fieldMappingRules;
|
||||
|
||||
/**
|
||||
* 数据验证规则(JSON格式)
|
||||
*/
|
||||
@Schema(description = "数据验证规则", example = "{\"product_name\":{\"required\":true,\"max_length\":255}}")
|
||||
private String dataValidationRules;
|
||||
|
||||
/**
|
||||
* 数据转换规则(JSON格式)
|
||||
*/
|
||||
@Schema(description = "数据转换规则", example = "{\"cost_price\":{\"type\":\"decimal\",\"precision\":2}}")
|
||||
private String dataTransformationRules;
|
||||
|
||||
/**
|
||||
* 默认值配置(JSON格式)
|
||||
*/
|
||||
@Schema(description = "默认值配置", example = "{\"platform\":\"淘宝\",\"status\":\"待处理\"}")
|
||||
private String defaultValues;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用", example = "1", allowableValues = {"0", "1"})
|
||||
@NotNull(message = "是否启用不能为空")
|
||||
private Integer isActive;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "0")
|
||||
private Integer sortOrder;
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 导入规则过滤DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导入规则过滤DTO")
|
||||
public class ImportRuleFilterDTO {
|
||||
|
||||
/**
|
||||
* 规则名称(模糊查询)
|
||||
*/
|
||||
@Schema(description = "规则名称", example = "订单")
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 规则类型
|
||||
*/
|
||||
@Schema(description = "规则类型", example = "订单导入",
|
||||
allowableValues = {"订单导入", "商品导入", "推广费导入", "店铺导入"})
|
||||
private String ruleType;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用", example = "1", allowableValues = {"0", "1"})
|
||||
private Integer isActive;
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 更新导入规则DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "更新导入规则DTO")
|
||||
public class UpdateImportRuleDTO {
|
||||
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
@Schema(description = "规则名称", example = "订单导入规则")
|
||||
@NotBlank(message = "规则名称不能为空")
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 规则类型
|
||||
*/
|
||||
@Schema(description = "规则类型", example = "订单导入",
|
||||
allowableValues = {"订单导入", "商品导入", "推广费导入", "店铺导入"})
|
||||
@NotBlank(message = "规则类型不能为空")
|
||||
private String ruleType;
|
||||
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
@Schema(description = "规则描述", example = "用于处理订单数据的导入规则")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 字段映射规则(JSON格式)
|
||||
*/
|
||||
@Schema(description = "字段映射规则", example = "{\"excel_column_a\":\"product_name\",\"excel_column_b\":\"cost_price\"}")
|
||||
@NotBlank(message = "字段映射规则不能为空")
|
||||
private String fieldMappingRules;
|
||||
|
||||
/**
|
||||
* 数据验证规则(JSON格式)
|
||||
*/
|
||||
@Schema(description = "数据验证规则", example = "{\"product_name\":{\"required\":true,\"max_length\":255}}")
|
||||
private String dataValidationRules;
|
||||
|
||||
/**
|
||||
* 数据转换规则(JSON格式)
|
||||
*/
|
||||
@Schema(description = "数据转换规则", example = "{\"cost_price\":{\"type\":\"decimal\",\"precision\":2}}")
|
||||
private String dataTransformationRules;
|
||||
|
||||
/**
|
||||
* 默认值配置(JSON格式)
|
||||
*/
|
||||
@Schema(description = "默认值配置", example = "{\"platform\":\"淘宝\",\"status\":\"待处理\"}")
|
||||
private String defaultValues;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用", example = "1", allowableValues = {"0", "1"})
|
||||
private Integer isActive;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "0")
|
||||
private Integer sortOrder;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importtask;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 创建导入任务DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建导入任务DTO")
|
||||
public class CreateImportTaskDTO {
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product", required = true, allowableValues = {"product", "order"})
|
||||
@NotBlank(message = "导入类型不能为空")
|
||||
@Pattern(regexp = "^(product|order)$", message = "导入类型只能是product或order")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 原始文件名
|
||||
*/
|
||||
@Schema(description = "原始文件名", example = "商品导入.xlsx", required = true)
|
||||
@NotBlank(message = "文件名不能为空")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
@Schema(description = "存储路径", example = "/uploads/import/2025/01/xxx.xlsx", required = true)
|
||||
@NotBlank(message = "存储路径不能为空")
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* 字段映射记录(JSON字符串)
|
||||
*/
|
||||
@Schema(description = "字段映射记录", example = "{\"商品名称\":\"name\",\"价格\":\"price\"}")
|
||||
private String mapping;
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importtask;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 导入任务过滤DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导入任务过滤DTO")
|
||||
public class ImportTaskFilterDTO {
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product", allowableValues = {"product", "order"})
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 任务状态
|
||||
*/
|
||||
@Schema(description = "任务状态", example = "pending", allowableValues = {"pending", "processing", "success", "failed"})
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 文件名(模糊查询)
|
||||
*/
|
||||
@Schema(description = "文件名(模糊查询)", example = "商品")
|
||||
private String fileName;
|
||||
}
|
||||
|
||||
+40
@@ -1,9 +1,14 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建商品DTO
|
||||
*/
|
||||
@@ -23,4 +28,39 @@ public class CreateProductDTO {
|
||||
*/
|
||||
@Schema(description = "主图图片ID", example = "1")
|
||||
private Long mainImageId;
|
||||
|
||||
/**
|
||||
* 商品规格列表(可选)
|
||||
*/
|
||||
@Schema(description = "商品规格列表")
|
||||
@Valid
|
||||
private List<ProductSpecDTO> specs;
|
||||
|
||||
/**
|
||||
* 商品规格DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "商品规格DTO")
|
||||
public static class ProductSpecDTO {
|
||||
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
@Schema(description = "规格名称", example = "128GB 深空黑色", required = true)
|
||||
@NotBlank(message = "规格名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规格编码
|
||||
*/
|
||||
@Schema(description = "规格编码", example = "IPHONE15PRO-128G-BLACK")
|
||||
private String specCode;
|
||||
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
@Schema(description = "成本价", example = "8000.00", required = true)
|
||||
@NotNull(message = "成本价不能为空")
|
||||
private BigDecimal costPrice;
|
||||
}
|
||||
}
|
||||
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 一键创建商品和规格DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "一键创建商品和规格DTO")
|
||||
public class CreateProductWithSpecsDTO {
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", required = true)
|
||||
@NotBlank(message = "商品名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 主图图片ID
|
||||
*/
|
||||
@Schema(description = "主图图片ID", example = "1")
|
||||
private Long mainImageId;
|
||||
|
||||
/**
|
||||
* 商品规格列表
|
||||
*/
|
||||
@Schema(description = "商品规格列表", required = true)
|
||||
@NotEmpty(message = "商品规格列表不能为空")
|
||||
@Valid
|
||||
private List<ProductSpecDTO> specs;
|
||||
|
||||
/**
|
||||
* 商品规格DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "商品规格DTO")
|
||||
public static class ProductSpecDTO {
|
||||
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
@Schema(description = "规格名称", example = "128GB 深空黑色", required = true)
|
||||
@NotBlank(message = "规格名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规格编码
|
||||
*/
|
||||
@Schema(description = "规格编码", example = "IPHONE15PRO-128G-BLACK")
|
||||
private String specCode;
|
||||
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
@Schema(description = "成本价", example = "8000.00", required = true)
|
||||
@NotNull(message = "成本价不能为空")
|
||||
private BigDecimal costPrice;
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导入字段定义实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_import_field_defs")
|
||||
public class ImportFieldDefPO {
|
||||
|
||||
/**
|
||||
* 字段定义ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 数据库字段名,如 name
|
||||
*/
|
||||
@TableField("field_name")
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 中文字段名,如 商品名称
|
||||
*/
|
||||
@TableField("field_label")
|
||||
private String fieldLabel;
|
||||
|
||||
/**
|
||||
* 是否必填
|
||||
*/
|
||||
@TableField("required")
|
||||
private Boolean required;
|
||||
|
||||
/**
|
||||
* 数据类型(string, number, date等)
|
||||
*/
|
||||
@TableField("data_type")
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "created_at", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导入映射实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_import_mappings")
|
||||
public class ImportMappingPO {
|
||||
|
||||
/**
|
||||
* 映射ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 所属公司ID
|
||||
*/
|
||||
@TableField("company_id")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 字段映射(JSON格式)
|
||||
*/
|
||||
@TableField("mapping")
|
||||
private String mapping;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 电商-导入规则实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_import_rule")
|
||||
public class ImportRulePO {
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@TableField("company_id")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
@TableField("rule_name")
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 规则类型(如:订单导入、商品导入、推广费导入等)
|
||||
*/
|
||||
@TableField("rule_type")
|
||||
private String ruleType;
|
||||
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
@TableField("description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 字段映射规则(JSON格式)
|
||||
*/
|
||||
@TableField("field_mapping_rules")
|
||||
private String fieldMappingRules;
|
||||
|
||||
/**
|
||||
* 数据验证规则(JSON格式)
|
||||
*/
|
||||
@TableField("data_validation_rules")
|
||||
private String dataValidationRules;
|
||||
|
||||
/**
|
||||
* 数据转换规则(JSON格式)
|
||||
*/
|
||||
@TableField("data_transformation_rules")
|
||||
private String dataTransformationRules;
|
||||
|
||||
/**
|
||||
* 默认值配置(JSON格式)
|
||||
*/
|
||||
@TableField("default_values")
|
||||
private String defaultValues;
|
||||
|
||||
/**
|
||||
* 是否启用 0禁用 1启用
|
||||
*/
|
||||
@TableField("is_active")
|
||||
private Integer isActive;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("sort_order")
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导入任务实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_import_tasks")
|
||||
public class ImportTaskPO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 所属公司ID
|
||||
*/
|
||||
@TableField("company_id")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 原始文件名
|
||||
*/
|
||||
@TableField("file_name")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
@TableField("file_path")
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* 任务状态(pending-待处理 processing-处理中 success-成功 failed-失败)
|
||||
*/
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 总行数
|
||||
*/
|
||||
@TableField("total_count")
|
||||
private Integer totalCount;
|
||||
|
||||
/**
|
||||
* 成功行数
|
||||
*/
|
||||
@TableField("success_count")
|
||||
private Integer successCount;
|
||||
|
||||
/**
|
||||
* 失败行数
|
||||
*/
|
||||
@TableField("fail_count")
|
||||
private Integer failCount;
|
||||
|
||||
/**
|
||||
* 字段映射记录(JSON)
|
||||
*/
|
||||
@TableField("mapping")
|
||||
private String mapping;
|
||||
|
||||
/**
|
||||
* 错误信息或备注
|
||||
*/
|
||||
@TableField("message")
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导入字段定义VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导入字段定义VO")
|
||||
public class ImportFieldDefVO {
|
||||
|
||||
/**
|
||||
* 字段定义ID
|
||||
*/
|
||||
@Schema(description = "字段定义ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 数据库字段名,如 name
|
||||
*/
|
||||
@Schema(description = "数据库字段名", example = "name")
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 中文字段名,如 商品名称
|
||||
*/
|
||||
@Schema(description = "中文字段名", example = "商品名称")
|
||||
private String fieldLabel;
|
||||
|
||||
/**
|
||||
* 是否必填
|
||||
*/
|
||||
@Schema(description = "是否必填", example = "true")
|
||||
private Boolean required;
|
||||
|
||||
/**
|
||||
* 数据类型(string, number, date等)
|
||||
*/
|
||||
@Schema(description = "数据类型", example = "string")
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导入映射VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导入映射VO")
|
||||
public class ImportMappingVO {
|
||||
|
||||
/**
|
||||
* 映射ID
|
||||
*/
|
||||
@Schema(description = "映射ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 所属公司ID
|
||||
*/
|
||||
@Schema(description = "所属公司ID", example = "1")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 字段映射(JSON格式)
|
||||
*/
|
||||
@Schema(description = "字段映射(JSON格式)", example = "{\"商品名称\":\"name\",\"价格(元)\":\"price\"}")
|
||||
private String mapping;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@Schema(description = "创建人ID", example = "1")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@Schema(description = "更新人ID", example = "1")
|
||||
private Long updateBy;
|
||||
}
|
||||
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导入规则VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导入规则VO")
|
||||
public class ImportRuleVO {
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
@Schema(description = "规则ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Schema(description = "公司ID", example = "1")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
@Schema(description = "规则名称", example = "订单导入规则")
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 规则类型
|
||||
*/
|
||||
@Schema(description = "规则类型", example = "订单导入")
|
||||
private String ruleType;
|
||||
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
@Schema(description = "规则描述", example = "用于处理订单数据的导入规则")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 字段映射规则(JSON格式)
|
||||
*/
|
||||
@Schema(description = "字段映射规则", example = "{\"excel_column_a\":\"product_name\",\"excel_column_b\":\"cost_price\"}")
|
||||
private String fieldMappingRules;
|
||||
|
||||
/**
|
||||
* 数据验证规则(JSON格式)
|
||||
*/
|
||||
@Schema(description = "数据验证规则", example = "{\"product_name\":{\"required\":true,\"max_length\":255}}")
|
||||
private String dataValidationRules;
|
||||
|
||||
/**
|
||||
* 数据转换规则(JSON格式)
|
||||
*/
|
||||
@Schema(description = "数据转换规则", example = "{\"cost_price\":{\"type\":\"decimal\",\"precision\":2}}")
|
||||
private String dataTransformationRules;
|
||||
|
||||
/**
|
||||
* 默认值配置(JSON格式)
|
||||
*/
|
||||
@Schema(description = "默认值配置", example = "{\"platform\":\"淘宝\",\"status\":\"待处理\"}")
|
||||
private String defaultValues;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用", example = "1")
|
||||
private Integer isActive;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "0")
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@Schema(description = "创建人ID", example = "1")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@Schema(description = "更新人ID", example = "1")
|
||||
private Long updateBy;
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导入任务VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导入任务VO")
|
||||
public class ImportTaskVO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Schema(description = "主键ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 所属公司ID
|
||||
*/
|
||||
@Schema(description = "所属公司ID", example = "1")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 导入类型(product-商品 order-订单)
|
||||
*/
|
||||
@Schema(description = "导入类型", example = "product")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 原始文件名
|
||||
*/
|
||||
@Schema(description = "原始文件名", example = "商品导入.xlsx")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
@Schema(description = "存储路径", example = "/uploads/import/2025/01/xxx.xlsx")
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* 任务状态
|
||||
*/
|
||||
@Schema(description = "任务状态", example = "pending")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 总行数
|
||||
*/
|
||||
@Schema(description = "总行数", example = "100")
|
||||
private Integer totalCount;
|
||||
|
||||
/**
|
||||
* 成功行数
|
||||
*/
|
||||
@Schema(description = "成功行数", example = "95")
|
||||
private Integer successCount;
|
||||
|
||||
/**
|
||||
* 失败行数
|
||||
*/
|
||||
@Schema(description = "失败行数", example = "5")
|
||||
private Integer failCount;
|
||||
|
||||
/**
|
||||
* 字段映射记录(JSON字符串)
|
||||
*/
|
||||
@Schema(description = "字段映射记录", example = "{\"商品名称\":\"name\",\"价格\":\"price\"}")
|
||||
private String mapping;
|
||||
|
||||
/**
|
||||
* 错误信息或备注
|
||||
*/
|
||||
@Schema(description = "错误信息或备注", example = "处理完成")
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@Schema(description = "创建人ID", example = "1")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@Schema(description = "更新人ID", example = "1")
|
||||
private Long updateBy;
|
||||
}
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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.model.dto.importfielddef.CreateImportFieldDefDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef.ImportFieldDefFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef.UpdateImportFieldDefDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportFieldDefPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportFieldDefVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 导入字段定义服务接口
|
||||
*/
|
||||
public interface ImportFieldDefService extends IService<ImportFieldDefPO> {
|
||||
|
||||
/**
|
||||
* 创建导入字段定义
|
||||
*
|
||||
* @param createImportFieldDefDTO 创建导入字段定义DTO
|
||||
* @return 导入字段定义VO
|
||||
*/
|
||||
ImportFieldDefVO createImportFieldDef(CreateImportFieldDefDTO createImportFieldDefDTO);
|
||||
|
||||
/**
|
||||
* 更新导入字段定义
|
||||
*
|
||||
* @param updateImportFieldDefDTO 更新导入字段定义DTO
|
||||
* @param id 字段定义ID
|
||||
* @return 导入字段定义VO
|
||||
*/
|
||||
ImportFieldDefVO updateImportFieldDef(UpdateImportFieldDefDTO updateImportFieldDefDTO, Long id);
|
||||
|
||||
/**
|
||||
* 删除导入字段定义
|
||||
*
|
||||
* @param id 字段定义ID
|
||||
*/
|
||||
void deleteImportFieldDef(Long id);
|
||||
|
||||
/**
|
||||
* 获取指定类型所有字段列表
|
||||
*
|
||||
* @param type 导入类型
|
||||
* @return 字段定义VO列表
|
||||
*/
|
||||
List<ImportFieldDefVO> getFieldDefsByType(String type);
|
||||
|
||||
/**
|
||||
* 分页查询导入字段定义
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<ImportFieldDefVO> getImportFieldDefPage(PageQueryDTO<ImportFieldDefFilterDTO> pageQueryDTO);
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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.model.dto.importmapping.CreateImportMappingDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping.ImportMappingFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping.UpdateImportMappingDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportMappingPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportMappingVO;
|
||||
|
||||
/**
|
||||
* 导入映射服务接口
|
||||
*/
|
||||
public interface ImportMappingService extends IService<ImportMappingPO> {
|
||||
|
||||
/**
|
||||
* 创建导入映射模板
|
||||
*
|
||||
* @param createImportMappingDTO 创建导入映射DTO
|
||||
* @return 导入映射VO
|
||||
*/
|
||||
ImportMappingVO createImportMapping(CreateImportMappingDTO createImportMappingDTO);
|
||||
|
||||
/**
|
||||
* 更新导入映射模板
|
||||
*
|
||||
* @param updateImportMappingDTO 更新导入映射DTO
|
||||
* @param id 映射ID
|
||||
* @return 导入映射VO
|
||||
*/
|
||||
ImportMappingVO updateImportMapping(UpdateImportMappingDTO updateImportMappingDTO, Long id);
|
||||
|
||||
/**
|
||||
* 删除导入映射
|
||||
*
|
||||
* @param id 映射ID
|
||||
*/
|
||||
void deleteImportMapping(Long id);
|
||||
|
||||
/**
|
||||
* 分页获取导入映射列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<ImportMappingVO> getImportMappingPage(PageQueryDTO<ImportMappingFilterDTO> pageQueryDTO);
|
||||
}
|
||||
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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.model.dto.importrule.CreateImportRuleDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule.ImportRuleFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule.UpdateImportRuleDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportRulePO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportRuleVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 导入规则服务接口
|
||||
*/
|
||||
public interface ImportRuleService extends IService<ImportRulePO> {
|
||||
|
||||
/**
|
||||
* 创建导入规则
|
||||
*
|
||||
* @param createImportRuleDTO 创建导入规则DTO
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
ImportRuleVO createImportRule(CreateImportRuleDTO createImportRuleDTO);
|
||||
|
||||
/**
|
||||
* 更新导入规则
|
||||
*
|
||||
* @param updateImportRuleDTO 更新导入规则DTO
|
||||
* @param id 规则ID
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
ImportRuleVO updateImportRule(UpdateImportRuleDTO updateImportRuleDTO, Long id);
|
||||
|
||||
/**
|
||||
* 删除导入规则
|
||||
*
|
||||
* @param id 规则ID
|
||||
*/
|
||||
void deleteImportRule(Long id);
|
||||
|
||||
/**
|
||||
* 根据ID获取导入规则
|
||||
*
|
||||
* @param id 规则ID
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
ImportRuleVO getImportRuleById(Long id);
|
||||
|
||||
/**
|
||||
* 分页获取导入规则列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<ImportRuleVO> getImportRulePage(PageQueryDTO<ImportRuleFilterDTO> pageQueryDTO);
|
||||
|
||||
/**
|
||||
* 根据规则类型获取导入规则列表
|
||||
*
|
||||
* @param ruleType 规则类型
|
||||
* @return 导入规则VO列表
|
||||
*/
|
||||
List<ImportRuleVO> getImportRulesByType(String ruleType);
|
||||
|
||||
/**
|
||||
* 获取启用的导入规则列表
|
||||
*
|
||||
* @return 导入规则VO列表
|
||||
*/
|
||||
List<ImportRuleVO> getActiveImportRules();
|
||||
|
||||
/**
|
||||
* 根据规则类型获取启用的导入规则
|
||||
*
|
||||
* @param ruleType 规则类型
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
ImportRuleVO getActiveImportRuleByType(String ruleType);
|
||||
|
||||
/**
|
||||
* 启用/禁用导入规则
|
||||
*
|
||||
* @param id 规则ID
|
||||
* @param isActive 是否启用
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
ImportRuleVO toggleImportRuleStatus(Long id, Integer isActive);
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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.model.dto.importtask.CreateImportTaskDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importtask.ImportTaskFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportTaskPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportTaskVO;
|
||||
|
||||
/**
|
||||
* 导入任务服务接口
|
||||
*/
|
||||
public interface ImportTaskService extends IService<ImportTaskPO> {
|
||||
|
||||
/**
|
||||
* 创建导入任务
|
||||
*
|
||||
* @param createImportTaskDTO 创建导入任务DTO
|
||||
* @return 导入任务VO
|
||||
*/
|
||||
ImportTaskVO createImportTask(CreateImportTaskDTO createImportTaskDTO);
|
||||
|
||||
/**
|
||||
* 分页获取导入任务列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<ImportTaskVO> getImportTaskPage(PageQueryDTO<ImportTaskFilterDTO> pageQueryDTO);
|
||||
}
|
||||
|
||||
-9
@@ -4,7 +4,6 @@ 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.model.dto.product.CreateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.CreateProductWithSpecsDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.ProductFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.UpdateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ProductPO;
|
||||
@@ -49,14 +48,6 @@ public interface ProductService extends IService<ProductPO> {
|
||||
*/
|
||||
PageResultVO<ProductVO> getProductPage(PageQueryDTO<ProductFilterDTO> pageQueryDTO);
|
||||
|
||||
/**
|
||||
* 一键创建商品和规格
|
||||
*
|
||||
* @param createProductWithSpecsDTO 创建商品和规格DTO
|
||||
* @return 商品VO
|
||||
*/
|
||||
ProductVO createProductWithSpecs(CreateProductWithSpecsDTO createProductWithSpecsDTO);
|
||||
|
||||
/**
|
||||
* 根据名称精准查询商品
|
||||
*
|
||||
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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 org.springframework.util.StringUtils;
|
||||
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.mapper.ImportFieldDefMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef.CreateImportFieldDefDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef.ImportFieldDefFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importfielddef.UpdateImportFieldDefDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportFieldDefPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportFieldDefVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ImportFieldDefService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 导入字段定义服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class ImportFieldDefServiceImpl extends ServiceImpl<ImportFieldDefMapper, ImportFieldDefPO> implements ImportFieldDefService {
|
||||
|
||||
/**
|
||||
* 创建导入字段定义
|
||||
*
|
||||
* @param createImportFieldDefDTO 创建导入字段定义DTO
|
||||
* @return 导入字段定义VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ImportFieldDefVO createImportFieldDef(CreateImportFieldDefDTO createImportFieldDefDTO) {
|
||||
// 验证同一类型、同一字段名是否已存在(根据唯一索引)
|
||||
LambdaQueryWrapper<ImportFieldDefPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportFieldDefPO::getType, createImportFieldDefDTO.getType())
|
||||
.eq(ImportFieldDefPO::getFieldName, createImportFieldDefDTO.getFieldName());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("该类型的字段定义已存在");
|
||||
}
|
||||
|
||||
// 创建导入字段定义
|
||||
ImportFieldDefPO importFieldDefPO = new ImportFieldDefPO();
|
||||
BeanUtils.copyProperties(createImportFieldDefDTO, importFieldDefPO);
|
||||
|
||||
// 设置默认数据类型
|
||||
if (!StringUtils.hasText(importFieldDefPO.getDataType())) {
|
||||
importFieldDefPO.setDataType("string");
|
||||
}
|
||||
|
||||
this.save(importFieldDefPO);
|
||||
|
||||
// 转换为VO返回
|
||||
return convertToVO(importFieldDefPO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新导入字段定义
|
||||
*
|
||||
* @param updateImportFieldDefDTO 更新导入字段定义DTO
|
||||
* @param id 字段定义ID
|
||||
* @return 导入字段定义VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ImportFieldDefVO updateImportFieldDef(UpdateImportFieldDefDTO updateImportFieldDefDTO, Long id) {
|
||||
// 验证字段定义是否存在
|
||||
ImportFieldDefPO existingFieldDef = this.getById(id);
|
||||
if (existingFieldDef == null) {
|
||||
throw new BusinessException("导入字段定义不存在");
|
||||
}
|
||||
|
||||
// 更新字段定义
|
||||
ImportFieldDefPO importFieldDefPO = new ImportFieldDefPO();
|
||||
BeanUtils.copyProperties(updateImportFieldDefDTO, importFieldDefPO);
|
||||
importFieldDefPO.setId(id);
|
||||
|
||||
this.updateById(importFieldDefPO);
|
||||
|
||||
// 转换为VO返回
|
||||
return convertToVO(this.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除导入字段定义
|
||||
*
|
||||
* @param id 字段定义ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteImportFieldDef(Long id) {
|
||||
// 验证字段定义是否存在
|
||||
ImportFieldDefPO existingFieldDef = this.getById(id);
|
||||
if (existingFieldDef == null) {
|
||||
throw new BusinessException("导入字段定义不存在");
|
||||
}
|
||||
|
||||
// 删除字段定义
|
||||
this.removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定类型所有字段列表
|
||||
*
|
||||
* @param type 导入类型
|
||||
* @return 字段定义VO列表
|
||||
*/
|
||||
@Override
|
||||
public List<ImportFieldDefVO> getFieldDefsByType(String type) {
|
||||
LambdaQueryWrapper<ImportFieldDefPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportFieldDefPO::getType, type)
|
||||
.orderByAsc(ImportFieldDefPO::getFieldName);
|
||||
|
||||
List<ImportFieldDefPO> fieldDefPOs = this.list(wrapper);
|
||||
|
||||
return fieldDefPOs.stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询导入字段定义
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果VO
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<ImportFieldDefVO> getImportFieldDefPage(PageQueryDTO<ImportFieldDefFilterDTO> pageQueryDTO) {
|
||||
ImportFieldDefFilterDTO filter = pageQueryDTO.getFilters();
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<ImportFieldDefPO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (filter != null) {
|
||||
if (StringUtils.hasText(filter.getType())) {
|
||||
wrapper.eq(ImportFieldDefPO::getType, filter.getType());
|
||||
}
|
||||
if (StringUtils.hasText(filter.getFieldName())) {
|
||||
wrapper.like(ImportFieldDefPO::getFieldName, filter.getFieldName());
|
||||
}
|
||||
if (StringUtils.hasText(filter.getFieldLabel())) {
|
||||
wrapper.like(ImportFieldDefPO::getFieldLabel, filter.getFieldLabel());
|
||||
}
|
||||
}
|
||||
|
||||
// 按类型和字段名排序
|
||||
wrapper.orderByAsc(ImportFieldDefPO::getType)
|
||||
.orderByAsc(ImportFieldDefPO::getFieldName);
|
||||
|
||||
// 分页查询
|
||||
Page<ImportFieldDefPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<ImportFieldDefPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<ImportFieldDefVO> voList = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
*/
|
||||
private ImportFieldDefVO convertToVO(ImportFieldDefPO importFieldDefPO) {
|
||||
ImportFieldDefVO importFieldDefVO = new ImportFieldDefVO();
|
||||
BeanUtils.copyProperties(importFieldDefPO, importFieldDefVO);
|
||||
return importFieldDefVO;
|
||||
}
|
||||
}
|
||||
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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 org.springframework.util.StringUtils;
|
||||
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.mapper.ImportMappingMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping.CreateImportMappingDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping.ImportMappingFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importmapping.UpdateImportMappingDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportMappingPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportMappingVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ImportMappingService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 导入映射服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class ImportMappingServiceImpl extends ServiceImpl<ImportMappingMapper, ImportMappingPO> implements ImportMappingService {
|
||||
|
||||
private final CurrentUserContext currentUserContext;
|
||||
|
||||
public ImportMappingServiceImpl(CurrentUserContext currentUserContext) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建导入映射模板
|
||||
*
|
||||
* @param createImportMappingDTO 创建导入映射DTO
|
||||
* @return 导入映射VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ImportMappingVO createImportMapping(CreateImportMappingDTO createImportMappingDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证同一公司、同一类型是否已存在映射(根据唯一索引)
|
||||
LambdaQueryWrapper<ImportMappingPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportMappingPO::getCompanyId, companyId)
|
||||
.eq(ImportMappingPO::getType, createImportMappingDTO.getType());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("该类型的导入映射已存在,请使用更新接口");
|
||||
}
|
||||
|
||||
// 创建导入映射
|
||||
ImportMappingPO importMappingPO = new ImportMappingPO();
|
||||
BeanUtils.copyProperties(createImportMappingDTO, importMappingPO);
|
||||
importMappingPO.setCompanyId(companyId);
|
||||
importMappingPO.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
this.save(importMappingPO);
|
||||
|
||||
// 转换为VO返回
|
||||
return convertToVO(importMappingPO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新导入映射模板
|
||||
*
|
||||
* @param updateImportMappingDTO 更新导入映射DTO
|
||||
* @param id 映射ID
|
||||
* @return 导入映射VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ImportMappingVO updateImportMapping(UpdateImportMappingDTO updateImportMappingDTO, Long id) {
|
||||
// 验证映射是否存在
|
||||
ImportMappingPO existingMapping = this.getById(id);
|
||||
if (existingMapping == null) {
|
||||
throw new BusinessException("导入映射不存在");
|
||||
}
|
||||
|
||||
// 验证公司权限
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
if (!existingMapping.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("无权限操作此映射");
|
||||
}
|
||||
|
||||
// 更新映射
|
||||
ImportMappingPO importMappingPO = new ImportMappingPO();
|
||||
BeanUtils.copyProperties(updateImportMappingDTO, importMappingPO);
|
||||
importMappingPO.setId(id);
|
||||
importMappingPO.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
this.updateById(importMappingPO);
|
||||
|
||||
// 转换为VO返回
|
||||
return convertToVO(this.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除导入映射
|
||||
*
|
||||
* @param id 映射ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteImportMapping(Long id) {
|
||||
// 验证映射是否存在
|
||||
ImportMappingPO existingMapping = this.getById(id);
|
||||
if (existingMapping == null) {
|
||||
throw new BusinessException("导入映射不存在");
|
||||
}
|
||||
|
||||
// 验证公司权限
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
if (!existingMapping.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("无权限操作此映射");
|
||||
}
|
||||
|
||||
// 删除映射
|
||||
this.removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取导入映射列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果VO
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<ImportMappingVO> getImportMappingPage(PageQueryDTO<ImportMappingFilterDTO> pageQueryDTO) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
ImportMappingFilterDTO filter = pageQueryDTO.getFilters();
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<ImportMappingPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportMappingPO::getCompanyId, companyId);
|
||||
|
||||
if (filter != null && StringUtils.hasText(filter.getType())) {
|
||||
wrapper.eq(ImportMappingPO::getType, filter.getType());
|
||||
}
|
||||
|
||||
// 按创建时间倒序
|
||||
wrapper.orderByDesc(ImportMappingPO::getCreateTime);
|
||||
|
||||
// 分页查询
|
||||
Page<ImportMappingPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<ImportMappingPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<ImportMappingVO> voList = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
*/
|
||||
private ImportMappingVO convertToVO(ImportMappingPO importMappingPO) {
|
||||
ImportMappingVO importMappingVO = new ImportMappingVO();
|
||||
BeanUtils.copyProperties(importMappingPO, importMappingVO);
|
||||
return importMappingVO;
|
||||
}
|
||||
}
|
||||
|
||||
-298
@@ -1,298 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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 org.springframework.util.StringUtils;
|
||||
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.mapper.ImportRuleMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule.CreateImportRuleDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule.ImportRuleFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importrule.UpdateImportRuleDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportRulePO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportRuleVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ImportRuleService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 导入规则服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class ImportRuleServiceImpl extends ServiceImpl<ImportRuleMapper, ImportRulePO> implements ImportRuleService {
|
||||
|
||||
private final CurrentUserContext currentUserContext;
|
||||
|
||||
public ImportRuleServiceImpl(CurrentUserContext currentUserContext) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建导入规则
|
||||
* @param createImportRuleDTO 创建导入规则DTO
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ImportRuleVO createImportRule(CreateImportRuleDTO createImportRuleDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证规则名称是否重复
|
||||
LambdaQueryWrapper<ImportRulePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportRulePO::getCompanyId, companyId)
|
||||
.eq(ImportRulePO::getRuleName, createImportRuleDTO.getRuleName());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("规则名称已存在");
|
||||
}
|
||||
|
||||
// 创建导入规则
|
||||
ImportRulePO importRulePO = new ImportRulePO();
|
||||
BeanUtils.copyProperties(createImportRuleDTO, importRulePO);
|
||||
importRulePO.setCompanyId(companyId);
|
||||
importRulePO.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
this.save(importRulePO);
|
||||
|
||||
// 转换为VO返回
|
||||
return convertToVO(importRulePO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新导入规则
|
||||
* @param updateImportRuleDTO 更新导入规则DTO
|
||||
* @param id 导入规则ID
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ImportRuleVO updateImportRule(UpdateImportRuleDTO updateImportRuleDTO, Long id) {
|
||||
// 检查规则是否存在
|
||||
ImportRulePO importRulePO = this.getById(id);
|
||||
if (importRulePO == null) {
|
||||
throw new BusinessException("导入规则不存在");
|
||||
}
|
||||
|
||||
// 验证公司权限
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
if (!importRulePO.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("无权限操作此规则");
|
||||
}
|
||||
|
||||
// 验证规则名称是否重复(排除自己)
|
||||
LambdaQueryWrapper<ImportRulePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportRulePO::getCompanyId, companyId)
|
||||
.eq(ImportRulePO::getRuleName, updateImportRuleDTO.getRuleName())
|
||||
.ne(ImportRulePO::getId, id);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("规则名称已存在");
|
||||
}
|
||||
|
||||
// 更新导入规则
|
||||
BeanUtils.copyProperties(updateImportRuleDTO, importRulePO);
|
||||
importRulePO.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
this.updateById(importRulePO);
|
||||
|
||||
// 转换为VO返回
|
||||
return convertToVO(importRulePO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除导入规则
|
||||
* @param id 导入规则ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteImportRule(Long id) {
|
||||
// 检查规则是否存在
|
||||
ImportRulePO importRulePO = this.getById(id);
|
||||
if (importRulePO == null) {
|
||||
throw new BusinessException("导入规则不存在");
|
||||
}
|
||||
|
||||
// 验证公司权限
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
if (!importRulePO.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("无权限操作此规则");
|
||||
}
|
||||
|
||||
// 删除规则
|
||||
this.removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询导入规则
|
||||
* @param id 导入规则ID
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
@Override
|
||||
public ImportRuleVO getImportRuleById(Long id) {
|
||||
ImportRulePO importRulePO = this.getById(id);
|
||||
if (importRulePO == null) {
|
||||
throw new BusinessException("导入规则不存在");
|
||||
}
|
||||
|
||||
// 验证公司权限
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
if (!importRulePO.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("无权限查看此规则");
|
||||
}
|
||||
|
||||
return convertToVO(importRulePO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入规则分页列表
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果VO
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<ImportRuleVO> getImportRulePage(PageQueryDTO<ImportRuleFilterDTO> pageQueryDTO) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
ImportRuleFilterDTO filterDTO = pageQueryDTO.getFilters();
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<ImportRulePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportRulePO::getCompanyId, companyId);
|
||||
|
||||
if (filterDTO != null) {
|
||||
if (StringUtils.hasText(filterDTO.getRuleName())) {
|
||||
wrapper.like(ImportRulePO::getRuleName, filterDTO.getRuleName());
|
||||
}
|
||||
if (StringUtils.hasText(filterDTO.getRuleType())) {
|
||||
wrapper.eq(ImportRulePO::getRuleType, filterDTO.getRuleType());
|
||||
}
|
||||
if (filterDTO.getIsActive() != null) {
|
||||
wrapper.eq(ImportRulePO::getIsActive, filterDTO.getIsActive());
|
||||
}
|
||||
}
|
||||
|
||||
// 按排序字段和创建时间排序
|
||||
wrapper.orderByAsc(ImportRulePO::getSortOrder)
|
||||
.orderByDesc(ImportRulePO::getCreateTime);
|
||||
|
||||
// 分页查询
|
||||
Page<ImportRulePO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<ImportRulePO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<ImportRuleVO> voList = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new PageResultVO<>(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询导入规则
|
||||
* @param ruleType 类型
|
||||
* @return 导入规则VO列表
|
||||
*/
|
||||
@Override
|
||||
public List<ImportRuleVO> getImportRulesByType(String ruleType) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
LambdaQueryWrapper<ImportRulePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportRulePO::getCompanyId, companyId)
|
||||
.eq(ImportRulePO::getRuleType, ruleType)
|
||||
.orderByAsc(ImportRulePO::getSortOrder)
|
||||
.orderByDesc(ImportRulePO::getCreateTime);
|
||||
|
||||
List<ImportRulePO> poList = this.list(wrapper);
|
||||
return poList.stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有启用的导入规则
|
||||
* @return 导入规则VO列表
|
||||
*/
|
||||
@Override
|
||||
public List<ImportRuleVO> getActiveImportRules() {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
LambdaQueryWrapper<ImportRulePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportRulePO::getCompanyId, companyId)
|
||||
.eq(ImportRulePO::getIsActive, 1)
|
||||
.orderByAsc(ImportRulePO::getSortOrder)
|
||||
.orderByDesc(ImportRulePO::getCreateTime);
|
||||
|
||||
List<ImportRulePO> poList = this.list(wrapper);
|
||||
return poList.stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询启用的导入规则
|
||||
* @param ruleType 类型
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
@Override
|
||||
public ImportRuleVO getActiveImportRuleByType(String ruleType) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
LambdaQueryWrapper<ImportRulePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportRulePO::getCompanyId, companyId)
|
||||
.eq(ImportRulePO::getRuleType, ruleType)
|
||||
.eq(ImportRulePO::getIsActive, 1)
|
||||
.orderByAsc(ImportRulePO::getSortOrder)
|
||||
.orderByDesc(ImportRulePO::getCreateTime)
|
||||
.last("LIMIT 1");
|
||||
|
||||
ImportRulePO importRulePO = this.getOne(wrapper);
|
||||
if (importRulePO == null) {
|
||||
throw new BusinessException("未找到启用的" + ruleType + "规则");
|
||||
}
|
||||
|
||||
return convertToVO(importRulePO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换导入规则状态
|
||||
* @param id 导入规则ID
|
||||
* @param isActive 状态
|
||||
* @return 导入规则VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ImportRuleVO toggleImportRuleStatus(Long id, Integer isActive) {
|
||||
// 检查规则是否存在
|
||||
ImportRulePO importRulePO = this.getById(id);
|
||||
if (importRulePO == null) {
|
||||
throw new BusinessException("导入规则不存在");
|
||||
}
|
||||
|
||||
// 验证公司权限
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
if (!importRulePO.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("无权限操作此规则");
|
||||
}
|
||||
|
||||
// 更新状态
|
||||
importRulePO.setIsActive(isActive);
|
||||
importRulePO.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
this.updateById(importRulePO);
|
||||
|
||||
return convertToVO(importRulePO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
*/
|
||||
private ImportRuleVO convertToVO(ImportRulePO importRulePO) {
|
||||
ImportRuleVO importRuleVO = new ImportRuleVO();
|
||||
BeanUtils.copyProperties(importRulePO, importRuleVO);
|
||||
return importRuleVO;
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.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 org.springframework.util.StringUtils;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.ImportTaskMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importtask.CreateImportTaskDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.importtask.ImportTaskFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ImportTaskPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ImportTaskVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.service.ImportTaskService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 导入任务服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class ImportTaskServiceImpl extends ServiceImpl<ImportTaskMapper, ImportTaskPO> implements ImportTaskService {
|
||||
|
||||
private final CurrentUserContext currentUserContext;
|
||||
|
||||
public ImportTaskServiceImpl(CurrentUserContext currentUserContext) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建导入任务
|
||||
*
|
||||
* @param createImportTaskDTO 创建导入任务DTO
|
||||
* @return 导入任务VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ImportTaskVO createImportTask(CreateImportTaskDTO createImportTaskDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 创建导入任务
|
||||
ImportTaskPO importTaskPO = new ImportTaskPO();
|
||||
BeanUtils.copyProperties(createImportTaskDTO, importTaskPO);
|
||||
importTaskPO.setCompanyId(companyId);
|
||||
importTaskPO.setStatus("pending"); // 初始状态为待处理
|
||||
importTaskPO.setTotalCount(0);
|
||||
importTaskPO.setSuccessCount(0);
|
||||
importTaskPO.setFailCount(0);
|
||||
importTaskPO.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
this.save(importTaskPO);
|
||||
|
||||
// 转换为VO返回
|
||||
return convertToVO(importTaskPO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取导入任务列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果VO
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<ImportTaskVO> getImportTaskPage(PageQueryDTO<ImportTaskFilterDTO> pageQueryDTO) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
ImportTaskFilterDTO filter = pageQueryDTO.getFilters();
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<ImportTaskPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ImportTaskPO::getCompanyId, companyId);
|
||||
|
||||
if (filter != null) {
|
||||
if (StringUtils.hasText(filter.getType())) {
|
||||
wrapper.eq(ImportTaskPO::getType, filter.getType());
|
||||
}
|
||||
if (StringUtils.hasText(filter.getStatus())) {
|
||||
wrapper.eq(ImportTaskPO::getStatus, filter.getStatus());
|
||||
}
|
||||
if (StringUtils.hasText(filter.getFileName())) {
|
||||
wrapper.like(ImportTaskPO::getFileName, filter.getFileName());
|
||||
}
|
||||
}
|
||||
|
||||
// 按创建时间倒序
|
||||
wrapper.orderByDesc(ImportTaskPO::getCreateTime);
|
||||
|
||||
// 分页查询
|
||||
Page<ImportTaskPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<ImportTaskPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<ImportTaskVO> voList = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
*/
|
||||
private ImportTaskVO convertToVO(ImportTaskPO importTaskPO) {
|
||||
ImportTaskVO importTaskVO = new ImportTaskVO();
|
||||
BeanUtils.copyProperties(importTaskPO, importTaskVO);
|
||||
return importTaskVO;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-57
@@ -13,7 +13,6 @@ import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.mapper.ProductMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.CreateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.CreateProductWithSpecsDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.ProductFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.product.UpdateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.model.po.ProductPO;
|
||||
@@ -87,6 +86,22 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductPO> im
|
||||
// 保存商品
|
||||
this.save(product);
|
||||
|
||||
// 如果提供了规格列表,则创建商品规格
|
||||
if (createProductDTO.getSpecs() != null && !createProductDTO.getSpecs().isEmpty()) {
|
||||
List<CreateProductDTO.ProductSpecDTO> specDTOs = createProductDTO.getSpecs();
|
||||
for (CreateProductDTO.ProductSpecDTO specDTO : specDTOs) {
|
||||
ProductSpecPO productSpec = new ProductSpecPO();
|
||||
productSpec.setCompanyId(companyId);
|
||||
productSpec.setProductId(product.getId());
|
||||
productSpec.setName(specDTO.getName());
|
||||
productSpec.setSpecCode(specDTO.getSpecCode());
|
||||
productSpec.setCostPrice(specDTO.getCostPrice());
|
||||
productSpec.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
productSpecService.save(productSpec);
|
||||
}
|
||||
}
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(product);
|
||||
}
|
||||
@@ -204,62 +219,6 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductPO> im
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品并创建商品规格
|
||||
* @param createProductWithSpecsDTO 创建商品并创建商品规格DTO
|
||||
* @return 商品VO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ProductVO createProductWithSpecs(CreateProductWithSpecsDTO createProductWithSpecsDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证商品名称是否重复
|
||||
LambdaQueryWrapper<ProductPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProductPO::getName, createProductWithSpecsDTO.getName())
|
||||
.eq(ProductPO::getCompanyId, companyId);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("商品名称已存在");
|
||||
}
|
||||
|
||||
// 创建商品
|
||||
ProductPO product = new ProductPO();
|
||||
product.setName(createProductWithSpecsDTO.getName());
|
||||
product.setCompanyId(companyId);
|
||||
|
||||
// 处理主图图片关联
|
||||
if (createProductWithSpecsDTO.getMainImageId() != null) {
|
||||
MediaImageVO mainImage = mediaImageService.getImageById(createProductWithSpecsDTO.getMainImageId());
|
||||
if (mainImage != null) {
|
||||
product.setMainImageId(createProductWithSpecsDTO.getMainImageId());
|
||||
product.setMainImage(mainImage.getUrl()); // 设置冗余字段
|
||||
}
|
||||
}
|
||||
|
||||
// 设置创建人ID
|
||||
product.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
// 保存商品
|
||||
this.save(product);
|
||||
|
||||
// 创建商品规格
|
||||
List<CreateProductWithSpecsDTO.ProductSpecDTO> specDTOs = createProductWithSpecsDTO.getSpecs();
|
||||
for (CreateProductWithSpecsDTO.ProductSpecDTO specDTO : specDTOs) {
|
||||
ProductSpecPO productSpec = new ProductSpecPO();
|
||||
productSpec.setCompanyId(companyId);
|
||||
productSpec.setProductId(product.getId());
|
||||
productSpec.setName(specDTO.getName());
|
||||
productSpec.setSpecCode(specDTO.getSpecCode());
|
||||
productSpec.setCostPrice(specDTO.getCostPrice());
|
||||
productSpec.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
productSpecService.save(productSpec);
|
||||
}
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(product);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
|
||||
-58
@@ -279,51 +279,6 @@ public class CompanyMenuServiceImpl extends ServiceImpl<CompanyMenuMapper, Compa
|
||||
return buildCompanyMenuTreeRecursive(parentMap, 0L, new ArrayList<>(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建菜单树(保留原方法用于其他用途)
|
||||
*/
|
||||
private List<MenuVO> buildMenuTree(List<MenuVO> menuList) {
|
||||
// 按父ID分组
|
||||
Map<Long, List<MenuVO>> parentMap = menuList.stream()
|
||||
.collect(Collectors.groupingBy(menu -> menu.getParentId() != null ? menu.getParentId() : 0L));
|
||||
|
||||
// 递归构建树
|
||||
return buildTreeRecursive(parentMap, 0L, new ArrayList<>(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建树形结构(带循环引用检测)
|
||||
*/
|
||||
private List<MenuVO> buildTreeRecursive(Map<Long, List<MenuVO>> parentMap, Long parentId,
|
||||
List<Long> visitedIds, int depth) {
|
||||
// 防止无限递归,设置最大深度限制
|
||||
if (depth > 100) {
|
||||
throw new BusinessException("菜单层级过深,可能存在循环引用");
|
||||
}
|
||||
|
||||
List<MenuVO> children = parentMap.get(parentId);
|
||||
if (children == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
for (MenuVO menu : children) {
|
||||
// 检查是否已经访问过该节点,防止循环引用
|
||||
if (visitedIds.contains(menu.getId())) {
|
||||
throw new BusinessException("检测到菜单循环引用,菜单ID: " + menu.getId());
|
||||
}
|
||||
|
||||
// 创建新访问路径,包含当前节点
|
||||
List<Long> newVisitedIds = new ArrayList<>(visitedIds);
|
||||
newVisitedIds.add(menu.getId());
|
||||
|
||||
// 递归构建子菜单
|
||||
List<MenuVO> childList = buildTreeRecursive(parentMap, menu.getId(), newVisitedIds, depth + 1);
|
||||
menu.setChildren(childList);
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建公司菜单树形结构(带循环引用检测)
|
||||
*/
|
||||
@@ -376,19 +331,6 @@ public class CompanyMenuServiceImpl extends ServiceImpl<CompanyMenuMapper, Compa
|
||||
return companyMenuVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换MenuPO为MenuVO(包含权限信息)
|
||||
*/
|
||||
private MenuVO convertMenuToVO(MenuPO menu) {
|
||||
MenuVO menuVO = new MenuVO();
|
||||
BeanUtils.copyProperties(menu, menuVO);
|
||||
|
||||
// 查询菜单关联的权限
|
||||
List<PermissionVO> permissions = menuMapper.selectPermissionsByMenuId(menu.getId());
|
||||
menuVO.setPermissions(permissions);
|
||||
|
||||
return menuVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
|
||||
+1
@@ -354,6 +354,7 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
||||
PositionCompanyMenuPO newPositionMenu = new PositionCompanyMenuPO();
|
||||
newPositionMenu.setPositionId(positionId);
|
||||
newPositionMenu.setCompanyMenuId(companyMenuId);
|
||||
newPositionMenu.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
this.save(newPositionMenu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,31 +192,62 @@ CREATE TABLE `ec_promotion_fee` (
|
||||
CONSTRAINT `fk_ec_promotion_fee_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-推广费记录表';
|
||||
|
||||
-- 导入数据匹配规则表
|
||||
CREATE TABLE `ec_import_rule` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '规则ID',
|
||||
`company_id` BIGINT UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`rule_name` VARCHAR(200) NOT NULL COMMENT '规则名称',
|
||||
`rule_type` VARCHAR(50) NOT NULL COMMENT '规则类型(如:订单导入、商品导入、推广费导入等)',
|
||||
`description` VARCHAR(500) DEFAULT NULL COMMENT '规则描述',
|
||||
`field_mapping_rules` JSON NOT NULL COMMENT '字段映射规则(JSON格式)',
|
||||
`data_validation_rules` JSON DEFAULT NULL COMMENT '数据验证规则(JSON格式)',
|
||||
`data_transformation_rules` JSON DEFAULT NULL COMMENT '数据转换规则(JSON格式)',
|
||||
`default_values` JSON DEFAULT NULL COMMENT '默认值配置(JSON格式)',
|
||||
`is_active` TINYINT NOT NULL DEFAULT 1 COMMENT '是否启用 0禁用 1启用',
|
||||
`sort_order` INT NOT NULL DEFAULT 0 COMMENT '排序',
|
||||
-- 导入任务表
|
||||
CREATE TABLE `ec_import_tasks` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`company_id` bigint unsigned NOT NULL COMMENT '所属公司ID',
|
||||
`type` enum('product','order') NOT NULL COMMENT '导入类型(product-商品 order-订单)',
|
||||
`file_name` varchar(255) NOT NULL COMMENT '原始文件名',
|
||||
`file_path` varchar(500) NOT NULL COMMENT '存储路径',
|
||||
`status` enum('pending','processing','success','failed') DEFAULT 'pending' NOT NULL COMMENT '任务状态(pending-待处理 processing-处理中 success-成功 failed-失败)',
|
||||
`total_count` int unsigned DEFAULT 0 COMMENT '总行数',
|
||||
`success_count` int unsigned DEFAULT 0 COMMENT '成功行数',
|
||||
`fail_count` int unsigned DEFAULT 0 COMMENT '失败行数',
|
||||
`mapping` json DEFAULT NULL COMMENT '字段映射记录',
|
||||
`message` text DEFAULT NULL COMMENT '错误信息或备注',
|
||||
`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 DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID',
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_company_id` (`company_id`),
|
||||
KEY `idx_rule_type` (`rule_type`),
|
||||
KEY `idx_is_active` (`is_active`),
|
||||
KEY `idx_sort_order` (`sort_order`),
|
||||
KEY `fk_ec_import_rule_creator` (`create_by`),
|
||||
KEY `fk_ec_import_rule_updater` (`update_by`),
|
||||
CONSTRAINT `fk_ec_import_rule_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_import_rule_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_import_rule_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-导入数据匹配规则表';
|
||||
KEY `idx_create_by` (`create_by`),
|
||||
KEY `idx_update_by` (`update_by`),
|
||||
CONSTRAINT `fk_import_task_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_import_task_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_import_task_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-导入任务表';
|
||||
|
||||
-- 导入映射表
|
||||
CREATE TABLE `ec_import_mappings` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '映射ID',
|
||||
`company_id` bigint unsigned NOT NULL COMMENT '所属公司ID',
|
||||
`type` enum('product','order') NOT NULL COMMENT '导入类型(product-商品 order-订单)',
|
||||
`mapping` json NOT NULL COMMENT '{"商品名称":"name","价格(元)":"price"}',
|
||||
`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 DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_by` bigint unsigned DEFAULT NULL COMMENT '更新人ID',
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uniq_company_type` (`company_id`, `type`),
|
||||
CONSTRAINT `fk_import_mapping_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_import_mapping_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_import_mapping_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-导入映射表';
|
||||
|
||||
-- 导入字段定义表
|
||||
CREATE TABLE `ec_import_field_defs` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '字段定义ID',
|
||||
`type` enum('product','order') NOT NULL COMMENT '导入类型(product-商品 order-订单)',
|
||||
`field_name` varchar(100) NOT NULL COMMENT '数据库字段名,如 name',
|
||||
`field_label` varchar(100) NOT NULL COMMENT '中文字段名,如 商品名称',
|
||||
`required` tinyint(1) DEFAULT 0 COMMENT '是否必填',
|
||||
`data_type` varchar(50) DEFAULT 'string' COMMENT 'string, number, date等',
|
||||
`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uniq_type_field` (`type`,`field_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-导入字段定义表';
|
||||
|
||||
Reference in New Issue
Block a user