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
c8c21d23
Commit
c8c21d23
authored
Apr 17, 2015
by
邓军
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development
Conflicts: app/controllers/mobile/forumShare.js
parents
2e0696cb
b410dc34
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
20 deletions
+70
-20
forumIdentifyUser.js
app/controllers/admin/forumIdentifyUser.js
+9
-0
forumShare.js
app/controllers/mobile/forumShare.js
+28
-8
forumThread.js
app/controllers/mobile/forumThread.js
+6
-5
httpService.js
app/service/httpService.js
+27
-7
No files found.
app/controllers/admin/forumIdentifyUser.js
View file @
c8c21d23
...
...
@@ -7,6 +7,7 @@ var express = require('express'),
var
mongoose
=
require
(
'mongoose'
);
var
forumUserService
=
require
(
'../../service/forumUserService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
async
=
require
(
'async'
);
...
...
@@ -51,4 +52,12 @@ router.post('/user/identifyUser',function(req,res,next){
}
else
{
res
.
json
(
'success'
);
}
});
//微信分享带来用户
router
.
get
(
'/user/from/share'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
query
.
mid
,
action
=
req
.
query
.
action
,
ent_code
=
req
.
query
.
ent_code
;
httpService
.
sendRequest
(
ent_code
,
mid
,
action
);
res
.
status
(
200
).
end
();
});
\ No newline at end of file
app/controllers/mobile/forumShare.js
View file @
c8c21d23
...
...
@@ -9,6 +9,7 @@ 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'
);
...
...
@@ -16,7 +17,9 @@ module.exports = function(app) {
app
.
use
(
'/v1/forum'
,
router
);
};
function
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
)
{
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'
,
...
...
@@ -30,7 +33,11 @@ function write(res, title, desc, link, imgUrl, mid) {
// imgUrl = 'http://dev.fs.wxpai.cn/upload/100001_2015410_1428671539587_40.jpg',
// desc = '测试描述';
// var string = '';
var
string
=
'wx.onMenuShareTimeline({'
+
'
\
"title
\
":
\
"'
+
title
+
'
\
",'
+
'
\
"link
\
":
\
"'
+
link
+
'
\
",'
+
'
\
"imgUrl
\
":
\
"'
+
imgUrl
+
'
\
", '
+
'success: function(){},'
+
'cancel: function () {}'
+
' });'
+
' wx.onMenuShareAppMessage({'
+
'
\
"title
\
":
\
"'
+
title
+
'
\
", '
+
'
\
"desc
\
":
\
"'
+
desc
+
'
\
", '
+
'
\
"link
\
":
\
"'
+
link
+
'
\
", '
+
'
\
"imgUrl
\
":
\
"'
+
imgUrl
+
'
\
", '
+
'
\
"type
\
":
\'\'
,'
+
'
\
"dataUrl
\
":
\'\'
, '
+
'success: function(){},'
+
'cancel: function () { '
+
'}'
+
' });'
var
success
=
'$.ajax({'
+
'type:
\'
GET
\'
,'
+
'url:
\'
/v1/forum/'
+
ent_code
+
'/timeline
\'
'
+
'});'
;
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 () { '
+
'}'
+
' });'
res
.
write
(
'wx.ready(function(){'
+
string
+
'});'
);
res
.
write
(
'wx.error(function(res){console.log(res);});'
);
...
...
@@ -38,7 +45,7 @@ function write(res, title, desc, link, imgUrl, mid) {
res
.
end
();
}
function
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
id
,
type
,
forumThread
)
{
function
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
id
,
type
,
forumThread
)
{
//['{板块名称}','{文章标题}','{话题名称}','{照片墙标题}'];
//share_type:是否使用默认设置:1使用默认分享设置 2.使用自己的分享设置
link
=
config
.
service
+
link
+
"&mid="
+
mid
;
...
...
@@ -56,14 +63,14 @@ function getWX(res, title, desc, link, imgUrl, mid, id,type,forumThread) {
}
else
{
title
=
title
.
replace
(
/{板块名称}/g
,
forumInfo
.
name
);
desc
=
desc
.
replace
(
/{板块名称}/g
,
forumInfo
.
name
);
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
);
}
});
}
else
if
(
type
===
"Thread"
){
title
=
title
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
title
);
desc
=
desc
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
title
);
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
);
}
}
...
...
@@ -104,8 +111,9 @@ router.get('/:ent_code/share.js', function(req, res, next) {
}
else
{
link
=
link
+
'index'
;
}
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
id
,
type
,
null
);
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
id
,
type
,
null
);
}
else
{
cont
(
err
);
}
...
...
@@ -191,7 +199,8 @@ router.get('/:ent_code/share.js', function(req, res, next) {
}
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
result
.
_id
,
type
,
result
);
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
,
result
.
_id
,
type
,
result
);
}
else
{
cont
(
err
);
}
...
...
@@ -213,7 +222,8 @@ router.get('/:ent_code/share.js', function(req, res, next) {
//key = 'photo';
}
getWX
(
res
,
forumShare
.
title
,
forumShare
.
description
,
link
,
forumShare
.
icon
,
mid
,
result
.
_id
,
type
,
result
);
getWX
(
res
,
forumShare
.
title
,
forumShare
.
description
,
link
,
forumShare
.
icon
,
mid
,
ent_code
,
result
.
_id
,
type
,
result
);
});
}
}).
fail
(
function
(
cont
,
err
)
{
...
...
@@ -231,3 +241,13 @@ router.get('/:ent_code/share.js', function(req, res, next) {
});
}
});
//微信分享接口
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 @
c8c21d23
...
...
@@ -76,6 +76,7 @@ router.post('/thread/create', function(req, res, next) {
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
req
.
session
.
openUser
.
mid
,
'post'
);
var
rs
=
{};
rs
.
data
=
{
'id'
:
thread
.
_id
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
...
...
@@ -221,7 +222,7 @@ router.post('/thread/:tid/raise', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
user
.
getOpenId
(
req
),
tid
,
'
raise'
);
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
req
.
session
.
openUser
.
mid
,
'thread_p
raise'
);
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
doc
){
if
(
err
){
console
.
error
(
err
);
...
...
@@ -305,7 +306,7 @@ router.post('/thread/:tid/share', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
user
.
getOpenId
(
req
),
t
id
,
'share'
);
// httpService.sendRequest(req.session.user.ent_code,req.session.openUser.m
id,'share');
res
.
json
(
returnCode
.
SUCCESS
);
}
});
...
...
@@ -396,7 +397,7 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
user
.
getOpenId
(
req
),
t
id
,
'comment'
);
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
req
.
session
.
openUser
.
m
id
,
'comment'
);
async
.
parallel
([
function
(
callback
){
//获取最新5条评论
...
...
@@ -522,7 +523,7 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
user
.
getOpenId
(
req
),
t
id
,
'reply'
);
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
req
.
session
.
openUser
.
m
id
,
'reply'
);
ForumComment
.
populate
(
results
[
0
],
{
path
:
'from to'
,
select
:
'uid nickName icon comments'
}
,
function
(
err
,
c
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -682,7 +683,7 @@ router.post('/thread/:tid/comment/:cid/raise', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
user
.
getOpenId
(
req
),
tid
,
'
raise'
);
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
req
.
session
.
openUser
.
mid
,
'comment_p
raise'
);
//返回点赞总数
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
doc
){
if
(
err
){
...
...
app/service/httpService.js
View file @
c8c21d23
...
...
@@ -2,10 +2,30 @@
// var request=require('request');
// var REMOTE_URL='http://127.0.0.1:3011/admin/forum/http/receive';
exports
.
sendRequest
=
function
(
ent_code
,
uid
,
tid
,
action
){
// var url=REMOTE_URL+'?ent_code='+ent_code+'&uid='+uid+'&tid='+tid+'&action='+action;
// request.get({url:url}, function (e, r, body) {
// });
};
\ No newline at end of file
var
ACTION_KEY
=
{
'post'
:
'FORUM_THREAD_POST'
,
'share'
:
'FORUM_THREAD_SHARE'
,
'share_timeline'
:
'FORUM_THREAD_SHARE_TIMELINE'
,
'comment'
:
'FORUM_THREAD_COMMENT'
,
'thread_praise'
:
'FORUM_THREAD_PRAISE'
,
'comment_praise'
:
'FORUM_COMMENT_PRAISE'
,
'reply'
:
'FORUM_COMMENT_REPLY'
,
'user_from_share'
:
'FORUM_USER_FROM_SHARE'
}
exports
.
sendRequest
=
function
(
ent_code
,
mid
,
action
,
messageid
,
integral
,
exp
){
var
obj
=
{
tag
:
'member'
,
key
:
'forum'
,
action
:
ACTION_KEY
[
action
],
mid
:
mid
,
entcode
:
ent_code
,
messageid
:
messageid
||
''
,
integral
:
integral
||
0
,
exp
:
exp
||
0
};
redis
.
lpush
(
'adapter-redis-to-ons'
,
JSON
.
stringify
(
obj
),
function
(
err
,
reply
){
if
(
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