diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..7b016a89 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file diff --git a/ecom-dmb-backend/pom.xml b/ecom-dmb-backend/pom.xml index 819a9302..7d819498 100644 --- a/ecom-dmb-backend/pom.xml +++ b/ecom-dmb-backend/pom.xml @@ -19,7 +19,20 @@ 17 1.18.30 3.5.5 + + 4.5.14 + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + + diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/config/WebConfig.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/config/WebConfig.java index fd6e05ab..0869f0da 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/config/WebConfig.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/config/WebConfig.java @@ -1,6 +1,7 @@ package top.xyquan.ecomdmbbackend.common.config; import org.springframework.context.annotation.Configuration; +import org.springframework.lang.NonNull; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -12,7 +13,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; public class WebConfig implements WebMvcConfigurer { @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { + public void addResourceHandlers(@NonNull ResourceHandlerRegistry registry) { // 配置静态资源处理 registry.addResourceHandler("/static/**") .addResourceLocations("classpath:/static/"); @@ -30,7 +31,7 @@ public class WebConfig implements WebMvcConfigurer { } @Override - public void addCorsMappings(CorsRegistry registry) { + public void addCorsMappings(@NonNull CorsRegistry registry) { registry.addMapping("/**") .allowedOriginPatterns("*") .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS") diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/filter/JwtAuthenticationFilter.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/filter/JwtAuthenticationFilter.java index 70b74740..b0fd6b29 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/filter/JwtAuthenticationFilter.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/filter/JwtAuthenticationFilter.java @@ -4,9 +4,9 @@ import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.springframework.lang.NonNull; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; - import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import org.springframework.web.filter.OncePerRequestFilter; @@ -27,13 +27,16 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { } @Override - protected boolean shouldNotFilter(HttpServletRequest request) { + protected boolean shouldNotFilter(@NonNull HttpServletRequest request) { String uri = request.getRequestURI(); return uri != null && uri.startsWith("/open/"); } @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) + protected void doFilterInternal( + @NonNull HttpServletRequest request, + @NonNull HttpServletResponse response, + @NonNull FilterChain filterChain) throws ServletException, IOException { // 添加调试日志 diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/utils/BeanCopyUtils.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/utils/BeanCopyUtils.java new file mode 100644 index 00000000..feb4811f --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/utils/BeanCopyUtils.java @@ -0,0 +1,31 @@ +package top.xyquan.ecomdmbbackend.common.utils; + +import org.springframework.beans.BeanUtils; + +import java.util.Objects; + +/** + * 属性拷贝工具:在调用 Spring {@link BeanUtils#copyProperties} 前断言 source/target 非空, + * 消除 IDE 空值分析对 {@code BeanUtils.copyProperties} 入参的 Null type safety 警告。 + */ +public final class BeanCopyUtils { + + private BeanCopyUtils() { + } + + public static void copyProperties(Object source, Object target) { + BeanUtils.copyProperties(Objects.requireNonNull(source), Objects.requireNonNull(target)); + } + + public static void copyProperties(Object source, Object target, String... ignoreProperties) { + Object nonNullSource = Objects.requireNonNull(source); + Object nonNullTarget = Objects.requireNonNull(target); + // varargs 在分析器里可能是可空数组,需显式断言后再传给 Spring + String[] nonNullIgnores = Objects.requireNonNull(ignoreProperties); + if (nonNullIgnores.length == 0) { + BeanUtils.copyProperties(nonNullSource, nonNullTarget); + return; + } + BeanUtils.copyProperties(nonNullSource, nonNullTarget, nonNullIgnores); + } +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/brushorder/service/impl/BrushOrderServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/brushorder/service/impl/BrushOrderServiceImpl.java index 1314736e..6a0c2df1 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/brushorder/service/impl/BrushOrderServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/brushorder/service/impl/BrushOrderServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.brushorder.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -150,7 +150,7 @@ public class BrushOrderServiceImpl extends ServiceImpl private CategoryVO convertToVO(CategoryPO po, Map parentNameMap) { CategoryVO vo = new CategoryVO(); - BeanUtils.copyProperties(po, vo); + BeanCopyUtils.copyProperties(po, vo); if (po.getParentId() != null) { vo.setParentName(parentNameMap.getOrDefault(po.getParentId(), null)); } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/importmapping/service/impl/ImportMappingServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/importmapping/service/impl/ImportMappingServiceImpl.java index 524daf08..50cf3033 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/importmapping/service/impl/ImportMappingServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/importmapping/service/impl/ImportMappingServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.importmapping.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; 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; @@ -58,7 +58,7 @@ public class ImportMappingServiceImpl extends ServiceImpl @@ -51,7 +43,6 @@ public class OrderImportProcessor { private static final int ORDER_BATCH_SIZE = 200; private static final int RELATION_BATCH_SIZE = 500; - private static final int IN_QUERY_BATCH_SIZE = 1000; private static final int PARALLELISM = 4; // Worker 线程数 private static final int WORKER_TERMINATE_TIMEOUT_SEC = 60; // awaitTermination 超时 @@ -75,35 +66,6 @@ public class OrderImportProcessor { /** * 队列元素:原始 CSV 行数据(由主线程解析出,传递给 workers) */ - /** Excel 行数据包装器(用于替代 CSVRecord) */ - public static class ExcelRow { - private final Map rowData; - private final List orderedHeaders; - - public ExcelRow(Map rowData, List orderedHeaders) { - this.rowData = rowData; - this.orderedHeaders = orderedHeaders; - } - - public String get(String header) { - if (header == null) return null; - String v = rowData.get(header); - if (v != null) return v; - String normalized = normalizeHeader(header); - for (Map.Entry e : rowData.entrySet()) { - if (normalizeHeader(e.getKey()).equals(normalized)) { - return e.getValue(); - } - } - return null; - } - - public boolean isEmpty(String header) { - String v = get(header); - return v == null || v.trim().isEmpty(); - } - } - public static class PendingRow { public final int rowNumber; /** 原始行数据(CSV → Map via csvRecordToMap;Excel → 直接为 Map) */ @@ -930,11 +892,6 @@ public class OrderImportProcessor { CreateOrderDTO dto = row.dto; Long companyId = row.companyId; - String specCode = dto.getPlatformOrderNo() != null ? null : null; // DTO中无specCode,需从record重新获取 - // 重新从 CSVRecord 获取 specCode(Worker 不能直接访问 CSVRecordParser) - // 方案:从 DTO 中取,或者在 parseOrderFromCSV 时预存 - // 由于 parseOrderFromCSV 已填充了 productSpecId 等,此处只处理找不到的情况 - if (dto.getProductSpecId() == null) { // 重新获取关键字段 String specCodeRaw = getValue(row.rowData, row.fieldMapping.get("spec_code")); @@ -1101,22 +1058,6 @@ public class OrderImportProcessor { return workerFailCount; } - /** - * 等待 workers 把当前 pendingOrders 消费完(flushed) - * 通过轮询 pendingOrders size 为 0 实现,最多等待 30 秒 - */ - private void waitForBatchFlush(ImportRuntimeContext context) { - long deadline = System.currentTimeMillis() + 30_000; - while (context.pendingOrders.size() > 0 && System.currentTimeMillis() < deadline) { - try { - Thread.sleep(50); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - break; - } - } - } - private int[] doFlushPendingOrders(ImportRuntimeContext context, StringBuilder errorMessages) { synchronized (context.pendingOrders) { if (context.pendingOrders.isEmpty()) { @@ -1846,16 +1787,6 @@ public class OrderImportProcessor { } } - private String getValue(CSVRecord record, String header) { - if (header == null || header.trim().isEmpty()) return null; - try { - String val = record.get(header.trim()); - return (val != null && !val.trim().isEmpty()) ? val.trim() : null; - } catch (IllegalArgumentException e) { - return null; - } - } - private static String normalizeHeader(String header) { if (header == null) return ""; return header.replace("\uFEFF", "") diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/importtask/service/impl/SseNotificationServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/importtask/service/impl/SseNotificationServiceImpl.java index 09a25c5e..18395437 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/importtask/service/impl/SseNotificationServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/importtask/service/impl/SseNotificationServiceImpl.java @@ -3,6 +3,7 @@ package top.xyquan.ecomdmbbackend.modules.ecom.importtask.service.impl; import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import top.xyquan.ecomdmbbackend.modules.ecom.importtask.model.po.ImportTaskPO; @@ -14,6 +15,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.*; /** @@ -129,7 +131,7 @@ public class SseNotificationServiceImpl implements SseNotificationService { ); emitter.send(SseEmitter.event() .name("message") - .data(objectMapper.writeValueAsString(msg))); + .data(Objects.requireNonNull(serializeForSse(msg)))); } catch (IOException e) { logger.error("发送初始SSE消息失败,userId={}, deviceId={}", userId, deviceId, e); entries.remove(newEntry); @@ -233,7 +235,7 @@ public class SseNotificationServiceImpl implements SseNotificationService { try { entry.emitter.send(SseEmitter.event() .name("ping") - .data(objectMapper.writeValueAsString(pingMsg))); + .data(Objects.requireNonNull(serializeForSse(pingMsg)))); entry.lastHeartbeat = System.currentTimeMillis(); } catch (IOException e) { logger.debug("心跳发送失败,移除连接,userId={}, deviceId={}", userId, entry.deviceId); @@ -280,7 +282,7 @@ public class SseNotificationServiceImpl implements SseNotificationService { try { entry.emitter.send(SseEmitter.event() .name("task_progress") - .data(objectMapper.writeValueAsString(progressMsg))); + .data(Objects.requireNonNull(serializeForSse(progressMsg)))); } catch (IOException e) { logger.debug("发送任务进度失败,移除连接,userId={}, deviceId={}", userId, entry.deviceId); deadEntries.add(entry); @@ -330,7 +332,7 @@ public class SseNotificationServiceImpl implements SseNotificationService { try { entry.emitter.send(SseEmitter.event() .name("all_tasks_completed") - .data(objectMapper.writeValueAsString(msg))); + .data(Objects.requireNonNull(serializeForSse(msg)))); } catch (IOException e) { deadEntries.add(entry); } @@ -362,6 +364,11 @@ public class SseNotificationServiceImpl implements SseNotificationService { // ==================== 查询 ==================== + /** 序列化 SSE 载荷;@NonNull 满足 IDE 对 SseEmitter.data(@NonNull Object) 的空值分析 */ + private @NonNull String serializeForSse(Object payload) throws IOException { + return Objects.requireNonNull(objectMapper.writeValueAsString(payload)); + } + @Override public boolean hasActiveTasks(Long userId) { com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper wrapper = diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/mapper/OrderMapper.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/mapper/OrderMapper.java index bc1c95b5..1904a6fd 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/mapper/OrderMapper.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/mapper/OrderMapper.java @@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Update; -import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import top.xyquan.ecomdmbbackend.modules.ecom.order.model.po.OrderPO; import top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.OrderShopStatDateRow; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/service/impl/OrderServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/service/impl/OrderServiceImpl.java index c17fd093..3cb4e899 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/service/impl/OrderServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/service/impl/OrderServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.order.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -235,7 +235,7 @@ public class OrderServiceImpl extends ServiceImpl implemen // 更新订单 OrderPO order = new OrderPO(); - BeanUtils.copyProperties(updateOrderDTO, order); + BeanCopyUtils.copyProperties(updateOrderDTO, order); order.setId(id); order.setCompanyId(companyId); @@ -453,7 +453,7 @@ public class OrderServiceImpl extends ServiceImpl implemen */ private OrderVO convertToVO(OrderPO order) { OrderVO orderVO = new OrderVO(); - BeanUtils.copyProperties(order, orderVO); + BeanCopyUtils.copyProperties(order, orderVO); // 设置状态信息 if (order.getStatusId() != null) { @@ -461,7 +461,7 @@ public class OrderServiceImpl extends ServiceImpl implemen if (orderStatus != null) { orderVO.setStatusName(orderStatus.getStatusName()); OrderStatusVO orderStatusVO = new OrderStatusVO(); - BeanUtils.copyProperties(orderStatus, orderStatusVO); + BeanCopyUtils.copyProperties(orderStatus, orderStatusVO); orderVO.setOrderStatus(orderStatusVO); } } @@ -471,7 +471,7 @@ public class OrderServiceImpl extends ServiceImpl implemen if (shop != null) { orderVO.setShopName(shop.getName()); ShopVO shopVO = new ShopVO(); - BeanUtils.copyProperties(shop, shopVO); + BeanCopyUtils.copyProperties(shop, shopVO); orderVO.setShop(shopVO); } @@ -480,13 +480,13 @@ public class OrderServiceImpl extends ServiceImpl implemen ProductSpecPO productSpec = productSpecService.getById(order.getProductSpecId()); if (productSpec != null) { ProductSpecVO productSpecVO = new ProductSpecVO(); - BeanUtils.copyProperties(productSpec, productSpecVO); + BeanCopyUtils.copyProperties(productSpec, productSpecVO); orderVO.setProductSpec(productSpecVO); if (productSpec.getProductId() != null) { ProductPO product = productService.getById(productSpec.getProductId()); if (product != null) { ProductVO productVO = new ProductVO(); - BeanUtils.copyProperties(product, productVO); + BeanCopyUtils.copyProperties(product, productVO); orderVO.setProduct(productVO); } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/stat/service/OrderStatCacheService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/stat/service/OrderStatCacheService.java index 58d6b861..86dc9847 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/stat/service/OrderStatCacheService.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/stat/service/OrderStatCacheService.java @@ -3,10 +3,12 @@ package top.xyquan.ecomdmbbackend.modules.ecom.order.stat.service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; import top.xyquan.ecomdmbbackend.modules.ecom.order.stat.config.OrderStatProperties; import java.time.LocalDate; +import java.util.Objects; import java.util.concurrent.TimeUnit; /** @@ -19,10 +21,10 @@ public class OrderStatCacheService { private static final String KEY_PREFIX = "order-stat:read:"; private final OrderStatProperties properties; - private final RedisTemplate redisTemplate; + private final @NonNull RedisTemplate redisTemplate; public OrderStatCacheService(OrderStatProperties properties, - RedisTemplate redisTemplate) { + @NonNull RedisTemplate redisTemplate) { this.properties = properties; this.redisTemplate = redisTemplate; } @@ -33,11 +35,15 @@ public class OrderStatCacheService { /** 写入缓存(Query 层按需调用) */ public void put(String cacheKey, Object value, long ttlSeconds) { - if (!isEnabled() || cacheKey == null) { + if (!isEnabled() || cacheKey == null || value == null) { return; } try { - redisTemplate.opsForValue().set(KEY_PREFIX + cacheKey, value, ttlSeconds, TimeUnit.SECONDS); + redisTemplate.opsForValue().set( + KEY_PREFIX + cacheKey, + Objects.requireNonNull(value), + ttlSeconds, + TimeUnit.SECONDS); } catch (Exception e) { log.debug("order-stat cache put skip: {}", cacheKey, e); } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/stat/support/OrderStatParamHelper.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/stat/support/OrderStatParamHelper.java index 74c8c7d8..13196ab6 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/stat/support/OrderStatParamHelper.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/stat/support/OrderStatParamHelper.java @@ -5,7 +5,6 @@ import top.xyquan.ecomdmbbackend.modules.ecom.order.status.support.OrderStatusSt import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Set; /** 将 OrderStatusStatSets 转为 MyBatis IN 列表参数。 */ public final class OrderStatParamHelper { diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/status/service/impl/OrderStatusServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/status/service/impl/OrderStatusServiceImpl.java index 6e348986..750163c7 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/status/service/impl/OrderStatusServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/order/status/service/impl/OrderStatusServiceImpl.java @@ -1,8 +1,8 @@ package top.xyquan.ecomdmbbackend.modules.ecom.order.status.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -63,7 +63,7 @@ public class OrderStatusServiceImpl extends ServiceImpl orderSpecIdToProductIdMap(List orders) { List specIds = orders.stream() .map(OrderPO::getProductSpecId) diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/service/impl/PlatformServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/service/impl/PlatformServiceImpl.java index 1e36ce8e..37e74c0d 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/service/impl/PlatformServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/service/impl/PlatformServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.platform.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -57,7 +57,7 @@ public class PlatformServiceImpl extends ServiceImpl // 创建平台 PlatformPO platform = new PlatformPO(); - BeanUtils.copyProperties(createPlatformDTO, platform); + BeanCopyUtils.copyProperties(createPlatformDTO, platform); platform.setCompanyId(companyId); // 设置默认值 @@ -109,7 +109,7 @@ public class PlatformServiceImpl extends ServiceImpl // 更新平台 PlatformPO platform = new PlatformPO(); - BeanUtils.copyProperties(updatePlatformDTO, platform); + BeanCopyUtils.copyProperties(updatePlatformDTO, platform); platform.setId(id); platform.setCompanyId(companyId); @@ -223,7 +223,7 @@ public class PlatformServiceImpl extends ServiceImpl private PlatformVO convertToVO(PlatformPO platform) { PlatformVO vo = new PlatformVO(); - BeanUtils.copyProperties(platform, vo); + BeanCopyUtils.copyProperties(platform, vo); return vo; } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/controller/ProductSpecController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/controller/ProductSpecController.java index c29fe363..f8166753 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/controller/ProductSpecController.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/controller/ProductSpecController.java @@ -1,5 +1,6 @@ package top.xyquan.ecomdmbbackend.modules.ecom.product.controller; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -90,7 +91,7 @@ public class ProductSpecController { .filter(spec -> spec.getCompanyId().equals(companyId)) .map(spec -> { ProductSpecVO vo = new ProductSpecVO(); - org.springframework.beans.BeanUtils.copyProperties(spec, vo); + BeanCopyUtils.copyProperties(spec, vo); return vo; }) .collect(java.util.stream.Collectors.toList()); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/model/dto/SyncCostDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/model/dto/SyncCostDTO.java index 715900db..63dafcf2 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/model/dto/SyncCostDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/model/dto/SyncCostDTO.java @@ -1,13 +1,11 @@ package top.xyquan.ecomdmbbackend.modules.ecom.product.model.dto; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.Data; import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.List; /** * 同步规格成本到订单的请求DTO diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/service/impl/ProductOverviewServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/service/impl/ProductOverviewServiceImpl.java index 72663237..2e47e21e 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/service/impl/ProductOverviewServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/service/impl/ProductOverviewServiceImpl.java @@ -294,10 +294,11 @@ public class ProductOverviewServiceImpl implements ProductOverviewService { .map(ShopMonthlyTargetPO::getTargetAmount) .filter(Objects::nonNull) .reduce(BigDecimal.ZERO, BigDecimal::add); - Integer totalTargetOrderCount = shopTargets.stream() + int totalTargetOrderCount = shopTargets.stream() .map(ShopMonthlyTargetPO::getTargetOrderCount) .filter(Objects::nonNull) - .reduce(0, Integer::sum); + .mapToInt(Integer::intValue) + .sum(); if (totalTargetAmount.compareTo(BigDecimal.ZERO) > 0) { BigDecimal salesRate = totalSalesAmount @@ -306,7 +307,7 @@ public class ProductOverviewServiceImpl implements ProductOverviewService { .setScale(2, RoundingMode.HALF_UP); vo.setSalesAmountAchievementRate(salesRate); } - if (totalTargetOrderCount != null && totalTargetOrderCount > 0) { + if (totalTargetOrderCount > 0) { BigDecimal orderRate = BigDecimal.valueOf((long) totalOrderCount) .divide(BigDecimal.valueOf(totalTargetOrderCount), 4, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")) @@ -589,8 +590,8 @@ public class ProductOverviewServiceImpl implements ProductOverviewService { // 总件数 int quantity = specOrders.stream() - .map(o -> o.getQuantity() != null ? o.getQuantity() : 1) - .reduce(0, Integer::sum); + .mapToInt(o -> o.getQuantity() != null ? o.getQuantity() : 1) + .sum(); // 客单价 BigDecimal avgOV = orderCount > 0 diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/service/impl/ProductServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/service/impl/ProductServiceImpl.java index 261444e6..68b415ff 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/service/impl/ProductServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/service/impl/ProductServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.product.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; 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.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -86,7 +86,7 @@ public class ProductServiceImpl extends ServiceImpl im // 创建商品 ProductPO product = new ProductPO(); - BeanUtils.copyProperties(createProductDTO, product); + BeanCopyUtils.copyProperties(createProductDTO, product); // 设置公司ID product.setCompanyId(companyId); @@ -157,7 +157,7 @@ public class ProductServiceImpl extends ServiceImpl im throw new BusinessException("同公司下商品名称与商品编码组合已存在"); } ProductPO product = new ProductPO(); - BeanUtils.copyProperties(createProductDTO, product); + BeanCopyUtils.copyProperties(createProductDTO, product); product.setCompanyId(companyId); product.setCreateBy(userId); this.save(product); @@ -282,7 +282,7 @@ public class ProductServiceImpl extends ServiceImpl im // 更新商品 ProductPO product = new ProductPO(); - BeanUtils.copyProperties(updateProductDTO, product); + BeanCopyUtils.copyProperties(updateProductDTO, product); product.setId(id); product.setCompanyId(companyId); @@ -564,7 +564,7 @@ public class ProductServiceImpl extends ServiceImpl im */ private ProductVO convertToVO(ProductPO product) { ProductVO productVO = new ProductVO(); - BeanUtils.copyProperties(product, productVO); + BeanCopyUtils.copyProperties(product, productVO); // 查询主图文件信息并生成访问URL if (product.getMainImageId() != null) { @@ -604,7 +604,7 @@ public class ProductServiceImpl extends ServiceImpl im */ private ProductSpecVO convertSpecToVO(ProductSpecPO productSpec) { ProductSpecVO productSpecVO = new ProductSpecVO(); - BeanUtils.copyProperties(productSpec, productSpecVO); + BeanCopyUtils.copyProperties(productSpec, productSpecVO); return productSpecVO; } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/service/impl/ProductSpecServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/service/impl/ProductSpecServiceImpl.java index 8288b43e..fb00fb2a 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/service/impl/ProductSpecServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/service/impl/ProductSpecServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.product.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -29,6 +29,7 @@ import top.xyquan.ecomdmbbackend.utils.CurrentUserContext; import java.math.BigDecimal; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -131,20 +132,13 @@ public class ProductSpecServiceImpl extends ServiceImpl isCostReallyChanged = (dbVal, dtoVal) -> { - boolean dbIsEmpty = dbVal == null || dbVal.compareTo(java.math.BigDecimal.ZERO) == 0; - boolean dtoIsEmpty = dtoVal == null || dtoVal.compareTo(java.math.BigDecimal.ZERO) == 0; - if (dbIsEmpty && dtoIsEmpty) return false; // 都是空,无变化 - if (dbIsEmpty || dtoIsEmpty) return true; // 一个是空一个有值,有变化 - return dbVal.compareTo(dtoVal) != 0; // 都有非零值,精确比较 - }; - boolean costChanged = isCostReallyChanged.apply(existingProductSpec.getProductCost(), updateProductSpecDTO.getProductCost()) - || isCostReallyChanged.apply(existingProductSpec.getShippingCost(), updateProductSpecDTO.getShippingCost()) - || isCostReallyChanged.apply(existingProductSpec.getOtherCost(), updateProductSpecDTO.getOtherCost()); + boolean costChanged = isSpecCostChanged(existingProductSpec.getProductCost(), updateProductSpecDTO.getProductCost()) + || isSpecCostChanged(existingProductSpec.getShippingCost(), updateProductSpecDTO.getShippingCost()) + || isSpecCostChanged(existingProductSpec.getOtherCost(), updateProductSpecDTO.getOtherCost()); // 更新商品规格 ProductSpecPO productSpec = new ProductSpecPO(); - BeanUtils.copyProperties(updateProductSpecDTO, productSpec); + BeanCopyUtils.copyProperties(updateProductSpecDTO, productSpec); productSpec.setId(id); productSpec.setCompanyId(companyId); productSpec.setProductId(existingProductSpec.getProductId()); @@ -355,7 +349,7 @@ public class ProductSpecServiceImpl extends ServiceImpl { // 转换为商品VO ProductVO productVO = new ProductVO(); - BeanUtils.copyProperties(product, productVO); + BeanCopyUtils.copyProperties(product, productVO); // 添加匹配的规格信息 List specs = productSpecsMap.get(product.getId()); @@ -488,7 +482,7 @@ public class ProductSpecServiceImpl extends ServiceImpl { PromotionFeeTypeVO vo = new PromotionFeeTypeVO(); - BeanUtils.copyProperties(po, vo); + BeanCopyUtils.copyProperties(po, vo); // 设置计算方式描述 if (po.getCalculationMethod() != null) { @@ -173,7 +173,7 @@ public class PromotionFeeTypeServiceImpl implements PromotionFeeTypeService { return poList.stream() .map(po -> { PromotionFeeTypeVO vo = new PromotionFeeTypeVO(); - BeanUtils.copyProperties(po, vo); + BeanCopyUtils.copyProperties(po, vo); // 设置计算方式描述 if (po.getCalculationMethod() != null) { diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/monthlytarget/service/impl/ShopMonthlyTargetServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/monthlytarget/service/impl/ShopMonthlyTargetServiceImpl.java index 66578d1f..070f8ac8 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/monthlytarget/service/impl/ShopMonthlyTargetServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/monthlytarget/service/impl/ShopMonthlyTargetServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.shop.monthlytarget.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -74,7 +74,7 @@ public class ShopMonthlyTargetServiceImpl extends ServiceImpl implements ShopService { private final CurrentUserContext currentUserContext; - private final SysFileMapper sysFileMapper; private final SysFileService sysFileService; private final OrderMapper orderMapper; private final PromotionFeeMapper promotionFeeMapper; @@ -73,14 +68,13 @@ public class ShopServiceImpl extends ServiceImpl implements private final BrushOrderMapper brushOrderMapper; private final ShopMonthlyTargetMapper shopMonthlyTargetMapper; - public ShopServiceImpl(CurrentUserContext currentUserContext, SysFileMapper sysFileMapper, SysFileService sysFileService, + public ShopServiceImpl(CurrentUserContext currentUserContext, SysFileService sysFileService, OrderMapper orderMapper, PromotionFeeMapper promotionFeeMapper, ProductMapper productMapper, ShopProductRelationMapper shopProductRelationMapper, ProductSpecService productSpecService, PlatformMapper platformMapper, BrushOrderMapper brushOrderMapper, ShopMonthlyTargetMapper shopMonthlyTargetMapper) { this.currentUserContext = currentUserContext; - this.sysFileMapper = sysFileMapper; this.sysFileService = sysFileService; this.orderMapper = orderMapper; this.promotionFeeMapper = promotionFeeMapper; @@ -113,7 +107,7 @@ public class ShopServiceImpl extends ServiceImpl implements // 创建店铺 ShopPO shop = new ShopPO(); - BeanUtils.copyProperties(createShopDTO, shop); + BeanCopyUtils.copyProperties(createShopDTO, shop); // 设置公司ID shop.setCompanyId(companyId); @@ -157,7 +151,7 @@ public class ShopServiceImpl extends ServiceImpl implements // 更新店铺 ShopPO shop = new ShopPO(); - BeanUtils.copyProperties(updateShopDTO, shop); + BeanCopyUtils.copyProperties(updateShopDTO, shop); shop.setId(id); shop.setCompanyId(companyId); @@ -254,7 +248,7 @@ public class ShopServiceImpl extends ServiceImpl implements */ private ShopVO convertToVO(ShopPO shop) { ShopVO shopVO = new ShopVO(); - BeanUtils.copyProperties(shop, shopVO); + BeanCopyUtils.copyProperties(shop, shopVO); if (shop.getLogoImageId() != null) { shopVO.setLogo(sysFileService.getFileAccessUrl(shop.getLogoImageId())); @@ -337,7 +331,7 @@ public class ShopServiceImpl extends ServiceImpl implements */ private ProductVO convertProductToVO(ProductPO product) { ProductVO productVO = new ProductVO(); - BeanUtils.copyProperties(product, productVO); + BeanCopyUtils.copyProperties(product, productVO); // 查询商品规格列表 LambdaQueryWrapper specWrapper = new LambdaQueryWrapper<>(); @@ -359,7 +353,7 @@ public class ShopServiceImpl extends ServiceImpl implements */ private ProductSpecVO convertSpecToVO(ProductSpecPO productSpec) { ProductSpecVO productSpecVO = new ProductSpecVO(); - BeanUtils.copyProperties(productSpec, productSpecVO); + BeanCopyUtils.copyProperties(productSpec, productSpecVO); return productSpecVO; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/workbench/service/impl/WorkbenchServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/workbench/service/impl/WorkbenchServiceImpl.java index 8184f780..9f39d3e4 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/workbench/service/impl/WorkbenchServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/workbench/service/impl/WorkbenchServiceImpl.java @@ -3,14 +3,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.workbench.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.springframework.stereotype.Service; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; -import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.mapper.BrushOrderMapper; -import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.model.po.BrushOrderPO; import top.xyquan.ecomdmbbackend.modules.ecom.category.model.po.CategoryPO; import top.xyquan.ecomdmbbackend.modules.ecom.category.service.CategoryService; -import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper; import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderStatAggMapper; import top.xyquan.ecomdmbbackend.modules.ecom.order.stat.service.OrderStatReadFacade; -import top.xyquan.ecomdmbbackend.modules.ecom.order.model.po.OrderPO; import top.xyquan.ecomdmbbackend.modules.ecom.order.status.support.OrderStatusStatResolver; import top.xyquan.ecomdmbbackend.modules.ecom.order.status.support.OrderStatusStatSets; import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.CompanyOverviewVO; @@ -18,11 +14,7 @@ import top.xyquan.ecomdmbbackend.modules.ecom.overview.service.CompanyOverviewSe import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper; import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO; import top.xyquan.ecomdmbbackend.modules.ecom.product.mapper.ProductMapper; -import top.xyquan.ecomdmbbackend.modules.ecom.product.mapper.ProductSpecMapper; import top.xyquan.ecomdmbbackend.modules.ecom.product.model.po.ProductPO; -import top.xyquan.ecomdmbbackend.modules.ecom.product.model.po.ProductSpecPO; -import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper; -import top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.po.PromotionFeePO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.po.ShopPO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.service.ShopService; import top.xyquan.ecomdmbbackend.modules.ecom.workbench.model.dto.WorkbenchQueryDTO; @@ -63,9 +55,9 @@ import java.util.stream.Collectors; *
    *
  • 「实际销售额、成本、退款、多维行、趋势」等与 {@link OrderStatusStatSets} 一致:仅统计配置为「计入销售额」的订单状态, * 金额字段由 {@code stat} 解析商家实收、成本、退款等。
  • - *
  • 「总 GMV」为同店铺、同时间范围内全部订单状态的 {@link OrderPO#getReceivedAmount()} 合计。
  • + *
  • 「总 GMV」为同店铺、同时间范围内全部订单状态的商家实收合计(由汇总表 KPI 提供)。
  • *
  • 推广费、刷单费为区间汇总;多维行与趋势中的「净利润」按销售额 / 净销售额占比将区间推广、刷单、税额分摊到各维度或各日, - * 与 {@link #aggregateTotals} 得到的区间总毛利润、总税额自洽。
  • + * 与 {@link #totalsFromOrderRows} 得到的区间总毛利润、总税额自洽。 *
*

* 分 Tab 输出:{@link #financeSlice}、{@link #multiAnalysis}、{@link #salesRank}。 @@ -79,12 +71,8 @@ public class WorkbenchServiceImpl implements WorkbenchService { private static final DateTimeFormatter TREND_DATE_FMT = DateTimeFormatter.ofPattern("M/d"); private final CurrentUserContext currentUserContext; - private final OrderMapper orderMapper; private final ShopService shopService; private final OrderStatusStatResolver orderStatusStatResolver; - private final PromotionFeeMapper promotionFeeMapper; - private final BrushOrderMapper brushOrderMapper; - private final ProductSpecMapper productSpecMapper; private final ProductMapper productMapper; private final CategoryService categoryService; private final PlatformMapper platformMapper; @@ -92,24 +80,16 @@ public class WorkbenchServiceImpl implements WorkbenchService { private final CompanyOverviewService companyOverviewService; public WorkbenchServiceImpl(CurrentUserContext currentUserContext, - OrderMapper orderMapper, ShopService shopService, OrderStatusStatResolver orderStatusStatResolver, - PromotionFeeMapper promotionFeeMapper, - BrushOrderMapper brushOrderMapper, - ProductSpecMapper productSpecMapper, ProductMapper productMapper, CategoryService categoryService, PlatformMapper platformMapper, OrderStatReadFacade orderStatReadFacade, CompanyOverviewService companyOverviewService) { this.currentUserContext = currentUserContext; - this.orderMapper = orderMapper; this.shopService = shopService; this.orderStatusStatResolver = orderStatusStatResolver; - this.promotionFeeMapper = promotionFeeMapper; - this.brushOrderMapper = brushOrderMapper; - this.productSpecMapper = productSpecMapper; this.productMapper = productMapper; this.categoryService = categoryService; this.platformMapper = platformMapper; @@ -413,15 +393,6 @@ public class WorkbenchServiceImpl implements WorkbenchService { .stream().collect(Collectors.toMap(CategoryPO::getId, CategoryPO::getName, (a, b) -> a)); } - private static List statusList(java.util.Set ids) { - if (ids == null || ids.isEmpty()) { - return List.of(-1L); - } - List list = new ArrayList<>(ids); - Collections.sort(list); - return list; - } - private static BigDecimal dayNetSales(OrderStatAggMapper.DailyRow row) { if (row == null) { return BigDecimal.ZERO; @@ -488,95 +459,6 @@ public class WorkbenchServiceImpl implements WorkbenchService { } } - /** 当前区间:计入销售额订单、推广/刷单、汇总 Totals(导出等仍用) */ - private CurrentPeriodBundle loadCurrentPeriod(ShopContext ctx) { - List unionStatusIds = ctx.stat().getUnionStatusIds(); - List orders = loadOrders(ctx.companyId(), ctx.shopIds(), - ctx.range().startDateTime(), ctx.range().endDateTime(), unionStatusIds); - List promotionFees = loadPromotionFees(ctx.companyId(), ctx.shopIds(), - ctx.range().startDate(), ctx.range().endDate()); - List brushOrders = loadBrushOrders(ctx.companyId(), ctx.shopIds(), - ctx.range().startDateTime(), ctx.range().endDateTime()); - Totals totals = aggregateTotals(orders, ctx.stat(), promotionFees, brushOrders, ctx.taxRate()); - return new CurrentPeriodBundle(orders, promotionFees, brushOrders, totals); - } - - /** 环比/同比:用于 KPI 对比与总 GMV(导出等仍用) */ - private ComparePeriodBundle loadComparePeriods(ShopContext ctx) { - List unionStatusIds = ctx.stat().getUnionStatusIds(); - List curOrdersAllStatuses = loadOrdersAllStatuses(ctx.companyId(), ctx.shopIds(), - ctx.range().startDateTime(), ctx.range().endDateTime()); - DateRange lastRange = lastMonthSameSpan(ctx.range()); - List lastOrders = loadOrders(ctx.companyId(), ctx.shopIds(), - lastRange.startDateTime(), lastRange.endDateTime(), unionStatusIds); - List lastOrdersAllStatuses = loadOrdersAllStatuses(ctx.companyId(), ctx.shopIds(), - lastRange.startDateTime(), lastRange.endDateTime()); - List lastPromo = loadPromotionFees(ctx.companyId(), ctx.shopIds(), - lastRange.startDate(), lastRange.endDate()); - List lastBrush = loadBrushOrders(ctx.companyId(), ctx.shopIds(), - lastRange.startDateTime(), lastRange.endDateTime()); - Totals prev = aggregateTotals(lastOrders, ctx.stat(), lastPromo, lastBrush, ctx.taxRate()); - - DateRange yoyRange = new DateRange(ctx.range().startDate().minusYears(1), ctx.range().endDate().minusYears(1)); - List yoyOrders = loadOrders(ctx.companyId(), ctx.shopIds(), - yoyRange.startDateTime(), yoyRange.endDateTime(), unionStatusIds); - List yoyOrdersAllStatuses = loadOrdersAllStatuses(ctx.companyId(), ctx.shopIds(), - yoyRange.startDateTime(), yoyRange.endDateTime()); - List yoyPromo = loadPromotionFees(ctx.companyId(), ctx.shopIds(), - yoyRange.startDate(), yoyRange.endDate()); - List yoyBrush = loadBrushOrders(ctx.companyId(), ctx.shopIds(), - yoyRange.startDateTime(), yoyRange.endDateTime()); - Totals yoy = aggregateTotals(yoyOrders, ctx.stat(), yoyPromo, yoyBrush, ctx.taxRate()); - - return new ComparePeriodBundle(lastRange, yoyRange, prev, yoy, - sumAllReceivedAmount(curOrdersAllStatuses), - sumAllReceivedAmount(lastOrdersAllStatuses), - sumAllReceivedAmount(yoyOrdersAllStatuses)); - } - - /** 四维订单聚合 + 名称解析 */ - private DimensionAggMaps aggregateDimensions(List orders, - List shops, - Map shopById, - OrderStatusStatSets stat) { - Map specToProduct = buildSpecToProductMap(orders); - Map productById = loadProducts(specToProduct.values()); - Map categoryNames = loadCategoryNames(productById.values()); - Map platformNames = loadPlatformNames(shops); - - Map platformAgg = new HashMap<>(); - Map shopAgg = new HashMap<>(); - Map categoryAgg = new HashMap<>(); - Map productAgg = new HashMap<>(); - - for (OrderPO o : orders) { - ShopPO shop = shopById.get(o.getShopId()); - if (shop == null) { - continue; - } - long platformKey = shop.getPlatformId() != null ? shop.getPlatformId() : 0L; - long shopKey = shop.getId() != null ? shop.getId() : 0L; - long productId = o.getProductSpecId() != null - ? specToProduct.getOrDefault(o.getProductSpecId(), -1L) - : -1L; - long categoryKey = 0L; - if (productId > 0) { - ProductPO p = productById.get(productId); - if (p != null && p.getCategoryId() != null) { - categoryKey = p.getCategoryId(); - } - } - - addOrder(platformAgg, String.valueOf(platformKey), o, stat); - addOrder(shopAgg, String.valueOf(shopKey), o, stat); - addOrder(categoryAgg, String.valueOf(categoryKey), o, stat); - addOrder(productAgg, String.valueOf(productId), o, stat); - } - - return new DimensionAggMaps(platformAgg, shopAgg, categoryAgg, productAgg, - platformNames, categoryNames, productById, shopById); - } - private WorkbenchMultiAnalysisPanelVO buildMultiPanel(DimensionAggMaps aggs, Totals cur) { BigDecimal salesAllocBase = cur.totalSales(); return WorkbenchMultiAnalysisPanelVO.builder() @@ -615,29 +497,6 @@ public class WorkbenchServiceImpl implements WorkbenchService { .build(); } - private WorkbenchFinancePanelVO buildFinancePanel(ShopContext ctx, - CurrentPeriodBundle current, - ComparePeriodBundle compare, - Map platformAgg, - Map platformNames) { - List ordersAllStatuses = loadOrdersAllStatuses(ctx.companyId(), ctx.shopIds(), - ctx.range().startDateTime(), ctx.range().endDateTime()); - BigDecimal totalGmvCur = sumAllReceivedAmount(ordersAllStatuses); - BigDecimal salesAllocBase = current.totals().totalSales(); - - return WorkbenchFinancePanelVO.builder() - .kpis(buildKpis(current.totals(), compare.prev(), compare.yoy(), ctx.range(), ctx.taxRate(), - totalGmvCur, compare.totalGmvPrev(), compare.totalGmvYoy())) - .gmvTrend(buildTrend(current.orders(), ctx.stat(), - ctx.range().startDate(), ctx.range().endDate(), current.totals())) - .platformSalesShare(buildPlatformSalesSlices(platformAgg, platformNames, salesAllocBase)) - .momCompareDateStart(compare.lastRange().startDate().toString()) - .momCompareDateEnd(compare.lastRange().endDate().toString()) - .yoyCompareDateStart(compare.yoyRange().startDate().toString()) - .yoyCompareDateEnd(compare.yoyRange().endDate().toString()) - .build(); - } - /** * 按公司 + 可选平台/单店筛选店铺列表;指定 {@code shopId} 时校验归属与平台一致性。 */ @@ -660,103 +519,6 @@ public class WorkbenchServiceImpl implements WorkbenchService { return shopService.list(w); } - /** - * 查询「计入销售额」口径订单:状态 id 落在 {@code unionStatusIds} 内;若公司未配置任何计入状态则查不到数据(条件恒假)。 - */ - private List loadOrders(Long companyId, List shopIds, - LocalDateTime start, LocalDateTime end, List unionStatusIds) { - if (shopIds.isEmpty()) { - return Collections.emptyList(); - } - LambdaQueryWrapper orderWrapper = new LambdaQueryWrapper<>(); - orderWrapper.eq(OrderPO::getCompanyId, companyId) - .in(OrderPO::getShopId, shopIds) - .ge(OrderPO::getOrderTime, start) - .le(OrderPO::getOrderTime, end); - if (!unionStatusIds.isEmpty()) { - orderWrapper.in(OrderPO::getStatusId, unionStatusIds); - } else { - orderWrapper.isNull(OrderPO::getId); - } - return orderMapper.selectList(orderWrapper); - } - - /** - * 总 GMV 用:同店铺、时间范围内全部订单状态的列表,不按「计入销售额」过滤。 - */ - private List loadOrdersAllStatuses(Long companyId, List shopIds, - LocalDateTime start, LocalDateTime end) { - if (shopIds.isEmpty()) { - return Collections.emptyList(); - } - LambdaQueryWrapper w = new LambdaQueryWrapper<>(); - w.eq(OrderPO::getCompanyId, companyId) - .in(OrderPO::getShopId, shopIds) - .ge(OrderPO::getOrderTime, start) - .le(OrderPO::getOrderTime, end); - return orderMapper.selectList(w); - } - - /** 将订单列表的商家实收相加,用于总 GMV KPI */ - private static BigDecimal sumAllReceivedAmount(List orders) { - BigDecimal s = BigDecimal.ZERO; - if (orders == null) { - return s; - } - for (OrderPO o : orders) { - if (o.getReceivedAmount() != null) { - s = s.add(o.getReceivedAmount()); - } - } - return s; - } - - /** 推广费按费用发生日落在 [start, end] 闭区间内 */ - private List loadPromotionFees(Long companyId, List shopIds, LocalDate start, LocalDate end) { - if (shopIds.isEmpty()) { - return Collections.emptyList(); - } - LambdaQueryWrapper w = new LambdaQueryWrapper<>(); - w.eq(PromotionFeePO::getCompanyId, companyId) - .in(PromotionFeePO::getShopId, shopIds) - .ge(PromotionFeePO::getFeeDate, start) - .le(PromotionFeePO::getFeeDate, end); - return promotionFeeMapper.selectList(w); - } - - /** 刷单记录按刷单时间落在 [start, end] 内 */ - private List loadBrushOrders(Long companyId, List shopIds, LocalDateTime start, LocalDateTime end) { - if (shopIds.isEmpty()) { - return Collections.emptyList(); - } - LambdaQueryWrapper w = new LambdaQueryWrapper<>(); - w.eq(BrushOrderPO::getCompanyId, companyId) - .in(BrushOrderPO::getShopId, shopIds) - .ge(BrushOrderPO::getBrushTime, start) - .le(BrushOrderPO::getBrushTime, end); - return brushOrderMapper.selectList(w); - } - - /** 批量解析订单中出现的规格 id → 商品 id,减少重复查库 */ - private Map buildSpecToProductMap(List orders) { - List specIds = orders.stream() - .map(OrderPO::getProductSpecId) - .filter(Objects::nonNull) - .distinct() - .toList(); - if (specIds.isEmpty()) { - return Collections.emptyMap(); - } - List specs = productSpecMapper.selectList(new LambdaQueryWrapper() - .in(ProductSpecPO::getId, specIds) - .select(ProductSpecPO::getId, ProductSpecPO::getProductId)); - Map map = new HashMap<>(); - for (ProductSpecPO s : specs) { - map.put(s.getId(), s.getProductId()); - } - return map; - } - /** 按商品 id 批量加载主数据,供类目解析与商品名称展示 */ private Map loadProducts(Iterable productIds) { List ids = new ArrayList<>(); @@ -773,22 +535,6 @@ public class WorkbenchServiceImpl implements WorkbenchService { return list.stream().collect(Collectors.toMap(ProductPO::getId, p -> p, (a, b) -> a)); } - /** 从商品上收集类目 id,再批量查类目名称 */ - private Map loadCategoryNames(Iterable products) { - List catIds = new ArrayList<>(); - for (ProductPO p : products) { - if (p.getCategoryId() != null) { - catIds.add(p.getCategoryId()); - } - } - catIds = catIds.stream().distinct().toList(); - if (catIds.isEmpty()) { - return Collections.emptyMap(); - } - List cats = categoryService.list(new LambdaQueryWrapper().in(CategoryPO::getId, catIds)); - return cats.stream().collect(Collectors.toMap(CategoryPO::getId, CategoryPO::getName, (a, b) -> a)); - } - /** 从店铺收集平台 id,再批量查平台名称(多维「平台」行展示) */ private Map loadPlatformNames(List shops) { List pids = shops.stream() @@ -803,11 +549,6 @@ public class WorkbenchServiceImpl implements WorkbenchService { return list.stream().collect(Collectors.toMap(PlatformPO::getId, PlatformPO::getPlatformName, (a, b) -> a)); } - /** 将单条订单累加到指定 key 的 {@link Agg} 桶中 */ - private void addOrder(Map map, String key, OrderPO o, OrderStatusStatSets stat) { - map.computeIfAbsent(key, k -> new Agg()).add(o, stat); - } - /** * 将「字符串 key → 聚合桶」转为多维表格行:每行毛利润 = 销售−成本−退款; * 推广费、刷单费按该行销售额占 {@code salesTotalCompany} 比例分摊;税额按该行净销售额占全部分桶净销售额之和比例分摊; @@ -885,60 +626,6 @@ public class WorkbenchServiceImpl implements WorkbenchService { return amount.multiply(part).divide(total, 4, RoundingMode.HALF_UP); } - /** - * 趋势点:毛利润按日订单聚合;净利润按区间总推广/刷单/税额,以「日销售额占比」「日净销售额占比」分摊到各日, - * 与 {@link #buildDimRows} 及 KPI 净利润口径一致。 - */ - private List buildTrend(List orders, OrderStatusStatSets stat, - LocalDate start, LocalDate end, Totals periodTotals) { - Map byDay = new HashMap<>(); - for (OrderPO o : orders) { - if (o.getOrderTime() == null) { - continue; - } - LocalDate day = o.getOrderTime().toLocalDate(); - byDay.computeIfAbsent(day, x -> new Agg()).add(o, stat); - } - BigDecimal salesTotal = periodTotals.totalSales(); - BigDecimal promoTotal = periodTotals.promotion(); - BigDecimal brushTotal = periodTotals.brush(); - BigDecimal taxTotal = periodTotals.tax(); - - BigDecimal netSum = BigDecimal.ZERO; - for (LocalDate x = start; !x.isAfter(end); x = x.plusDays(1)) { - netSum = netSum.add(byDay.getOrDefault(x, new Agg()).netSalesBase()); - } - - List list = new ArrayList<>(); - LocalDate d = start; - while (!d.isAfter(end)) { - Agg a = byDay.getOrDefault(d, new Agg()); - BigDecimal salesYuan = yuan2(a.sales); - BigDecimal gross = a.sales.subtract(a.cost).subtract(a.refund); - BigDecimal profitYuan = yuan2(gross); - BigDecimal refundYuan = yuan2(a.refund); - - BigDecimal promoB = allocShare(a.sales, salesTotal, promoTotal); - BigDecimal brushB = allocShare(a.sales, salesTotal, brushTotal); - BigDecimal taxB = allocShare(a.netSalesBase(), netSum.max(BigDecimal.ONE), taxTotal); - if (netSum.compareTo(BigDecimal.ZERO) <= 0) { - taxB = BigDecimal.ZERO; - } - BigDecimal netDay = gross.subtract(promoB).subtract(brushB).subtract(taxB); - BigDecimal netProfitYuan = yuan2(netDay); - - list.add(WorkbenchTrendPointVO.builder() - .date(d.format(TREND_DATE_FMT)) - .salesYuan(salesYuan) - .profitYuan(profitYuan) - .netProfitYuan(netProfitYuan) - .refundYuan(refundYuan) - .build()); - d = d.plusDays(1); - } - return list; - } - /** * 各平台实际销售额占比:与多维分析「平台」维度同源订单聚合;分母为当前筛选下公司实际销售额合计。 */ @@ -1076,51 +763,6 @@ public class WorkbenchServiceImpl implements WorkbenchService { .setScale(2, RoundingMode.HALF_UP); } - /** - * 将一段时间内的订单 + 推广 + 刷单聚合成 {@link Totals}:销售额/退款/成本分项、推广与刷单合计、 - * 按「销售额−退款」为税基的税额、毛利润、净利润、计入销售额订单数与客单价。 - */ - private Totals aggregateTotals(List orders, OrderStatusStatSets stat, - List promotionFees, List brushOrders, - BigDecimal taxRate) { - BigDecimal sales = BigDecimal.ZERO; - BigDecimal refund = BigDecimal.ZERO; - BigDecimal cost = BigDecimal.ZERO; - BigDecimal productCost = BigDecimal.ZERO; - BigDecimal freight = BigDecimal.ZERO; - BigDecimal other = BigDecimal.ZERO; - int orderCount = 0; - for (OrderPO o : orders) { - sales = sales.add(stat.receivedForSales(o)); - refund = refund.add(stat.receivedForRefund(o)); - productCost = productCost.add(stat.productCostForStats(o)); - freight = freight.add(stat.freightCostForStats(o)); - other = other.add(stat.otherCostForStats(o)); - cost = cost.add(stat.totalCostForStats(o)); - if (stat.includesSales(o.getStatusId())) { - orderCount++; - } - } - BigDecimal promotion = promotionFees.stream() - .map(f -> f.getFeeAmount() != null ? f.getFeeAmount() : BigDecimal.ZERO) - .reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal brush = brushOrders.stream() - .map(b -> b.getBrushAmount() != null ? b.getBrushAmount() : BigDecimal.ZERO) - .reduce(BigDecimal.ZERO, BigDecimal::add); - - BigDecimal grossOrder = sales.subtract(cost).subtract(refund); - BigDecimal profitBeforeTax = grossOrder.subtract(promotion).subtract(brush); - BigDecimal tax = salesTaxOnNetSales(sales, refund, taxRate); - BigDecimal netProfit = profitBeforeTax.subtract(tax); - - BigDecimal aov = orderCount > 0 - ? sales.divide(BigDecimal.valueOf(orderCount), 2, RoundingMode.HALF_UP) - : BigDecimal.ZERO; - - return new Totals(sales, refund, cost, productCost, freight, other, promotion, brush, tax, - grossOrder, netProfit, orderCount, aov); - } - /** * 与单店概览一致:订单流水中「销售额−成本」的合计,再扣推广、刷单得税前;再扣税得净利。 */ @@ -1207,13 +849,6 @@ public class WorkbenchServiceImpl implements WorkbenchService { Map shopById) { } - /** 当前区间订单与费用 */ - private record CurrentPeriodBundle(List orders, - List promotionFees, - List brushOrders, - Totals totals) { - } - /** 环比/同比汇总 */ private record ComparePeriodBundle(DateRange lastRange, DateRange yoyRange, @@ -1265,41 +900,22 @@ public class WorkbenchServiceImpl implements WorkbenchService { BigDecimal netProfit, int orderCount, BigDecimal averageOrderValue) { - /** max(0, 销售额 − 退款),作税额分摊分母用 */ - BigDecimal netSalesBase() { - BigDecimal b = totalSales.subtract(totalRefund); - return b.max(BigDecimal.ZERO); - } } - /** - * 多维或按日聚合用的累加桶:与 {@link OrderStatusStatSets} 同步累计销售额、退款、成本,并统计计入销售额的订单笔数。 - */ + /** 多维或按日聚合用的累加桶:累计销售额、退款、成本 */ private static final class Agg { BigDecimal sales = BigDecimal.ZERO; BigDecimal refund = BigDecimal.ZERO; BigDecimal cost = BigDecimal.ZERO; - int orders; - - /** 累加单笔订单的销售额、退款、成本;若状态计入销售额则订单笔数 +1 */ - void add(OrderPO o, OrderStatusStatSets stat) { - sales = sales.add(stat.receivedForSales(o)); - refund = refund.add(stat.receivedForRefund(o)); - cost = cost.add(stat.totalCostForStats(o)); - if (stat.includesSales(o.getStatusId())) { - orders++; - } - } /** 累加 SQL 聚合行 */ void addFromAggRow(OrderStatAggMapper.ShopProductRow row) { sales = sales.add(nz(row.getSalesAmount())); refund = refund.add(nz(row.getRefundAmount())); cost = cost.add(nz(row.getProductCost())).add(nz(row.getFreightCost())).add(nz(row.getOtherCost())); - orders += row.getOrderCount() != null ? row.getOrderCount().intValue() : 0; } - /** 桶内净销售额 max(0, 销售−退款),与 {@link Totals#netSalesBase()} 含义一致,用于税额分摊 */ + /** 桶内净销售额 max(0, 销售−退款),用于税额分摊 */ BigDecimal netSalesBase() { BigDecimal b = sales.subtract(refund); return b.max(BigDecimal.ZERO); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/api/filter/ApiKeyAuthenticationFilter.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/api/filter/ApiKeyAuthenticationFilter.java index fe62a16d..122a2691 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/api/filter/ApiKeyAuthenticationFilter.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/api/filter/ApiKeyAuthenticationFilter.java @@ -6,6 +6,7 @@ import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; +import org.springframework.lang.NonNull; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; @@ -41,13 +42,16 @@ public class ApiKeyAuthenticationFilter extends OncePerRequestFilter { } @Override - protected boolean shouldNotFilter(HttpServletRequest request) { + protected boolean shouldNotFilter(@NonNull HttpServletRequest request) { String uri = request.getRequestURI(); return uri == null || !uri.startsWith(OPEN_PATH_PREFIX); } @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) + protected void doFilterInternal( + @NonNull HttpServletRequest request, + @NonNull HttpServletResponse response, + @NonNull FilterChain filterChain) throws ServletException, IOException { try { String apiKey = extractApiKey(request); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/key/service/impl/OpenApiKeyServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/key/service/impl/OpenApiKeyServiceImpl.java index fd1f5e80..48e8e5e4 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/key/service/impl/OpenApiKeyServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/key/service/impl/OpenApiKeyServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.open.key.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -256,7 +256,7 @@ public class OpenApiKeyServiceImpl implements OpenApiKeyService { } private void copyToVo(OpenApiKeyPO po, OpenApiKeyVO vo) { - BeanUtils.copyProperties(po, vo, "ipWhitelist"); + BeanCopyUtils.copyProperties(po, vo, "ipWhitelist"); List permissions = openApiKeyPermissionMapper.selectPermissionsByApiKeyId(po.getId()); vo.setPermissions(permissions); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/AccountController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/AccountController.java index ccfde210..ce837a8a 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/AccountController.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/AccountController.java @@ -1,4 +1,4 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.controller; +package top.xyquan.ecomdmbbackend.modules.org.company.account.controller; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -9,11 +9,11 @@ import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission; import top.xyquan.ecomdmbbackend.common.response.ApiResponse; import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.CreateAccountDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.UpdateAccountDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO; -import top.xyquan.ecomdmbbackend.modules.org.account.service.AccountService; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.CreateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.UpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.service.AccountService; /** * 公司账户管理控制器 @@ -35,8 +35,8 @@ public class AccountController { @Operation(summary = "创建账户(拥有者)", description = "公司拥有者创建本公司账户;手机号已存在时将用户拉入本公司,不存在则新建用户") @PostMapping("/create") @RequirePermission(value = "org:company:manage", description = "创建账户", allowSuper = true) - public ApiResponse createAccountForCompany(@Valid @RequestBody CreateAccountDTO createAccountDTO) { - AccountVO accountVO = accountService.createAccountForCompany(createAccountDTO); + public ApiResponse createAccountForCompany(@Valid @RequestBody CreateAccountDTO createAccountDTO) { + CompanyAccountVO accountVO = accountService.createAccountForCompany(createAccountDTO); return ApiResponse.success("账户创建成功", accountVO); } @@ -44,8 +44,8 @@ public class AccountController { @Operation(summary = "分页查询账户(拥有者)", description = "公司拥有者分页查询本公司账户") @PostMapping("/list") @RequirePermission(value = "org:company:manage", description = "查询账户列表", allowSuper = true) - public ApiResponse> getAccountPageForCompany(@Valid @RequestBody PageQueryDTO pageQuery) { - PageResultVO pageResult = accountService.getAccountPageForCompany(pageQuery); + public ApiResponse> getAccountPageForCompany(@Valid @RequestBody PageQueryDTO pageQuery) { + PageResultVO pageResult = accountService.getAccountPageForCompany(pageQuery); return ApiResponse.success("获取账户列表成功", pageResult); } @@ -53,10 +53,10 @@ public class AccountController { @Operation(summary = "更新账户信息", description = "公司拥有者更新本公司账户信息") @PutMapping("/update/{accountId}") @RequirePermission(value = "org:company:manage", description = "更新账户", allowSuper = true) - public ApiResponse updateAccount( + public ApiResponse updateAccount( @Parameter(description = "账户ID", example = "1") @PathVariable Long accountId, @Valid @RequestBody UpdateAccountDTO updateAccountDTO) { - AccountVO accountVO = accountService.updateAccountForCompany(updateAccountDTO, accountId); + CompanyAccountVO accountVO = accountService.updateAccountForCompany(updateAccountDTO, accountId); return ApiResponse.success("账户更新成功", accountVO); } @@ -73,9 +73,9 @@ public class AccountController { @Operation(summary = "获取账户详情", description = "获取账户详细信息") @GetMapping("/detail/{accountId}") @RequirePermission(value = "org:company:manage", description = "获取账户详情", allowSuper = true) - public ApiResponse getAccountDetail( + public ApiResponse getAccountDetail( @Parameter(description = "账户ID", example = "1") @PathVariable Long accountId) { - AccountVO accountVO = accountService.getAccountDetail(accountId); + CompanyAccountVO accountVO = accountService.getAccountDetail(accountId); return ApiResponse.success("获取账户详情成功", accountVO); } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/SuperAccountController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/SuperAccountController.java index f1fa7654..3be46af8 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/SuperAccountController.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/SuperAccountController.java @@ -1,4 +1,4 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.controller; +package top.xyquan.ecomdmbbackend.modules.org.company.account.controller; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -9,11 +9,11 @@ import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission; import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; import top.xyquan.ecomdmbbackend.common.response.ApiResponse; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperCreateAccountDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperUpdateAccountDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO; -import top.xyquan.ecomdmbbackend.modules.org.account.service.SuperAccountService; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperCreateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperUpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.service.SuperAccountService; /** * 超级管理员账户管理控制器 @@ -32,26 +32,26 @@ public class SuperAccountController { @Operation(summary = "创建账户", description = "超级管理员创建账户,可指定公司") @PostMapping("/create") @RequirePermission(value = "org:company:manage", description = "创建账户", allowSuper = true) - public ApiResponse createAccount(@Valid @RequestBody SuperCreateAccountDTO superCreateAccountDTO) { - AccountVO accountVO = superAccountService.createAccount(superCreateAccountDTO); + public ApiResponse createAccount(@Valid @RequestBody SuperCreateAccountDTO superCreateAccountDTO) { + CompanyAccountVO accountVO = superAccountService.createAccount(superCreateAccountDTO); return ApiResponse.success("账户创建成功", accountVO); } @Operation(summary = "分页查询账户", description = "超级管理员分页查询所有账户") @PostMapping("/list") @RequirePermission(value = "org:company:manage", description = "查询账户列表", allowSuper = true) - public ApiResponse> getAccountPage(@Valid @RequestBody PageQueryDTO pageQuery) { - PageResultVO pageResult = superAccountService.getAccountPage(pageQuery); + public ApiResponse> getAccountPage(@Valid @RequestBody PageQueryDTO pageQuery) { + PageResultVO pageResult = superAccountService.getAccountPage(pageQuery); return ApiResponse.success("获取账户列表成功", pageResult); } @Operation(summary = "更新账户信息", description = "超级管理员更新账户信息") @PutMapping("/update/{accountId}") @RequirePermission(value = "org:company:manage", description = "更新账户", allowSuper = true) - public ApiResponse updateAccount( + public ApiResponse updateAccount( @Parameter(description = "账户ID", example = "1") @PathVariable Long accountId, @Valid @RequestBody SuperUpdateAccountDTO superUpdateAccountDTO) { - AccountVO accountVO = superAccountService.updateAccount(superUpdateAccountDTO, accountId); + CompanyAccountVO accountVO = superAccountService.updateAccount(superUpdateAccountDTO, accountId); return ApiResponse.success("账户更新成功", accountVO); } @@ -67,9 +67,9 @@ public class SuperAccountController { @Operation(summary = "获取账户详情", description = "超级管理员获取账户详细信息") @GetMapping("/detail/{accountId}") @RequirePermission(value = "org:company:manage", description = "查询账户详情", allowSuper = true) - public ApiResponse getAccountDetail( + public ApiResponse getAccountDetail( @Parameter(description = "账户ID", example = "1") @PathVariable Long accountId) { - AccountVO accountVO = superAccountService.getAccountDetail(accountId); + CompanyAccountVO accountVO = superAccountService.getAccountDetail(accountId); return ApiResponse.success("获取账户详情成功", accountVO); } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/AccountFilterDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/AccountFilterDTO.java index f3172af6..8b4f224a 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/AccountFilterDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/AccountFilterDTO.java @@ -1,4 +1,4 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.model.dto; +package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/CreateAccountDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/CreateAccountDTO.java index 826d4c20..ea94b00c 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/CreateAccountDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/CreateAccountDTO.java @@ -1,4 +1,4 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.model.dto; +package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperCreateAccountDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperCreateAccountDTO.java index 7bccea63..5c9715dd 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperCreateAccountDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperCreateAccountDTO.java @@ -1,4 +1,4 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.model.dto; +package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperUpdateAccountDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperUpdateAccountDTO.java index b806069b..72c22df5 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperUpdateAccountDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperUpdateAccountDTO.java @@ -1,4 +1,4 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.model.dto; +package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Pattern; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/UpdateAccountDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/UpdateAccountDTO.java index 8b04fdb6..1a7f83db 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/UpdateAccountDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/UpdateAccountDTO.java @@ -1,4 +1,4 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.model.dto; +package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Pattern; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountPageVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountPageVO.java index c8eded18..651b35fc 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountPageVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountPageVO.java @@ -1,4 +1,4 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.model.vo; +package top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -13,7 +13,7 @@ import java.util.List; public class AccountPageVO { @Schema(description = "账户列表") - private List records; + private List records; @Schema(description = "总记录数", example = "100") private Long total; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/CompanyAccountVO.java similarity index 96% rename from ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountVO.java rename to ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/CompanyAccountVO.java index edf254bf..1148e97d 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/CompanyAccountVO.java @@ -1,4 +1,4 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.model.vo; +package top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -10,7 +10,7 @@ import java.time.LocalDateTime; */ @Data @Schema(description = "账户信息") -public class AccountVO { +public class CompanyAccountVO { @Schema(description = "用户ID", example = "1") private Long id; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/AccountService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/AccountService.java index de4c16f7..068f532f 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/AccountService.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/AccountService.java @@ -1,13 +1,13 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.service; +package top.xyquan.ecomdmbbackend.modules.org.company.account.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.org.account.model.dto.AccountFilterDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.CreateAccountDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.UpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.CreateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.UpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO; import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO; /** * 账户管理服务接口 @@ -23,7 +23,7 @@ public interface AccountService extends IService { * @param createAccountDTO 创建账户信息 * @return 账户信息 */ - AccountVO createAccountForCompany(CreateAccountDTO createAccountDTO); + CompanyAccountVO createAccountForCompany(CreateAccountDTO createAccountDTO); /** * 更新账户信息(拥有者接口) @@ -32,7 +32,7 @@ public interface AccountService extends IService { * @param accountId 账户ID * @return 更新后的账户信息 */ - AccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId); + CompanyAccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId); /** * 删除账户(逻辑删除) @@ -47,7 +47,7 @@ public interface AccountService extends IService { * @param accountId 账户ID * @return 账户详情 */ - AccountVO getAccountDetail(Long accountId); + CompanyAccountVO getAccountDetail(Long accountId); /** * 分页查询账户(超管接口) @@ -55,7 +55,7 @@ public interface AccountService extends IService { * @param pageQuery 分页查询参数 * @return 分页结果 */ - PageResultVO getAccountPage(PageQueryDTO pageQuery); + PageResultVO getAccountPage(PageQueryDTO pageQuery); /** * 分页查询账户(拥有者接口,只能查询本公司账户) @@ -63,5 +63,5 @@ public interface AccountService extends IService { * @param pageQuery 分页查询参数 * @return 分页结果 */ - PageResultVO getAccountPageForCompany(PageQueryDTO pageQuery); + PageResultVO getAccountPageForCompany(PageQueryDTO pageQuery); } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/SuperAccountService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/SuperAccountService.java index 3e606293..139114f9 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/SuperAccountService.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/SuperAccountService.java @@ -1,13 +1,13 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.service; +package top.xyquan.ecomdmbbackend.modules.org.company.account.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.org.account.model.dto.AccountFilterDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperCreateAccountDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperUpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperCreateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperUpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO; import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO; /** * 超级管理员账户管理服务接口 @@ -20,7 +20,7 @@ public interface SuperAccountService extends IService { * @param superCreateAccountDTO 创建账户信息 * @return 账户信息 */ - AccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO); + CompanyAccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO); /** * 更新账户信息(超管接口) @@ -29,7 +29,7 @@ public interface SuperAccountService extends IService { * @param accountId 账户ID * @return 更新后的账户信息 */ - AccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId); + CompanyAccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId); /** * 删除账户(逻辑删除) @@ -44,7 +44,7 @@ public interface SuperAccountService extends IService { * @param accountId 账户ID * @return 账户详情 */ - AccountVO getAccountDetail(Long accountId); + CompanyAccountVO getAccountDetail(Long accountId); /** * 分页查询账户(超管接口) @@ -52,5 +52,5 @@ public interface SuperAccountService extends IService { * @param pageQuery 分页查询参数 * @return 分页结果 */ - PageResultVO getAccountPage(PageQueryDTO pageQuery); + PageResultVO getAccountPage(PageQueryDTO pageQuery); } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/AccountServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/AccountServiceImpl.java index 5d400c97..053d69b8 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/AccountServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/AccountServiceImpl.java @@ -1,10 +1,10 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.service.impl; +package top.xyquan.ecomdmbbackend.modules.org.company.account.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; 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.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -12,12 +12,12 @@ 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.sys.user.mapper.UserMapper; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.CreateAccountDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.UpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.CreateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.UpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.service.AccountService; import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO; -import top.xyquan.ecomdmbbackend.modules.org.account.service.AccountService; import top.xyquan.ecomdmbbackend.modules.org.company.service.CompanyService; import top.xyquan.ecomdmbbackend.modules.org.department.member.model.po.DepartmentMemberPO; import top.xyquan.ecomdmbbackend.modules.org.department.member.model.vo.DepartmentMemberVO; @@ -80,7 +80,7 @@ public class AccountServiceImpl extends ServiceImpl implemen * @return 账户VO */ @Override - public AccountVO createAccountForCompany(CreateAccountDTO createAccountDTO) { + public CompanyAccountVO createAccountForCompany(CreateAccountDTO createAccountDTO) { Long companyId = currentUserContext.getCurrentCompanyId(); if (companyId == null) { throw new BusinessException("无法获取公司信息"); @@ -124,7 +124,7 @@ public class AccountServiceImpl extends ServiceImpl implemen * 将已存在用户加入当前公司 * 不修改密码;可选更新姓名、备注;同时建立公司成员及部门关联 */ - private AccountVO addExistingUserToCompany( + private CompanyAccountVO addExistingUserToCompany( UserPO user, Long companyId, CreateAccountDTO createAccountDTO, @@ -160,7 +160,7 @@ public class AccountServiceImpl extends ServiceImpl implemen * 新建用户并加入当前公司 * 登录账号与手机号相同,系统角色固定为 user,须传入密码 */ - private AccountVO createNewUserAndAddToCompany( + private CompanyAccountVO createNewUserAndAddToCompany( Long companyId, CreateAccountDTO createAccountDTO, CompanyMemberRole memberRole) { @@ -169,7 +169,7 @@ public class AccountServiceImpl extends ServiceImpl implemen } UserPO user = new UserPO(); - BeanUtils.copyProperties(createAccountDTO, user); + BeanCopyUtils.copyProperties(createAccountDTO, user); user.setPassword(passwordEncoder.encode(createAccountDTO.getPassword())); user.setLoginCode(createAccountDTO.getPhone()); user.setRole("user"); @@ -197,7 +197,7 @@ public class AccountServiceImpl extends ServiceImpl implemen * @return 账户VO */ @Override - public AccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId) { + public CompanyAccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId) { // 查询账户 UserPO user = super.getById(accountId); if (user == null) { @@ -287,7 +287,7 @@ public class AccountServiceImpl extends ServiceImpl implemen * @return 账户VO */ @Override - public AccountVO getAccountDetail(Long accountId) { + public CompanyAccountVO getAccountDetail(Long accountId) { // 查询账户 UserPO user = super.getById(accountId); if (user == null) { @@ -304,7 +304,7 @@ public class AccountServiceImpl extends ServiceImpl implemen * @return 分页结果VO */ @Override - public PageResultVO getAccountPage(PageQueryDTO pageQuery) { + public PageResultVO getAccountPage(PageQueryDTO pageQuery) { // 构建查询条件 LambdaQueryWrapper wrapper = buildQueryWrapper(pageQuery.getFilters()); @@ -313,7 +313,7 @@ public class AccountServiceImpl extends ServiceImpl implemen IPage pageResult = this.page(page, wrapper); // 转换为VO - List records = pageResult.getRecords().stream() + List records = pageResult.getRecords().stream() .map(this::convertToVO) .collect(Collectors.toList()); @@ -327,7 +327,7 @@ public class AccountServiceImpl extends ServiceImpl implemen * @return 分页结果VO */ @Override - public PageResultVO getAccountPageForCompany(PageQueryDTO pageQuery) { + public PageResultVO getAccountPageForCompany(PageQueryDTO pageQuery) { // 从用户上下文获取公司ID Long companyId = currentUserContext.getCurrentCompanyId(); if (companyId == null) { @@ -411,9 +411,9 @@ public class AccountServiceImpl extends ServiceImpl implemen * @param user 用户PO * @return 账户VO */ - private AccountVO convertToVO(UserPO user) { - AccountVO accountVO = new AccountVO(); - BeanUtils.copyProperties(user, accountVO); + private CompanyAccountVO convertToVO(UserPO user) { + CompanyAccountVO accountVO = new CompanyAccountVO(); + BeanCopyUtils.copyProperties(user, accountVO); // 设置状态名称 accountVO.setStatusName(getStatusName(user.getStatus())); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/SuperAccountServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/SuperAccountServiceImpl.java index cb16069e..2b9c2be6 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/SuperAccountServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/SuperAccountServiceImpl.java @@ -1,10 +1,10 @@ -package top.xyquan.ecomdmbbackend.modules.org.account.service.impl; +package top.xyquan.ecomdmbbackend.modules.org.company.account.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; 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.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -12,12 +12,12 @@ 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.sys.user.mapper.UserMapper; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperCreateAccountDTO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperUpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperCreateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperUpdateAccountDTO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO; +import top.xyquan.ecomdmbbackend.modules.org.company.account.service.SuperAccountService; import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO; -import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO; -import top.xyquan.ecomdmbbackend.modules.org.account.service.SuperAccountService; import top.xyquan.ecomdmbbackend.modules.org.company.service.CompanyService; import top.xyquan.ecomdmbbackend.modules.org.department.member.model.po.DepartmentMemberPO; import top.xyquan.ecomdmbbackend.modules.org.department.member.model.vo.DepartmentMemberVO; @@ -67,7 +67,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp * @return 账户VO */ @Override - public AccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO) { + public CompanyAccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO) { // 验证登录账号是否已存在 if (StringUtils.hasText(superCreateAccountDTO.getLoginCode())) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -88,7 +88,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp // 创建账户 UserPO user = new UserPO(); - BeanUtils.copyProperties(superCreateAccountDTO, user); + BeanCopyUtils.copyProperties(superCreateAccountDTO, user); user.setPassword(passwordEncoder.encode(superCreateAccountDTO.getPassword())); user.setStatus(1); // 正常状态(与 sys_user 表定义一致:1=正常,0=停用) user.setPwdSecurityLevel(calculatePasswordSecurityLevel(superCreateAccountDTO.getPassword())); @@ -120,7 +120,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp * @return 账户VO */ @Override - public AccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId) { + public CompanyAccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId) { // 查询账户 UserPO user = super.getById(accountId); if (user == null) { @@ -247,7 +247,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp * @return 账户详情 */ @Override - public AccountVO getAccountDetail(Long accountId) { + public CompanyAccountVO getAccountDetail(Long accountId) { // 查询账户 UserPO user = super.getById(accountId); if (user == null) { @@ -264,7 +264,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp * @return 分页结果VO */ @Override - public PageResultVO getAccountPage(PageQueryDTO pageQuery) { + public PageResultVO getAccountPage(PageQueryDTO pageQuery) { // 构建查询条件 LambdaQueryWrapper wrapper = buildQueryWrapper(pageQuery.getFilters()); @@ -273,7 +273,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp IPage pageResult = this.page(page, wrapper); // 转换为VO - List records = pageResult.getRecords().stream() + List records = pageResult.getRecords().stream() .map(this::convertToVO) .collect(Collectors.toList()); @@ -376,9 +376,9 @@ public class SuperAccountServiceImpl extends ServiceImpl imp /** * 转换为VO */ - private AccountVO convertToVO(UserPO user) { - AccountVO accountVO = new AccountVO(); - BeanUtils.copyProperties(user, accountVO); + private CompanyAccountVO convertToVO(UserPO user) { + CompanyAccountVO accountVO = new CompanyAccountVO(); + BeanCopyUtils.copyProperties(user, accountVO); // 设置状态名称 accountVO.setStatusName(getStatusName(user.getStatus())); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/member/service/impl/CompanyMemberServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/member/service/impl/CompanyMemberServiceImpl.java index 99949129..d395bcae 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/member/service/impl/CompanyMemberServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/member/service/impl/CompanyMemberServiceImpl.java @@ -1,8 +1,8 @@ package top.xyquan.ecomdmbbackend.modules.org.company.member.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -68,7 +68,7 @@ public class CompanyMemberServiceImpl extends ServiceImpl { MenuVO menuVO = new MenuVO(); - BeanUtils.copyProperties(menu, menuVO); + BeanCopyUtils.copyProperties(menu, menuVO); return menuVO; }) .collect(Collectors.toList()); @@ -315,7 +315,7 @@ public class CompanyMenuServiceImpl extends ServiceImpl im // 创建公司 CompanyPO company = new CompanyPO(); - BeanUtils.copyProperties(createCompanyDTO, company); + BeanCopyUtils.copyProperties(createCompanyDTO, company); // 设置默认值 if (company.getStatus() == null) { @@ -179,7 +179,7 @@ public class CompanyServiceImpl extends ServiceImpl im // 更新公司 CompanyPO company = new CompanyPO(); - BeanUtils.copyProperties(updateCompanyDTO, company); + BeanCopyUtils.copyProperties(updateCompanyDTO, company); // 设置公司ID(必须在updateById之前设置) company.setId(id); @@ -386,7 +386,7 @@ public class CompanyServiceImpl extends ServiceImpl im */ private CompanyVO convertToVO(CompanyPO company) { CompanyVO companyVO = new CompanyVO(); - BeanUtils.copyProperties(company, companyVO); + BeanCopyUtils.copyProperties(company, companyVO); // 计算是否过期 if (company.getExpireTime() != null) { diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/department/member/service/impl/DepartmentMemberServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/department/member/service/impl/DepartmentMemberServiceImpl.java index 58405d87..f65514a2 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/department/member/service/impl/DepartmentMemberServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/department/member/service/impl/DepartmentMemberServiceImpl.java @@ -1,8 +1,8 @@ package top.xyquan.ecomdmbbackend.modules.org.department.member.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -122,7 +122,7 @@ public class DepartmentMemberServiceImpl extends ServiceImpl { MenuVO menuVO = new MenuVO(); - BeanUtils.copyProperties(menu, menuVO); + BeanCopyUtils.copyProperties(menu, menuVO); return menuVO; }) .collect(Collectors.toList()); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/position/service/impl/PositionServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/position/service/impl/PositionServiceImpl.java index e188092d..5c16d5fb 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/position/service/impl/PositionServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/position/service/impl/PositionServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.org.position.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; 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; @@ -55,7 +55,7 @@ public class PositionServiceImpl extends ServiceImpl // 创建岗位 PositionPO position = new PositionPO(); - BeanUtils.copyProperties(createPositionDTO, position); + BeanCopyUtils.copyProperties(createPositionDTO, position); // 设置公司ID position.setCompanyId(companyId); @@ -109,7 +109,7 @@ public class PositionServiceImpl extends ServiceImpl // 更新岗位 PositionPO position = new PositionPO(); - BeanUtils.copyProperties(updatePositionDTO, position); + BeanCopyUtils.copyProperties(updatePositionDTO, position); position.setId(id); // 确保ID正确设置 position.setCompanyId(companyId); // 设置公司ID @@ -209,7 +209,7 @@ public class PositionServiceImpl extends ServiceImpl // 创建岗位 PositionPO position = new PositionPO(); - BeanUtils.copyProperties(createPositionDTO, position); + BeanCopyUtils.copyProperties(createPositionDTO, position); // 设置公司ID position.setCompanyId(companyId); @@ -234,7 +234,7 @@ public class PositionServiceImpl extends ServiceImpl */ private PositionVO convertToVO(PositionPO position) { PositionVO positionVO = new PositionVO(); - BeanUtils.copyProperties(position, positionVO); + BeanCopyUtils.copyProperties(position, positionVO); return positionVO; } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/plan/pricing/service/impl/PlanPricingServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/plan/pricing/service/impl/PlanPricingServiceImpl.java index 0f69a2f4..8e288af6 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/plan/pricing/service/impl/PlanPricingServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/plan/pricing/service/impl/PlanPricingServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.sub.plan.pricing.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -59,7 +59,7 @@ public class PlanPricingServiceImpl extends ServiceImpl implements // 创建套餐 PlanPO plan = new PlanPO(); - BeanUtils.copyProperties(createPlanDTO, plan); + BeanCopyUtils.copyProperties(createPlanDTO, plan); // 设置默认值 if (plan.getStatus() == null) { @@ -100,7 +100,7 @@ public class PlanServiceImpl extends ServiceImpl implements // 更新套餐 PlanPO plan = new PlanPO(); - BeanUtils.copyProperties(updatePlanDTO, plan); + BeanCopyUtils.copyProperties(updatePlanDTO, plan); // 设置更新人ID plan.setUpdateBy(SecurityUtils.getCurrentUserId()); @@ -172,7 +172,7 @@ public class PlanServiceImpl extends ServiceImpl implements */ private PlanVO convertToVO(PlanPO plan) { PlanVO planVO = new PlanVO(); - BeanUtils.copyProperties(plan, planVO); + BeanCopyUtils.copyProperties(plan, planVO); return planVO; } @@ -181,7 +181,7 @@ public class PlanServiceImpl extends ServiceImpl implements */ private PlanListVO convertToListVO(PlanPO plan) { PlanListVO planListVO = new PlanListVO(); - BeanUtils.copyProperties(plan, planListVO); + BeanCopyUtils.copyProperties(plan, planListVO); return planListVO; } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/subscription/service/impl/SubscriptionServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/subscription/service/impl/SubscriptionServiceImpl.java index 957c32b7..1e09e474 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/subscription/service/impl/SubscriptionServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/subscription/service/impl/SubscriptionServiceImpl.java @@ -1,10 +1,10 @@ package top.xyquan.ecomdmbbackend.modules.sub.subscription.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -57,7 +57,7 @@ public class SubscriptionServiceImpl extends ServiceImpl im // 创建当前公司的文件记录 SysFilePO sysFile = new SysFilePO(); - BeanUtils.copyProperties(otherCompanyFile, sysFile); + BeanCopyUtils.copyProperties(otherCompanyFile, sysFile); sysFile.setId(null); sysFile.setCompanyId(companyId); sysFile.setStoragePath(storagePath); @@ -268,7 +268,7 @@ public class SysFileServiceImpl extends ServiceImpl im if (verifyFileExists(otherCompanyFile)) { // 创建当前公司的文件记录 SysFilePO newFile = new SysFilePO(); - BeanUtils.copyProperties(otherCompanyFile, newFile); + BeanCopyUtils.copyProperties(otherCompanyFile, newFile); newFile.setId(null); newFile.setCompanyId(companyId); newFile.setFilename(item.getFilename()); @@ -363,7 +363,7 @@ public class SysFileServiceImpl extends ServiceImpl im if (otherCompanyFile != null) { // 其他公司已有相同文件,复制记录并关联当前公司 sysFile = new SysFilePO(); - BeanUtils.copyProperties(otherCompanyFile, sysFile); + BeanCopyUtils.copyProperties(otherCompanyFile, sysFile); sysFile.setId(null); sysFile.setCompanyId(companyId); sysFile.setStoragePath(item.getStoragePath()); @@ -521,7 +521,7 @@ public class SysFileServiceImpl extends ServiceImpl im */ private SysFileVO convertToVO(SysFilePO sysFile) { SysFileVO vo = new SysFileVO(); - BeanUtils.copyProperties(sysFile, vo); + BeanCopyUtils.copyProperties(sysFile, vo); // 使用工具类生成访问URL String accessUrl = SysFileUtils.getFileAccessUrl(sysFile.getStoragePath(), sysFile.getStorageType()); @@ -628,7 +628,7 @@ public class SysFileServiceImpl extends ServiceImpl im return null; } SysFileVO vo = new SysFileVO(); - BeanUtils.copyProperties(file, vo); + BeanCopyUtils.copyProperties(file, vo); return vo; } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/menu/service/impl/MenuServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/menu/service/impl/MenuServiceImpl.java index 152d79f3..fbadb29a 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/menu/service/impl/MenuServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/menu/service/impl/MenuServiceImpl.java @@ -1,9 +1,9 @@ package top.xyquan.ecomdmbbackend.modules.sys.menu.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -59,7 +59,7 @@ public class MenuServiceImpl extends ServiceImpl implements // 创建菜单 MenuPO menu = new MenuPO(); - BeanUtils.copyProperties(createMenuDTO, menu); + BeanCopyUtils.copyProperties(createMenuDTO, menu); // 设置默认值 if (menu.getSuperMenu() == null) { @@ -122,7 +122,7 @@ public class MenuServiceImpl extends ServiceImpl implements } // 更新菜单 - BeanUtils.copyProperties(updateMenuDTO, existingMenu); + BeanCopyUtils.copyProperties(updateMenuDTO, existingMenu); existingMenu.setId(id); // 确保ID正确设置 // 设置更新人ID @@ -285,7 +285,7 @@ public class MenuServiceImpl extends ServiceImpl implements */ private MenuVO convertToVO(MenuPO menu) { MenuVO menuVO = new MenuVO(); - BeanUtils.copyProperties(menu, menuVO); + BeanCopyUtils.copyProperties(menu, menuVO); // 查询菜单关联的权限 List permissions = baseMapper.selectPermissionsByMenuId(menu.getId()); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/permission/service/impl/PermissionServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/permission/service/impl/PermissionServiceImpl.java index d989484a..94bb5864 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/permission/service/impl/PermissionServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/permission/service/impl/PermissionServiceImpl.java @@ -1,11 +1,11 @@ package top.xyquan.ecomdmbbackend.modules.sys.permission.service.impl; +import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils; 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 lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; @@ -58,7 +58,7 @@ public class PermissionServiceImpl extends ServiceImpl implements // 转换为VO UserVO userVO = new UserVO(); - BeanUtils.copyProperties(user, userVO); + BeanCopyUtils.copyProperties(user, userVO); fillCompanyFromCurrentToken(userVO); userVO.setCompanyCount(countAvailableCompanies(userId)); return userVO; @@ -255,7 +255,7 @@ public class UserServiceImpl extends ServiceImpl implements // 转换为VO并返回 UserVO userVO = new UserVO(); - BeanUtils.copyProperties(user, userVO); + BeanCopyUtils.copyProperties(user, userVO); fillCompanyFromCurrentToken(userVO); return userVO; } @@ -321,7 +321,7 @@ public class UserServiceImpl extends ServiceImpl implements // 转换为VO并返回 UserVO userVO = new UserVO(); - BeanUtils.copyProperties(user, userVO); + BeanCopyUtils.copyProperties(user, userVO); fillCompanyFromCurrentToken(userVO); return userVO; } @@ -557,7 +557,7 @@ public class UserServiceImpl extends ServiceImpl implements */ private UserVO convertToUserVO(UserPO user) { UserVO userVO = new UserVO(); - BeanUtils.copyProperties(user, userVO); + BeanCopyUtils.copyProperties(user, userVO); fillCompanyByCompanyId(userVO, user.getLastCompanyId()); return userVO; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/PermissionUtils.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/PermissionUtils.java index 4726ef21..2715fe56 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/PermissionUtils.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/PermissionUtils.java @@ -3,6 +3,7 @@ package top.xyquan.ecomdmbbackend.utils; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; +import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; import top.xyquan.ecomdmbbackend.modules.sys.permission.service.PermissionCheckService; @@ -16,7 +17,7 @@ public class PermissionUtils implements ApplicationContextAware { private static ApplicationContext applicationContext; @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException { PermissionUtils.applicationContext = applicationContext; }