윤혜원

DB에 user, toon 정보 INSERT 성공!

......@@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/YTMT" vcs="Git" />
</component>
</project>
\ No newline at end of file
......
......@@ -2,8 +2,11 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="ffe1a490-8fdb-4611-8537-4d1c03c40b8d" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/app.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/routes/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/routes/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/routes/mytoons.js" beforeDir="false" afterPath="$PROJECT_DIR$/routes/mytoons.js" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/out/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
......@@ -102,41 +105,70 @@
</counts>
</usages-collector>
</session>
<session id="-66201460">
<usages-collector id="statistics.lifecycle.project">
<counts>
<entry key="project.closed" value="1" />
<entry key="project.open.time.10" value="1" />
<entry key="project.opened" value="1" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="js" value="2" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="JavaScript" value="2" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="js" value="868" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="JavaScript" value="868" />
</counts>
</usages-collector>
</session>
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/routes/mytoons.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1349">
<caret line="71" column="24" selection-start-line="71" selection-start-column="24" selection-end-line="71" selection-end-column="24" />
<state relative-caret-position="141">
<caret line="54" column="36" selection-start-line="54" selection-start-column="36" selection-end-line="54" selection-end-column="36" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/routes/setting.js">
<entry file="file://$PROJECT_DIR$/routes/toonviewer.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="247">
<caret line="13" column="11" selection-start-line="13" selection-start-column="11" selection-end-line="13" selection-end-column="11" />
<state>
<caret lean-forward="true" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/routes/index.js">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/routes/setting.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="19">
<caret line="188" lean-forward="true" selection-start-line="188" selection-end-line="188" />
<state>
<caret lean-forward="true" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/views/index.ejs">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/routes/index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="399">
<caret line="21" column="15" lean-forward="true" selection-start-line="21" selection-start-column="15" selection-end-line="21" selection-end-column="15" />
<state relative-caret-position="583">
<caret line="336" lean-forward="true" selection-start-line="336" selection-end-line="336" />
</state>
</provider>
</entry>
......@@ -144,8 +176,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1425">
<caret line="75" column="16" lean-forward="true" selection-start-line="75" selection-start-column="16" selection-end-line="75" selection-end-column="16" />
<state relative-caret-position="397">
<caret line="32" lean-forward="true" selection-start-line="32" selection-end-line="32" />
</state>
</provider>
</entry>
......@@ -162,8 +194,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>mytoon</find>
<find>list</find>
<find>authen</find>
<find>connection.</find>
<find>connection.end</find>
......@@ -178,7 +208,6 @@
<find>query</find>
<find>br</find>
<find>kakao</find>
<find>로그인</find>
<find>get</find>
<find>serialized</find>
<find>쿼리</find>
......@@ -190,6 +219,11 @@
<find>connec</find>
<find>connection</find>
<find>로그인 쿼리</find>
<find>sql</find>
<find>loginByThirdparty</find>
<find>de</find>
<find>로그인</find>
<find>console.log(</find>
</findStrings>
<dirStrings>
<dir>$PROJECT_DIR$/views</dir>
......@@ -227,15 +261,15 @@
<option value="$PROJECT_DIR$/views/toonviewer.html" />
<option value="$PROJECT_DIR$/views/toonviewer.ejs" />
<option value="$PROJECT_DIR$/node_modules/phantomjs/lib/phantom/examples/module.js" />
<option value="$PROJECT_DIR$/routes/mytoons.js" />
<option value="$PROJECT_DIR$/routes/setting.js" />
<option value="$PROJECT_DIR$/routes/toonviewer.js" />
<option value="$PROJECT_DIR$/views/mytoons.ejs" />
<option value="$PROJECT_DIR$/views/daum" />
<option value="$PROJECT_DIR$/views/daum.ejs" />
<option value="$PROJECT_DIR$/views/index.ejs" />
<option value="$PROJECT_DIR$/app.js" />
<option value="$PROJECT_DIR$/routes/daum.js" />
<option value="$PROJECT_DIR$/app.js" />
<option value="$PROJECT_DIR$/routes/mytoons.js" />
<option value="$PROJECT_DIR$/routes/index.js" />
</list>
</option>
......@@ -257,9 +291,9 @@
</packageJsonPaths>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-9" />
<option name="width" value="978" />
<option name="height" value="1039" />
<option name="x" value="-8" />
<option name="width" value="977" />
<option name="height" value="1038" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
......@@ -267,6 +301,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
......@@ -282,17 +317,6 @@
<path>
<item name="YTMT" type="b2602c69:ProjectViewProjectNode" />
<item name="YTMT" type="462c0819:PsiDirectoryNode" />
<item name="public" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="YTMT" type="b2602c69:ProjectViewProjectNode" />
<item name="YTMT" type="462c0819:PsiDirectoryNode" />
<item name="public" type="462c0819:PsiDirectoryNode" />
<item name="stylesheets" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="YTMT" type="b2602c69:ProjectViewProjectNode" />
<item name="YTMT" type="462c0819:PsiDirectoryNode" />
<item name="routes" type="462c0819:PsiDirectoryNode" />
</path>
<path>
......@@ -304,7 +328,6 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="AndroidView" />
<pane id="PackagesPane" />
</panes>
......@@ -463,6 +486,7 @@
<workItem from="1543487409434" duration="1283000" />
<workItem from="1543489136305" duration="5743000" />
<workItem from="1543495038044" duration="387000" />
<workItem from="1543588884449" duration="7362000" />
</task>
<task id="LOCAL-00001" summary="초기 commit by intellij">
<created>1512174269218</created>
......@@ -482,7 +506,7 @@
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="219277000" />
<option name="totallyTimeSpent" value="226639000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
......@@ -495,7 +519,6 @@
</component>
<component name="ToolWindowManager">
<frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
<editor active="true" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.48880598" visible="true" weight="0.16523464" />
<window_info id="Structure" order="1" weight="0.24964234" />
......@@ -656,83 +679,90 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/toonviewer.ejs">
<entry file="file://$PROJECT_DIR$/views/daum" />
<entry file="file://$PROJECT_DIR$/routes/users.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="247">
<caret line="13" column="3" lean-forward="true" selection-start-line="13" selection-start-column="3" selection-end-line="13" selection-end-column="3" />
<state relative-caret-position="133">
<caret line="7" lean-forward="true" selection-start-line="7" selection-end-line="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/daum.ejs" />
<entry file="file://$PROJECT_DIR$/routes/daum.js" />
<entry file="file://$PROJECT_DIR$/views/setting.ejs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="27">
<caret line="16" column="21" lean-forward="true" selection-start-line="16" selection-start-column="21" selection-end-line="16" selection-end-column="21" />
<state>
<caret lean-forward="true" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/error.ejs">
<entry file="file://$PROJECT_DIR$/views/toonviewer.ejs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="57">
<caret line="3" lean-forward="true" selection-start-line="3" selection-end-line="3" />
<state relative-caret-position="247">
<caret line="13" column="3" selection-start-line="13" selection-start-column="3" selection-end-line="13" selection-end-column="3" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/mytoons.ejs">
<entry file="file://$PROJECT_DIR$/views/index.ejs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="513">
<caret line="27" column="11" lean-forward="true" selection-start-line="27" selection-start-column="11" selection-end-line="27" selection-end-column="11" />
<state relative-caret-position="399">
<caret line="21" column="8" selection-start-line="21" selection-start-column="8" selection-end-line="21" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/routes/toonviewer.js">
<entry file="file://$PROJECT_DIR$/views/mytoons.ejs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-418">
<caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
<state relative-caret-position="616">
<caret line="56" lean-forward="true" selection-start-line="56" selection-end-line="56" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/daum" />
<entry file="file://$PROJECT_DIR$/routes/users.js">
<entry file="file://$PROJECT_DIR$/views/error.ejs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="133">
<caret line="7" lean-forward="true" selection-start-line="7" selection-end-line="7" />
<state relative-caret-position="57">
<caret line="3" selection-start-line="3" selection-end-line="3" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/daum.ejs" />
<entry file="file://$PROJECT_DIR$/routes/daum.js" />
<entry file="file://$PROJECT_DIR$/routes/mytoons.js">
<entry file="file://$PROJECT_DIR$/routes/toonviewer.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1349">
<caret line="71" column="24" selection-start-line="71" selection-start-column="24" selection-end-line="71" selection-end-column="24" />
<state>
<caret lean-forward="true" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/routes/setting.js">
<entry file="file://$USER_HOME$/Desktop/YTMT-master-f6ba581c2d39966c105a13a31a3246237b655d48/YTMT-master-f6ba581c2d39966c105a13a31a3246237b655d48/app.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="247">
<caret line="13" column="11" selection-start-line="13" selection-start-column="11" selection-end-line="13" selection-end-column="11" />
<state>
<caret lean-forward="true" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/index.ejs">
<entry file="file://$PROJECT_DIR$/routes/mytoons.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="399">
<caret line="21" column="15" lean-forward="true" selection-start-line="21" selection-start-column="15" selection-end-line="21" selection-end-column="15" />
<state relative-caret-position="141">
<caret line="54" column="36" selection-start-line="54" selection-start-column="36" selection-end-line="54" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1425">
<caret line="75" column="16" lean-forward="true" selection-start-line="75" selection-start-column="16" selection-end-line="75" selection-end-column="16" />
<state relative-caret-position="397">
<caret line="32" lean-forward="true" selection-start-line="32" selection-end-line="32" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/routes/setting.js">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret lean-forward="true" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/routes/index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="19">
<caret line="188" lean-forward="true" selection-start-line="188" selection-end-line="188" />
<state relative-caret-position="583">
<caret line="336" lean-forward="true" selection-start-line="336" selection-end-line="336" />
</state>
</provider>
</entry>
......
......@@ -15,9 +15,7 @@ var setting = require('./routes/setting');
var session = require('express-session');
var toonviewer = require('./routes/toonviewer');
//port
passport.serializeUser(function(user, done) {
console.log('serialized');
done(null, user);
......@@ -44,7 +42,7 @@ app.use(express.static(path.join(__dirname, 'public')));
connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'hs970010!',
password : 'password',
port : 3306,
database : 'ytmt'
});
......@@ -62,8 +60,6 @@ app.use('/users', users);
app.use('/mytoons', mytoons);
app.use('/setting', setting);
app.use('/toonviewer', toonviewer);
//app.use('/daum', daum);
//app.use(express.static('views'));
// catch 404 and forward to error handler
......
......@@ -9,8 +9,8 @@ var passport = require('passport'),
passport.use(new KakaoStrategy({
clientID : 'bd2e610396fb7bbb84cf91a786b3cc72',
callbackURL :'/auth/login/kakao/callback'
// clientSecret : 'eUtJGtlLoCZJufevp3LKfDP0KOtZUV7R'
callbackURL :'/auth/login/kakao/callback',
clientSecret : 'eUtJGtlLoCZJufevp3LKfDP0KOtZUV7R'
},
function(accessToken, refreshToken,params, profile, done){
//사용자 정보는 profile에
......@@ -41,8 +41,11 @@ router.get('/auth/login/kakao/callback',
);
function loginByThirdparty(accessToken, refreshToken, profile) {
var stmt_duplicated = 'INSERT INTO user(id) VALUES(?) ON DUPLICATE KEY UPDATE id=?;'
connection.query(stmt_duplicated, [profile._json.id] , function (err, result) {
//예전 코드는 MySQL 버젼이 맞지 않음
// var sql = 'INSERT INTO `user`(id) VALUES(?) ON DUPLICATE KEY(PRIMARY) UPDATE id=(?);'
var sql = "INSERT INTO `user` (id) VALUES (?) ON DUPLICATE KEY UPDATE id=id";
var kid=[profile._json.id];
connection.query(sql,kid,function(err,result){
if (err) {
console.log("로그인 쿼리중 에러 : " + err);
} else {
......@@ -59,7 +62,7 @@ router.get('/auth/logout/kakao',function (req,res) {
allWebtoons = new Array();
function getLatestToon(titleid, day ,cb) {
var url = "http://comic.naver.com/webtoon/list.nhn?titleId=" + titleid+ "&weekday="+day;
/*var url = "http://comic.naver.com/webtoon/list.nhn?titleId=" + titleid+ "&weekday="+day;
console.log(url);
request(url, function (err, res, html) {
if (!err) {
......@@ -88,7 +91,7 @@ function getLatestToon(titleid, day ,cb) {
console.log("최신화 못가져왔습니다.");
//throw err;
}
});
});*/
}
function getAllToons() {
......@@ -150,7 +153,7 @@ function getAllToons() {
var list = data["data"];
list.forEach(function(item, idx){
console.log(item.id + ' ' + item.title + ' ' + wed);
var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString();
var webtoon= {
toon_index: item.id,
......@@ -279,23 +282,30 @@ function getAllToons() {
site : site,
latest : 0
};
allWebtoonList.push(webtoon);
});
p.then(function() {
i = 0;
allWebtoonList.forEach(function (webtoon) {
getLatestToon(webtoon.toon_index, webtoon.week, function (latest_toon) {
webtoon.latest = latest_toon.latest;
console.log(i + " = " + webtoon.name + " : " + webtoon.latest)
i++;
connection.query("INSERT INTO toon SET ? ON DUPLICATE KEY UPDATE latest=?",
[webtoon,webtoon.latest], function () {
if(err){
console.log("웹툰 갱신중 에러!");
// getLatestToon(webtoon.toon_index, webtoon.week, function (latest_toon) {
// webtoon.latest = latest_toon.latest;
//i++;
//console.log(i + " = " + webtoon.name + " : " + webtoon.latest);
var sql= "INSERT INTO `toon` (toon_index, name, thum_link, webtoon_link, week, site, latest) VALUES(?) ON DUPLICATE KEY UPDATE latest=latest";
var values=[webtoon.toon_index, webtoon.name, webtoon.thum_link, webtoon.webtoon_link,webtoon.week, webtoon.site, webtoon.latest];
connection.query(sql,[values],function(err,result){
if (err) {
console.log("웹툰 DB 에러 : " + err);
} else {
console.log("웹툰 DB처리 완료!");
}
//[webtoon,webtoon.latest], function () {
// if (err) {
// console.log("웹툰 갱신중 에러!");
//}
// }
});
});
//});
})
});
}
......
......@@ -33,7 +33,11 @@ function getUpdatedToons(cb){
}
function getMyToons(id,cb){
var sqlquery = 'SELECT name, thum_link, webtoon_link, week, last, latest, t.toon_index AS toon_index FROM user u, user_toon_relation ur, toon t WHERE u.id=? && u.id=ur.user_id && t.toon_index=ur.toon_index;';
//var sql = "INSERT INTO `user` (id) VALUES (?)";
//var kid=[profile._json.id];
//connection.query(sql,kid,function(err,result){
var sqlquery = "SELECT name, thum_link, webtoon_link, week, last, t.toon_index AS toon_index FROM user u, user_toon_relation ur, toon t WHERE u.id=? && u.id=ur.user_id && t.toon_index=ur.toon_index;";
//var sqlquery = "SELECT name, thum_link, webtoon_link, week, last, latest, t.toon_index AS toon_index FROM user u, user_toon_relation ur, toon t WHERE u.id=? && u.id=ur.user_id && t.toon_index=ur.toon_index;";
var mylist = new Array();
connection.query(sqlquery,id,function(err,rows,result){
if(!err){
......