mirror of
https://gitee.com/ssssssss-team/magic-api.git
synced 2026-05-07 19:07:21 +08:00
新增ObjectId函数
This commit is contained in:
@@ -28,4 +28,9 @@ public class MagicMongoConfiguration implements MagicPluginConfiguration {
|
||||
JavaReflection.registerMethodExtension(FindIterable.class, new MongoFindIterableExtension());
|
||||
return new MongoModule(mongoTemplate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MongoFunction mongoFunction(){
|
||||
return new MongoFunction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.ssssssss.magicapi.mongo;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.ssssssss.magicapi.core.config.MagicFunction;
|
||||
import org.ssssssss.script.annotation.Comment;
|
||||
import org.ssssssss.script.annotation.Function;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class MongoFunction implements MagicFunction {
|
||||
|
||||
@Comment("创建ObjectId")
|
||||
@Function
|
||||
public ObjectId ObjectId(String hexString){
|
||||
return new ObjectId(hexString);
|
||||
}
|
||||
|
||||
@Comment("创建ObjectId")
|
||||
@Function
|
||||
public ObjectId ObjectId(){
|
||||
return new ObjectId();
|
||||
}
|
||||
|
||||
@Comment("创建ObjectId")
|
||||
@Function
|
||||
public ObjectId ObjectId(byte[] bytes){
|
||||
return new ObjectId(bytes);
|
||||
}
|
||||
|
||||
@Comment("创建ObjectId")
|
||||
@Function
|
||||
public ObjectId ObjectId(Date date){
|
||||
return new ObjectId(date);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user