Showing
1 changed file
with
53 additions
and
27 deletions
... | @@ -43,42 +43,68 @@ const s3 = new AWS.S3(); | ... | @@ -43,42 +43,68 @@ 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 | - let checkfolder = 'SELECT * FROM folders WHERE folder_id = ? AND user_id = ?;'; | 48 | + if (folder_id == -1) { |
49 | - connection.query(checkfolder, [curPath, user_id], function(err, rows) { | 49 | + let location = '/'; |
50 | - if (err) { | 50 | + let gerFolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; |
51 | - console.log('select1 error'); | 51 | + connection.query(gerFolder, [location, user_id], function(err, folder) { |
52 | - res.status(400).send({ err: err }); | 52 | + if (err) { |
53 | - } else { | 53 | + console.log('select2 error'); |
54 | - let location = rows[0].location + rows[0].folder_name + '/'; | 54 | + res.status(400).send({ err: err }); |
55 | - if (rows.length == 0) { | ||
56 | - console.log('does not exist'); | ||
57 | - res.status(400).send({ err: 'does not exist' }); | ||
58 | } else { | 55 | } else { |
59 | - let gerFolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | 56 | + let gerFile = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; |
60 | - connection.query(gerFolder, [location, user_id], function(err, folder) { | 57 | + connection.query(gerFile, [location, user_id], function(err, file) { |
61 | if (err) { | 58 | if (err) { |
62 | - console.log('select2 error'); | 59 | + console.log('select3 error'); |
63 | res.status(400).send({ err: err }); | 60 | res.status(400).send({ err: err }); |
64 | } else { | 61 | } else { |
65 | - let gerFile = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; | 62 | + res.status(200).send({ |
66 | - connection.query(gerFile, [location, user_id], function(err, folder) { | 63 | + folders: folder, |
67 | - if (err) { | 64 | + files: file, |
68 | - console.log('select3 error'); | 65 | + cur: location |
69 | - res.status(400).send({ err: err }); | ||
70 | - } else { | ||
71 | - res.status(200).send({ | ||
72 | - folders: folder, | ||
73 | - files: file | ||
74 | - }); | ||
75 | - } | ||
76 | }); | 66 | }); |
77 | } | 67 | } |
78 | }); | 68 | }); |
79 | } | 69 | } |
80 | - } | 70 | + }); |
81 | - }); | 71 | + } else { |
72 | + let checkfolder = 'SELECT * FROM folders WHERE folder_id = ? AND user_id = ?;'; | ||
73 | + connection.query(checkfolder, [curPath, user_id], function(err, rows) { | ||
74 | + if (err) { | ||
75 | + console.log('select1 error'); | ||
76 | + res.status(400).send({ err: err }); | ||
77 | + } else { | ||
78 | + if (rows.length == 0) { | ||
79 | + console.log('does not exist'); | ||
80 | + res.status(400).send({ err: 'does not exist' }); | ||
81 | + } else { | ||
82 | + let location = rows[0].location + rows[0].folder_name + '/'; | ||
83 | + let gerFolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
84 | + connection.query(gerFolder, [location, user_id], function(err, folder) { | ||
85 | + if (err) { | ||
86 | + console.log('select2 error'); | ||
87 | + res.status(400).send({ err: err }); | ||
88 | + } else { | ||
89 | + let gerFile = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; | ||
90 | + connection.query(gerFile, [location, user_id], function(err, file) { | ||
91 | + if (err) { | ||
92 | + console.log('select3 error'); | ||
93 | + res.status(400).send({ err: err }); | ||
94 | + } else { | ||
95 | + res.status(200).send({ | ||
96 | + folders: folder, | ||
97 | + files: file, | ||
98 | + cur: location | ||
99 | + }); | ||
100 | + } | ||
101 | + }); | ||
102 | + } | ||
103 | + }); | ||
104 | + } | ||
105 | + } | ||
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