当前位置: 首页 > news >正文

MongoDB - 组合聚合阶段:$group、$match、$limit、$sort、$skip、$project、$count

文章目录

    • 1. $group
    • 2. $group-> $project
        • 2.1 $group
        • 2.2 $group-> $project
        • 2.3 SpringBoot 整合 MongoDB
    • 3. $match-> $group -> $match
        • 3.1 $match
        • 3.2 $match-> $group
        • 3.3 $match-> $group-> $match
        • 3.4 SpringBoot 整合 MongoDB
    • 4. $match-> $group-> $project-> $sort-> skip-> $limit
        • 4.1 $match
        • 4.2 $match-> $group
        • 4.3 $match-> $group-> $project
        • 4.4 $match-> $group-> $project-> $sort
        • 4.5 $match-> $group-> $project-> $sort-> $skip
        • 4.5 $match-> $group-> $project-> $sort-> $skip-> $limit
        • 4.6 SpringBoot 整合 MongoDB
    • 5. $group-> $project
        • 5.1 $group 多字段分组聚合
        • 5.2 $group-> $project
        • 5.3 $group-> $project-> $sort
        • 5.4 $group-> $project-> $sort-> $limit
        • 5.5 SpringBoot 整合 MongoDB

根据工作中常见的业务需求,构造了一些场景来练习 mongodb 聚合阶段的使用。

1. $group

$group 根据单个字段对文档进行分组。

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "A", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "B", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "C", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "C", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "D", "category": "Clothing", "quantity": 12, "price": 700 }
])

根据 category 字段对文档进行分组并计算每个分组内文档的数量:

db.sales.aggregate([{$group : {_id : "$category",count: { $sum: 1 }}}
])

执行 $group 聚合阶段后输出的文档:

// 1
{"_id": "Clothing","count": 4
}// 2
{"_id": "Electronics","count": 4
}

SpringBoot整合MongoDB实现:

// 输入文档
@Data
@Document(collection = "sales")
public class Sales {@MongoIdprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档
@Data
public class AggregationResult {private int _id;private int count;
}// 聚合操作
@Test
public void aggregateTest() {// $group 聚合阶段GroupOperation group = Aggregation.group("category").count().as("count");// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(group);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(_id=Clothing, count=4)//AggregationResult(_id=Electronics, count=4)
}

2. $group-> $project

$group 单字段分组 + $project 排除字段 + $project 重命名字段

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "A", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "B", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "C", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "C", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "D", "category": "Clothing", "quantity": 12, "price": 700 }
])
2.1 $group

执行 $group 聚合阶段后输出的文档:

db.sales.aggregate([{$group : {_id : "$category",count: { $sum: 1 }}}
])
// 1
{"_id": "Clothing","count": 4
}// 2
{"_id": "Electronics","count": 4
}
2.2 $group-> $project

执行 g r o u p + group+ group+project 聚合阶段后输出的文档:

db.sales.aggregate([// $group阶段:将聚合管道内的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$category",count: { $sum: 1 }}},// $project阶段:将聚合管道内的文档排除_id字段,并将count字段的名称重命名newCount字段{$project : {_id : 0,newCount: "$count"}}
])
// 1
{"newCount": 4
}// 2
{"newCount": 4
}
2.3 SpringBoot 整合 MongoDB
// 输入文档实体类
@Data
@Document(collection = "sales")
public class Sales {@Idprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档实体类
@Data
public class AggregationResult {private String newCount;
}// 聚合操作
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $group 聚合阶段GroupOperation group = Aggregation.group("category").count().as("count");// $project 聚合阶段ProjectionOperation project = Aggregation.project().andExclude("_id").and("count").as("newCount");// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(group,project);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(newCount=4)//AggregationResult(newCount=4)}
}

3. $match-> $group -> $match

$match 根据条件筛选文档+ $group 根据单字段分组文档 + $match 筛选分组后的文档

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "A", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "B", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "C", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "C", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "D", "category": "Clothing", "quantity": 12, "price": 700 }
])
3.1 $match

执行 $match 聚合阶段输出的文档为:

db.sales.aggregate([// 第一阶段:筛选出 price>=300 的文档{$match : {"price": { $gte: 300 }}}
])
// 1
{"_id": 3,"product": "C","category": "Electronics","quantity": 5,"price": 300
}// 2
{"_id": 4,"product": "D","category": "Electronics","quantity": 10,"price": 500
}// 3
{"_id": 5,"product": "A","category": "Clothing","quantity": 8,"price": 500
}// 4
{"_id": 7,"product": "C","category": "Clothing","quantity": 8,"price": 600
}// 5
{"_id": 8,"product": "D","category": "Clothing","quantity": 12,"price": 700
}
3.2 $match-> $group

执行 m a t c h + match+ match+group 聚合阶段是输出的文档为:

db.sales.aggregate([// 第一阶段:筛选出 price>=300 的文档{$match : {"price": { $gte: 300 }}},// 第二阶段:将聚合管道内的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$category",count: { $sum: 1 }}}
])
// 1
{"_id": "Clothing","count": 3
}// 2
{"_id": "Electronics","count": 2
}
3.3 $match-> $group-> $match

执行 m a t c h + match+ match+group+$match 聚合阶段是输出的文档为:

db.sales.aggregate([// 第一阶段:筛选出 price>=300 的文档{$match : {"price": { $gte: 300 }}},// 第二阶段:将聚合管道内的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$category",count: { $sum: 1 }}},// 第三阶段:筛选出 count>=3 的文档{$match : {"count": { $gte: 3 }}}
])
// 1
{"_id": "Clothing","count": 3
}
3.4 SpringBoot 整合 MongoDB
// 输入文档实体
@Data
@Document(collection = "sales")
public class Sales {@Idprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档实体
@Data
public class AggregationResult {private String _id;private int count;
}// 执行聚合阶段
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $match 聚合阶段MatchOperation match1 = Aggregation.match(Criteria.where("price").gte(300));// $group 聚合阶段GroupOperation group = Aggregation.group("category").count().as("count");// $match 聚合阶段MatchOperation match2 = Aggregation.match(Criteria.where("count").gte(3));// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(match1,group,match2);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(_id=Clothing, count=3)}
}

4. $match-> $group-> $project-> $sort-> skip-> $limit

$match 根据条件筛选文档+ $group 根据单字段分组文档 + $project 重命名字段+ $sort 对文档按照唯一键排序

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "C", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "A", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "A", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "B", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "C", "category": "Clothing", "quantity": 12, "price": 700 }
])
4.1 $match

执行 $match 聚合阶段输出的文档为:

db.sales.aggregate([// $match 阶段:筛选出 price>100 的文档{$match : {"price": { $gt: 100 }}}
])
// 1
{"_id": 2,"product": "A","category": "Electronics","quantity": 5,"price": 200
}// 2
{"_id": 3,"product": "A","category": "Electronics","quantity": 5,"price": 300
}// 3
{"_id": 4,"product": "D","category": "Electronics","quantity": 10,"price": 500
}// 4
{"_id": 5,"product": "A","category": "Clothing","quantity": 8,"price": 500
}// 5
{"_id": 6,"product": "B","category": "Clothing","quantity": 12,"price": 200
}// 6
{"_id": 7,"product": "B","category": "Clothing","quantity": 8,"price": 600
}// 7
{"_id": 8,"product": "C","category": "Clothing","quantity": 12,"price": 700
}
4.2 $match-> $group

执行 $match + $group 聚合阶段输出的文档为:

db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}},// $group阶段:将聚合管道内的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}}
])
// 1
{"_id": "C","count": 1
}// 2
{"_id": "D","count": 1
}// 3
{"_id": "B","count": 2
}// 4
{"_id": "A","count": 3
}
4.3 $match-> $group-> $project

执行$match + $group + $project 聚合阶段输出的文档为:

db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}},// $group阶段:将聚合管道的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}},// $project阶段:输出文档排除_id字段,包含count字段,并将_id字段重命名为product字段{$project : {_id:0,count: 1,product: "$_id"}}
])
// 1
{"count": 1,"product": "C"
}// 2
{"count": 1,"product": "D"
}// 3
{"count": 2,"product": "B"
}// 4
{"count": 3,"product": "A"
}
4.4 $match-> $group-> $project-> $sort

执行$match + $group + $project + $sort 聚合阶段输出的文档为:

db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}}, // $group阶段:将聚合管道的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}},// $project阶段:将聚合管道内的文档排除_id字段,包含count字段,并将_id字段重命名为product字段{$project : {_id:0,count: 1,product: "$_id"}},// $sort阶段:将聚合管道内的文档按照count字段降序排序{$sort : {count:-1}}
])
// 1
{"count": 3,"product": "A"
}// 2
{"count": 2,"product": "B"
}// 3
{"count": 1,"product": "C"
}// 4
{"count": 1,"product": "D"
}
4.5 $match-> $group-> $project-> $sort-> $skip
db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}}, // $group阶段:将聚合管道的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}},// $project阶段:将聚合管道内的文档排除_id字段,包含count字段,并将_id字段重命名为product字段{$project : {_id:0,count: 1,product: "$_id"}},// $sort阶段:将聚合管道内的文档按照count字段降序排序{$sort : {count:-1}},// $skip阶段:跳过聚合管道的前2个文档并输出{$skip: 2}
])
// 1
{"count": 1,"product": "C"
}// 2
{"count": 1,"product": "D"
}
4.5 $match-> $group-> $project-> $sort-> $skip-> $limit

执行 $match + $group + $project + $sort + $limit 聚合阶段输出的文档为:

db.sales.aggregate([// $match阶段:筛选出 price>=300 的文档{$match : {"price": { $gt: 100 }}}, // $group阶段:将聚合管道的文档按照category分组,并计算分组内的文档数量{$group : {_id : "$product",count: { $sum: 1 }}},// $project阶段:将聚合管道内的文档排除_id字段,包含count字段,并将_id字段重命名为product字段{$project : {_id:0,count: 1,product: "$_id"}},// $sort阶段:将聚合管道内的文档按照count字段降序排序{$sort : {count:-1}},// $skip阶段:跳过聚合管道的前2个文档并输出{$skip: 2},// $limit阶段:仅输出聚合管道内的前1个文档{$limit: 1}
])
// 1
{"count": 1,"product": "C"
}
4.6 SpringBoot 整合 MongoDB
// 输入文档实体类
@Data
@Document(collection = "sales")
public class Sales {@Idprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档实体类
@Data
public class AggregationResult {private int count;private String product;
}// 执行聚合操作
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $match 聚合阶段MatchOperation match = Aggregation.match(Criteria.where("price").gt(100));// $group 聚合阶段GroupOperation group = Aggregation.group("product").count().as("count");// $project 聚合阶段ProjectionOperation project = Aggregation.project("count").andExclude("_id").and("$_id").as("product");// $sort聚合阶段SortOperation sort = Aggregation.sort(Sort.Direction.DESC, "count");// $skip 聚合阶段SkipOperation skip = Aggregation.skip(2);// $limit 聚合阶段LimitOperation limit = Aggregation.limit(1);// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(match,group,project,sort,skip,limit);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(count=1, product=C)}
}

5. $group-> $project

构造测试数据:

db.sales.drop()db.sales.insertMany([{ "_id": 1, "product": "C", "category": "Electronics", "quantity": 10, "price": 100 },{ "_id": 2, "product": "A", "category": "Electronics", "quantity": 5, "price": 200 },{ "_id": 3, "product": "A", "category": "Electronics", "quantity": 5, "price": 300 },{ "_id": 4, "product": "D", "category": "Electronics", "quantity": 10, "price": 500 },{ "_id": 5, "product": "A", "category": "Clothing", "quantity": 8, "price": 500},{ "_id": 6, "product": "B", "category": "Clothing", "quantity": 12, "price": 200 },{ "_id": 7, "product": "B", "category": "Clothing", "quantity": 8, "price": 600 },{ "_id": 8, "product": "C", "category": "Clothing", "quantity": 12, "price": 700 }
])
5.1 $group 多字段分组聚合

$group 根据 category 和 product 字段分组后输出的文档为:

db.sales.aggregate([{// $group聚合阶段:将输入文档按照category和product字段分组$group: {_id: {category: "$category",product: "$product"},count: { $sum: 1 }}}
])
// 1
{"_id": {"category": "Clothing","product": "C"},"count": 1
}// 2
{"_id": {"category": "Clothing","product": "B"},"count": 2
}// 3
{"_id": {"category": "Clothing","product": "A"},"count": 1
}// 4
{"_id": {"category": "Electronics","product": "A"},"count": 2
}// 5
{"_id": {"category": "Electronics","product": "D"},"count": 1
}// 6
{"_id": {"category": "Electronics","product": "C"},"count": 1
}
5.2 $group-> $project

执行 $group + $project 聚合阶段后输出的文档为:

db.sales.aggregate([// $group聚合阶段:将输入文档按照category和product字段分组{$group: {_id: {category: "$category",product: "$product"},count: { $sum: 1 }}},// $project聚合阶段:发将_id.category重命名为category,将_id.product重命名为product,包含count字段,排除_id字段{$project: {category: "$_id.category",product: "$_id.product",count: 1,_id: 0}}
])
// 1
{"count": 1,"category": "Clothing","product": "C"
}// 2
{"count": 2,"category": "Clothing","product": "B"
}// 3
{"count": 1,"category": "Clothing","product": "A"
}// 4
{"count": 2,"category": "Electronics","product": "A"
}// 5
{"count": 1,"category": "Electronics","product": "D"
}// 6
{"count": 1,"category": "Electronics","product": "C"
}
5.3 $group-> $project-> $sort

执行 $group + $project + $sort 聚合阶段后输出的文档为:

db.sales.aggregate([// $group聚合阶段:将输入文档按照category和product字段分组{$group: {_id: {category: "$category",product: "$product"},count: { $sum: 1 }}},// $project聚合阶段:发将_id.category重命名为category,将_id.product重命名为product,包含count字段,排除_id字段{$project: {category: "$_id.category",product: "$_id.product",count: 1,_id: 0}},// $sort聚合阶段:将聚合管道内的文档按照count字段升序排序{$sort: {count:1}}
])
// 1
{"count": 1,"category": "Clothing","product": "C"
}// 2
{"count": 1,"category": "Clothing","product": "A"
}// 3
{"count": 1,"category": "Electronics","product": "D"
}// 4
{"count": 1,"category": "Electronics","product": "C"
}// 5
{"count": 2,"category": "Clothing","product": "B"
}// 6
{"count": 2,"category": "Electronics","product": "A"
}
5.4 $group-> $project-> $sort-> $limit

执行 $group + $project + $sort + $limit 聚合阶段后输出的文档为:

db.sales.aggregate([// $group聚合阶段:将输入文档按照category和product字段分组{$group: {_id: {category: "$category",product: "$product"},count: { $sum: 1 }}},// $project聚合阶段:发将_id.category重命名为category,将_id.product重命名为product,包含count字段,排除_id字段{$project: {category: "$_id.category",product: "$_id.product",count: 1,_id: 0}},// $sort聚合阶段:将聚合管道内的文档按照count字段升序排序{$sort: {count:1}},// $limit聚合阶段:仅输出聚合管道内的前2个文档{$limit:2}
])
// 1
{"count": 1,"category": "Clothing","product": "A"
}// 2
{"count": 1,"category": "Clothing","product": "C"
}
5.5 SpringBoot 整合 MongoDB
// 输入文档实体类
@Data
@Document(collection = "sales")
public class Sales {@Idprivate int _id;private String product;private String category;private int quantity;private int price;
}// 输出文档实体类
@Data
public class AggregationResult {private int count;private String product;private String category;
}// 执行聚合操作
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $group 聚合阶段GroupOperation group = Aggregation.group("category","product").count().as("count");// $project 聚合阶段ProjectionOperation project = Aggregation.project("count").andExclude("_id").and("$_id.category").as("category").and("$_id.product").as("product");// $sort聚合阶段SortOperation sort = Aggregation.sort(Sort.Direction.DESC, "count");// $limit 聚合阶段LimitOperation limit = Aggregation.limit(2);// 组合聚合阶段Aggregation aggregation = Aggregation.newAggregation(group,project,sort,limit);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Sales.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(count=2, product=A, category=Electronics)//AggregationResult(count=2, product=B, category=Clothing)}
}

相关文章:

MongoDB - 组合聚合阶段:$group、$match、$limit、$sort、$skip、$project、$count

文章目录 1. $group2. $group-> $project2.1 $group2.2 $group-> $project2.3 SpringBoot 整合 MongoDB 3. $match-> $group -> $match3.1 $match3.2 $match-> $group3.3 $match-> $group-> $match3.4 SpringBoot 整合 MongoDB 4. $match-> $group->…...

vue element-ui日期控件传参

前端&#xff1a;Vue element-ui <el-form-item label"过期时间" :rules"[ { required: true, message: 请选择过期时间, trigger: blur }]"><el-date-picker v-model"form.expireTime" type"date" format"yyyy-MM-dd&…...

MacOS安装SDKMan管理Java版本

文章目录 1 简介2 安装与卸载2.1 安装2.2 卸载 3 使用3.1 查看其他工具&#xff1a;支持 Ant, Maven 等3.2 查看Java版本3.3 安装Java&#xff0c;加上相关的版本3.4 设置Java版本(全局)3.5 只在当前窗口生效3.6 卸载1 默认环境无法卸载 4 jdk安装的位置5 与IDEA集成参考 1 简介…...

【网络安全的神秘世界】文件包含漏洞

&#x1f31d;博客主页&#xff1a;泥菩萨 &#x1f496;专栏&#xff1a;Linux探索之旅 | 网络安全的神秘世界 | 专接本 | 每天学会一个渗透测试工具 一、概述 文件包含&#xff1a;重复使用的函数写在文件里&#xff0c;需要使用某个函数时直接调用此文件&#xff0c;而无需再…...

并发编程--volatile

1.什么是volatile volatile是 轻 量 级 的 synchronized&#xff0c;它在多 处 理器开 发 中保 证 了共享 变 量的 “ 可 见 性 ” 。可 见 性的意思是当一个 线 程 修改一个共享变 量 时 &#xff0c;另外一个 线 程能 读 到 这 个修改的 值 。如果 volatile 变 量修 饰 符使用…...

记录unraid docker更新的域名

背景&#xff1a;级联 一、安装内容 unraid更新docker&#xff0c;之前一直失败&#xff0c;修改网络后可以进行安装。 二、查看域名 查看域名&#xff0c;发现是走github的&#xff0c;怪不得有一些docker无法正常更新 三、解决方法 更改代理&#xff0c;这里为unraid的…...

SpringCloud+Vue3多对多,多表联查

♥️作者&#xff1a;小宋1021 &#x1f935;‍♂️个人主页&#xff1a;小宋1021主页 ♥️坚持分析平时学习到的项目以及学习到的软件开发知识&#xff0c;和大家一起努力呀&#xff01;&#xff01;&#xff01; &#x1f388;&#x1f388;加油&#xff01; 加油&#xff01…...

麒麟系统信创改造

麒麟系统信创改造 一、查看操作系统架构下载相应的依赖,压缩包1、查看Linux系统架构、CPU(1)uname -m(2)lscpu(3)cat /proc/cpuinfo(4)arch(5)getconf LONG_BIT(6)dmidecode2、根据Linux系统架构、CPU的差异进行下载相关依赖,看第二项二、以下是根据本系统的aarc…...

【Android】ListView和RecyclerView知识总结

文章目录 ListView步骤适配器AdpterArrayAdapterSimpleAdapterBaseAdpter效率问题 RecyclerView具体实现不同布局形式的设置横向滚动瀑布流网格 点击事件 ListView ListView 是 Android 中的一种视图组件&#xff0c;用于显示可滚动的垂直列表。每个列表项都是一个视图对象&…...

泛域名绑定到wordpress网站二级目录

要将WordPress的泛域名绑定到二级目录&#xff0c;你需要在你的服务器上修改Apache或Nginx配置文件。以下是两种最常见的服务器配置的示例&#xff1a; Apache服务器 编辑你的虚拟主机配置文件&#xff0c;通常位于/etc/apache2/sites-available/目录下。 <VirtualHost *…...

8、从0搭建企业门户网站——网站部署

目录 正文 1、域名解析 2、云服务器端口授权 3、Mysql数据库初始化 4、上传网站软件包 5、Tomcat配置 6、运行Tomcat 7、停止Tomcat 8、部署后发现验证码无法使用 完毕! 正文 当云服务器租用、域名购买和软件开发都完成后,我们就可以开始网站部署上线,ICP备案会长…...

uniapp中出现图片过小会与盒子偏离

结论&#xff1a;在image的父盒子中加上display: flex&#xff0c;原因不清楚 出问题的代码和图片如下&#xff1a; <template><view style" background-color: greenyellow; height: 10rpx;width: 10rpx;"><image :src"imgSrc.seatnull" …...

MySQL练手 --- 1934. 确认率

题目链接&#xff1a;1934. 确认率 思路 由题可知&#xff0c;两个表&#xff0c;一个表为Signups注册表&#xff0c;另一个表为Confirmations信息确认表&#xff0c;表的关联关系为 一对一&#xff0c;且user_id作为两个表的连接条件&#xff08;匹配字段&#xff09;&#…...

【OpenCV C++20 学习笔记】扫描图片数据

扫描图片数据 应用情景图像数据扫描的难点颜色空间缩减&#xff08;color space reduction&#xff09;查询表 扫描算法计算查询表统计运算时长连续内存3种扫描方法C风格的扫描方法迭代器方法坐标方法LUT方法 算法效率对比结论 应用情景 图像数据扫描的难点 在上一篇文章《基…...

LeetCode:爬楼梯(C语言)

1、问题概述&#xff1a;每次可以爬 1 或 2 个台阶。有多少种不同的方法可以爬到楼顶 2、示例 示例 1&#xff1a; 输入&#xff1a;n 2 输出&#xff1a;2 解释&#xff1a;有两种方法可以爬到楼顶。 1. 1 阶 1 阶 2. 2 阶 示例 2&#xff1a; 输入&#xff1a;n 3 输出&a…...

银河麒麟(arm64)环境下通过docker安装postgis3,并实现数据整体迁移

银河麒麟(arm64)环境下通过docker安装postgis3,并实现数据整体迁移 硬件配置:麒麟9006C 系统环境:银河麒麟桌面版v10 sp1 数据库:postgresql11+postgis3.0 具体的步骤参考https://blog.csdn.net/qq_34817440/article/details/103914574 -----主要操作-----------------…...

C语言 | Leetcode C语言题解之第278题第一个错误的版本

题目&#xff1a; 题解&#xff1a; int firstBadVersion(int n) {int left 1, right n;while (left < right) { // 循环直至区间左右端点相同int mid left (right - left) / 2; // 防止计算时溢出if (isBadVersion(mid)) {right mid; // 答案在区间 [left, mid] 中…...

京东科技集团将在香港发行与港元1:1挂钩的加密货币稳定币

据京东科技集团旗下公司京东币链科技(香港)官网信息&#xff0c;京东稳定币是一种基于公链并与港元(HKD) 1:1挂钩的稳定币&#xff0c;将在公共区块链上发行&#xff0c;其储备由高度流动且可信的资产组成&#xff0c;这些资产安全存放于持牌金融机构的独立账户中&#xff0c;通…...

Vue 实现电子签名并生成签名图片

目录 前言项目结构代码实现 安装依赖创建签名画布组件生成签名图片 总结相关阅读 1. 前言 电子签名在现代Web应用中越来越普遍&#xff0c;例如合同签署、确认表单等。本文将介绍如何使用Vue.js实现一个简单的电子签名功能&#xff0c;并将签名生成图片。 2. 项目结构 项…...

Visual Studio 2022美化

说明&#xff1a; VS版本&#xff1a;Visual Studio Community 2022 背景美化 【扩展】【管理扩展】搜索“ClaudiaIDE”&#xff0c;【下载】&#xff0c;安装完扩展要重启VS 在wallhaven下载壁纸图片作为文本编辑器区域背景图片 【工具】【选项】搜索ClaudiaIDE&#xff…...

UE5 学习系列(二)用户操作界面及介绍

这篇博客是 UE5 学习系列博客的第二篇&#xff0c;在第一篇的基础上展开这篇内容。博客参考的 B 站视频资料和第一篇的链接如下&#xff1a; 【Note】&#xff1a;如果你已经完成安装等操作&#xff0c;可以只执行第一篇博客中 2. 新建一个空白游戏项目 章节操作&#xff0c;重…...

多云管理“拦路虎”:深入解析网络互联、身份同步与成本可视化的技术复杂度​

一、引言&#xff1a;多云环境的技术复杂性本质​​ 企业采用多云策略已从技术选型升维至生存刚需。当业务系统分散部署在多个云平台时&#xff0c;​​基础设施的技术债呈现指数级积累​​。网络连接、身份认证、成本管理这三大核心挑战相互嵌套&#xff1a;跨云网络构建数据…...

C++实现分布式网络通信框架RPC(3)--rpc调用端

目录 一、前言 二、UserServiceRpc_Stub 三、 CallMethod方法的重写 头文件 实现 四、rpc调用端的调用 实现 五、 google::protobuf::RpcController *controller 头文件 实现 六、总结 一、前言 在前边的文章中&#xff0c;我们已经大致实现了rpc服务端的各项功能代…...

RocketMQ延迟消息机制

两种延迟消息 RocketMQ中提供了两种延迟消息机制 指定固定的延迟级别 通过在Message中设定一个MessageDelayLevel参数&#xff0c;对应18个预设的延迟级别指定时间点的延迟级别 通过在Message中设定一个DeliverTimeMS指定一个Long类型表示的具体时间点。到了时间点后&#xf…...

<6>-MySQL表的增删查改

目录 一&#xff0c;create&#xff08;创建表&#xff09; 二&#xff0c;retrieve&#xff08;查询表&#xff09; 1&#xff0c;select列 2&#xff0c;where条件 三&#xff0c;update&#xff08;更新表&#xff09; 四&#xff0c;delete&#xff08;删除表&#xf…...

React19源码系列之 事件插件系统

事件类别 事件类型 定义 文档 Event Event 接口表示在 EventTarget 上出现的事件。 Event - Web API | MDN UIEvent UIEvent 接口表示简单的用户界面事件。 UIEvent - Web API | MDN KeyboardEvent KeyboardEvent 对象描述了用户与键盘的交互。 KeyboardEvent - Web…...

Fabric V2.5 通用溯源系统——增加图片上传与下载功能

fabric-trace项目在发布一年后,部署量已突破1000次,为支持更多场景,现新增支持图片信息上链,本文对图片上传、下载功能代码进行梳理,包含智能合约、后端、前端部分。 一、智能合约修改 为了增加图片信息上链溯源,需要对底层数据结构进行修改,在此对智能合约中的农产品数…...

LLMs 系列实操科普(1)

写在前面&#xff1a; 本期内容我们继续 Andrej Karpathy 的《How I use LLMs》讲座内容&#xff0c;原视频时长 ~130 分钟&#xff0c;以实操演示主流的一些 LLMs 的使用&#xff0c;由于涉及到实操&#xff0c;实际上并不适合以文字整理&#xff0c;但还是决定尽量整理一份笔…...

华为OD机考-机房布局

import java.util.*;public class DemoTest5 {public static void main(String[] args) {Scanner in new Scanner(System.in);// 注意 hasNext 和 hasNextLine 的区别while (in.hasNextLine()) { // 注意 while 处理多个 caseSystem.out.println(solve(in.nextLine()));}}priv…...

GraphQL 实战篇:Apollo Client 配置与缓存

GraphQL 实战篇&#xff1a;Apollo Client 配置与缓存 上一篇&#xff1a;GraphQL 入门篇&#xff1a;基础查询语法 依旧和上一篇的笔记一样&#xff0c;主实操&#xff0c;没啥过多的细节讲解&#xff0c;代码具体在&#xff1a; https://github.com/GoldenaArcher/graphql…...