Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-CloudComputing
/
D_Team_Khuloud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
toror33
2020-06-07 19:52:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f9f0f0660c73e7f94a6dadbb9a6a2f0838166144
f9f0f066
1 parent
20c7d110
연락처 검색
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletions
backend/routes/contact.js
backend/routes/contact.js
View file @
f9f0f06
...
...
@@ -42,7 +42,37 @@ contact_search : 연락처 검색 모듈
input : 사용자가 이름, 전화번호, 이메일 중 하나를 검색
output : 검색을 요청한 데이터에 부합하는 연락처를 찾았다면 출력
*/
router
.
get
(
'/contact_search'
,
function
(
req
,
res
,
next
)
{
router
.
post
(
'/contact_search'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
"req.query"
,
req
.
query
);
var
user_id
=
req
.
query
.
id
;
var
type
=
req
.
query
.
type
;
var
info
=
""
;
if
(
type
==
"name"
)
{
info
=
req
.
query
.
name
;
var
sqlquery
=
"SELECT * FROM contact WHERE user_id = ? and name = ?"
;
}
else
if
(
type
==
"phone"
)
{
info
=
req
.
query
.
phone
;
var
sqlquery
=
"SELECT * FROM contact WHERE user_id = ? and phone = ?"
;
}
else
if
(
type
==
"email"
)
{
info
=
req
.
query
.
email
;
var
sqlquery
=
"SELECT * FROM contact WHERE user_id = ? and email = ?"
;
}
console
.
log
(
sqlquery
);
connection
.
query
(
sqlquery
,
[
user_id
,
info
],
function
(
err
,
rows
)
{
if
(
err
)
{
console
.
log
(
"search contact failed"
);
throw
err
;
}
else
{
console
.
log
(
rows
);
res
.
status
(
200
).
send
({
contact_list
:
rows
});
}
});
});
/*
...
...
Please
register
or
login
to post a comment