Showing
2 changed files
with
12 additions
and
11 deletions
... | @@ -77,7 +77,7 @@ app.use(express.static(path.join(__dirname, 'public'))); | ... | @@ -77,7 +77,7 @@ app.use(express.static(path.join(__dirname, 'public'))); |
77 | connection = mysql.createConnection({ | 77 | connection = mysql.createConnection({ |
78 | host : 'localhost', | 78 | host : 'localhost', |
79 | user : 'root', | 79 | user : 'root', |
80 | - password : 'asd123', | 80 | + password : '', |
81 | port : 3306, | 81 | port : 3306, |
82 | database : 'ytmt' | 82 | database : 'ytmt' |
83 | }); | 83 | }); | ... | ... |
... | @@ -3,18 +3,19 @@ var router = express.Router(); | ... | @@ -3,18 +3,19 @@ var router = express.Router(); |
3 | 3 | ||
4 | function addMyToons(id,index,cb){ | 4 | function addMyToons(id,index,cb){ |
5 | connection.query("INSERT INTO user_toon_relation SET ?;", {user_id : id,toon_index : index},function (err) { | 5 | connection.query("INSERT INTO user_toon_relation SET ?;", {user_id : id,toon_index : index},function (err) { |
6 | + | ||
6 | if(err) { | 7 | if(err) { |
7 | throw err; | 8 | throw err; |
8 | console.log("내 웹툰 추가 중 에러!") | 9 | console.log("내 웹툰 추가 중 에러!") |
9 | - } else { | 10 | + } else{ |
10 | - alert("추가되었습니다.") | 11 | + // alert("추가되었습니다.") |
11 | cb(); | 12 | cb(); |
12 | } | 13 | } |
13 | }); | 14 | }); |
14 | } | 15 | } |
15 | 16 | ||
16 | //내툰 수정하기 | 17 | //내툰 수정하기 |
17 | -router.post('/toggle_toon',function(req,res,next) { | 18 | +router.post('/toggle_toon',function(req,res,next){ |
18 | var index = req.body.toon_index; | 19 | var index = req.body.toon_index; |
19 | var id = req.user.user_id; | 20 | var id = req.user.user_id; |
20 | connection.query("SELECT COUNT(*) FROM user_toon_relation WHERE user_id='"+id+"' && toon_index='"+index+"'", [id,index], function (err, rows,result) { | 21 | connection.query("SELECT COUNT(*) FROM user_toon_relation WHERE user_id='"+id+"' && toon_index='"+index+"'", [id,index], function (err, rows,result) { |
... | @@ -22,18 +23,18 @@ router.post('/toggle_toon',function(req,res,next) { | ... | @@ -22,18 +23,18 @@ router.post('/toggle_toon',function(req,res,next) { |
22 | console.log("내 웹툰 등록 중 에러!"); | 23 | console.log("내 웹툰 등록 중 에러!"); |
23 | } else { | 24 | } else { |
24 | var count = rows[0]["COUNT(*)"]; | 25 | var count = rows[0]["COUNT(*)"]; |
25 | - if(count > 0) { //이미 등록되어 있는 것이라면, | 26 | + if(count>0) {//이미 등록되어 있는 것이라면, |
26 | connection.query("DELETE FROM user_toon_relation WHERE user_id='"+id+"' && toon_index='"+index+"';", [id, index],function (err, rows, result) { | 27 | connection.query("DELETE FROM user_toon_relation WHERE user_id='"+id+"' && toon_index='"+index+"';", [id, index],function (err, rows, result) { |
27 | if(err) { | 28 | if(err) { |
28 | console.log("내 웹툰 제거중 에러!"); | 29 | console.log("내 웹툰 제거중 에러!"); |
29 | throw err; | 30 | throw err; |
30 | } else { | 31 | } else { |
31 | - alert("제거되었습니다.") | 32 | + //alert("제거되었습니다.") |
32 | res.redirect('/setting'); | 33 | res.redirect('/setting'); |
33 | } | 34 | } |
34 | }); | 35 | }); |
35 | } else { | 36 | } else { |
36 | - addMyToons(id,index,function() { | 37 | + addMyToons(id,index,function(){ |
37 | res.redirect('/setting'); | 38 | res.redirect('/setting'); |
38 | }); | 39 | }); |
39 | } | 40 | } |
... | @@ -46,11 +47,11 @@ function getMyToons(id,cb){ | ... | @@ -46,11 +47,11 @@ function getMyToons(id,cb){ |
46 | //mysql5.7 syntax에 맞게 수정 => 로그인한 유저의 | 47 | //mysql5.7 syntax에 맞게 수정 => 로그인한 유저의 |
47 | var sqlquery = "SELECT t.toon_index, t.name, t.thum_link, t.webtoon_link, t.week, 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;"; | 48 | var sqlquery = "SELECT t.toon_index, t.name, t.thum_link, t.webtoon_link, t.week, 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;"; |
48 | var mylist = new Array(); | 49 | var mylist = new Array(); |
49 | - connection.query(sqlquery,id,function(err,rows,result) { | 50 | + connection.query(sqlquery,id,function(err,rows,result){ |
50 | - if(!err) { | 51 | + if(!err){ |
51 | - mylist = rows; | 52 | + mylist=rows; |
52 | cb(mylist); | 53 | cb(mylist); |
53 | - } else { | 54 | + }else{ |
54 | router.get('/') | 55 | router.get('/') |
55 | console.log("내 웹툰 리스트 가져오는데 실패했습니다!"); | 56 | console.log("내 웹툰 리스트 가져오는데 실패했습니다!"); |
56 | //throw err; | 57 | //throw err; | ... | ... |
-
Please register or login to post a comment