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
e3456dc4
Commit
e3456dc4
authored
Apr 24, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development
parents
6a5fdb67
454540ef
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
267 additions
and
236 deletions
+267
-236
forumThread.js
app/controllers/admin/forumThread.js
+21
-22
forumShare.js
app/controllers/mobile/forumShare.js
+133
-172
forumThread.js
app/controllers/mobile/forumThread.js
+5
-3
forumShareLog.js
app/models/forumShareLog.js
+66
-30
forumThreadService.js
app/service/forumThreadService.js
+4
-2
httpService.js
app/service/httpService.js
+24
-3
user.js
app/utils/user.js
+14
-4
No files found.
app/controllers/admin/forumThread.js
View file @
e3456dc4
...
...
@@ -81,9 +81,7 @@ router.post('/thread/create', function(req, res, next) {
}
});
}
});
}
}
});
}
}
});
});
...
...
@@ -212,6 +210,7 @@ router.get('/threads/list', function(req, res, next) {
var
infoId
=
req
.
query
.
infoId
;
var
tagId
=
req
.
query
.
tagId
;
var
pid
=
req
.
query
.
pid
;
var
content
=
req
.
query
.
content
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
level
:
1
...
...
@@ -230,6 +229,13 @@ router.get('/threads/list', function(req, res, next) {
conditions
.
level
=
2
;
}
if
(
content
){
conditions
.
content
=
{
$regex
:
content
,
$options
:
'i'
}
}
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -357,30 +363,23 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
var
cid
=
req
.
params
.
cid
||
null
;
var
replayComment_id
=
req
.
body
.
replayComment_id
;
// 获取评论的子评论列表
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
// 更新文章评论 + 1
forumThreadService
.
updateThreadCommentCountInc
(
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
callback
(
err
,
null
);
console
.
error
(
err
);
}
});
// 更新评论对象
result
.
comments
.
push
(
replayComment_id
);
// 添加子评论ID
// result.comment_count+=1; // 回复评论+1
forumCommentService
.
updateCommentById
(
cid
,
result
,
function
(
err
,
result
)
{
forumCommentService
.
updateCommentById
(
cid
,
{
$push
:{
comments
:
replayComment_id
},
$inc
:{
comment_count
:
1
}},
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
});
// 更新评论的子评论列表
...
...
app/controllers/mobile/forumShare.js
View file @
e3456dc4
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
_
=
require
(
'lodash'
),
then
=
require
(
'thenjs'
),
mongoose
=
require
(
'mongoose'
);
var
mongoose
=
require
(
'mongoose'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
forumShareConfigService
=
require
(
'../../service/forumShareConfigService'
);
var
forumShareService
=
require
(
'../../service/forumShareService'
);
var
config
=
require
(
'../../../config/config'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
then
=
require
(
'thenjs'
);
var
forumInfoService
=
require
(
'../../service/forumInfoService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
),
returnCode
=
require
(
'../../utils/returnCode'
),
forumShareConfigService
=
require
(
'../../service/forumShareConfigService'
),
forumShareService
=
require
(
'../../service/forumShareService'
),
config
=
require
(
'../../../config/config'
),
httpService
=
require
(
'../../service/httpService'
),
forumInfoService
=
require
(
'../../service/forumInfoService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
...
...
@@ -24,19 +24,17 @@ function write(res, title, desc, link, imgUrl, mid, ent_code) {
'Cache-Control'
:
'no-cache'
,
'Pragma'
:
'no-cache'
});
// result.debug = 'true' === isDebug ? true : false;
// result.jsApiList = jsApiList;
res
.
write
(
'$(function(){'
);
// var title = type+'类型分享',
// link = 'http://sandbox.wxpai.cn/app/aubywx/100041',
// imgUrl = 'http://dev.fs.wxpai.cn/upload/100001_2015410_1428671539587_40.jpg',
// desc = '测试描述';
// var string = '';
var
success
=
'$.ajax({'
+
var
success_singlemessage
=
'$.ajax({'
+
'type:
\'
GET
\'
,'
+
'url:
\'
/v1/forum/'
+
ent_code
+
'/timelin
e
\'
'
+
'url:
\'
/v1/forum/'
+
ent_code
+
'/share/singlemessag
e
\'
'
+
'});'
;
var
string
=
'wx.onMenuShareTimeline({'
+
'
\
"title
\
":
\
"'
+
title
+
'
\
",'
+
'
\
"link
\
":
\
"'
+
link
+
'
\
",'
+
'
\
"imgUrl
\
":
\
"'
+
imgUrl
+
'
\
", '
+
'success: function(){'
+
success
+
'},'
+
'cancel: function () {}'
+
' });'
+
' wx.onMenuShareAppMessage({'
+
'
\
"title
\
":
\
"'
+
title
+
'
\
", '
+
'
\
"desc
\
":
\
"'
+
desc
+
'
\
", '
+
'
\
"link
\
":
\
"'
+
link
+
'
\
", '
+
'
\
"imgUrl
\
":
\
"'
+
imgUrl
+
'
\
", '
+
'
\
"type
\
":
\'\'
,'
+
'
\
"dataUrl
\
":
\'\'
, '
+
'success: function(){},'
+
'cancel: function () { '
+
'}'
+
' });'
var
success_timeline
=
'$.ajax({'
+
'type:
\'
GET
\'
,'
+
'url:
\'
/v1/forum/'
+
ent_code
+
'/share/timeline
\'
'
+
'});'
;
var
string
=
'wx.onMenuShareTimeline({'
+
'
\
"title
\
":
\
"'
+
title
+
'
\
",'
+
'
\
"link
\
":
\
"'
+
link
+
'
\
",'
+
'
\
"imgUrl
\
":
\
"'
+
imgUrl
+
'
\
", '
+
'success: function(){'
+
success_timeline
+
'},'
+
'cancel: function () {}'
+
' });'
+
' wx.onMenuShareAppMessage({'
+
'
\
"title
\
":
\
"'
+
title
+
'
\
", '
+
'
\
"desc
\
":
\
"'
+
desc
+
'
\
", '
+
'
\
"link
\
":
\
"'
+
link
+
'
\
", '
+
'
\
"imgUrl
\
":
\
"'
+
imgUrl
+
'
\
", '
+
'
\
"type
\
":
\'\'
,'
+
'
\
"dataUrl
\
":
\'\'
, '
+
'success: function(){'
+
success_singlemessage
+
'},'
+
'cancel: function () { '
+
'}'
+
' });'
res
.
write
(
'wx.ready(function(){'
+
string
+
'});'
);
res
.
write
(
'wx.error(function(res){console.log(res);});'
);
...
...
@@ -73,179 +71,142 @@ function getWX(res, title, desc, link, imgUrl, mid,ent_code, id,type,forumThread
}
}
//微信分享接口
router
.
get
(
'/:ent_code/share.js'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
var
type
=
req
.
query
.
type
;
var
id
=
req
.
query
.
id
;
var
uId
=
req
.
session
.
mobileForumUser
.
userId
;
var
mid
=
0
;
var
rs
=
{},
type
=
req
.
query
.
type
,
id
=
req
.
query
.
id
,
uId
=
req
.
session
.
mobileForumUser
.
userId
,
ent_code
=
req
.
session
.
user
.
ent_code
,
mid
=
0
,
link
=
'/app/forum/'
+
ent_code
+
'/index?pageUrl='
,
share_log
=
{};
if
(
req
.
session
.
openUser
&&
req
.
session
.
openUser
.
mid
)
{
mid
=
req
.
session
.
openUser
.
mid
;
}
var
ent_code
=
req
.
params
.
ent_code
;
var
link
=
'/app/forum/'
+
ent_code
+
'/index?pageUrl='
;
if
(
type
)
{
delete
req
.
session
.
mobileForumUser
.
share_log
;
//板块微信接口
if
(
type
===
'Info'
)
{
then
(
function
(
cont
)
{
if
(
!
type
||
!
id
){
console
.
error
(
'请求参数错误'
)
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
WRONG_PARAM
));
}
else
if
(
type
===
'Info'
)
{
//分享记录对象
share_log
.
type
=
2
;
share_log
.
info
=
id
;
//查询板块默认分享设置
forumShareConfigService
.
getByKey
(
ent_code
,
'share'
,
function
(
err
,
result
)
{
var
title
=
''
,
desc
=
''
,
imgUrl
=
''
;
if
(
err
){
console
.
error
(
err
);
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
BUSY
));
}
else
{
var
title
=
''
,
desc
=
''
,
imgUrl
=
''
;
if
(
result
)
{
//匹配板块默认分享设置
result
=
result
.
meta_value
;
for
(
var
i
=
0
;
i
<
result
.
length
;
i
++
)
{
if
(
result
[
i
]
.
type
===
'info'
)
{
title
=
result
[
i
]
.
title
;
desc
=
result
[
i
]
.
desc
;
imgUrl
=
result
[
i
]
.
imgUrl
;
}
_
.
forEach
(
result
,
function
(
e
)
{
if
(
e
.
type
===
'info'
)
{
title
=
e
.
title
;
desc
=
e
.
desc
;
imgUrl
=
e
.
imgUrl
;
return
;
}
if
(
id
)
{
link
=
link
+
'index&infoId='
+
id
;
}
else
{
link
=
link
+
'index'
;
}
link
=
link
+
'&uId='
+
uId
;
});
link
=
link
+
'index&infoId='
+
id
+
'&uId='
+
uId
;
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
id
,
type
,
null
);
}
else
{
cont
(
err
);
}
else
{
//没找到板块默认分享设置
console
.
error
(
'info默认分享设置不存在'
);
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
DATA_NOTEXITS
));
}
}
});
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
res
.
json
({
result
:
false
,
code
:
'10002'
});
});
}
else
if
(
!
id
)
{
console
.
error
(
"ID不能为空"
);
res
.
json
({
message
:
'ID不能为空'
,
result
:
false
,
code
:
'10002'
});
}
else
if
(
type
===
'Thread'
)
{
}
else
if
(
type
===
'Thread'
)
{
share_log
.
type
=
3
;
share_log
.
thread
=
id
;
then
(
function
(
cont
)
{
//获得文章
forumThreadService
.
getById
(
id
,
function
(
err
,
result
)
{
if
(
result
)
{
cont
(
null
,
result
);
}
else
{
cont
(
err
);
forumThreadService
.
getById
(
id
,
cont
);
}).
then
(
function
(
cont
,
thread
)
{
if
(
!
thread
){
//文章个性化分享设置不存在
console
.
error
(
'分享文章不存在'
);
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
DATA_NOTEXITS
));
}
else
{
share_log
.
p_thread
=
thread
.
pid
;
share_log
.
info
=
thread
.
info
;
share_log
.
thread_type
=
thread
.
pid
?
4
:
thread
.
type
;
//组装分享路径与判断分享类型
//判断分享类型 1、文章 2、话题 3、照片墙
var
share_type
=
''
;
if
(
thread
.
type
===
1
||
(
thread
.
type
===
2
&&
thread
.
level
===
2
))
{
link
=
link
+
'thread&infoId='
+
thread
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
thread
.
_id
;
share_type
=
'article'
;
}
else
if
(
thread
.
type
===
2
&&
thread
.
level
===
1
)
{
link
=
link
+
'topicList&infoId='
+
thread
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
thread
.
_id
;
share_type
=
'topic'
;
}
else
if
(
thread
.
type
===
3
)
{
link
=
link
+
'photoList&infoId='
+
thread
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
thread
.
_id
;
share_type
=
'photo'
;
}
});
}).
then
(
function
(
cont
,
result
)
{
//如果没有share值则用默认值
if
(
!
result
.
share
||
result
.
share_type
==
2
)
{
link
=
link
+
'&uId='
+
uId
;
//获取分享设置
if
(
!
thread
.
share
||
thread
.
share_type
==
2
)
{
//获取默认文章分享设置
forumShareConfigService
.
getByKey
(
ent_code
,
'share'
,
function
(
err
,
sc
)
{
var
title
=
''
,
desc
=
''
,
imgUrl
=
''
;
if
(
sc
)
{
if
(
result
.
type
===
1
||
(
result
.
type
===
2
&&
result
.
level
===
2
))
{
link
=
link
+
'thread&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
}
else
if
(
result
.
type
===
2
&&
result
.
level
===
1
)
{
link
=
link
+
'topicList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
}
else
if
(
result
.
type
===
3
)
{
link
=
link
+
'photoList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
}
//1、文章 2、话题 3、照片墙
var
title
=
''
,
desc
=
''
,
imgUrl
=
''
;
if
(
err
||
!
sc
){
cont
(
err
||
share_type
+
'默认分享设置不存在'
);
}
else
{
sc
=
sc
.
meta_value
;
for
(
var
i
=
0
;
i
<
sc
.
length
;
i
++
)
{
if
(
result
.
type
===
1
||
(
result
.
type
===
2
&&
result
.
level
===
2
))
{
if
(
sc
[
i
].
type
===
'article'
)
{
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
imgUrl
=
sc
[
i
].
imgUrl
;
}
}
else
if
(
result
.
type
===
2
&&
result
.
level
===
1
)
{
if
(
sc
[
i
].
type
===
'topic'
)
{
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
imgUrl
=
sc
[
i
].
imgUrl
;
}
}
else
if
(
result
.
type
===
3
)
{
if
(
sc
[
i
].
type
===
'photo'
)
{
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
imgUrl
=
sc
[
i
].
imgUrl
;
}
}
//设置分享信息
_
.
forEach
(
sc
,
function
(
e
){
if
(
share_type
===
e
.
type
){
title
=
e
.
title
;
desc
=
e
.
desc
;
imgUrl
=
e
.
imgUrl
;
return
;
}
link
=
link
+
'&uId='
+
uId
;
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
result
.
_id
,
type
,
result
);
}
else
{
cont
(
err
);
});
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
thread
.
_id
,
type
,
thread
);
}
});
}
else
{
//如果有分享设置,则返回分享设置
forumShareService
.
getById
(
result
.
share
,
function
(
err
,
forumShare
)
{
//1、文章 2、话题 3、照片墙
if
(
result
.
type
===
1
||
(
result
.
type
===
2
&&
result
.
level
===
2
))
{
link
=
link
+
'thread&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
//key = 'article';
}
else
if
(
result
.
type
===
2
&&
result
.
level
===
1
)
{
link
=
link
+
'topicList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
//key = 'topic';
}
else
if
(
result
.
type
===
3
)
{
link
=
link
+
'photoList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
//key = 'photo';
//获取个性化文章分享设置
forumShareService
.
getById
(
thread
.
share
,
function
(
err
,
forumShare
)
{
if
(
err
||
!
forumShare
){
//文章个性化分享设置不存在
console
.
error
(
err
||
'文章个性化分享设置不存在'
);
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
DATA_NOTEXITS
));
}
else
{
getWX
(
res
,
forumShare
.
title
,
forumShare
.
description
,
link
,
forumShare
.
icon
,
mid
,
ent_code
,
thread
.
_id
,
type
,
thread
);
}
link
=
link
+
'&uId='
+
uId
;
getWX
(
res
,
forumShare
.
title
,
forumShare
.
description
,
link
,
forumShare
.
icon
,
mid
,
ent_code
,
result
.
_id
,
type
,
result
);
});
}
}
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
res
.
json
({
result
:
false
,
code
:
'10002'
});
});
}
}
else
{
res
.
json
({
result
:
false
,
code
:
'10002'
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
WRONG_PARAM
));
});
}
req
.
session
.
mobileForumUser
.
share_log
=
share_log
;
});
//微信分享接口
router
.
get
(
'/:ent_code/timeline'
,
function
(
req
,
res
,
next
)
{
//微信分享
朋友圈
接口
router
.
get
(
'/:ent_code/
share/
timeline'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
session
.
openUser
.
mid
,
action
=
'share_timeline'
,
ent_code
=
req
.
session
.
user
.
ent_code
;
httpService
.
createShareLog
(
req
,
1
);
httpService
.
sendRequest
(
ent_code
,
mid
,
action
);
res
.
status
(
200
).
end
();
});
//微信分享单人接口
router
.
get
(
'/:ent_code/share/singlemessage'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
session
.
openUser
.
mid
,
action
=
'share_singlemessage'
,
ent_code
=
req
.
session
.
user
.
ent_code
;
httpService
.
createShareLog
(
req
,
2
);
httpService
.
sendRequest
(
ent_code
,
mid
,
action
);
res
.
status
(
200
).
end
();
});
app/controllers/mobile/forumThread.js
View file @
e3456dc4
...
...
@@ -466,7 +466,7 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
function
(
callback
)
{
//3.更新文章统计数据(评论数)
if
(
thread
)
{
forumThreadService
.
updateThreadCommentCount
(
tid
,
function
(
err
,
results
)
{
forumThreadService
.
updateThreadCommentCount
Inc
(
tid
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
callback
(
err
,
null
);
...
...
@@ -914,7 +914,8 @@ router.get('/thread/:tid/latestPhotos', function(req, res, next) {
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
pid
:
tid
,
type
:
3
type
:
3
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
if
(
tid
)
{
...
...
@@ -967,7 +968,8 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) {
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
pid
:
tid
,
type
:
3
type
:
3
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
if
(
tid
)
{
...
...
app/models/forumShareLog.js
View file @
e3456dc4
...
...
@@ -9,30 +9,66 @@ var ForumShareLogSchema = new Schema({
require
:
true
,
index
:
true
},
user
:
{
//分享
者
type
:
Schema
.
Types
.
ObjectId
,
user
:
{
//访问
者
type
:
String
,
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
},
thread
:
{
//分享内容
type
:
Schema
.
Types
.
ObjectId
,
mid
:
{
//会员ID
type
:
Number
,
require
:
true
,
index
:
true
,
ref
:
'ForumThread'
index
:
true
},
destination
:
{
//分享的目标,微信好友,微信朋友圈,QQ空间,微博等等
open_id
:
{
//微信公众号唯一识别
type
:
String
,
require
:
true
,
index
:
true
},
ip
:
{
//IP地址
info
:
{
//板块ID
type
:
String
,
index
:
true
,
ref
:
'ForumInfo'
},
thread
:
{
//话题、文章、照片墙的ID
type
:
String
,
index
:
true
,
ref
:
'forumThread'
},
type
:
{
//页面:1.主页 2.板块 3.文章
type
:
Number
,
index
:
true
,
require
:
true
},
created
:
{
//分享时间
type
:
Date
,
thread_type
:
{
//文章类型:1.话题 2.文章 3.照片墙 4.子文章
type
:
Number
,
index
:
true
},
share_type
:{
//分享类型:1.微信朋友圈 2.微信单人 3.微信组
type
:
Number
,
index
:
true
,
require
:
true
},
p_thread
:
{
//父文章ID
type
:
String
,
index
:
true
,
ref
:
'forumThread'
},
source
:
{
//分享者
type
:
String
,
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
},
ip
:
{
//IP地址
type
:
String
},
userAgent
:
{
type
:
String
},
created
:
{
type
:
Date
,
required
:
true
,
default
:
Date
.
now
}
},
{
...
...
app/service/forumThreadService.js
View file @
e3456dc4
...
...
@@ -179,7 +179,8 @@ exports.getThreadById = function(tid, callback) {
//获取照片墙最新文章列表
var
conditions
=
{
pid
:
tid
,
type
:
3
type
:
3
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
getAllThreadByFidHelp
(
conditions
,
1
,
10
,
'-created'
,
function
(
err
,
threads
)
{
if
(
err
)
{
...
...
@@ -194,7 +195,8 @@ exports.getThreadById = function(tid, callback) {
//获取照片墙最热文章列表
var
conditions
=
{
pid
:
tid
,
type
:
3
type
:
3
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
getAllThreadByFidHelp
(
conditions
,
1
,
10
,
'-praise_count'
,
function
(
err
,
threads
)
{
if
(
err
)
{
...
...
app/service/httpService.js
View file @
e3456dc4
...
...
@@ -16,8 +16,9 @@ var mongoose = require('mongoose'),
moment
=
require
(
'moment'
),
then
=
require
(
'thenjs'
);
var
ForumPVLog
=
mongoose
.
model
(
'ForumPVLog'
);
var
ForumUVLog
=
mongoose
.
model
(
'ForumUVLog'
);
var
ForumPVLog
=
mongoose
.
model
(
'ForumPVLog'
),
ForumUVLog
=
mongoose
.
model
(
'ForumUVLog'
),
ForumShareLog
=
mongoose
.
model
(
'ForumShareLog'
);
exports
.
sendRequest
=
function
(
ent_code
,
mid
,
action
,
messageid
,
integral
,
exp
)
{
var
obj
=
{
tag
:
'member'
,
...
...
@@ -51,7 +52,6 @@ var getClientIP = function(req) {
};
exports
.
createLog
=
function
(
req
,
source
,
info
,
type
,
thread_type
,
thread
,
p_thread
)
{
var
logObj
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
source
:
source
,
...
...
@@ -97,3 +97,24 @@ exports.createLog = function(req,source,info,type,thread_type,thread,p_thread) {
console
.
error
(
'没有日志信息'
);
}
};
exports
.
createShareLog
=
function
(
req
,
share_type
)
{
var
logObj
=
req
.
session
.
mobileForumUser
.
share_log
;
logObj
.
source
=
req
.
session
.
mobileForumUser
.
source
;
logObj
.
mid
=
req
.
session
.
openUser
.
mid
;
logObj
.
ent_code
=
req
.
session
.
user
.
ent_code
;
logObj
.
user
=
req
.
session
.
mobileForumUser
.
userId
;
logObj
.
open_id
=
req
.
session
.
mobileForumUser
.
openId
;
logObj
.
ip
=
getClientIP
(
req
);
logObj
.
share_type
=
share_type
;
logObj
.
userAgent
=
req
.
headers
[
'user-agent'
];
if
(
logObj
){
then
(
function
(
cont
){
var
share_log_model
=
new
ForumShareLog
(
logObj
);
share_log_model
.
save
(
cont
);
}).
fail
(
function
(
cont
,
err
){
console
.
error
(
err
);
});
}
};
app/utils/user.js
View file @
e3456dc4
...
...
@@ -25,9 +25,11 @@ exports.identifyUser=function() {
openId
:
doc
.
uid
};
if
(
req
.
session
.
source
){
if
(
req
.
session
.
source
!==
req
.
session
.
mobileForumUser
.
userId
){
req
.
session
.
mobileForumUser
.
source
=
req
.
session
.
source
;
delete
req
.
session
.
source
;
}
}
next
(
null
);
}
else
{
if
(
req
.
session
.
tmpOpenId
){
...
...
@@ -49,9 +51,11 @@ exports.identifyUser=function() {
openId
:
doc
.
uid
};
if
(
req
.
session
.
source
){
if
(
req
.
session
.
source
!==
req
.
session
.
mobileForumUser
.
userId
){
req
.
session
.
mobileForumUser
.
source
=
req
.
session
.
source
;
delete
req
.
session
.
source
;
}
}
next
(
null
);
}
...
...
@@ -61,6 +65,12 @@ exports.identifyUser=function() {
}
});
}
else
{
if
(
req
.
session
.
source
){
if
(
req
.
session
.
source
!==
req
.
session
.
mobileForumUser
.
userId
){
req
.
session
.
mobileForumUser
.
source
=
req
.
session
.
source
;
delete
req
.
session
.
source
;
}
}
next
(
null
);
}
...
...
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