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
98a887e2
Commit
98a887e2
authored
Apr 17, 2015
by
邓军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化LOG接口
parent
8cd71c2a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
85 deletions
+47
-85
forumInfo.js
app/controllers/mobile/forumInfo.js
+3
-38
forumThread.js
app/controllers/mobile/forumThread.js
+8
-39
httpService.js
app/service/httpService.js
+36
-8
No files found.
app/controllers/mobile/forumInfo.js
View file @
98a887e2
...
@@ -41,44 +41,9 @@ router.post('/info/create', function(req, res, next) {
...
@@ -41,44 +41,9 @@ router.post('/info/create', function(req, res, next) {
router
.
get
(
'/info/:fid/get'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/info/:fid/get'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
||
null
;
var
fid
=
req
.
params
.
fid
||
null
;
//模拟数据
/*req.session.user.ent_code = 100001;
req.session.openUser = {};
httpService
.
createLog
(
req
,
2
,
null
);
req.session.openUser.mid=1;
req.session.mobileForumUser = {
openId: '54c9e321d5037010b44d4b1f',
userId: '54c9e321d5037010b44d4b1f'
};*/
var
ip
=
''
;
var
userAgent
=
''
;
var
getClientIP
=
function
(
req
)
{
var
ipAddress
;
var
headers
=
req
.
headers
;
var
forwardedIpsStr
=
headers
[
'x-real-ip'
]
||
headers
[
'x-forwarded-for'
];
if
(
forwardedIpsStr
)
{
ipAddress
=
forwardedIpsStr
;
}
else
{
ipAddress
=
null
;
}
if
(
!
ipAddress
)
{
ipAddress
=
req
.
connection
.
remoteAddress
;
}
return
ipAddress
;
};
ip
=
getClientIP
(
req
);
userAgent
=
req
.
headers
[
'user-agent'
];
var
log
=
{
ent_code
:
req
.
session
.
user
,
mid
:
req
.
session
.
openUser
.
mid
,
forumInfo
:
fid
,
open_id
:
req
.
session
.
mobileForumUser
.
openId
,
user
:
req
.
session
.
mobileForumUser
.
userId
,
type
:
2
,
ip
:
ip
,
userAgent
:
userAgent
};
httpService
.
createLog
(
log
);
if
(
fid
)
{
if
(
fid
)
{
...
...
app/controllers/mobile/forumThread.js
View file @
98a887e2
...
@@ -108,50 +108,19 @@ router.get('/thread/:tid/get', function(req, res, next) {
...
@@ -108,50 +108,19 @@ router.get('/thread/:tid/get', function(req, res, next) {
},
},
function
(
data
,
callback
)
{
function
(
data
,
callback
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
var
ip
=
''
;
var
userAgent
=
''
;
//文章类型 1、文章 2、话题 3、照片墙
var
getClientIP
=
function
(
req
)
{
var
ipAddress
;
var
headers
=
req
.
headers
;
var
forwardedIpsStr
=
headers
[
'x-real-ip'
]
||
headers
[
'x-forwarded-for'
];
if
(
forwardedIpsStr
)
{
ipAddress
=
forwardedIpsStr
;
}
else
{
ipAddress
=
null
;
}
if
(
!
ipAddress
)
{
ipAddress
=
req
.
connection
.
remoteAddress
;
}
return
ipAddress
;
};
ip
=
getClientIP
(
req
);
userAgent
=
req
.
headers
[
'user-agent'
];
var
log
=
{
ent_code
:
req
.
session
.
user
,
mid
:
req
.
session
.
openUser
.
mid
,
forumInfo
:
tid
,
open_id
:
req
.
session
.
mobileForumUser
.
openId
,
user
:
req
.
session
.
mobileForumUser
.
userId
,
type
:
3
,
thread_type
:
2
,
ip
:
ip
,
userAgent
:
userAgent
};
if
(
thread
.
type
==
1
)
{
if
(
thread
.
type
==
1
)
{
log
.
thread_type
=
2
;
httpService
.
createLog
(
req
,
3
,
2
,
tid
);
httpService
.
createLog
(
log
);
}
else
if
(
thread
.
type
==
2
&&
thread
.
level
==
1
)
{
}
else
if
(
thread
.
type
==
2
&&
thread
.
level
==
1
)
{
log
.
thread_type
=
1
;
httpService
.
createLog
(
req
,
3
,
1
,
tid
);
httpService
.
createLog
(
log
);
}
else
if
(
thread
.
type
==
2
&&
thread
.
level
==
2
)
{
}
else
if
(
thread
.
type
==
2
&&
thread
.
level
==
2
)
{
log
.
thread_type
=
4
;
httpService
.
createLog
(
req
,
3
,
4
,
tid
);
httpService
.
createLog
(
log
);
}
else
if
(
thread
.
type
==
3
)
{
}
else
if
(
thread
.
type
==
3
)
{
log
.
thread_type
=
3
;
httpService
.
createLog
(
req
,
3
,
3
,
tid
);
httpService
.
createLog
(
log
);
}
}
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
...
...
app/service/httpService.js
View file @
98a887e2
...
@@ -34,8 +34,37 @@ exports.sendRequest = function(ent_code, mid, action, messageid, integral, exp)
...
@@ -34,8 +34,37 @@ exports.sendRequest = function(ent_code, mid, action, messageid, integral, exp)
}
}
});
});
};
};
var
getClientIP
=
function
(
req
)
{
var
ipAddress
;
var
headers
=
req
.
headers
;
var
forwardedIpsStr
=
headers
[
'x-real-ip'
]
||
headers
[
'x-forwarded-for'
];
if
(
forwardedIpsStr
)
{
ipAddress
=
forwardedIpsStr
;
}
else
{
ipAddress
=
null
;
}
if
(
!
ipAddress
)
{
ipAddress
=
req
.
connection
.
remoteAddress
;
}
return
ipAddress
;
};
exports
.
createLog
=
function
(
log
)
{
exports
.
createLog
=
function
(
req
,
type
,
thread_type
,
id
)
{
var
ip
=
getClientIP
(
req
);
var
userAgent
=
req
.
headers
[
'user-agent'
];
var
log
=
{
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
,
type
:
type
,
thread_type
:
thread_type
,
ip
:
ip
,
userAgent
:
userAgent
};
if
(
log
)
{
if
(
log
)
{
var
forumPVLog
=
new
ForumPVLog
(
log
);
var
forumPVLog
=
new
ForumPVLog
(
log
);
var
forumUVLog
=
new
ForumUVLog
(
log
);
var
forumUVLog
=
new
ForumUVLog
(
log
);
...
@@ -52,17 +81,16 @@ exports.createLog = function(log) {
...
@@ -52,17 +81,16 @@ exports.createLog = function(log) {
'$gte'
:
startTime
,
'$gte'
:
startTime
,
'$lte'
:
entTime
'$lte'
:
entTime
},
},
user
:
log
.
fid
user
:
log
.
fid
};
};
ForumUVLog
.
find
(
q
,
function
(
err
,
uv
)
{
ForumUVLog
.
find
(
q
,
function
(
err
,
uv
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
}
else
if
(
uv
.
length
==
0
)
{
}
else
if
(
uv
.
length
==
0
)
{
console
.
log
(
ForumUVLog
);
forumUVLog
.
save
(
function
(
err
,
uv
)
{
forumUVLog
.
save
(
function
(
err
,
uv
){
if
(
err
)
{
if
(
err
){
console
.
error
(
err
);
console
.
error
(
err
);
}
}
});
});
}
}
});
});
...
...
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