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
Hong
2020-06-10 22:47:48 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
33d9ddb2b99c79439b838ce9d2d342274a62a3ec
33d9ddb2
1 parent
f0bec4c9
즐겨찾기ing
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
6 deletions
backend/routes/favorites.js
backend/routes/trashcan.js
front-end/src/components/Fav_list.vue
backend/routes/favorites.js
View file @
33d9ddb
...
...
@@ -44,8 +44,8 @@ router.post('/addfolder', function(req, res, next) {
console
.
log
(
'update error'
);
res
.
status
(
400
).
send
({
error
:
err
});
}
else
{
let
getfolder
=
'SELECT * FROM folders WHERE location = ? AND user_id = ?;'
;
connection
.
query
(
getfolder
,
[
cur
,
user_id
],
function
(
err
,
folders
,
fields
)
{
let
getfolder
=
'SELECT * FROM folders WHERE location = ? AND user_id = ?
AND folder_name != ?
;'
;
connection
.
query
(
getfolder
,
[
cur
,
user_id
,
'trashcan'
],
function
(
err
,
folders
,
fields
)
{
res
.
status
(
200
).
send
({
folders
:
folders
})
...
...
@@ -112,8 +112,8 @@ router.post('/delfolder', function(req, res, next) {
console
.
log
(
'update error'
);
res
.
status
(
400
).
send
({
error
:
err
});
}
else
{
let
getfolder
=
'SELECT * FROM folders WHERE location = ? AND user_id = ?;'
;
connection
.
query
(
getfolder
,
[
cur
,
user_id
],
function
(
err
,
folders
,
fields
)
{
let
getfolder
=
'SELECT * FROM folders WHERE location = ? AND user_id = ?
AND folder_name != ?
;'
;
connection
.
query
(
getfolder
,
[
cur
,
user_id
,
'trashcan'
],
function
(
err
,
folders
,
fields
)
{
res
.
status
(
200
).
send
({
folders
:
folders
})
...
...
backend/routes/trashcan.js
View file @
33d9ddb
...
...
@@ -179,4 +179,116 @@ router.get('/all', function(req, res, next) {
});
});
router
.
post
(
'/restore'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
req
.
body
);
let
user_id
=
req
.
body
.
user_id
;
let
id
=
req
.
body
.
id
;
if
(
req
.
body
.
isfolder
)
{
let
checkfolder
=
'SELECT * FROM folders WHERE folder_id = ? AND user_id = ?;'
;
connection
.
query
(
checkfolder
,
[
id
,
user_id
],
function
(
err1
,
rows
,
fields
)
{
console
.
log
(
rows
);
if
(
rows
.
length
!=
0
)
{
let
curPath
=
user_id
+
'/trashcan/'
let
name
=
rows
[
0
].
folder_name
let
copy_params
=
{
Bucket
:
S3
.
BUCKET_NAM
,
CopySource
:
S3
.
BUCKET_NAM
+
'/drive/'
+
curPath
+
name
+
'/'
,
Key
:
'drive/'
+
user_id
+
'/'
+
name
+
'/'
};
let
del_params
=
{
Bucket
:
S3
.
BUCKET_NAM
,
Key
:
'drive/'
+
curPath
+
name
+
'/'
};
s3
.
copyObject
(
copy_params
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
err
,
data
);
console
.
log
(
"copy error"
);
res
.
status
(
304
).
send
({
error
:
"copy error"
});
}
else
{
s3
.
deleteObject
(
del_params
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
err
,
data
);
console
.
log
(
"delete error"
);
res
.
status
(
304
).
send
({
error
:
"delete error"
});
}
else
{
let
values
=
[
'/'
,
'/trashcan/'
,
name
,
user_id
];
let
updatesql
=
'UPDATE folders SET location = ? WHERE location = ? AND folder_name = ? AND user_id = ?;'
;
connection
.
query
(
updatesql
,
values
,
function
(
err3
,
result
,
field
)
{
if
(
err3
)
{
console
.
log
(
"updatesql error"
);
res
.
status
(
304
).
send
({
error
:
"updatesql error"
});
}
else
{
let
resultsql
=
'SELECT * FROM folders WHERE location = ? AND user_id = ?;'
;
connection
.
query
(
resultsql
,
[
'/trashcan/'
,
user_id
],
function
(
err
,
folder
,
fields
)
{
res
.
status
(
200
).
send
({
folders
:
folder
});
});
}
});
}
});
}
});
}
else
{
console
.
log
(
"Does not exist folder"
);
res
.
status
(
304
).
send
({
error
:
"Does not exist"
});
}
});
}
else
{
let
checkfile
=
'SELECT * FROM files WHERE file_id = ? AND user_id = ?;'
;
connection
.
query
(
checkfile
,
[
id
,
user_id
],
function
(
err1
,
rows
,
fields
)
{
console
.
log
(
rows
);
if
(
rows
.
length
!=
0
)
{
let
curPath
=
user_id
+
'/trashcan/'
let
name
=
rows
[
0
].
file_name
let
copy_params
=
{
Bucket
:
S3
.
BUCKET_NAME
,
CopySource
:
S3
.
BUCKET_NAME
+
'/drive/'
+
curPath
+
name
,
Key
:
'drive/'
+
user_id
+
'/'
+
name
};
let
del_params
=
{
Bucket
:
S3
.
BUCKET_NAME
,
Key
:
'drive/'
+
curPath
+
name
};
s3
.
copyObject
(
copy_params
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
err
,
data
);
console
.
log
(
"copy error"
);
res
.
status
(
304
).
send
({
error
:
"copy error"
});
}
else
{
s3
.
deleteObject
(
del_params
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
err
,
data
);
console
.
log
(
"delete error"
);
res
.
status
(
304
).
send
({
error
:
"delete error"
});
}
else
{
let
values
=
[
'/'
,
'/trashcan/'
,
name
,
user_id
];
let
updatesql
=
'UPDATE files SET location = ? WHERE location = ? AND folder_name = ? AND user_id = ?;'
;
connection
.
query
(
updatesql
,
values
,
function
(
err3
,
result
,
field
)
{
if
(
err3
)
{
console
.
log
(
"updatesql error"
);
res
.
status
(
304
).
send
({
error
:
"updatesql error"
});
}
else
{
let
resultsql
=
'SELECT * FROM files WHERE location = ? AND user_id = ?;'
;
connection
.
query
(
resultsql
,
[
'/trashcan/'
,
user_id
],
function
(
err
,
file
,
fields
)
{
res
.
status
(
200
).
send
({
files
:
file
});
});
}
});
}
});
}
});
}
else
{
console
.
log
(
"Does not exist file"
);
res
.
status
(
304
).
send
({
error
:
"Does not exist"
});
}
});
}
});
module
.
exports
=
router
;
\ No newline at end of file
...
...
front-end/src/components/Fav_list.vue
View file @
33d9ddb
...
...
@@ -518,7 +518,8 @@ export default {
name: this.curfName.folder_name,
};
console.log(cData);
const response = await delFavorite(cData);
const del = await delFavorite(cData);
const response = await getFavoriteList(this.$store.state.id);
this.$store.commit('setfavFolderList', response.data.folders);
} catch (error) {
console.log('에러');
...
...
@@ -546,7 +547,8 @@ export default {
name: this.cfilename.file_name,
};
console.log(fData);
const response = await delFavoriteFile(fData);
const del = await delFavoriteFile(fData);
const response = await getFavoriteList(this.$store.state.id);
this.$store.commit('setfavFileList', response.data.files);
} catch (error) {
console.log('에러');
...
...
Please
register
or
login
to post a comment