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
a1b4cb97
Commit
a1b4cb97
authored
Apr 23, 2015
by
陈家荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development
parents
3256c22d
7dae0ac7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
211 additions
and
16 deletions
+211
-16
forumInfo.js
app/controllers/mobile/forumInfo.js
+2
-1
forumShare.js
app/controllers/mobile/forumShare.js
+176
-1
forumThread.js
app/controllers/mobile/forumThread.js
+6
-5
forumPVLog.js
app/models/forumPVLog.js
+7
-3
forumUVLog.js
app/models/forumUVLog.js
+7
-3
httpService.js
app/service/httpService.js
+2
-1
user.js
app/utils/user.js
+11
-2
No files found.
app/controllers/mobile/forumInfo.js
View file @
a1b4cb97
...
...
@@ -41,7 +41,8 @@ router.post('/info/create', function(req, res, next) {
router
.
get
(
'/info/:fid/get'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
||
null
;
if
(
fid
)
{
httpService
.
createLog
(
req
,
fid
,
2
);
var
source
=
req
.
session
.
mobileForumUser
.
source
;
httpService
.
createLog
(
req
,
source
,
fid
,
2
);
async
.
waterfall
([
function
(
callback
)
{
//更新浏览数
...
...
app/controllers/mobile/forumShare.js
View file @
a1b4cb97
...
...
@@ -17,8 +17,8 @@ module.exports = function(app) {
app
.
use
(
'/v1/forum'
,
router
);
};
function
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
)
{
link
=
config
.
service
+
link
+
"&mid="
+
mid
;
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/javascript'
,
'Cache-Control'
:
'no-cache'
,
...
...
@@ -74,3 +74,178 @@ 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
;
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
)
{
//板块微信接口
if
(
type
===
'Info'
)
{
then
(
function
(
cont
)
{
forumShareConfigService
.
getByKey
(
ent_code
,
'share'
,
function
(
err
,
result
)
{
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
;
}
}
if
(
id
)
{
link
=
link
+
'index&infoId='
+
id
;
}
else
{
link
=
link
+
'index'
;
}
link
=
link
+
'&uId='
+
uId
;
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
id
,
type
,
null
);
}
else
{
cont
(
err
);
}
});
}).
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'
)
{
then
(
function
(
cont
)
{
//获得文章
forumThreadService
.
getById
(
id
,
function
(
err
,
result
)
{
if
(
result
)
{
cont
(
null
,
result
);
}
else
{
cont
(
err
);
}
});
}).
then
(
function
(
cont
,
result
)
{
//如果没有share值则用默认值
if
(
!
result
.
share
||
result
.
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、照片墙
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
;
}
}
}
link
=
link
+
'&uId='
+
uId
;
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
result
.
_id
,
type
,
result
);
}
else
{
cont
(
err
);
}
});
}
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';
}
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'
});
}
});
//微信分享接口
router
.
get
(
'/:ent_code/timeline'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
session
.
openUser
.
mid
,
action
=
'share_timeline'
,
ent_code
=
req
.
session
.
user
.
ent_code
;
httpService
.
sendRequest
(
ent_code
,
mid
,
action
);
res
.
status
(
200
).
end
();
});
app/controllers/mobile/forumThread.js
View file @
a1b4cb97
...
...
@@ -175,15 +175,16 @@ router.get('/thread/:tid/get', function(req, res, next) {
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
//文章类型 1、文章 2、话题 3、照片墙
var
info_id
=
thread
.
info
.
_id
,
pid
=
thread
.
pid
;
pid
=
thread
.
pid
,
source
=
req
.
session
.
mobileForumUser
.
source
;
if
(
thread
.
type
==
1
&&
thread
.
level
==
1
)
{
httpService
.
createLog
(
req
,
info_id
,
3
,
1
,
tid
);
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
1
,
tid
);
}
else
if
(
thread
.
type
==
1
&&
thread
.
level
==
2
)
{
httpService
.
createLog
(
req
,
info_id
,
3
,
4
,
tid
,
pid
);
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
4
,
tid
,
pid
);
}
else
if
(
thread
.
type
==
2
&&
thread
.
level
==
1
)
{
httpService
.
createLog
(
req
,
info_id
,
3
,
2
,
tid
);
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
2
,
tid
);
}
else
if
(
thread
.
type
==
3
&&
thread
.
level
==
1
)
{
httpService
.
createLog
(
req
,
info_id
,
3
,
3
,
tid
);
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
3
,
tid
);
}
...
...
app/models/forumPVLog.js
View file @
a1b4cb97
...
...
@@ -45,11 +45,15 @@ var ForumPVLogSchema = new Schema({
index
:
true
},
p_thread
:
{
//父文章ID
type
:
Number
,
index
:
true
type
:
String
,
index
:
true
,
ref
:
'forumThread'
},
source
:
{
//分享者
type
:
String
type
:
String
,
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
},
ip
:
{
//IP地址
type
:
String
...
...
app/models/forumUVLog.js
View file @
a1b4cb97
...
...
@@ -45,11 +45,15 @@ var ForumUVLogSchema = new Schema({
index
:
true
},
p_thread
:
{
//父文章ID
type
:
Number
,
index
:
true
type
:
String
,
index
:
true
,
ref
:
'forumThread'
},
source
:
{
//分享者
type
:
String
type
:
String
,
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
},
ip
:
{
//IP地址
type
:
String
...
...
app/service/httpService.js
View file @
a1b4cb97
...
...
@@ -50,10 +50,11 @@ var getClientIP = function(req) {
return
ipAddress
;
};
exports
.
createLog
=
function
(
req
,
info
,
type
,
thread_type
,
thread
,
p_thread
)
{
exports
.
createLog
=
function
(
req
,
source
,
info
,
type
,
thread_type
,
thread
,
p_thread
)
{
var
logObj
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
source
:
source
,
mid
:
req
.
session
.
openUser
.
mid
,
open_id
:
req
.
session
.
mobileForumUser
.
openId
,
user
:
req
.
session
.
mobileForumUser
.
userId
,
...
...
app/utils/user.js
View file @
a1b4cb97
...
...
@@ -3,8 +3,8 @@
var
forumUserService
=
require
(
'../service/forumUserService'
);
exports
.
getMobileUser
=
function
(
req
){
//
return req.session.mobileForumUser.userId;
return
'55015675868b65a028187c49'
;
return
req
.
session
.
mobileForumUser
.
userId
;
//
return '55015675868b65a028187c49';
}
exports
.
getOpenId
=
function
(
req
){
...
...
@@ -24,6 +24,10 @@ exports.identifyUser=function() {
userId
:
doc
.
_id
,
openId
:
doc
.
uid
};
if
(
req
.
session
.
source
){
req
.
session
.
mobileForumUser
.
source
=
req
.
session
.
source
;
delete
req
.
session
.
source
;
}
next
(
null
);
}
else
{
if
(
req
.
session
.
tmpOpenId
){
...
...
@@ -44,6 +48,11 @@ exports.identifyUser=function() {
userId
:
doc
.
_id
,
openId
:
doc
.
uid
};
if
(
req
.
session
.
source
){
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