package com.demo.dao;

import com.demo.entity.po.Secret;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;


@Repository
public class SecretDao {
    @Autowired
    private MongoTemplate mongoTemplate;

    public Secret findEnableSecret(String gorganization){
        Query query = Query.query(Criteria.where("status").is(true).and("gorganization").is(gorganization));
        Secret secret = mongoTemplate.findOne(query, Secret.class);
        return secret;
    }

    public void insert(Secret secret){
        mongoTemplate.insert(secret);
    }

}
