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
c4856b8e
Commit
c4856b8e
authored
Oct 08, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.wxpai.cn/scrmgroup/pisns-forum-api
parents
965f98d3
fa7784c1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
46 deletions
+61
-46
forumIdentifyUser.js
app/controllers/admin/forumIdentifyUser.js
+39
-13
forumShare.js
app/controllers/mobile/forumShare.js
+20
-12
httpService.js
app/service/httpService.js
+1
-1
user.js
app/utils/user.js
+1
-20
No files found.
app/controllers/admin/forumIdentifyUser.js
View file @
c4856b8e
...
...
@@ -37,7 +37,28 @@ function compareTime(now, begin_time, end_time) {
}
}
var
updateUser
=
function
(
uid
,
nickName
,
icon
){
var
entity
=
{},
isUpdate
=
false
;
if
(
nickName
){
entity
.
nickName
=
nickName
;
isUpdate
=
true
;
}
if
(
icon
){
entity
.
icon
=
icon
;
isUpdate
=
true
;
}
if
(
isUpdate
){
forumUserService
.
updateUserById
(
uid
,
entity
,
function
(
err
,
result
){
if
(
err
){
console
.
log
(
err
);
}
else
{
console
.
log
(
'用户:'
+
uid
+
'---------更新成功'
);
console
.
log
(
entity
);
}
});
}
}
//验证用户身份
router
.
post
(
'/user/identifyUser'
,
function
(
req
,
res
,
next
){
var
entity
=
req
.
body
;
...
...
@@ -50,6 +71,11 @@ router.post('/user/identifyUser',function(req,res,next){
res
.
json
(
'error'
);
}
else
{
if
(
doc
){
if
(
entity
.
nickName
||
entity
.
icon
){
if
(
doc
.
nickName
!==
entity
.
nickName
||
doc
.
icon
!==
entity
.
icon
){
updateUser
(
doc
.
_id
,
entity
.
nickName
,
entity
.
icon
);
}
}
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
...
...
@@ -77,25 +103,25 @@ router.post('/user/identifyUser',function(req,res,next){
});
//微信分享带来用户
router
.
get
(
'/user/from/share'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
//
var userId = req.session.mobileForumUser.userId;
var
mid
=
req
.
query
.
mid
,
action
=
req
.
query
.
action
,
ent_code
=
req
.
query
.
ent_code
;
forumLimitOperationService
.
checkLimitOperationProhibitionAddIntegral
(
userId
,
function
(
err
,
flag
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
PROHIBITION_OF_SPEECH
);
}
else
{
if
(
flag
){
res
.
json
(
returnCode
.
PROHIBITION_OF_SPEECH
);
}
else
{
//
forumLimitOperationService.checkLimitOperationProhibitionAddIntegral(userId, function(err, flag){
//
if(err){
//
console.error(err);
//
res.json(returnCode.PROHIBITION_OF_SPEECH);
//
}else{
//
if(flag){
//
res.json(returnCode.PROHIBITION_OF_SPEECH);
//
}else{
httpService
.
sendRequest
(
ent_code
,
mid
,
action
);
res
.
status
(
200
).
end
();
}
}
});
//
}
//
}
//
});
});
//检查用户权限 旧版
...
...
app/controllers/mobile/forumShare.js
View file @
c4856b8e
...
...
@@ -61,16 +61,19 @@ function getWX(res, title, desc, link, imgUrl, mid,ent_code, id,type,forumThread
});
}
else
{
title
=
title
?
title
.
replace
(
/{板块名称}/g
,
forumInfo
.
name
):
''
;
desc
=
desc
?
desc
.
replace
(
/{板块名称}/g
,
forumInfo
.
name
):
''
;
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
);
desc
=
desc
?
desc
.
replace
(
/{板块名称}/g
,
forumInfo
.
description
):
''
;
}
});
}
else
if
(
type
===
"Thread"
){
title
=
title
?
title
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
title
):
''
;
desc
=
desc
?
desc
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
title
):
''
;
write
(
res
,
title
,
desc
.
substr
(
0
,
30
),
link
,
imgUrl
,
mid
,
ent_code
);
desc
=
desc
?
desc
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
content
):
''
;
}
if
(
desc
&&
desc
.
length
>
30
){
desc
=
desc
.
substr
(
0
,
30
);
}
else
if
(
!
desc
){
desc
=
''
;
}
write
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
,
ent_code
);
}
//微信分享接口
...
...
@@ -133,7 +136,7 @@ router.get('/:ent_code/share.js', function(req, res, next) {
case
1
:
link
+=
'thread'
;
share_type
=
'article'
;
title
=
thread
.
info
.
name
;
title
=
thread
.
title
==
'发话题'
?
thread
.
info
.
name
:
thread
.
title
;
;
break
;
case
2
:
if
(
thread
.
level
===
2
){
...
...
@@ -238,7 +241,7 @@ function getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,forumThre
//share_type:是否使用默认设置:1使用默认分享设置 2.使用自己的分享设置
link
=
config
.
service
+
link
+
"&mid="
+
mid
;
if
(
type
===
"Info"
)
{
if
(
type
===
"Info"
)
{
forumInfoService
.
getInfoById
(
id
,
function
(
err
,
forumInfo
)
{
if
(
err
||
forumInfo
<
1
)
{
console
.
error
(
"板块不存在或者发生未知错误"
);
...
...
@@ -250,16 +253,21 @@ function getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,forumThre
});
}
else
{
title
=
title
?
title
.
replace
(
/{板块名称}/g
,
forumInfo
.
name
):
''
;
desc
=
desc
?
desc
.
replace
(
/{板块名称}/g
,
forumInfo
.
name
):
''
;
desc
=
desc
?
desc
.
replace
(
/{板块名称}/g
,
forumInfo
.
description
):
''
;
}
});
}
else
if
(
type
===
"Thread"
){
}
else
if
(
type
===
"Thread"
){
title
=
title
?
title
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
title
):
''
;
desc
=
desc
?
desc
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
title
):
''
;
desc
=
desc
?
desc
.
replace
(
/{文章标题}|{话题名称}|{照片墙标题}/g
,
forumThread
.
content
):
''
;
}
if
(
desc
&&
desc
.
length
>
30
){
desc
=
desc
.
substr
(
0
,
30
);
}
else
if
(
!
desc
){
desc
=
''
;
}
res
.
json
({
title
:
title
,
desc
:
desc
.
substr
(
0
,
30
)
,
desc
:
desc
,
link
:
link
,
imgUrl
:
imgUrl
,
ent_code
:
ent_code
...
...
@@ -325,7 +333,7 @@ router.get('/sharev2.js', function(req, res, next) {
case
1
:
//文章
link
=
link
+
'detail'
;
share_type
=
'article'
;
title
=
thread
.
info
.
nam
e
;
title
=
thread
.
title
==
'发话题'
?
thread
.
info
.
name
:
thread
.
titl
e
;
break
;
case
2
:
//话题
if
(
thread
.
level
===
2
){
...
...
app/service/httpService.js
View file @
c4856b8e
...
...
@@ -143,7 +143,7 @@ exports.createLog = function(req,source,info,type,thread_type,thread,p_thread) {
};
exports
.
createShareLog
=
function
(
req
,
share_type
)
{
var
logObj
=
req
.
session
.
mobileForumUser
.
share_log
;
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
;
...
...
app/utils/user.js
View file @
c4856b8e
...
...
@@ -10,25 +10,7 @@ exports.getMobileUser=function(req){
exports
.
getOpenId
=
function
(
req
){
return
req
.
session
.
mobileForumUser
.
openId
;
}
var
updateUser
=
function
(
uid
,
nickName
,
icon
,
cb
){
var
entity
=
{},
isUpdate
=
false
;
if
(
nickName
){
entity
.
nickName
=
nickName
;
isUpdate
=
true
;
}
if
(
icon
){
entity
.
icon
=
icon
;
isUpdate
=
true
;
}
if
(
isUpdate
){
forumUserService
.
updateUserById
(
uid
,
entity
,
function
(
err
,
result
){
if
(
err
){
console
.
log
(
err
);
}
});
}
}
exports
.
identifyUser
=
function
()
{
return
function
(
req
,
res
,
next
){
...
...
@@ -38,7 +20,6 @@ exports.identifyUser=function() {
next
(
err
);
}
else
{
if
(
doc
){
updateUser
(
doc
.
_id
,
req
.
session
.
openUser
.
nickName
,
req
.
session
.
openUser
.
icon
,
function
(){});
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
...
...
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