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
0381b4fa
Commit
0381b4fa
authored
Feb 09, 2015
by
张淼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
dc86d020
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
356 deletions
+0
-356
forumFavorite.js
app/controllers/admin/forumFavorite.js
+0
-5
forumThread.js
app/controllers/admin/forumThread.js
+0
-351
No files found.
app/controllers/admin/forumFavorite.js
View file @
0381b4fa
...
@@ -42,8 +42,3 @@ router.post('/favorite/:fid/delete', function(req, res, next) {
...
@@ -42,8 +42,3 @@ router.post('/favorite/:fid/delete', function(req, res, next) {
}
}
});
});
//获取当前用户的收藏列表
router
.
get
(
'/favorite/list'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
app/controllers/admin/forumThread.js
View file @
0381b4fa
...
@@ -82,354 +82,3 @@ router.post('/thread/:tid/delete', function(req, res, next) {
...
@@ -82,354 +82,3 @@ router.post('/thread/:tid/delete', function(req, res, next) {
res
.
json
(
returnCode
.
WRONG_PARAM
);
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
}
});
});
//文章点赞
router
.
post
(
'/thread/:tid/raise'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
if
(
tid
){
var
integral
=
req
.
session
.
openUser
.
integral
||
0
;
var
exp
=
req
.
session
.
openUser
.
exp
||
0
;
//1.检查是否有权限
forumRolePermissionService
.
checkRolePermiss
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
action
,
integral
,
exp
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
result
){
//有操作权限
//2.获取论坛文章
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
async
.
parallel
([
function
(
callback
){
//3.更新文章统计数据(点赞数)
if
(
thread
){
var
raiseCount
=
thread
.
praise_count
||
0
;
raiseCount
=
Number
(
raiseCount
)
+
Number
(
1
);
forumThreadService
.
updateThreadById
(
tid
,{
praise_count
:
raiseCount
},
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
}
else
{
callback
(
'cannot find thread by id'
,
null
);
}
},
function
(
callback
){
var
entity
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
user
:
req
.
session
.
openUser
.
openId
,
thread
:
tid
,
ip
:
req
.
ip
};
//4.创建点赞日志
forumPraiseLogService
.
createPraiseLog
(
entity
,
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
}
],
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
}
else
{
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//文章分享
router
.
post
(
'/thread/:tid/share'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
if
(
tid
){
var
integral
=
req
.
session
.
openUser
.
integral
||
0
;
var
exp
=
req
.
session
.
openUser
.
exp
||
0
;
var
destination
=
req
.
body
.
destination
||
'1'
;
//1.检查是否有权限
forumRolePermissionService
.
checkRolePermiss
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
action
,
integral
,
exp
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
result
){
//有操作权限
//2.获取论坛文章
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
async
.
parallel
([
function
(
callback
){
//3.更新文章统计数据(分享数)
if
(
thread
){
var
shareCount
=
thread
.
share_count
||
0
;
shareCount
=
Number
(
shareCount
)
+
Number
(
1
);
forumThreadService
.
updateThreadById
(
tid
,{
share_count
:
shareCount
},
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
}
else
{
callback
(
'cannot find thread by id'
,
null
);
}
},
function
(
callback
){
var
entity
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
user
:
req
.
session
.
openUser
.
openId
,
thread
:
tid
,
destination
:
destination
,
ip
:
req
.
ip
};
//4.创建分享日志
forumShareLogService
.
createShareLog
(
entity
,
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
}
],
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
}
else
{
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//新增文章评论
/**
**输入:
tid:文章id
pId:评论父id
comment:评论内容
**输出:
操作结果
**/
router
.
post
(
'/thread/:tid/comment/create'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
if
(
tid
){
var
integral
=
req
.
session
.
openUser
.
integral
||
0
;
var
exp
=
req
.
session
.
openUser
.
exp
||
0
;
var
destination
=
req
.
body
.
destination
||
'1'
;
//1.检查是否有权限
forumRolePermissionService
.
checkRolePermiss
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
action
,
integral
,
exp
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
result
){
//有操作权限
var
content
=
req
.
body
.
content
;
if
(
content
){
//评论不能为空
//2.获取论坛文章
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
async
.
parallel
([
function
(
callback
){
var
entity
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
from
:
req
.
session
.
openUser
.
openId
,
to
:
req
.
session
.
openUser
.
openId
,
content
:
content
,
ip
:
req
.
ip
};
//4.创建文章评论
forumCommentService
.
createComment
(
entity
,
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
var
comments
=
thread
.
comments
;
var
array
=
[];
if
(
comments
&&
comments
.
length
>
0
){
array
=
comments
;
}
array
.
push
(
result
.
_id
);
forumThreadService
.
updateThreadById
(
tid
,{
comments
:
array
},
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
}
});
},
function
(
callback
){
//3.更新文章统计数据(评论数)
if
(
thread
){
var
commentCount
=
thread
.
comment_count
||
0
;
commentCount
=
Number
(
commentCount
)
+
Number
(
1
);
forumThreadService
.
updateThreadById
(
tid
,{
comment_count
:
commentCount
},
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
}
else
{
callback
(
'cannot find thread by id'
,
null
);
}
}
],
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
}
else
{
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//新建文章评论的子评论
router
.
post
(
'/thread/:tid/comment/:cid/create'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
cid
=
req
.
params
.
cid
||
null
;
if
(
tid
&&
cid
){
var
integral
=
req
.
session
.
openUser
.
integral
||
0
;
var
exp
=
req
.
session
.
openUser
.
exp
||
0
;
var
destination
=
req
.
body
.
destination
||
'1'
;
//1.检查是否有权限
forumRolePermissionService
.
checkRolePermiss
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
action
,
integral
,
exp
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
result
){
//有操作权限
var
content
=
req
.
body
.
content
;
if
(
content
){
//评论不能为空
//2.获取论坛评论
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
comment
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
async
.
parallel
([
function
(
callback
){
var
entity
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
from
:
req
.
session
.
openUser
.
openId
,
to
:
req
.
session
.
openUser
.
openId
,
content
:
content
,
ip
:
req
.
ip
};
//4.创建文章评论
forumCommentService
.
createComment
(
entity
,
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
var
comments
=
comment
.
comments
;
var
array
=
[];
if
(
comments
&&
comments
.
length
>
0
){
array
=
comments
;
}
array
.
push
(
result
.
_id
);
forumCommentService
.
updateCommentById
(
cid
,{
comments
:
array
},
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
}
});
}
],
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
}
else
{
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//删除文章评论
router
.
post
(
'/thread/:tid/comment/:cid/delete'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.检查是否有权限
//2.获取论坛文章
//3.新增文章评论
//4.更新文章统计数据(评论数)
});
//更新文章评论状态为:显示/不显示
router
.
post
(
'/thread/:tid/comment/:cid/:status'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
cid
=
req
.
params
.
cid
||
null
;
var
status
=
req
.
params
.
status
||
null
;
if
(
tid
&&
cid
&&
status
){
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
comment
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumCommentService
.
updateThreadById
(
cid
,{
status
:
status
},
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
\ No newline at end of file
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