feat(config): 添加Mybatis Plus分页插件和Mapper扫描配置
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good

- 配置MybatisPlusInterceptor分页插件
- 添加@MapperScan注解扫描多个mapper包
- 为多个service注入添加@Lazy注解解决循环依赖
- 在VoucherServiceImpl和PuzzleGenerateServiceImpl中启用懒加载
- 优化订单服务中的依赖注入配置
This commit is contained in:
2025-12-05 16:14:43 +08:00
parent ee13ef09f7
commit 24bbb63bf7
5 changed files with 25 additions and 3 deletions

View File

@@ -1,6 +1,5 @@
package com.ycwl.basic;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@@ -9,8 +8,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@MapperScan(basePackages = "com.ycwl.basic.mapper")
@MapperScan(basePackages = "com.ycwl.basic.*.mapper")
public class Application {
public static void main(String[] args) {

View File

@@ -3,6 +3,7 @@ package com.ycwl.basic.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -11,6 +12,15 @@ import org.springframework.context.annotation.Configuration;
* @date 2021年06月04日 9:42
*/
@Configuration
@MapperScan(basePackages = {
"com.ycwl.basic.mapper",
"com.ycwl.basic.order.mapper",
"com.ycwl.basic.pricing.mapper",
"com.ycwl.basic.product.mapper",
"com.ycwl.basic.profitsharing.mapper",
"com.ycwl.basic.puzzle.mapper",
"com.ycwl.basic.stats.mapper"
})
public class MybatisPlusPageConfig {
/* 旧版本配置

View File

@@ -47,6 +47,7 @@ import com.ycwl.basic.repository.FaceRepository;
import com.ycwl.basic.service.pc.ScenicService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -70,13 +71,20 @@ public class OrderServiceImpl implements IOrderService {
private final OrderItemMapper orderItemMapper;
private final OrderDiscountMapper orderDiscountMapper;
private final OrderRefundMapper orderRefundMapper;
@Lazy
private final OrderEventManager orderEventManager;
@Lazy
private final ScenicService scenicService;
private final MemberMapper memberMapper;
@Lazy
private final ICouponService couponService;
@Lazy
private final IVoucherService voucherService;
@Lazy
private final IProductConfigService productConfigService;
@Lazy
private final IProductTypeCapabilityService productTypeCapabilityService;
@Lazy
private final DuplicatePurchaseCheckerFactory duplicatePurchaseCheckerFactory;
@Override

View File

@@ -18,6 +18,7 @@ import com.ycwl.basic.pricing.entity.PriceVoucherUsageRecord;
import com.ycwl.basic.pricing.service.IVoucherService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@@ -60,6 +61,7 @@ import java.util.stream.Collectors;
*/
@Slf4j
@Service
@Lazy
@RequiredArgsConstructor
public class VoucherServiceImpl implements IVoucherService {

View File

@@ -21,6 +21,7 @@ import com.ycwl.basic.storage.StorageFactory;
import com.ycwl.basic.utils.WxMpUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.imageio.ImageIO;
@@ -51,9 +52,13 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
private final PuzzleTemplateMapper templateMapper;
private final PuzzleElementMapper elementMapper;
private final PuzzleGenerationRecordMapper recordMapper;
@Lazy
private final PuzzleImageRenderer imageRenderer;
@Lazy
private final PuzzleElementFillEngine fillEngine;
@Lazy
private final ScenicRepository scenicRepository;
@Lazy
private final PuzzleDuplicationDetector duplicationDetector;
@Override