在春季启动中审核休息日志

时间:2020-08-03 11:44:13

标签: mongodb spring-boot rest

'我正在尝试将 userId,时间戳,_id 登录到每个审计文档的Spring Boot for Rest API中的mongodbDatabase的audit_logs集合中。我的代码如下所示'

@RequestMapping(value = "/id/", method = RequestMethod.GET)

public List getDetailsById(@RequestParam(value = "userId") String userId,
                           @RequestParam(value = "id") String id) throws 
   JsonProcessingException {
    
 MongoDatabase database = this.mongoClient.getDatabase(this.database);

MongoCollection<Document> collection = database.getCollection(this.collection);

    List  sample  = new ArrayList();

    Document document = new Document("_id", new ObjectId(id))
    List sampleList = collection.find(document).into(sampleList);
    return sampleList;
}

这是来自Main Application Class的RestController。我是Spring Boot和Mongodb数据库的新手。谁能建议如何将审核信息记录到数据库。

0 个答案:

没有答案