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
423cb350
Commit
423cb350
authored
Sep 15, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
我的消息 关于我的
parent
017ee255
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
270 additions
and
34 deletions
+270
-34
forumThread.js
app/controllers/admin/forumThread.js
+8
-1
forumAboutMe.js
app/controllers/mobile/forumAboutMe.js
+39
-0
forumThread.js
app/controllers/mobile/forumThread.js
+5
-1
forumAboutMe.js
app/models/forumAboutMe.js
+11
-32
forumAboutMEService.js
app/service/forumAboutMEService.js
+207
-0
No files found.
app/controllers/admin/forumThread.js
View file @
423cb350
...
...
@@ -16,7 +16,7 @@ var forumTagService = require('../../service/forumTagService');
var
forumUserService
=
require
(
'../../service/forumUserService'
);
// var forumLimitActionRefService = require('../../service/forumLimitActionRefService');
var
forumLimitOperationService
=
require
(
'../../service/forumLimitOperationService'
);
var
forumAboutMEService
=
require
(
'../../service/forumAboutMEService'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
userUtil
=
require
(
'../../utils/user'
);
...
...
@@ -101,6 +101,7 @@ router.post('/thread/create', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
saveThread
(
entity
);
rs
.
data
=
{
'id'
:
entity
.
_id
};
...
...
@@ -126,6 +127,7 @@ router.post('/thread/create', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
saveThread
(
entity
);
rs
.
data
=
{
'id'
:
entity
.
_id
};
...
...
@@ -615,6 +617,7 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
saveCommentLevel2BySearch
(
tid
,
cid
,
replayComment_id
);
res
.
json
(
returnCode
.
SUCCESS
);
}
});
...
...
@@ -746,7 +749,11 @@ router.post('/thread/comment/add', function(req, res, next) {
if
(
err
)
{
callback
(
err
);
}
else
{
forumThreadService
.
getById
(
tid
,
function
(
err
,
thread
){
if
(
entity
.
level
==
1
){
forumAboutMEService
.
saveCommentLevel1
(
thread
,
comment
);
}
var
comments
=
thread
.
comments
;
var
array
=
[];
if
(
comments
&&
comments
.
length
>
0
)
{
...
...
app/controllers/mobile/forumAboutMe.js
0 → 100644
View file @
423cb350
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
user
=
require
(
'../../utils/user'
),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
forumAboutMEService
=
require
(
'../../service/forumAboutMEService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
router
.
get
(
'/aboutme/me2other'
,
function
(
req
,
res
,
next
)
{
var
userId
=
user
.
getMobileUser
(
req
);
var
entcode
=
req
.
session
.
user
.
ent_code
;
var
pageNo
=
req
.
params
.
pageNo
;
var
pageSize
=
req
.
params
.
pageSize
;
forumAboutMEService
.
me2other
(
entcode
,
userId
,
pageNo
,
pageSize
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
router
.
get
(
'/aboutme/other2me'
,
function
(
req
,
res
,
next
)
{
var
userId
=
user
.
getMobileUser
(
req
);
var
entcode
=
req
.
session
.
user
.
ent_code
;
var
pageNo
=
req
.
params
.
pageNo
;
var
pageSize
=
req
.
params
.
pageSize
;
forumAboutMEService
.
other2me
(
entcode
,
userId
,
pageNo
,
pageSize
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
\ No newline at end of file
app/controllers/mobile/forumThread.js
View file @
423cb350
...
...
@@ -18,7 +18,7 @@ var forumLimitOperationService = require('../../service/forumLimitOperationServi
var
forumThreadAttendService
=
require
(
'../../service/forumThreadAttendService'
);
var
commentTips
=
require
(
'../../utils/commentTips'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
forumAboutMEService
=
require
(
'../../service/forumAboutMEService'
);
var
user
=
require
(
'../../utils/user'
);
var
async
=
require
(
'async'
);
module
.
exports
=
function
(
app
)
{
...
...
@@ -181,6 +181,7 @@ router.post('/thread/create', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
saveThread
(
thread
);
forumLimitOperationService
.
checkLimitOperationProhibitionAddIntegral
(
userId
,
function
(
err
,
flag
){
if
(
err
){
console
.
error
(
err
);
...
...
@@ -557,6 +558,7 @@ router.post('/thread/:tid/comment/add', function(req, res, next) {
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
thread
.
from
.
_id
);
forumThreadAttendService
.
threadAttend
(
thread
.
_id
,
user
.
getMobileUser
(
req
),
function
(
err
){});
}
forumAboutMEService
.
saveCommentLevel1
(
thread
,
newComment
);
var
comments
=
thread
.
comments
;
var
array
=
[];
if
(
comments
&&
comments
.
items
&&
comments
.
items
.
length
>
0
)
{
...
...
@@ -699,6 +701,7 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
thread
.
from
.
_id
);
forumThreadAttendService
.
threadAttend
(
thread
.
_id
,
user
.
getMobileUser
(
req
),
function
(
err
){});
}
forumAboutMEService
.
saveCommentLevel1
(
thread
,
newComment
);
var
comments
=
thread
.
comments
;
// console.log('=========');
// console.log(comments);
...
...
@@ -861,6 +864,7 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
to
);
forumThreadAttendService
.
threadAttend
(
tid
,
user
.
getMobileUser
(
req
),
function
(
err
){});
}
forumAboutMEService
.
saveCommentLevel2
(
tid
,
comment
,
newComment
);
var
comments
=
comment
.
comments
;
var
array
=
[];
if
(
comments
&&
comments
.
length
>
0
)
{
...
...
app/models/forumAboutMe.js
View file @
423cb350
...
...
@@ -9,62 +9,41 @@ var ForumAboutMeSchema = new Schema({
require
:
true
,
index
:
true
},
owner
:
{
//归属用户(本人)
from
:
{
//该记录的作者
type
:
Schema
.
Types
.
ObjectId
,
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
},
type
:{
//分类 1.我发的贴子(创建帖子) 2.我的帖子的一级评论(创建一级评论时,thread.from是我的) 3.评论我的评论(创建二级评论时,to是我)(帖子不一定是我自己的)
type
:
Number
,
require
:
true
,
default
:
0
},
thread
:{
//帖子 type为1,2时必定为我发的帖子
type
:
Schema
.
Types
.
ObjectId
,
index
:
true
,
ref
:
'ForumThread'
,
require
:
true
},
threadOwner
:{
//发帖人(储存非我的帖子的发帖人) type为3是需要
to
:
{
//如果是评论, 代表被评论人
type
:
Schema
.
Types
.
ObjectId
,
require
:
false
,
index
:
true
,
ref
:
'ForumUser'
},
t
hreadStatus
:{
//帖子状态
t
ype
:{
//分类 1帖子 2一级评论 3二级评论
type
:
Number
,
require
:
true
,
default
:
0
},
comment
:{
//评论(别人对我的评论) type为2和3时必须
thread
:{
//帖子
type
:
Schema
.
Types
.
ObjectId
,
index
:
true
,
ref
:
'ForumThread'
,
require
:
true
},
commentLevel1
:{
//一级评论
type
:
Schema
.
Types
.
ObjectId
,
require
:
false
,
index
:
true
,
ref
:
'ForumComment'
},
comment
Owner
:{
//评论人 type为2和3时必须
comment
Level2
:{
//二级评论
type
:
Schema
.
Types
.
ObjectId
,
require
:
false
,
index
:
true
,
ref
:
'ForumUser'
},
commentStatus
:{
//评论状态
type
:
Number
,
require
:
true
,
default
:
0
},
parentComment
:{
//父级评论(我发的评论) type为3时需要
type
:
Schema
.
Types
.
ObjectId
,
require
:
false
,
index
:
true
,
ref
:
'ForumComment'
},
parentCommentStatus
:{
//评论状态
type
:
Number
,
require
:
true
,
default
:
0
},
created
:
{
//时间
type
:
Date
,
require
:
true
,
...
...
app/service/forumAboutMEService.js
0 → 100644
View file @
423cb350
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumAboutMe
=
mongoose
.
model
(
'ForumAboutMe'
);
var
THREAD_TYPE
=
1
;
var
COMMENTLEVEL1_TYPE
=
2
;
var
COMMENTLEVEL2_TYPE
=
3
;
var
forumCommentService
=
require
(
'./forumCommentService'
);
exports
.
saveThread
=
function
(
thread
){
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
thread
.
ent_code
,
from
:
thread
.
from
,
type
:
THREAD_TYPE
,
thread
:
thread
.
_id
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
};
exports
.
saveCommentLevel1
=
function
(
thread
,
commentLevel1
){
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
thread
.
ent_code
,
from
:
commentLevel1
.
from
,
to
:
commentLevel1
.
to
,
type
:
COMMENTLEVEL1_TYPE
,
thread
:
thread
.
_id
,
commentLevel1
:
commentLevel1
.
_id
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
};
exports
.
saveCommentLevel2
=
function
(
tid
,
commentLevel1
,
commentLevel2
){
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
commentLevel2
.
ent_code
,
from
:
commentLevel2
.
from
,
to
:
commentLevel2
.
to
,
type
:
COMMENTLEVEL2_TYPE
,
thread
:
tid
,
commentLevel1
:
commentLevel1
.
_id
,
commentLevel2
:
commentLevel2
.
_id
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
};
exports
.
saveCommentLevel2BySearch
=
function
(
tid
,
l1id
,
l2id
){
forumCommentService
.
getCommentById
(
l2id
,
function
(
err
,
commentLevel2
){
if
(
err
){
return
console
.
log
(
err
);
}
if
(
commentLevel2
){
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
commentLevel2
.
ent_code
,
from
:
commentLevel2
.
from
,
to
:
commentLevel2
.
to
,
type
:
COMMENTLEVEL2_TYPE
,
thread
:
tid
,
commentLevel1
:
l1id
,
commentLevel2
:
l2id
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
}
});
};
/*exports.updateThreadStatus=function(tid,status){
var condition={
type:THREAD_TYPE,
thread:tid
}
ForumAboutMe.findOneAndUpdate(condition,{threadStatus:status},function(err){
if(err){
console.log(err);
}
});
};
exports.updateCommentLevel1Status=function(cid,status){
var condition={
type:COMMENTLEVEL1_TYPE,
commentLevel1:cid
}
ForumAboutMe.findOneAndUpdate(condition,{commentLevel1Status:status},function(err){
if(err){
console.log(err);
}
});
};
exports.updateCommentLevel2Status=function(cid,status){
var condition={
type:COMMENTLEVEL2_TYPE,
commentLevel2:cid
}
ForumAboutMe.findOneAndUpdate(condition,{commentLevel2Status:status},function(err){
if(err){
console.log(err);
}
});
};*/
exports
.
me2other
=
function
(
ent_code
,
id
,
pageNo
,
pageSize
,
callback
){
var
condition
=
{
ent_code
:
ent_code
,
from
:
id
,
$or
:[{
type
:
THREAD_TYPE
,
'thread.status'
:
1
},{
type
:
COMMENTLEVEL1_TYPE
,
'commentLevel1.status'
:
1
},{
type
:
COMMENTLEVEL2_TYPE
,
'commentLevel2.status'
:
1
}]
};
ForumAboutMe
.
find
(
condition
).
count
(
function
(
err
,
count
){
if
(
err
){
return
callback
&&
callback
(
err
);
}
var
obj
=
{};
obj
.
total
=
count
||
0
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
[];
if
(
!
count
){
return
callback
&&
callback
(
null
,
obj
);
}
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-created'
;
ForumAboutMe
.
find
(
condition
).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon displayName displayIcon classLevel'
}).
populate
({
path
:
'thread'
,
select
:
'-title -topTime -tag_topTime -tag -comments -created'
}).
populate
({
path
:
'commentLevel1 commentLevel2'
,
select
:
'content comment_count praise_count status floor'
}).
limit
(
limit
).
skip
(
skip
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
){
return
callback
&&
callback
(
err
);
}
obj
.
items
=
docs
||
[];
return
callback
&&
callback
(
null
,
obj
);
});
});
};
exports
.
other2me
=
function
(
ent_code
,
id
,
pageNo
,
pageSize
,
callback
){
var
condition
=
{
ent_code
:
ent_code
,
to
:
id
,
$or
:[{
type
:
COMMENTLEVEL1_TYPE
,
'commentLevel1.status'
:
1
},{
type
:
COMMENTLEVEL2_TYPE
,
'commentLevel2.status'
:
1
}]
};
ForumAboutMe
.
find
(
condition
).
count
(
function
(
err
,
count
){
if
(
err
){
return
callback
&&
callback
(
err
);
}
var
obj
=
{};
obj
.
total
=
count
||
0
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
[];
if
(
!
count
){
return
callback
&&
callback
(
null
,
obj
);
}
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-created'
;
ForumAboutMe
.
find
(
condition
).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon displayName displayIcon classLevel'
}).
populate
({
path
:
'thread'
,
select
:
'-title -topTime -tag_topTime -tag -comments -created'
}).
populate
({
path
:
'commentLevel1 commentLevel2'
,
select
:
'content comment_count praise_count status floor'
}).
limit
(
limit
).
skip
(
skip
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
){
return
callback
&&
callback
(
err
);
}
obj
.
items
=
docs
||
[];
return
callback
&&
callback
(
null
,
obj
);
});
});
};
\ 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