feat: mongo联查一版-清楚无用代码
This commit is contained in:
parent
33c9563611
commit
404d30bee9
|
@ -3,21 +3,16 @@ package org.example.mongosimple.controller;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.example.mongosimple.entity.ShoppingResult;
|
||||
import org.example.mongosimple.prepareEntity.MongoAggregationBuilder;
|
||||
import org.example.mongosimple.prepareEntity.PageResult;
|
||||
import org.example.mongosimple.prepareEntity.ShoppingSearchParams;
|
||||
import org.example.mongosimple.service.ShoppingAggregationService;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,13 +28,13 @@ public class DataInitializer implements CommandLineRunner {
|
|||
// System.out.println("开始初始化测试数据...");
|
||||
|
||||
// 初始化用户数据
|
||||
// initUsers();
|
||||
// init();
|
||||
|
||||
|
||||
// System.out.println("测试数据初始化完成!");
|
||||
}
|
||||
|
||||
private void initUsers() {
|
||||
private void init() {
|
||||
// System.out.println("初始化用户数据...");
|
||||
|
||||
Address address = new Address();
|
||||
|
@ -79,7 +79,7 @@ public class DataInitializer implements CommandLineRunner {
|
|||
mongoTemplate.save(product1);
|
||||
mongoTemplate.save(product2);
|
||||
|
||||
// 来自的dezhou的用户 在618期间买的 价格位于 5000 - 6000 的电子产品z
|
||||
// 来自的dezhou的用户 在618期间买的 价格位于 5000 - 6000 的电子产品
|
||||
|
||||
ShoppingRecord shoppingRecord = new ShoppingRecord("68c4fabe669d40228340eaa9", "68c4fcd9f53fc172ab23f4ac", "68c4fb3a370a3428ec124244");
|
||||
ShoppingRecord shoppingRecord1 = new ShoppingRecord("68c4fabe669d40228340eaab", "68c4fcd9f53fc172ab23f4ac", "68c4fb3a370a3428ec124244");
|
||||
|
|
|
@ -529,15 +529,7 @@ public class MongoAggregationBuilder {
|
|||
* 自动添加字段展平投影
|
||||
*/
|
||||
public static MongoAggregationBuilder fromWithCompatibility(MongoTemplate mongoTemplate, String sourceCollection) {
|
||||
MongoAggregationBuilder builder = new MongoAggregationBuilder(mongoTemplate, sourceCollection);
|
||||
|
||||
// 检查是否需要兼容性处理
|
||||
if (!SpringBootCompatibilityHelper.supportsNestedFieldReferences()) {
|
||||
System.out.println("检测到Spring Boot 2环境,启用兼容性模式");
|
||||
// 在后续的lookup操作后自动添加字段展平
|
||||
}
|
||||
|
||||
return builder;
|
||||
return new MongoAggregationBuilder(mongoTemplate, sourceCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue