Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Paisagem
api
Commits
6806e2f2
Commit
6806e2f2
authored
6 years ago
by
Unknown
Browse files
Options
Download
Email Patches
Plain Diff
Atualizada a api para cadastro de especie
parent
e0203a50
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
DAO/EspeciesDAO.js
+14
-1
DAO/EspeciesDAO.js
DAO/nomesPopularesDAO.js
+2
-2
DAO/nomesPopularesDAO.js
models/nomesPopulares.js
+1
-1
models/nomesPopulares.js
with
17 additions
and
4 deletions
+17
-4
DAO/EspeciesDAO.js
View file @
6806e2f2
const
constants
=
require
(
"
../config/contants
"
);
const
db
=
require
(
"
../models/index
"
);
const
nomesPopularesDAO
=
require
(
'
./nomesPopularesDAO
'
);
const
especies
=
db
.
sequelize
.
model
(
"
Especies
"
);
const
nomesPopulares
=
db
.
sequelize
.
model
(
"
nomesPopulares
"
);
/*
* Fetch a specific especies page
...
...
@@ -79,6 +81,17 @@ function addEspecie(especie, callback) {
.
create
(
especie
)
.
then
(
newEspecie
=>
{
callback
(
null
,
newEspecie
);
if
(
especie
.
nomePopular
){
for
(
let
i
=
0
;
i
<
especie
.
nomePopular
.
length
;
i
++
){
let
nomePopular
=
{
id_especie
:
newEspecie
.
id_especie
,
descricao
:
especie
.
nomePopular
[
i
].
name
}
nomesPopularesDAO
.
addNomePopular
(
nomePopular
,
null
);
}
}
})
.
catch
(
error
=>
{
let
errorObj
=
{
...
...
@@ -154,7 +167,7 @@ function createOrderClause(query) {
function
createWhereClause
(
query
)
{
if
(
query
.
contains
!==
undefined
)
{
query
.
$or
=
[
{
id_especie
:
{
like
:
`%
${
query
.
contains
}
%`
}
},
{
id_especie
s
:
{
like
:
`%
${
query
.
contains
}
%`
}
},
{
nome_cientifico
:
{
like
:
`%
${
query
.
contains
}
%`
}
},
{
nome_popular
:
{
like
:
`%
${
query
.
contains
}
%`
}
},
{
naturalidade
:
{
like
:
`%
${
query
.
contains
}
%`
}
},
...
...
This diff is collapsed.
Click to expand it.
DAO/nomesPopularesDAO.js
View file @
6806e2f2
...
...
@@ -24,7 +24,7 @@ function fetchNomesPopulares(orderQuery, whereQuery, callback) {
});
}
function
G
etByEspecie
(
id
,
callback
)
{
function
g
etByEspecie
(
id
,
callback
)
{
nomesPopulares
.
findAll
({
where
:
{
id_especie
:
id
}
...
...
@@ -158,7 +158,7 @@ function createWhereClause(query) {
module
.
exports
.
fetchNomesPopulares
=
fetchNomesPopulares
;
module
.
exports
.
findByID
=
findByID
;
module
.
exports
.
findByNomePop
=
findByNomePop
;
//
module.exports.findByNomePop = findByNomePop;
module
.
exports
.
addNomePopular
=
addNomePopular
;
module
.
exports
.
deleteNomePopularBy
=
deleteNomePopularBy
;
module
.
exports
.
updateNomePopular
=
updateNomePopular
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
models/nomesPopulares.js
View file @
6806e2f2
module
.
exports
=
(
sequelize
,
DataType
)
=>
{
var
nomesPopulares
=
sequelize
.
define
(
"
nomesPopulares
"
,
{
id_nomepopular
:
{
id_nome
_
popular
:
{
type
:
DataType
.
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help