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
c917666e
Commit
c917666e
authored
Apr 22, 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/forumThread.js
parents
b1b7e6ad
21a75806
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
420 additions
and
274 deletions
+420
-274
forumThread.js
app/controllers/admin/forumThread.js
+382
-270
forumThreadService.js
app/service/forumThreadService.js
+38
-4
No files found.
app/controllers/admin/forumThread.js
View file @
c917666e
...
...
@@ -5,16 +5,18 @@ var express = require('express'),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumThread
=
mongoose
.
model
(
'ForumThread'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
forumRolePermissionService
=
require
(
'../../service/forumRolePermissionService'
);
var
forumPraiseLogService
=
require
(
'../../service/forumPraiseLogService'
);
var
forumShareLogService
=
require
(
'../../service/forumShareLogService'
);
var
forumCommentService
=
require
(
'../../service/forumCommentService'
);
var
forumTagService
=
require
(
'../../service/forumTagService'
);
var
forumUserService
=
require
(
'../../service/forumUserService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
forumRolePermissionService
=
require
(
'../../service/forumRolePermissionService'
);
var
forumPraiseLogService
=
require
(
'../../service/forumPraiseLogService'
);
var
forumShareLogService
=
require
(
'../../service/forumShareLogService'
);
var
forumCommentService
=
require
(
'../../service/forumCommentService'
);
var
forumTagService
=
require
(
'../../service/forumTagService'
);
var
forumUserService
=
require
(
'../../service/forumUserService'
);
var
userUtil
=
require
(
'../../utils/user'
);
var
async
=
require
(
'async'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
userUtil
=
require
(
'../../utils/user'
);
var
async
=
require
(
'async'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
...
...
@@ -26,50 +28,55 @@ module.exports = function(app) {
//新增论坛文章
router
.
post
(
'/thread/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
var
uid
=
req
.
session
.
user
.
id
;
var
uid
=
req
.
session
.
user
.
id
;
// var uid='12345';
if
(
req
.
body
.
pid
)
{
req
.
body
.
level
=
2
;
}
async
.
waterfall
([
function
(
callback
)
{
forumUserService
.
getUserByUid
(
uid
,
callback
);
function
(
callback
)
{
forumUserService
.
getUserByUid
(
uid
,
callback
);
}
],
function
(
err
,
user
)
{
if
(
err
)
{
],
function
(
err
,
user
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
user
)
{
req
.
body
.
from
=
user
.
_id
;
forumThreadService
.
createThread
(
req
.
body
,
function
(
err
,
entity
)
{
}
else
{
if
(
user
)
{
req
.
body
.
from
=
user
.
_id
;
forumThreadService
.
createThread
(
req
.
body
,
function
(
err
,
entity
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
{
'id'
:
entity
.
_id
};
rs
.
data
=
{
'id'
:
entity
.
_id
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
var
entity
=
{
uid
:
uid
,
nickName
:
req
.
session
.
user
.
name
,
icon
:
req
.
session
.
user
.
headPic
}
else
{
var
entity
=
{
uid
:
uid
,
nickName
:
req
.
session
.
user
.
name
,
icon
:
req
.
session
.
user
.
headPic
};
forumUserService
.
createUser
(
entity
,
function
(
err
,
doc
)
{
if
(
err
)
{
forumUserService
.
createUser
(
entity
,
function
(
err
,
doc
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
req
.
body
.
from
=
doc
.
_id
;
forumThreadService
.
createThread
(
req
.
body
,
function
(
err
,
entity
)
{
req
.
body
.
from
=
doc
.
_id
;
forumThreadService
.
createThread
(
req
.
body
,
function
(
err
,
entity
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
{
'id'
:
entity
.
_id
};
rs
.
data
=
{
'id'
:
entity
.
_id
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
...
...
@@ -86,30 +93,30 @@ router.get('/thread/:tid/get', function(req, res, next) {
var
rs
=
{};
if
(
tid
)
{
async
.
parallel
([
function
(
callback
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
thread
);
function
(
callback
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
thread
);
}
});
},
function
(
callback
)
{
forumTagService
.
getAllTag
(
req
.
session
.
user
.
ent_code
,
1
,
100
,
function
(
err
,
results
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
results
);
function
(
callback
)
{
forumTagService
.
getAllTag
(
req
.
session
.
user
.
ent_code
,
1
,
100
,
function
(
err
,
results
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
results
);
}
});
}
],
function
(
err
,
results
)
{
if
(
err
)
{
],
function
(
err
,
results
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
results
[
0
];
rs
.
tagList
=
results
[
1
];
}
else
{
rs
.
data
=
results
[
0
];
rs
.
tagList
=
results
[
1
];
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
...
...
@@ -120,21 +127,23 @@ router.get('/thread/:tid/get', function(req, res, next) {
//更新文章状态、如:屏蔽
router
.
post
(
'/thread/:tid/update'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
var
tid
=
req
.
params
.
tid
;
var
fatherTitle
=
req
.
body
.
father
;
delete
req
.
body
.
father
;
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
tid
)
{
forumThreadService
.
updateThreadById
(
tid
,
req
.
body
,
function
(
err
,
thread
)
{
if
(
err
)
{
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
tid
)
{
forumThreadService
.
updateThreadById
(
tid
,
req
.
body
,
function
(
err
,
thread
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
console
.
log
(
thread
);
console
.
log
(
fatherTitle
);
res
.
json
({
message
:
"success"
,
data
:
thread
,
title
:
fatherTitle
});
}
else
{
res
.
json
({
message
:
"success"
,
data
:
thread
,
title
:
fatherTitle
});
}
});
}
else
{
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
...
...
@@ -142,50 +151,50 @@ router.post('/thread/:tid/update', function(req, res, next) {
//删除文章
router
.
post
(
'/thread/:tid/delete'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
if
(
tid
)
{
forumThreadService
.
deleteThreadById
(
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
var
tid
=
req
.
params
.
tid
;
if
(
tid
)
{
forumThreadService
.
deleteThreadById
(
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//文章置顶
router
.
post
(
'/thread/:tid/:fid/top'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
//文章ID
var
fid
=
req
.
params
.
fid
;
//板块ID
if
(
tid
&&
fid
)
{
forumThreadService
.
updateTopByThreadId
(
fid
,
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
var
tid
=
req
.
params
.
tid
;
//文章ID
var
fid
=
req
.
params
.
fid
;
//板块ID
if
(
tid
&&
fid
)
{
forumThreadService
.
updateTopByThreadId
(
fid
,
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//文章取消置顶
router
.
post
(
'/thread/:tid/:fid/unTop'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
//文章ID
var
fid
=
req
.
params
.
fid
;
//板块ID
if
(
tid
&&
fid
)
{
forumThreadService
.
updateUnTopByThreadId
(
fid
,
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
var
tid
=
req
.
params
.
tid
;
//文章ID
var
fid
=
req
.
params
.
fid
;
//板块ID
if
(
tid
&&
fid
)
{
forumThreadService
.
updateUnTopByThreadId
(
fid
,
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
...
...
@@ -200,31 +209,32 @@ router.post('/thread/:tid/:fid/unTop', function(req, res, next) {
router
.
get
(
'/threads/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
infoId
=
req
.
query
.
infoId
;
var
tagId
=
req
.
query
.
tagId
;
var
pid
=
req
.
query
.
pid
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
level
:
1
var
infoId
=
req
.
query
.
infoId
;
var
tagId
=
req
.
query
.
tagId
;
var
pid
=
req
.
query
.
pid
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
level
:
1
};
if
(
infoId
)
{
conditions
.
info
=
infoId
;
if
(
infoId
)
{
conditions
.
info
=
infoId
;
}
if
(
tagId
){
conditions
.
tag
=
{
$in
:[
tagId
]};
if
(
tagId
)
{
conditions
.
tag
=
{
$in
:
[
tagId
]
};
}
if
(
pid
)
{
if
(
pid
)
{
conditions
.
pid
=
pid
;
conditions
.
level
=
2
;
}
console
.
log
(
conditions
);
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
){
if
(
err
){
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
...
...
@@ -234,81 +244,136 @@ router.get('/threads/list', function(req, res, next) {
//评论列表
router
.
get
(
'/thread/:tid/comment/list'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
tid
=
req
.
params
.
tid
||
null
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
thread
:
tid
,
level
:
'1'
,
status
:{
$ne
:
2
}
//过滤被删除的数据,status 为 2 表示删除
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
thread
:
tid
,
level
:
'1'
,
status
:
{
$ne
:
2
}
//过滤被删除的数据,status 为 2 表示删除
};
if
(
tid
)
{
if
(
tid
)
{
//获取最新5条评论
forumCommentService
.
getAllComment
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
forumCommentService
.
getAllComment
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
}
else
{
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
// 更新评论状态
router
.
post
(
'/thread/comment/update/:cid'
,
function
(
req
,
res
,
next
)
{
router
.
post
(
'/thread/comment/update/:cid'
,
function
(
req
,
res
,
next
)
{
var
cid
=
req
.
params
.
cid
||
null
;
var
status
=
req
.
body
.
status
;
var
tid
=
req
.
body
.
tid
;
var
comment_count
=
req
.
body
.
comment_count
;
var
level
=
req
.
body
.
level
;
var
parent_cid
=
req
.
body
.
parent_cid
;
if
(
cid
)
{
forumCommentService
.
updateCommentStatusById
(
cid
,
status
,
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
// 如果是删除
if
(
status
==
2
)
{
if
(
level
==
1
)
{
// 如果删除的是一级评论
// 获取评论的评论列表,并移除cid评论
forumThreadService
.
getById
(
tid
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
result
.
comment_count
-=
1
;
var
commentList
=
result
.
comments
;
result
.
comments
=
forumThreadService
.
remove
(
commentList
,
cid
);
forumThreadService
.
updateThreadById
(
tid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
}
else
{
// 删除子评论
if
(
cid
){
forumCommentService
.
updateCommentStatusById
(
cid
,
status
,
function
(
err
,
result
){
if
(
err
){
// 更新文章评论 - 1
forumThreadService
.
updateThreadCommentCount
(
tid
,
comment_count
-
1
,
function
(
err
,
result
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
});
// 更新评论的子评论列表
if
(
parent_cid
)
{
forumCommentService
.
getCommentById
(
parent_cid
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
commentList
=
result
.
comments
;
result
.
comments
=
forumCommentService
.
remove
(
commentList
,
cid
);
forumCommentService
.
updateCommentById
(
parent_cid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
}
})
};
}
}
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
// 更新回复评论
router
.
post
(
'/thread/comment/update/:cid/comments'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
router
.
post
(
'/thread/comment/update/:cid/comments'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
var
cid
=
req
.
params
.
cid
||
null
;
var
replayComment_id
=
req
.
body
.
replayComment_id
;
// 获取评论的子评论列表
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
result
)
{
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
// 更新文章对象
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
thread
.
comment_count
+=
1
;
// 更新文章评论 + 1
forumThreadService
.
updateThreadCommentCountInc
(
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
});
// 更新评论对象
result
.
comments
.
push
(
replayComment_id
);
// 添加子评论ID
result
.
comment_count
+=
1
;
// 回复评论+1
//
result.comment_count+=1; // 回复评论+1
forumCommentService
.
updateCommentById
(
cid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
forumCommentService
.
updateCommentById
(
cid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
...
...
@@ -321,22 +386,69 @@ router.post('/thread/comment/update/:cid/comments',function(req,res,next){
router
.
post
(
'/thread/comment/add'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
var
entity
=
req
.
body
;
var
ip
=
getClientIP
(
req
);
entity
.
created
=
new
Date
();
entity
.
ent_code
=
req
.
session
.
user
.
ent_code
;
entity
.
ip
=
ip
;
// entity.from = req.session.mobileForumUser.userId; // 正式环境
entity
.
from
=
'55015675868b65a028187c49'
;
// 测试环境
if
(
tid
)
{
if
(
tid
)
{
// 添加评论
forumCommentService
.
createComment
(
entity
,
function
(
err
,
result
)
{
if
(
err
)
{
forumCommentService
.
createComment
(
entity
,
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
var
returnData
=
{
// returnCode.SUCCESS,
comment
:
result
comment
:
result
,
errorcode
:
0
,
errormsg
:
'请求成功'
}
res
.
json
(
returnData
);
}
});
}
});
// 更新文章评论
router
.
post
(
'/thread/:tid/updateComments'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
cid
=
req
.
body
.
cid
||
null
;
// 获取评论的子评论列表
forumThreadService
.
getById
(
tid
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
result
.
comments
.
push
(
cid
);
result
.
comment_count
+=
1
;
forumThreadService
.
updateThreadById
(
tid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
});
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
;
};
app/service/forumThreadService.js
View file @
c917666e
...
...
@@ -253,10 +253,10 @@ exports.getThreadById = function(tid, callback) {
//根据ID更新文章
exports
.
updateThreadById
=
function
(
tid
,
entity
,
callback
)
{
var
shareEntity
=
entity
.
share
||
{}
;
var
shareEntity
=
entity
.
share
;
if
(
entity
.
share
&&
entity
.
share
.
_id
)
{
entity
.
share
=
entity
.
share
.
_id
;
}
else
{
}
else
{
entity
.
share
=
''
;
}
if
(
entity
.
share
)
{
...
...
@@ -283,7 +283,7 @@ exports.updateThreadById = function(tid, entity, callback) {
});
}
else
{
if
(
shareEntity
.
title
||
shareEntity
.
description
||
shareEntity
.
icon
)
{
if
(
shareEntity
&&
(
shareEntity
.
title
||
shareEntity
.
description
||
shareEntity
.
icon
)
)
{
shareEntity
.
ent_code
=
entity
.
ent_code
;
var
forumShare
=
new
ForumShare
(
shareEntity
);
...
...
@@ -630,7 +630,7 @@ exports.updateThreadShareCount = function(threadId, callback) {
};
//更新文章评论数
exports
.
updateThreadCommentCount
=
function
(
threadId
,
callback
)
{
exports
.
updateThreadCommentCount
Inc
=
function
(
threadId
,
callback
)
{
ForumThread
.
update
({
_id
:
threadId
},
{
...
...
@@ -651,6 +651,23 @@ exports.updateThreadCommentCount = function(threadId, callback) {
});
};
//更新文章评论数
exports
.
updateThreadCommentCount
=
function
(
threadId
,
comment_count
,
callback
)
{
ForumThread
.
update
({
_id
:
threadId
},
{
'comment_count'
:
comment_count
},
null
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//更新文章浏览数
exports
.
updateThreadPvCount
=
function
(
threadId
,
callback
)
{
ForumThread
.
update
({
...
...
@@ -672,3 +689,20 @@ exports.updateThreadPvCount = function(threadId, callback) {
}
});
};
// 查找数组元素下标
function
indexOf
(
array
,
val
)
{
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
)
{
if
(
array
[
i
]
==
val
)
return
i
;
}
return
-
1
;
};
// 删除数组指定值
exports
.
remove
=
function
(
array
,
val
)
{
var
index
=
indexOf
(
array
,
val
);
if
(
index
>
-
1
)
{
array
.
splice
(
index
,
1
);
}
return
array
;
};
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