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
5314d9ff
Commit
5314d9ff
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
ae864859
e05f0ffa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
26 deletions
+114
-26
forumThread.js
app/controllers/admin/forumThread.js
+75
-10
forumComplaint.js
app/controllers/mobile/forumComplaint.js
+1
-1
forumComplaintService.js
app/service/forumComplaintService.js
+38
-15
No files found.
app/controllers/admin/forumThread.js
View file @
5314d9ff
...
@@ -339,7 +339,7 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
...
@@ -339,7 +339,7 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
};
};
}
}
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
res
.
json
(
returnCode
.
SUCCESS
);
}
}
...
@@ -418,23 +418,88 @@ router.post('/thread/comment/add', function(req, res, next) {
...
@@ -418,23 +418,88 @@ router.post('/thread/comment/add', function(req, res, next) {
entity
.
created
=
new
Date
();
entity
.
created
=
new
Date
();
entity
.
ent_code
=
req
.
session
.
user
.
ent_code
;
entity
.
ent_code
=
req
.
session
.
user
.
ent_code
;
entity
.
ip
=
ip
;
entity
.
ip
=
ip
;
// entity.from = req.session.mobileForumUser.userId; // 正式环境
entity
.
from
=
'55015675868b65a028187c49'
;
// 测试环境
var
uid
=
req
.
session
.
user
.
id
;
// 正式环境
if
(
tid
)
{
if
(
tid
)
{
// 添加评论
async
.
waterfall
([
forumCommentService
.
createComment
(
entity
,
function
(
err
,
result
)
{
function
(
callback
)
{
forumUserService
.
getUserByUid
(
uid
,
callback
);
}
],
function
(
err
,
user
)
{
if
(
err
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
var
returnData
=
{
if
(
user
)
{
comment
:
result
,
entity
.
from
=
user
.
_id
;
errorcode
:
0
,
// 添加评论
errormsg
:
'请求成功'
forumCommentService
.
createComment
(
entity
,
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
returnData
=
{
comment
:
result
,
errorcode
:
0
,
errormsg
:
'请求成功'
}
res
.
json
(
returnData
);
}
});
}
else
{
var
userentity
=
{
uid
:
uid
,
nickName
:
req
.
session
.
user
.
name
,
icon
:
req
.
session
.
user
.
headPic
};
forumUserService
.
createUser
(
userentity
,
function
(
err
,
doc
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
entity
.
from
=
doc
.
_id
;
// 添加评论
forumCommentService
.
createComment
(
entity
,
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
returnData
=
{
comment
:
result
,
errorcode
:
0
,
errormsg
:
'请求成功'
}
res
.
json
(
returnData
);
}
});
}
});
}
}
res
.
json
(
returnData
);
}
}
});
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
}
// 测试环境
// entity.from = '55015675868b65a028187c49';
// if (tid) {
// // 添加评论
// forumCommentService.createComment(entity, function(err, result) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// var returnData = {
// comment: result,
// errorcode: 0,
// errormsg: '请求成功'
// }
// res.json(returnData);
// }
// });
// }
});
});
...
...
app/controllers/mobile/forumComplaint.js
View file @
5314d9ff
...
@@ -14,7 +14,7 @@ router.post('/complaints', function(req, res, next) {
...
@@ -14,7 +14,7 @@ router.post('/complaints', function(req, res, next) {
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
ForumComplaintService
.
addComplaint
(
req
.
body
,
ent_code
,
function
(
err
,
result
){
ForumComplaintService
.
addComplaint
(
req
.
body
,
ent_code
,
function
(
err
,
result
){
if
(
err
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
)
);
}
else
{
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
}
...
...
app/service/forumComplaintService.js
View file @
5314d9ff
'use strict'
;
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumComplaint
=
mongoose
.
model
(
'ForumComplaint'
);
var
ForumComplaint
=
mongoose
.
model
(
'ForumComplaint'
);
var
ForumThread
=
mongoose
.
model
(
'ForumThread'
);
var
ForumComment
=
mongoose
.
model
(
'ForumComment'
);
var
ForumUserService
=
require
(
"./forumUserService"
);
var
ForumUserService
=
require
(
"./forumUserService"
);
var
async
=
require
(
'async'
);
var
async
=
require
(
'async'
);
...
@@ -43,11 +45,46 @@ exports.getForumComplaintPageList=function(condition,pageNo,pageSize,callback){
...
@@ -43,11 +45,46 @@ exports.getForumComplaintPageList=function(condition,pageNo,pageSize,callback){
};
};
exports
.
addComplaint
=
function
(
complaint
,
entcode
,
callback
){
exports
.
addComplaint
=
function
(
complaint
,
entcode
,
callback
){
if
(
!!!
complaint
||
!!!
complaint
.
complaintId
){
if
(
!!!
complaint
||
!!!
complaint
.
complaintId
||
!!!
complaint
.
type
){
return
callback
&&
callback
(
'bad args'
);
return
callback
&&
callback
(
'bad args'
);
}
}
complaint
.
ent_code
=
entcode
;
complaint
.
ent_code
=
entcode
;
async
.
waterfall
([
function
(
cb
)
{
async
.
waterfall
([
function
(
cb
)
{
/*var to =complaint.to;
delete complaint.to;
if(!!!to){
return cb();
}
ForumUserService.getUserById(to,
function(err,result){
if(!!!err && result){
complaint.complaintTo = result;
}
cb();
});*/
var
_Model
=
null
;
var
type
=
0
;
try
{
type
=
Number
(
complaint
.
type
);
}
catch
(
e
){}
if
(
type
===
1
){
_Model
=
ForumThread
;
}
else
if
(
type
===
2
){
_Model
=
ForumComment
;
}
if
(
!!!
_Model
){
return
callback
&&
callback
(
'bad args'
);
}
_Model
.
findById
(
complaint
.
complaintId
).
populate
(
'from'
)
.
exec
(
function
(
err
,
result
){
if
(
err
||
!
result
){
//没有对应的文章或评论
return
callback
&&
callback
(
err
||
'无对应数据'
);
}
complaint
.
content
=
result
.
content
;
complaint
.
complaintTo
=
result
.
from
;
cb
();
});
},
function
(
cb
)
{
var
from
=
complaint
.
from
;
var
from
=
complaint
.
from
;
delete
complaint
.
from
;
delete
complaint
.
from
;
if
(
!!!
from
){
if
(
!!!
from
){
...
@@ -83,20 +120,6 @@ exports.addComplaint = function(complaint,entcode,callback){
...
@@ -83,20 +120,6 @@ exports.addComplaint = function(complaint,entcode,callback){
});
});
}
}
},
},
function
(
cb
)
{
var
to
=
complaint
.
to
;
delete
complaint
.
to
;
if
(
!!!
to
){
return
cb
();
}
ForumUserService
.
getUserById
(
to
,
function
(
err
,
result
){
if
(
!!!
err
&&
result
){
complaint
.
complaintTo
=
result
;
}
cb
();
});
},
function
(
n
,
cb
)
{
function
(
n
,
cb
)
{
var
_complaint
=
new
ForumComplaint
(
complaint
);
var
_complaint
=
new
ForumComplaint
(
complaint
);
_complaint
.
save
(
function
(
err
,
result
)
{
_complaint
.
save
(
function
(
err
,
result
)
{
...
...
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