Showing
1 changed file
with
19 additions
and
11 deletions
| ... | @@ -315,20 +315,28 @@ router.post('/modify', function(req, res, next) { | ... | @@ -315,20 +315,28 @@ router.post('/modify', function(req, res, next) { |
| 315 | 315 | ||
| 316 | }); | 316 | }); |
| 317 | 317 | ||
| 318 | -router.post('/search/:target', function(req, res, next) { | 318 | +router.get('/search', function(req, res, next) { |
| 319 | - user_id = req.params.id; | 319 | + console.log(req.query); |
| 320 | - let cur = req.params.cur; | 320 | + user_id = req.query.id; |
| 321 | - folders = {} | 321 | + let target = connection.escape('%' + req.query.target + '%'); |
| 322 | - let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | 322 | + console.log(target); |
| 323 | - connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | 323 | + let folders = [] |
| 324 | - if (rows.length != 0) { | 324 | + let files = [] |
| 325 | + let checkfolder = 'SELECT * FROM folders WHERE folder_name LIKE ' + target + ' AND user_id = ?;'; | ||
| 326 | + connection.query(checkfolder, [user_id], function(err, folder, fields) { | ||
| 327 | + console.log(folder); | ||
| 328 | + folders.push(folder) | ||
| 329 | + let checkfile = 'SELECT * FROM files WHERE file_name LIKE ' + target + ' AND user_id = ?;'; | ||
| 330 | + connection.query(checkfile, [user_id], function(err, file, fields) { | ||
| 331 | + console.log(file); | ||
| 332 | + files.push(file) | ||
| 325 | res.status(200).send({ | 333 | res.status(200).send({ |
| 326 | - folders: folders | 334 | + folders: folders, |
| 335 | + files: files | ||
| 327 | }) | 336 | }) |
| 328 | - } else { | 337 | + }); |
| 329 | - res.send({ error: "Does not exist" }); | ||
| 330 | - } | ||
| 331 | }); | 338 | }); |
| 339 | + | ||
| 332 | }); | 340 | }); |
| 333 | 341 | ||
| 334 | module.exports = router; | 342 | module.exports = router; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment