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-09 18:39:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6b4c0e8cb8e4ce9044cfa2de90277555fef794d3
6b4c0e8c
1 parent
34fb07b5
연락처 download
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
1 deletions
backend/package-lock.json
backend/package.json
backend/routes/contact.js
backend/package-lock.json
View file @
6b4c0e8
...
...
@@ -417,6 +417,11 @@
"ms"
:
"2.0.0"
}
},
"deepmerge"
:
{
"version"
:
"3.2.0"
,
"resolved"
:
"https://registry.npmjs.org/deepmerge/-/deepmerge-3.2.0.tgz"
,
"integrity"
:
"sha512-6+LuZGU7QCNUnAJyX8cIrlzoEgggTM6B7mm+znKOX4t5ltluT9KLjN6g61ECMS0LTsLW7yDpNoxhix5FZcrIow=="
},
"delayed-stream"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz"
,
...
...
@@ -516,6 +521,36 @@
"resolved"
:
"https://registry.npmjs.org/events/-/events-1.1.1.tgz"
,
"integrity"
:
"sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ="
},
"excel4node"
:
{
"version"
:
"1.7.2"
,
"resolved"
:
"https://registry.npmjs.org/excel4node/-/excel4node-1.7.2.tgz"
,
"integrity"
:
"sha512-3XSsPSSbUeGloTRQMTmgf4aA1WDGa9fWQitOCGN/URG8NvwPjgVdbyG7FWKukqTdl5XBz9jv0vVBz3BBIo52tg=="
,
"requires"
:
{
"deepmerge"
:
"3.2.0"
,
"image-size"
:
"0.7.2"
,
"jszip"
:
"3.2.1"
,
"lodash.get"
:
"4.4.2"
,
"lodash.isequal"
:
"4.5.0"
,
"lodash.isundefined"
:
"3.0.1"
,
"lodash.reduce"
:
"4.6.0"
,
"lodash.uniqueid"
:
"4.0.1"
,
"mime"
:
"2.4.0"
,
"uuid"
:
"3.3.2"
,
"xmlbuilder"
:
"11.0.1"
},
"dependencies"
:
{
"mime"
:
{
"version"
:
"2.4.0"
,
"resolved"
:
"https://registry.npmjs.org/mime/-/mime-2.4.0.tgz"
,
"integrity"
:
"sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w=="
},
"xmlbuilder"
:
{
"version"
:
"11.0.1"
,
"resolved"
:
"https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz"
,
"integrity"
:
"sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="
}
}
},
"exit-on-epipe"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz"
,
...
...
@@ -743,6 +778,16 @@
"resolved"
:
"https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz"
,
"integrity"
:
"sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
},
"image-size"
:
{
"version"
:
"0.7.2"
,
"resolved"
:
"https://registry.npmjs.org/image-size/-/image-size-0.7.2.tgz"
,
"integrity"
:
"sha512-CBmVIFHyDyiWi1U24eNHl8SH0Iir2IgmEv1RwdRVZxWsEbSCvV5b/eXaYP8epOFv2dbw5uNBOrn1Nc5P5KvsUA=="
},
"immediate"
:
{
"version"
:
"3.0.6"
,
"resolved"
:
"https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz"
,
"integrity"
:
"sha1-nbHb0Pr43m++D13V5Wu2BigN5ps="
},
"inherits"
:
{
"version"
:
"2.0.3"
,
"resolved"
:
"https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz"
,
...
...
@@ -851,11 +896,55 @@
"promise"
:
"^7.0.1"
}
},
"jszip"
:
{
"version"
:
"3.2.1"
,
"resolved"
:
"https://registry.npmjs.org/jszip/-/jszip-3.2.1.tgz"
,
"integrity"
:
"sha512-iCMBbo4eE5rb1VCpm5qXOAaUiRKRUKiItn8ah2YQQx9qymmSAY98eyQfioChEYcVQLh0zxJ3wS4A0mh90AVPvw=="
,
"requires"
:
{
"lie"
:
"~3.3.0"
,
"pako"
:
"~1.0.2"
,
"readable-stream"
:
"~2.3.6"
,
"set-immediate-shim"
:
"~1.0.1"
}
},
"lie"
:
{
"version"
:
"3.3.0"
,
"resolved"
:
"https://registry.npmjs.org/lie/-/lie-3.3.0.tgz"
,
"integrity"
:
"sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ=="
,
"requires"
:
{
"immediate"
:
"~3.0.5"
}
},
"lodash"
:
{
"version"
:
"4.17.15"
,
"resolved"
:
"https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz"
,
"integrity"
:
"sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
},
"lodash.get"
:
{
"version"
:
"4.4.2"
,
"resolved"
:
"https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz"
,
"integrity"
:
"sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
},
"lodash.isequal"
:
{
"version"
:
"4.5.0"
,
"resolved"
:
"https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz"
,
"integrity"
:
"sha1-QVxEePK8wwEgwizhDtMib30+GOA="
},
"lodash.isundefined"
:
{
"version"
:
"3.0.1"
,
"resolved"
:
"https://registry.npmjs.org/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz"
,
"integrity"
:
"sha1-I+89lTVWUgOmbO/VuDD4SJEa+0g="
},
"lodash.reduce"
:
{
"version"
:
"4.6.0"
,
"resolved"
:
"https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz"
,
"integrity"
:
"sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs="
},
"lodash.uniqueid"
:
{
"version"
:
"4.0.1"
,
"resolved"
:
"https://registry.npmjs.org/lodash.uniqueid/-/lodash.uniqueid-4.0.1.tgz"
,
"integrity"
:
"sha1-MmjyanyI5PSxdY1nknGBTjH6WyY="
},
"media-typer"
:
{
"version"
:
"0.3.0"
,
"resolved"
:
"https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz"
,
...
...
@@ -986,6 +1075,11 @@
"resolved"
:
"https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz"
,
"integrity"
:
"sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA=="
},
"pako"
:
{
"version"
:
"1.0.11"
,
"resolved"
:
"https://registry.npmjs.org/pako/-/pako-1.0.11.tgz"
,
"integrity"
:
"sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
},
"parseurl"
:
{
"version"
:
"1.3.3"
,
"resolved"
:
"https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz"
,
...
...
@@ -1300,6 +1394,11 @@
"send"
:
"0.16.2"
}
},
"set-immediate-shim"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz"
,
"integrity"
:
"sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E="
},
"setprototypeof"
:
{
"version"
:
"1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz"
,
...
...
backend/package.json
View file @
6b4c0e8
...
...
@@ -11,6 +11,7 @@
"crypto-js"
:
"^4.0.0"
,
"debug"
:
"~2.6.9"
,
"ejs"
:
"^3.1.3"
,
"excel4node"
:
"^1.7.2"
,
"express"
:
"~4.16.1"
,
"express-session"
:
"^1.17.1"
,
"formidable"
:
"^1.2.2"
,
...
...
backend/routes/contact.js
View file @
6b4c0e8
...
...
@@ -3,6 +3,7 @@ var router = express.Router();
const
XLSX
=
require
(
'xlsx'
);
var
multer
=
require
(
'multer'
);
var
fs
=
require
(
'fs'
);
var
xl
=
require
(
'excel4node'
);
// var pool = require('./../routes/modules/database');
//파일 저장위치와 파일이름 설정
...
...
@@ -88,7 +89,59 @@ contact_download : 연락처 파일 다운로드 모듈
input : 사용자의 연락처 다운로드 요청
output : 연락처 다운로드 성공 여부 및 csv, xlsx 파일
*/
router
.
get
(
'/contact_download'
,
function
(
req
,
res
,
next
)
{
router
.
post
(
'/contact_download'
,
function
(
req
,
res
,
next
)
{
var
filename
=
'public/upload/contactdownload.xlsx'
;
fs
.
exists
(
filename
,
function
(
exists
)
{
console
.
log
(
exists
);
if
(
exists
==
true
)
{
fs
.
unlink
(
filename
,
function
(
err
)
{
if
(
err
)
throw
err
;
console
.
log
(
'file deleted'
);
});
}
});
// Create a new instance of a Workbook class
var
wb
=
new
xl
.
Workbook
();
// Add Worksheets to the workbook
var
ws
=
wb
.
addWorksheet
(
'Sheet 1'
);
ws
.
cell
(
1
,
1
)
.
string
(
'name'
);
ws
.
cell
(
1
,
2
)
.
string
(
'phone'
);
ws
.
cell
(
1
,
3
)
.
string
(
'email'
);
ws
.
cell
(
1
,
4
)
.
string
(
'added_date'
);
var
user_id
=
req
.
query
.
id
;
var
sqlquery
=
"SELECT * FROM contact WHERE user_id = ?"
;
connection
.
query
(
sqlquery
,
[
user_id
],
function
(
err
,
rows
)
{
if
(
err
)
{
console
.
log
(
"download contact failed"
);
throw
err
;
}
else
{
if
(
rows
.
length
!=
0
)
{
for
(
var
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
ws
.
cell
(
i
+
2
,
1
).
string
(
rows
[
i
].
name
);
ws
.
cell
(
i
+
2
,
2
).
string
(
rows
[
i
].
phone
);
ws
.
cell
(
i
+
2
,
3
).
string
(
rows
[
i
].
email
);
ws
.
cell
(
i
+
2
,
4
).
string
(
rows
[
i
].
added_date
);
}
}
wb
.
write
(
'public/upload/contactdownload.xlsx'
);
var
file
=
__dirname
+
'/public/upload/contactdownload.xlsx'
;
// console.log(file);
res
.
download
(
file
);
}
});
});
/*
...
...
Please
register
or
login
to post a comment