이진아

mytoons2.js

1 +var express = require('express');
2 +var async = require('async');
3 +var router = express.Router();
4 +
5 +function getMyToons2(id,cb){
6 + //id 값을 가진 user가 저장한 웹툰들 가져오기
7 +
8 + var sqlquery = "SELECT t.name, t.thum_link, t.webtoon_link, t.year, t.site FROM user u, user_toon_relation ur, toon t WHERE u.id = '"+id+"' && u.id=ur.user_id && t.toon_index=ur.toon_index;";
9 + var mylist2 = new Array();
10 + connection.query(sqlquery,id,function(err,rows,result){
11 + if(!err){
12 + mylist2=rows;
13 + cb(mylist2);
14 + console.log(mylist2);
15 + }else{
16 + console.log("내 웹툰 리스트 가져오는데 실패했습니다!");
17 + //throw err;
18 + }
19 + });
20 +}
21 +
22 +/* GET home page. */
23 +router.get('/', function(req, res, next) {
24 + if(!req.isAuthenticated()){
25 + res.redirect('/');
26 + }else{
27 + async.series(
28 + [
29 + function(callback){
30 + getMyToons2(req.user.user_id, function (mytoon_list2) {
31 + callback(null,mytoon_list2);
32 + });
33 + }
34 + ],
35 + function(err, results){
36 + res.render('mytoons2', {
37 + mytoons2: results[0]
38 + });
39 + }
40 + );
41 + }
42 +});
43 +
44 +module.exports = router;
...\ No newline at end of file ...\ No newline at end of file