Skip to content

Instantly share code, notes, and snippets.

View gdonega's full-sized avatar
🐈

Gustavo Donegá Queiroz gdonega

🐈
  • Brasil, São Paulo
View GitHub Profile
db.getCollection("empresas").aggregate([
{$group:{_id: "$municipio", count: { $sum: 1 }}},
{$sort: { _id: 1}}
])
package com.testes.spring.exemplo.empresas.dtos;
public class CnpjDto {
private String cnpj;
public CnpjDto() {
}
public String getCnpj() {
return cnpj;
package com.testes.spring.exemplo.empresas.rest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.testes.spring.exemplo.empresas.dtos.CnpjDto;
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testes.spring.exemplo</groupId>
<artifactId>empresas</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
package com.testes.spring.exemplo.empresas.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.mongodb.BasicDBObject;
import com.testes.spring.exemplo.empresas.models.EmpresaEnvelope;
import com.testes.spring.exemplo.empresas.repositories.EmpresaEnvelopeRepository;
package com.testes.spring.exemplo.empresas.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.testes.spring.exemplo.empresas.repositories.EmpresaEnvelopeRepository;
package com.testes.spring.exemplo.empresas.repositories;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
import com.testes.spring.exemplo.empresas.models.EmpresaEnvelope;
@Repository
public interface EmpresaEnvelopeRepository extends MongoRepository<EmpresaEnvelope, String> {
package com.testes.spring.exemplo.empresas.models;
import org.apache.commons.text.WordUtils;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
@Document(collection = "empresas")
{
"cnpj": "99450169000100",
"cep": "04476230",
"municipio": "Sao Paulo",
"bairro": "Bairro Aleatorio",
"logradouro": "Av Faria Aleatoria",
"numero": 115,
"jsonApi":{
}
}
{
"atividade_principal": [
],
"data_situacao": "",
"complemento": "",
"nome": "",
"uf": "SP",
"telefone": "",
"email": "",
"atividades_secundarias": [],