Showing
1 changed file
with
30 additions
and
4 deletions
... | @@ -43,19 +43,43 @@ const s3 = new AWS.S3(); | ... | @@ -43,19 +43,43 @@ const s3 = new AWS.S3(); |
43 | 43 | ||
44 | router.get('/show', function(req, res, next) { | 44 | router.get('/show', function(req, res, next) { |
45 | console.log(req.query); | 45 | console.log(req.query); |
46 | - user_id = req.query.user_id; | 46 | + user_id = req.query.id; |
47 | folder_id = req.query.folder_id; | 47 | folder_id = req.query.folder_id; |
48 | + if (folder_id == -1) { | ||
49 | + let location = '/'; | ||
50 | + let gerFolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
51 | + connection.query(gerFolder, [location, user_id], function(err, folder) { | ||
52 | + if (err) { | ||
53 | + console.log('select2 error'); | ||
54 | + res.status(400).send({ err: err }); | ||
55 | + } else { | ||
56 | + let gerFile = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; | ||
57 | + connection.query(gerFile, [location, user_id], function(err, file) { | ||
58 | + if (err) { | ||
59 | + console.log('select3 error'); | ||
60 | + res.status(400).send({ err: err }); | ||
61 | + } else { | ||
62 | + res.status(200).send({ | ||
63 | + folders: folder, | ||
64 | + files: file, | ||
65 | + cur: location | ||
66 | + }); | ||
67 | + } | ||
68 | + }); | ||
69 | + } | ||
70 | + }); | ||
71 | + } else { | ||
48 | let checkfolder = 'SELECT * FROM folders WHERE folder_id = ? AND user_id = ?;'; | 72 | let checkfolder = 'SELECT * FROM folders WHERE folder_id = ? AND user_id = ?;'; |
49 | connection.query(checkfolder, [curPath, user_id], function(err, rows) { | 73 | connection.query(checkfolder, [curPath, user_id], function(err, rows) { |
50 | if (err) { | 74 | if (err) { |
51 | console.log('select1 error'); | 75 | console.log('select1 error'); |
52 | res.status(400).send({ err: err }); | 76 | res.status(400).send({ err: err }); |
53 | } else { | 77 | } else { |
54 | - let location = rows[0].location + rows[0].folder_name + '/'; | ||
55 | if (rows.length == 0) { | 78 | if (rows.length == 0) { |
56 | console.log('does not exist'); | 79 | console.log('does not exist'); |
57 | res.status(400).send({ err: 'does not exist' }); | 80 | res.status(400).send({ err: 'does not exist' }); |
58 | } else { | 81 | } else { |
82 | + let location = rows[0].location + rows[0].folder_name + '/'; | ||
59 | let gerFolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | 83 | let gerFolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; |
60 | connection.query(gerFolder, [location, user_id], function(err, folder) { | 84 | connection.query(gerFolder, [location, user_id], function(err, folder) { |
61 | if (err) { | 85 | if (err) { |
... | @@ -63,14 +87,15 @@ router.get('/show', function(req, res, next) { | ... | @@ -63,14 +87,15 @@ router.get('/show', function(req, res, next) { |
63 | res.status(400).send({ err: err }); | 87 | res.status(400).send({ err: err }); |
64 | } else { | 88 | } else { |
65 | let gerFile = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; | 89 | let gerFile = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; |
66 | - connection.query(gerFile, [location, user_id], function(err, folder) { | 90 | + connection.query(gerFile, [location, user_id], function(err, file) { |
67 | if (err) { | 91 | if (err) { |
68 | console.log('select3 error'); | 92 | console.log('select3 error'); |
69 | res.status(400).send({ err: err }); | 93 | res.status(400).send({ err: err }); |
70 | } else { | 94 | } else { |
71 | res.status(200).send({ | 95 | res.status(200).send({ |
72 | folders: folder, | 96 | folders: folder, |
73 | - files: file | 97 | + files: file, |
98 | + cur: location | ||
74 | }); | 99 | }); |
75 | } | 100 | } |
76 | }); | 101 | }); |
... | @@ -79,6 +104,7 @@ router.get('/show', function(req, res, next) { | ... | @@ -79,6 +104,7 @@ router.get('/show', function(req, res, next) { |
79 | } | 104 | } |
80 | } | 105 | } |
81 | }); | 106 | }); |
107 | + } | ||
82 | }); | 108 | }); |
83 | 109 | ||
84 | router.post('/makefolder', function(req, res, next) { | 110 | router.post('/makefolder', function(req, res, next) { | ... | ... |
-
Please register or login to post a comment