@@ -87,9 +87,19 @@ export const cadastrarVegetacao = (request, response, next) => {
8787} ;
8888
8989export const buscarRelevos = ( request , response , next ) => {
90+ let where = { } ;
91+
92+ if ( request . query . nome ) {
93+ where = {
94+ ...where ,
95+ nome : { [ sequelize . Op . like ] : `%${ request . query . nome } %` } ,
96+ } ;
97+ }
98+
9099 Promise . resolve ( )
91100 . then ( ( ) => Relevo . findAndCountAll ( {
92101 attributes : [ 'id' , 'nome' ] ,
102+ where,
93103 order : [ [ 'nome' , 'ASC' ] ] ,
94104 } ) )
95105 . then ( relevos => {
@@ -99,9 +109,19 @@ export const buscarRelevos = (request, response, next) => {
99109} ;
100110
101111export const buscarSolos = ( request , response , next ) => {
112+ let where = { } ;
113+
114+ if ( request . query . nome ) {
115+ where = {
116+ ...where ,
117+ nome : { [ sequelize . Op . like ] : `%${ request . query . nome } %` } ,
118+ } ;
119+ }
120+
102121 Promise . resolve ( )
103122 . then ( ( ) => Solo . findAndCountAll ( {
104123 attributes : [ 'id' , 'nome' ] ,
124+ where,
105125 order : [ [ 'nome' , 'ASC' ] ] ,
106126 } ) )
107127 . then ( solos => {
@@ -111,9 +131,19 @@ export const buscarSolos = (request, response, next) => {
111131} ;
112132
113133export const buscarVegetacoes = ( request , response , next ) => {
134+ let where = { } ;
135+
136+ if ( request . query . nome ) {
137+ where = {
138+ ...where ,
139+ nome : { [ sequelize . Op . like ] : `%${ request . query . nome } %` } ,
140+ } ;
141+ }
142+
114143 Promise . resolve ( )
115144 . then ( ( ) => Vegetacao . findAndCountAll ( {
116145 attributes : [ 'id' , 'nome' ] ,
146+ where,
117147 order : [ [ 'nome' , 'ASC' ] ] ,
118148 } ) )
119149 . then ( vegetacoes => {
@@ -134,7 +164,7 @@ export const cadastrarLocalColeta = async (request, response, next) => {
134164
135165export const buscarLocaisColeta = async ( request , response , next ) => {
136166 try {
137- const { cidade_id : cidadeId , estado_id : estadoId , pais_id : paisId } = request . query ;
167+ const { cidade_id : cidadeId , estado_id : estadoId , pais_id : paisId , descricao } = request . query ;
138168 const { limite, pagina, offset } = request . paginacao ;
139169 const { getAll } = request . query ;
140170
@@ -152,6 +182,10 @@ export const buscarLocaisColeta = async (request, response, next) => {
152182 { model : FaseSucessional } ,
153183 ] ;
154184
185+ if ( descricao ) {
186+ where . descricao = { [ sequelize . Op . like ] : `%${ descricao } %` } ;
187+ }
188+
155189 if ( cidadeId ) {
156190 where . cidade_id = cidadeId ;
157191 } else if ( estadoId ) {
0 commit comments