Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
41b3eacf
Commit
41b3eacf
authored
Apr 17, 2015
by
陈志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
社区Log
parent
98a887e2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
88 deletions
+84
-88
forumInfo.js
app/controllers/mobile/forumInfo.js
+1
-6
forumThread.js
app/controllers/mobile/forumThread.js
+9
-6
forumPVLog.js
app/models/forumPVLog.js
+22
-20
forumUVLog.js
app/models/forumUVLog.js
+19
-17
httpService.js
app/service/httpService.js
+33
-39
No files found.
app/controllers/mobile/forumInfo.js
View file @
41b3eacf
...
...
@@ -40,13 +40,8 @@ router.post('/info/create', function(req, res, next) {
//获取目标论坛板块
router
.
get
(
'/info/:fid/get'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
||
null
;
httpService
.
createLog
(
req
,
2
,
null
);
if
(
fid
)
{
httpService
.
createLog
(
req
,
fid
,
2
);
async
.
waterfall
([
function
(
callback
)
{
//更新浏览数
...
...
app/controllers/mobile/forumThread.js
View file @
41b3eacf
...
...
@@ -108,16 +108,19 @@ router.get('/thread/:tid/get', function(req, res, next) {
},
function
(
data
,
callback
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
//文章类型 1、文章 2、话题 3、照片墙
var
info_id
=
thread
.
info
.
_id
,
pid
=
thread
.
pid
;
if
(
thread
.
type
==
1
)
{
httpService
.
createLog
(
req
,
3
,
2
,
tid
);
httpService
.
createLog
(
req
,
info_id
,
3
,
1
,
tid
);
}
else
if
(
thread
.
type
==
2
&&
thread
.
level
==
1
)
{
httpService
.
createLog
(
req
,
3
,
1
,
tid
);
httpService
.
createLog
(
req
,
info_id
,
3
,
2
,
tid
);
}
else
if
(
thread
.
type
==
2
&&
thread
.
level
==
2
)
{
httpService
.
createLog
(
req
,
3
,
4
,
tid
);
}
else
if
(
thread
.
type
==
3
)
{
httpService
.
createLog
(
req
,
3
,
3
,
tid
);
httpService
.
createLog
(
req
,
info_id
,
3
,
4
,
tid
,
pid
);
}
else
if
(
thread
.
type
==
3
&&
thread
.
level
==
1
)
{
httpService
.
createLog
(
req
,
info_id
,
3
,
3
,
tid
);
}
else
if
(
thread
.
type
==
3
&&
thread
.
level
==
2
){
httpService
.
createLog
(
req
,
info_id
,
3
,
4
,
tid
,
pid
);
}
...
...
app/models/forumPVLog.js
View file @
41b3eacf
...
...
@@ -4,49 +4,52 @@ var mongoose = require('mongoose'),
Schema
=
mongoose
.
Schema
;
//话题广场,板块
var
ForumPVLogSchema
=
new
Schema
({
ent_code
:
{
ent_code
:
{
type
:
Number
,
require
:
true
,
index
:
true
},
user
:
{
//访问者
type
:
String
,
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
},
mid
:
{
//会员ID
type
:
Number
,
require
:
true
,
index
:
true
},
forumInfo
:
{
//板块ID
type
:
String
,
index
:
true
,
ref
:
'ForumInfo'
},
forumThread
:
{
//话题、文章、照片墙的ID
type
:
String
,
index
:
true
,
ref
:
'ForumThread'
},
open_id
:
{
//微信公众号唯一识别
type
:
String
,
require
:
true
,
index
:
true
},
user
:
{
//访问者
info
:
{
//板块ID
type
:
String
,
require
:
true
,
index
:
true
,
ref
:
'Forum
User
'
ref
:
'Forum
Info
'
},
source
:
{
//分享者
type
:
String
thread
:
{
//话题、文章、照片墙的ID
type
:
String
,
index
:
true
,
ref
:
'forumThread'
},
type
:
{
//页面:1.主页 2.板块 3.文章
type
:
{
//页面:1.主页 2.板块 3.文章
type
:
Number
,
index
:
true
,
require
:
true
},
thread_type
:
{
//文章类型:1.
话题 2.文章
3.照片墙 4.子文章
thread_type
:
{
//文章类型:1.
普通文章 2.话题
3.照片墙 4.子文章
type
:
Number
,
index
:
true
},
p_thread
:
{
//父文章ID
type
:
Number
,
index
:
true
},
source
:
{
//分享者
type
:
String
},
ip
:
{
//IP地址
type
:
String
...
...
@@ -59,7 +62,6 @@ var ForumPVLogSchema = new Schema({
required
:
true
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_pv_log'
});
...
...
app/models/forumUVLog.js
View file @
41b3eacf
...
...
@@ -9,34 +9,31 @@ var ForumUVLogSchema = new Schema({
require
:
true
,
index
:
true
},
user
:
{
//访问者
type
:
String
,
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
},
mid
:
{
//会员ID
type
:
Number
,
require
:
true
,
index
:
true
},
forumInfo
:
{
//板块ID
type
:
String
,
index
:
true
,
ref
:
'ForumInfo'
},
forumThread
:
{
//话题、文章、照片墙的ID
type
:
String
,
index
:
true
,
ref
:
'forumThread'
},
open_id
:
{
//微信公众号唯一识别
type
:
String
,
require
:
true
,
index
:
true
},
user
:
{
//访问者
info
:
{
//板块ID
type
:
String
,
require
:
true
,
index
:
true
,
ref
:
'Forum
User
'
ref
:
'Forum
Info
'
},
source
:
{
//分享者
type
:
String
thread
:
{
//话题、文章、照片墙的ID
type
:
String
,
index
:
true
,
ref
:
'forumThread'
},
type
:
{
//页面:1.主页 2.板块 3.文章
type
:
Number
,
...
...
@@ -46,7 +43,13 @@ var ForumUVLogSchema = new Schema({
thread_type
:
{
//文章类型:1.话题 2.文章 3.照片墙 4.子文章
type
:
Number
,
index
:
true
},
p_thread
:
{
//父文章ID
type
:
Number
,
index
:
true
},
source
:
{
//分享者
type
:
String
},
ip
:
{
//IP地址
type
:
String
...
...
@@ -59,7 +62,6 @@ var ForumUVLogSchema = new Schema({
required
:
true
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_uv_log'
});
...
...
app/service/httpService.js
View file @
41b3eacf
...
...
@@ -49,53 +49,47 @@ var getClientIP = function(req) {
return
ipAddress
;
};
exports
.
createLog
=
function
(
req
,
type
,
thread_type
,
i
d
)
{
exports
.
createLog
=
function
(
req
,
info
,
type
,
thread_type
,
thread
,
p_threa
d
)
{
var
ip
=
getClientIP
(
req
);
var
userAgent
=
req
.
headers
[
'user-agent'
];
var
log
=
{
var
logObj
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
mid
:
req
.
session
.
openUser
.
mid
,
forumInfo
:
id
,
open_id
:
req
.
session
.
mobileForumUser
.
openId
,
user
:
req
.
session
.
mobileForumUser
.
userId
,
info
:
info
,
type
:
type
,
thread_type
:
thread_type
,
ip
:
ip
,
userAgent
:
userAgent
thread_type
:
thread_type
,
thread
:
thread
,
p_thread
:
p_thread
,
ip
:
getClientIP
(
req
),
userAgent
:
req
.
headers
[
'user-agent'
]
};
if
(
log
)
{
var
forumPVLog
=
new
ForumPVLog
(
log
);
var
forumUVLog
=
new
ForumUVLog
(
log
);
forumPVLog
.
save
(
function
(
err
,
pv
)
{
if
(
err
)
{
console
.
error
(
err
);
}
else
{
var
nowTime
=
moment
(
new
Date
()).
format
(
'YYYY-MM-DD'
);
var
startTime
=
nowTime
+
" 00:00:00"
;
var
entTime
=
nowTime
+
" 23:59:59"
;
var
q
=
{
created
:
{
'$gte'
:
startTime
,
'$lte'
:
entTime
},
user
:
log
.
fid
};
ForumUVLog
.
find
(
q
,
function
(
err
,
uv
)
{
if
(
err
)
{
console
.
error
(
err
);
}
else
if
(
uv
.
length
==
0
)
{
forumUVLog
.
save
(
function
(
err
,
uv
)
{
if
(
err
)
{
console
.
error
(
err
);
}
});
}
});
if
(
logObj
)
{
then
(
function
(
cont
){
var
pv_model
=
new
ForumPVLog
(
logObj
);
pv_model
.
save
(
cont
);
}).
then
(
function
(
cont
){
var
q
=
{
created
:{
$gte
:
moment
(
new
Date
()).
format
(
'YYYY-MM-DD'
)},
mid
:
logObj
.
mid
,
openId
:
logObj
.
openId
,
user
:
logObj
.
user
,
info
:
logObj
.
info
};
if
(
logObj
.
thread
){
q
.
thread
=
logObj
.
thread
;
q
.
thread_type
=
logObj
.
thread_tyep
;
}
ForumUVLog
.
find
(
q
,
function
(
err
,
doc
){
cont
(
err
,
doc
?
false
:
true
);
})
}).
then
(
function
(
cont
,
isLog
){
if
(
isLog
){
var
uv_model
=
new
ForumUVLog
(
log
);
uv_model
.
save
();
}
}).
fail
(
function
(
cont
,
err
){
console
.
error
(
err
);
});
}
else
{
console
.
error
(
'没有日志信息'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment