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
0c1302b5
Commit
0c1302b5
authored
Dec 02, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'newfunc_1120_thread_quality'
# Conflicts: # app/controllers/mobile/forumThread.js
parents
43a2e2b3
89770488
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
629 additions
and
156 deletions
+629
-156
forumIdentifyUser.js
app/controllers/admin/forumIdentifyUser.js
+38
-31
forumMember.js
app/controllers/admin/forumMember.js
+3
-0
forumThread.js
app/controllers/admin/forumThread.js
+257
-109
forumInfo.js
app/controllers/mobile/forumInfo.js
+4
-4
forumThread.js
app/controllers/mobile/forumThread.js
+219
-1
forumThread.js
app/models/forumThread.js
+5
-0
forumUser.js
app/models/forumUser.js
+6
-0
forumCommentService.js
app/service/forumCommentService.js
+48
-3
forumThreadService.js
app/service/forumThreadService.js
+38
-8
forumUserService.js
app/service/forumUserService.js
+11
-0
No files found.
app/controllers/admin/forumIdentifyUser.js
View file @
0c1302b5
...
...
@@ -6,6 +6,7 @@ var express = require('express'),
var
mongoose
=
require
(
'mongoose'
);
var
moment
=
require
(
'moment'
);
var
ForumThread
=
require
(
'../../models/forumThread'
);
var
forumUserService
=
require
(
'../../service/forumUserService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
httpService
=
require
(
'../../service/httpService'
);
...
...
@@ -37,27 +38,36 @@ 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
);
}
});
}
var
updateUser
=
function
(
user
,
entity
){
var
updateObj
=
{},
isUpdate
=
false
;
if
(
user
&&
entity
&&
user
.
_id
){
if
(
entity
.
nickName
&&
user
.
nickName
!==
entity
.
nickName
){
updateObj
.
nickName
=
entity
.
nickName
;
isUpdate
=
true
;
}
if
(
entity
.
icon
&&
user
.
icon
!==
entity
.
icon
){
updateObj
.
icon
=
entity
.
icon
;
isUpdate
=
true
;
}
if
(
entity
.
mid
&&
!
user
.
mid
){
updateObj
.
mid
=
entity
.
mid
;
isUpdate
=
true
;
}
if
(
isUpdate
){
forumUserService
.
updateUserById
(
user
.
_id
,
updateObj
,
function
(
err
,
result
){
if
(
err
){
console
.
log
(
err
);
}
else
{
console
.
log
(
'用户:'
+
user
.
_id
+
'---------更新成功'
);
console
.
log
(
updateObj
);
}
});
}
}
}
//验证用户身份
router
.
post
(
'/user/identifyUser'
,
function
(
req
,
res
,
next
){
...
...
@@ -67,29 +77,27 @@ router.post('/user/identifyUser',function(req,res,next){
}
else
if
(
!
req
.
session
.
mobileForumUser
||
req
.
session
.
mobileForumUser
.
openId
!==
entity
.
openId
){
forumUserService
.
getUserByUid
(
entity
.
uid
,
function
(
err
,
doc
){
if
(
err
){
console
.
log
(
err
);
console
.
error
(
err
);
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
);
}
}
updateUser
(
doc
,
entity
);
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
openId
:
doc
.
uid
,
mid
:
doc
.
mid
||
entity
.
mid
};
res
.
json
({
result
:
'success'
,
userId
:
doc
.
_id
});
}
else
{
forumUserService
.
createUser
(
entity
,
function
(
err
,
doc
){
if
(
err
){
console
.
log
(
err
);
console
.
error
(
err
);
res
.
json
(
'error'
);
}
else
{
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
openId
:
doc
.
uid
,
mid
:
doc
.
mid
};
res
.
json
({
result
:
'success'
,
userId
:
doc
.
_id
});
}
...
...
@@ -196,4 +204,3 @@ router.post('/user/checkLimitAction', function(req, res, next) {
res
.
json
(
returnObject
);
}
});
app/controllers/admin/forumMember.js
View file @
0c1302b5
...
...
@@ -51,6 +51,9 @@ router.post('/member/searchMembers', function(req, res, next) {
$regex
:
search
.
nickName
};
}
if
(
search
.
mid
){
q
.
mid
=
search
.
mid
;
}
if
(
search
.
displayName
)
{
q
.
displayName
=
{
$regex
:
search
.
displayName
...
...
app/controllers/admin/forumThread.js
View file @
0c1302b5
...
...
@@ -20,7 +20,7 @@ var forumThreadService = require('../../service/forumThreadService'),
forumCommentService
=
require
(
'../../service/forumCommentService'
),
forumTagService
=
require
(
'../../service/forumTagService'
),
forumUserService
=
require
(
'../../service/forumUserService'
),
// var forumLimitActionRefService = require('../../service/forumLimitActionRefService');
// var forumLimitActionRefService = require('../../service/forumLimitActionRefService');
forumLimitOperationService
=
require
(
'../../service/forumLimitOperationService'
),
forumAboutMEService
=
require
(
'../../service/forumAboutMEService'
),
httpService
=
require
(
'../../service/httpService'
);
...
...
@@ -385,6 +385,8 @@ router.get('/threads/list', function(req, res, next) {
var
type
=
req
.
query
.
type
;
var
status
=
req
.
query
.
status
;
var
nickName
=
req
.
query
.
nickName
;
var
mid
=
req
.
query
.
mid
;
var
quality
=
req
.
query
.
quality
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
...
...
@@ -420,8 +422,27 @@ router.get('/threads/list', function(req, res, next) {
if
(
status
)
{
conditions
.
status
=
status
;
}
if
(
nickName
)
{
if
(
quality
)
{
conditions
.
quality
=
quality
;
}
if
(
mid
)
{
forumThreadService
.
getAllThreadByFidAndMid
(
mid
,
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
pid
)
{
forumThreadService
.
getById
(
pid
,
function
(
err
,
parentThread
)
{
res
.
json
(
_
.
assign
({
parentThread
:
parentThread
},
results
,
returnCode
.
SUCCESS
));
});
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
}
});
}
else
if
(
nickName
)
{
forumThreadService
.
getAllThreadByFidAndNickName
(
nickName
,
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -440,7 +461,7 @@ router.get('/threads/list', function(req, res, next) {
}
});
}
else
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
"-created"
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -561,6 +582,37 @@ router.get('/thread/:tid/comment/list/:floor', function(req, res, next) {
}
});
//评论列表(根据楼层查询)
router
.
get
(
'/thread/:tid/comment/list/member/:mid'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
,
content
=
req
.
query
.
content
||
''
,
mid
=
req
.
params
.
mid
,
pageNo
=
req
.
query
.
pageNo
||
1
,
pageSize
=
req
.
query
.
pageSize
||
10
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
thread
:
tid
};
if
(
content
)
{
conditions
.
content
=
{
$regex
:
content
,
$options
:
'i'
};
}
if
(
tid
&&
mid
)
{
forumCommentService
.
getCommentListByMid
(
mid
,
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
// 更新评论状态
router
.
post
(
'/thread/comment/update/:cid'
,
function
(
req
,
res
,
next
)
{
var
cid
=
req
.
params
.
cid
||
null
;
...
...
@@ -1024,81 +1076,109 @@ router.get('/thread/:tid/spreadchain', function(req, res, next) {
// 导出文章评论内容
router
.
get
(
'/thread/:tid/exportComments'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
,
ent_code
=
req
.
query
.
ent_code
||
null
;
then
(
function
(
cont
){
if
(
tid
&&
ent_code
){
ent_code
=
req
.
session
.
user
.
ent_code
||
null
,
mid
=
req
.
query
.
mid
,
floor
=
req
.
query
.
floor
,
content
=
req
.
query
.
content
;
then
(
function
(
cont
)
{
if
(
tid
&&
ent_code
)
{
then
.
parallel
([
function
(
cont2
){
forumThreadService
.
getThreadByIdSimple
({
_id
:
tid
},
function
(
err
,
doc
){
forumPraiseLogService
.
queryPraiseLogV2
({
ent_code
:
ent_code
,
thread
:
tid
,
type
:
1
},
function
(
err
,
results
){
if
(
err
){
function
(
cont2
)
{
forumThreadService
.
getThreadByIdSimple
({
_id
:
tid
},
function
(
err
,
doc
)
{
forumPraiseLogService
.
queryPraiseLogV2
({
ent_code
:
ent_code
,
thread
:
tid
,
type
:
1
},
function
(
err
,
results
)
{
if
(
err
)
{
cont2
(
err
);
}
else
{
if
(
results
&&
results
.
length
>
0
)
{
}
else
{
if
(
results
&&
results
.
length
>
0
)
{
var
praiseNames
=
[];
var
praiseOpenIds
=
[];
_
.
forEach
(
results
,
function
(
e
)
{
if
(
e
.
user
)
{
praiseNames
.
push
(
e
.
user
.
nickName
||
'游客'
);
praiseOpenIds
.
push
(
e
.
user
.
uid
);
if
(
e
.
user
)
{
praiseNames
.
push
(
e
.
user
.
nickName
||
'游客'
);
praiseOpenIds
.
push
(
e
.
user
.
uid
);
}
});
doc
=
doc
.
toObject
();
doc
.
praiseNames
=
praiseNames
.
toString
();
doc
.
praiseOpenIds
=
praiseOpenIds
.
toString
();
cont2
(
null
,
doc
);
}
else
{
cont2
(
null
,
doc
);
}
else
{
doc
=
doc
.
toObject
();
doc
.
praiseNames
=
''
;
doc
.
praiseOpenIds
=
''
;
cont2
(
null
,
doc
);
cont2
(
null
,
doc
);
}
}
});
});
},
function
(
cont2
){
function
(
cont2
)
{
var
conditions
=
{
ent_code
:
ent_code
,
thread
:
tid
,
level
:
1
thread
:
tid
};
//查询所有评论
forumCommentService
.
getAllCommentByThread
(
conditions
,
function
(
err
,
docs
)
{
cont2
(
err
,
docs
);
});
if
(
content
)
{
conditions
.
content
=
{
$regex
:
content
,
$options
:
'i'
};
}
if
(
mid
)
{
forumCommentService
.
getCommentListByMid
(
mid
,
conditions
,
1
,
10000
,
function
(
err
,
results
)
{
cont2
(
err
,
results
?
results
.
items
:
[]);
});
}
else
if
(
floor
)
{
conditions
.
level
=
'1'
;
conditions
.
floor
=
floor
;
forumCommentService
.
getAllComment
(
conditions
,
1
,
1
,
function
(
err
,
results
)
{
cont2
(
err
,
results
?
results
.
items
:
[]);
});
}
else
{
conditions
.
level
=
'1'
;
//查询所有评论
forumCommentService
.
getAllCommentByThread
(
conditions
,
function
(
err
,
docs
)
{
cont2
(
err
,
docs
);
});
}
}
]).
then
(
function
(
cont2
,
datas
)
{
cont
(
null
,
datas
[
0
],
datas
[
1
]);
}).
fail
(
function
(
cont2
,
err
)
{
]).
then
(
function
(
cont2
,
datas
)
{
cont
(
null
,
datas
[
0
],
datas
[
1
]);
}).
fail
(
function
(
cont2
,
err
)
{
cont
(
err
);
});
}
else
{
}
else
{
cont
(
'params error'
);
}
}).
then
(
function
(
cont
,
thread
,
comments
)
{
}).
then
(
function
(
cont
,
thread
,
comments
)
{
//获取点赞信息
var
asyncTasks
=
[];
_
.
forEach
(
comments
,
function
(
e
)
{
asyncTasks
.
push
(
function
(
cb
)
{
var
conditions
=
{
ent_code
:
ent_code
,
thread
:
tid
,
type
:
2
,
comment
:
e
.
_id
ent_code
:
ent_code
,
thread
:
tid
,
type
:
2
,
comment
:
e
.
_id
}
forumPraiseLogService
.
queryPraiseLogV2
(
conditions
,
function
(
err
,
results
){
if
(
err
)
{
forumPraiseLogService
.
queryPraiseLogV2
(
conditions
,
function
(
err
,
results
)
{
if
(
err
)
{
cb
(
null
,
e
);
}
else
{
if
(
results
)
{
}
else
{
if
(
results
)
{
var
praiseNames
=
[];
var
praiseOpenIds
=
[];
_
.
forEach
(
results
,
function
(
e2
)
{
if
(
e2
.
user
)
{
praiseNames
.
push
(
e2
.
user
.
nickName
||
'游客'
);
praiseOpenIds
.
push
(
e2
.
user
.
uid
);
if
(
e2
.
user
)
{
praiseNames
.
push
(
e2
.
user
.
nickName
||
'游客'
);
praiseOpenIds
.
push
(
e2
.
user
.
uid
);
}
});
e
.
praiseNames
=
praiseNames
.
toString
();
...
...
@@ -1111,94 +1191,141 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
});
});
async
.
parallel
(
asyncTasks
,
function
(
err
,
items
)
{
cont
(
err
,
thread
,
items
);
cont
(
err
,
thread
,
items
);
});
}).
then
(
function
(
cont
,
thread
,
items
)
{
}).
then
(
function
(
cont
,
thread
,
items
)
{
//表头
var
conf
=
{},
rows
=
[];
conf
.
cols
=
[
{
caption
:
'帖子标题'
,
type
:
'string'
},
{
caption
:
'发布时间'
,
type
:
'string'
},
{
caption
:
'发帖人'
,
type
:
'string'
},
{
caption
:
'openId'
,
type
:
'string'
},
{
caption
:
'内容'
,
type
:
'string'
},
{
caption
:
'评论数'
,
type
:
'string'
},
{
caption
:
'转发数'
,
type
:
'string'
},
{
caption
:
'点赞数'
,
type
:
'string'
},
{
caption
:
'点赞人'
,
type
:
'string'
},
{
caption
:
'点赞点赞人openId'
,
type
:
'string'
}
];
//内容
//文章内容
var
t_title
=
thread
.
title
==
'发话题'
?
'无标题'
:
thread
.
title
,
t_time
=
date_format
(
thread
.
created
),
t_from
=
thread
.
from
?
thread
.
from
.
nickName
:
'游客'
,
t_from_openId
=
thread
.
from
?
thread
.
from
.
uid
:
''
,
t_praiseNames
=
thread
.
praiseNames
,
t_praiseOpenIds
=
thread
.
praiseOpenIds
;
var
contentReplace
=
function
(
str
){
var
strAfter
=
''
;
var
regex
=
/
[\0
-
\x
1F
\x
7F-
\x
9F
\x
AD
\u
0378
\u
0379
\u
037F-
\u
0383
\u
038B
\u
038D
\u
03A2
\u
0528-
\u
0530
\u
0557
\u
0558
\u
0560
\u
0588
\u
058B-
\u
058E
\u
0590
\u
05C8-
\u
05CF
\u
05EB-
\u
05EF
\u
05F5-
\u
0605
\u
061C
\u
061D
\u
06DD
\u
070E
\u
070F
\u
074B
\u
074C
\u
07B2-
\u
07BF
\u
07FB-
\u
07FF
\u
082E
\u
082F
\u
083F
\u
085C
\u
085D
\u
085F-
\u
089F
\u
08A1
\u
08AD-
\u
08E3
\u
08FF
\u
0978
\u
0980
\u
0984
\u
098D
\u
098E
\u
0991
\u
0992
\u
09A9
\u
09B1
\u
09B3-
\u
09B5
\u
09BA
\u
09BB
\u
09C5
\u
09C6
\u
09C9
\u
09CA
\u
09CF-
\u
09D6
\u
09D8-
\u
09DB
\u
09DE
\u
09E4
\u
09E5
\u
09FC-
\u
0A00
\u
0A04
\u
0A0B-
\u
0A0E
\u
0A11
\u
0A12
\u
0A29
\u
0A31
\u
0A34
\u
0A37
\u
0A3A
\u
0A3B
\u
0A3D
\u
0A43-
\u
0A46
\u
0A49
\u
0A4A
\u
0A4E-
\u
0A50
\u
0A52-
\u
0A58
\u
0A5D
\u
0A5F-
\u
0A65
\u
0A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0DBF
\u
0DC7-
\u
0DC9
\u
0DCB-
\u
0DCE
\u
0DD5
\u
0DD7
\u
0DE0-
\u
0DF1
\u
0DF5-
\u
0E00
\u
0E3B-
\u
0E3E
\u
0E5C-
\u
0E80
\u
0E83
\u
0E85
\u
0E86
\u
0E89
\u
0E8B
\u
0E8C
\u
0E8E-
\u
0E93
\u
0E98
\u
0EA0
\u
0EA4
\u
0EA6
\u
0EA8
\u
0EA9
\u
0EAC
\u
0EBA
\u
0EBE
\u
0EBF
\u
0EC5
\u
0EC7
\u
0ECE
\u
0ECF
\u
0EDA
\u
0EDB
\u
0EE0-
\u
0EFF
\u
0F48
\u
0F6D-
\u
0F70
\u
0F98
\u
0FBD
\u
0FCD
\u
0FDB-
\u
0FFF
\u
10C6
\u
10C8-
\u
10CC
\u
10CE
\u
10CF
\u
1249
\u
124E
\u
124F
\u
1257
\u
1259
\u
125E
\u
125F
\u
1289
\u
128E
\u
128F
\u
12B1
\u
12B6
\u
12B7
\u
12BF
\u
12C1
\u
12C6
\u
12C7
\u
12D7
\u
1311
\u
1316
\u
1317
\u
135B
\u
135C
\u
137D-
\u
137F
\u
139A-
\u
139F
\u
13F5-
\u
13FF
\u
169D-
\u
169F
\u
16F1-
\u
16FF
\u
170D
\u
1715-
\u
171F
\u
1737-
\u
173F
\u
1754-
\u
175F
\u
176D
\u
1771
\u
1774-
\u
177F
\u
17DE
\u
17DF
\u
17EA-
\u
17EF
\u
17FA-
\u
17FF
\u
180F
\u
181A-
\u
181F
\u
1878-
\u
187F
\u
18AB-
\u
18AF
\u
18F6-
\u
18FF
\u
191D-
\u
191F
\u
192C-
\u
192F
\u
193C-
\u
193F
\u
1941-
\u
1943
\u
196E
\u
196F
\u
1975-
\u
197F
\u
19AC-
\u
19AF
\u
19CA-
\u
19CF
\u
19DB-
\u
19DD
\u
1A1C
\u
1A1D
\u
1A5F
\u
1A7D
\u
1A7E
\u
1A8A-
\u
1A8F
\u
1A9A-
\u
1A9F
\u
1AAE-
\u
1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u
A7F7
\u
A82C-
\u
A82F
\u
A83A-
\u
A83F
\u
A878-
\u
A87F
\u
A8C5-
\u
A8CD
\u
A8DA-
\u
A8DF
\u
A8FC-
\u
A8FF
\u
A954-
\u
A95E
\u
A97D-
\u
A97F
\u
A9CE
\u
A9DA-
\u
A9DD
\u
A9E0-
\u
A9FF
\u
AA37-
\u
AA3F
\u
AA4E
\u
AA4F
\u
AA5A
\u
AA5B
\u
AA7C-
\u
AA7F
\u
AAC3-
\u
AADA
\u
AAF7-
\u
AB00
\u
AB07
\u
AB08
\u
AB0F
\u
AB10
\u
AB17-
\u
AB1F
\u
AB27
\u
AB2F-
\u
ABBF
\u
ABEE
\u
ABEF
\u
ABFA-
\u
ABFF
\u
D7A4-
\u
D7AF
\u
D7C7-
\u
D7CA
\u
D7FC-
\u
F8FF
\u
FA6E
\u
FA6F
\u
FADA-
\u
FAFF
\u
FB07-
\u
FB12
\u
FB18-
\u
FB1C
\u
FB37
\u
FB3D
\u
FB3F
\u
FB42
\u
FB45
\u
FBC2-
\u
FBD2
\u
FD40-
\u
FD4F
\u
FD90
\u
FD91
\u
FDC8-
\u
FDEF
\u
FDFE
\u
FDFF
\u
FE1A-
\u
FE1F
\u
FE27-
\u
FE2F
\u
FE53
\u
FE67
\u
FE6C-
\u
FE6F
\u
FE75
\u
FEFD-
\u
FF00
\u
FFBF-
\u
FFC1
\u
FFC8
\u
FFC9
\u
FFD0
\u
FFD1
\u
FFD8
\u
FFD9
\u
FFDD-
\u
FFDF
\u
FFE7
\u
FFEF-
\u
FFFB
\u
FFFE
\u
FFFF
]
/g
if
(
str
){
strAfter
=
str
.
replace
(
/<
[^
>
]
+>/g
,
''
).
replace
(
regex
,
''
);
rows
=
[];
conf
.
cols
=
[{
caption
:
'帖子标题'
,
type
:
'string'
},
{
caption
:
'发布时间'
,
type
:
'string'
},
{
caption
:
'发帖人'
,
type
:
'string'
},
{
caption
:
'openId'
,
type
:
'string'
},
{
caption
:
'会员编号'
,
type
:
'string'
},
{
caption
:
'内容'
,
type
:
'string'
},
{
caption
:
'评论数'
,
type
:
'string'
},
{
caption
:
'转发数'
,
type
:
'string'
},
{
caption
:
'点赞数'
,
type
:
'string'
},
{
caption
:
'点赞人'
,
type
:
'string'
},
{
caption
:
'点赞点赞人openId'
,
type
:
'string'
}];
var
contentReplace
=
function
(
str
)
{
var
strAfter
=
''
;
var
regex
=
/
[\0
-
\x
1F
\x
7F-
\x
9F
\x
AD
\u
0378
\u
0379
\u
037F-
\u
0383
\u
038B
\u
038D
\u
03A2
\u
0528-
\u
0530
\u
0557
\u
0558
\u
0560
\u
0588
\u
058B-
\u
058E
\u
0590
\u
05C8-
\u
05CF
\u
05EB-
\u
05EF
\u
05F5-
\u
0605
\u
061C
\u
061D
\u
06DD
\u
070E
\u
070F
\u
074B
\u
074C
\u
07B2-
\u
07BF
\u
07FB-
\u
07FF
\u
082E
\u
082F
\u
083F
\u
085C
\u
085D
\u
085F-
\u
089F
\u
08A1
\u
08AD-
\u
08E3
\u
08FF
\u
0978
\u
0980
\u
0984
\u
098D
\u
098E
\u
0991
\u
0992
\u
09A9
\u
09B1
\u
09B3-
\u
09B5
\u
09BA
\u
09BB
\u
09C5
\u
09C6
\u
09C9
\u
09CA
\u
09CF-
\u
09D6
\u
09D8-
\u
09DB
\u
09DE
\u
09E4
\u
09E5
\u
09FC-
\u
0A00
\u
0A04
\u
0A0B-
\u
0A0E
\u
0A11
\u
0A12
\u
0A29
\u
0A31
\u
0A34
\u
0A37
\u
0A3A
\u
0A3B
\u
0A3D
\u
0A43-
\u
0A46
\u
0A49
\u
0A4A
\u
0A4E-
\u
0A50
\u
0A52-
\u
0A58
\u
0A5D
\u
0A5F-
\u
0A65
\u
0A76-
\u
0A80
\u
0A84
\u
0A8E
\u
0A92
\u
0AA9
\u
0AB1
\u
0AB4
\u
0ABA
\u
0ABB
\u
0AC6
\u
0ACA
\u
0ACE
\u
0ACF
\u
0AD1-
\u
0ADF
\u
0AE4
\u
0AE5
\u
0AF2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
0E89
\u
0E8B
\u
0E8C
\u
0E8E-
\u
0E93
\u
0E98
\u
0EA0
\u
0EA4
\u
0EA6
\u
0EA8
\u
0EA9
\u
0EAC
\u
0EBA
\u
0EBE
\u
0EBF
\u
0EC5
\u
0EC7
\u
0ECE
\u
0ECF
\u
0EDA
\u
0EDB
\u
0EE0-
\u
0EFF
\u
0F48
\u
0F6D-
\u
0F70
\u
0F98
\u
0FBD
\u
0FCD
\u
0FDB-
\u
0FFF
\u
10C6
\u
10C8-
\u
10CC
\u
10CE
\u
10CF
\u
1249
\u
124E
\u
124F
\u
1257
\u
1259
\u
125E
\u
125F
\u
1289
\u
128E
\u
128F
\u
12B1
\u
12B6
\u
12B7
\u
12BF
\u
12C1
\u
12C6
\u
12C7
\u
12D7
\u
1311
\u
1316
\u
1317
\u
135B
\u
135C
\u
137D-
\u
137F
\u
139A-
\u
139F
\u
13F5-
\u
13FF
\u
169D-
\u
169F
\u
16F1-
\u
16FF
\u
170D
\u
1715-
\u
171F
\u
1737-
\u
173F
\u
1754-
\u
175F
\u
176D
\u
1771
\u
1774-
\u
177F
\u
17DE
\u
17DF
\u
17EA-
\u
17EF
\u
17FA-
\u
17FF
\u
180F
\u
181A-
\u
181F
\u
1878-
\u
187F
\u
18AB-
\u
18AF
\u
18F6-
\u
18FF
\u
191D-
\u
191F
\u
192C-
\u
192F
\u
193C-
\u
193F
\u
1941-
\u
1943
\u
196E
\u
196F
\u
1975-
\u
197F
\u
19AC-
\u
19AF
\u
19CA-
\u
19CF
\u
19DB-
\u
19DD
\u
1A1C
\u
1A1D
\u
1A5F
\u
1A7D
\u
1A7E
\u
1A8A-
\u
1A8F
\u
1A9A-
\u
1A9F
\u
1AAE-
\u
1AFF
\u
1B4C-
\u
1B4F
\u
1B7D-
\u
1B7F
\u
1BF4-
\u
1BFB
\u
1C38-
\u
1C3A
\u
1C4A-
\u
1C4C
\u
1C80-
\u
1CBF
\u
1CC8-
\u
1CCF
\u
1CF7-
\u
1CFF
\u
1DE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DA-
\u
A9DD
\u
A9E0-
\u
A9FF
\u
AA37-
\u
AA3F
\u
AA4E
\u
AA4F
\u
AA5A
\u
AA5B
\u
AA7C-
\u
AA7F
\u
AAC3-
\u
AADA
\u
AAF7-
\u
AB00
\u
AB07
\u
AB08
\u
AB0F
\u
AB10
\u
AB17-
\u
AB1F
\u
AB27
\u
AB2F-
\u
ABBF
\u
ABEE
\u
ABEF
\u
ABFA-
\u
ABFF
\u
D7A4-
\u
D7AF
\u
D7C7-
\u
D7CA
\u
D7FC-
\u
F8FF
\u
FA6E
\u
FA6F
\u
FADA-
\u
FAFF
\u
FB07-
\u
FB12
\u
FB18-
\u
FB1C
\u
FB37
\u
FB3D
\u
FB3F
\u
FB42
\u
FB45
\u
FBC2-
\u
FBD2
\u
FD40-
\u
FD4F
\u
FD90
\u
FD91
\u
FDC8-
\u
FDEF
\u
FDFE
\u
FDFF
\u
FE1A-
\u
FE1F
\u
FE27-
\u
FE2F
\u
FE53
\u
FE67
\u
FE6C-
\u
FE6F
\u
FE75
\u
FEFD-
\u
FF00
\u
FFBF-
\u
FFC1
\u
FFC8
\u
FFC9
\u
FFD0
\u
FFD1
\u
FFD8
\u
FFD9
\u
FFDD-
\u
FFDF
\u
FFE7
\u
FFEF-
\u
FFFB
\u
FFFE
\u
FFFF
]
/g
if
(
str
)
{
strAfter
=
str
.
replace
(
/<
[^
>
]
+>/g
,
''
).
replace
(
regex
,
''
);
}
return
strAfter
;
}
return
strAfter
;
}
//文章内容
var
t_title
=
thread
.
title
==
'发话题'
?
'无标题'
:
thread
.
title
,
t_time
=
date_format
(
thread
.
created
),
t_from
=
contentReplace
(
thread
.
from
?
thread
.
from
.
nickName
:
'游客'
),
t_from_openId
=
thread
.
from
?
thread
.
from
.
uid
:
'暂无'
,
t_praiseNames
=
contentReplace
(
thread
.
praiseNames
),
t_praiseOpenIds
=
thread
.
praiseOpenIds
,
t_from_mid
=
thread
.
from
?
thread
.
from
.
mid
:
'暂无'
;
rows
.
push
([
t_title
,
t_time
,
t_from
,
t_from_openId
,
t_from_mid
?
t_from_mid
.
toString
()
:
'暂无'
,
contentReplace
(
thread
.
content
),
thread
.
comment_count
.
toString
(),
thread
.
share_count
.
toString
(),
thread
.
praise_count
.
toString
(),
t_praiseNames
,
t_praiseOpenIds
]);
rows
.
push
([
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
]);
rows
.
push
([
'楼层'
,
'发布时间'
,
'openId'
,
'会员名'
,
'内容'
,
'点赞数'
,
'点赞人'
,
'点赞人openId'
,
null
,
null
]);
t_praiseOpenIds
]);
rows
.
push
([
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
]);
rows
.
push
([
'楼层'
,
'发布时间'
,
'会员名'
,
'openId'
,
'会员编号'
,
'内容'
,
'点赞数'
,
'点赞人'
,
'点赞人openId'
,
null
,
null
]);
for
(
var
i
=
items
.
length
-
1
;
i
>=
0
;
i
--
)
{
var
comment
=
items
[
i
];
var
floor
=
comment
.
floor
,
var
thisFloor
=
comment
.
floor
||
'互动'
,
time
=
date_format
(
comment
.
created
),
openId
=
''
,
nickName
=
''
,
content
=
comment
.
content
?
contentReplace
(
comment
.
content
)
:
''
,
openId
=
'暂无'
,
nickName
=
'暂无'
,
fromMid
=
'暂无'
,
content
=
comment
.
content
?
contentReplace
(
comment
.
content
)
:
'暂无'
,
praiseCount
=
comment
.
praiseCount
||
0
,
praiseNames
=
''
,
praiseOpenIds
=
''
;
if
(
comment
.
praiseNames
)
{
praiseNames
=
'
暂无
'
,
praiseOpenIds
=
'
暂无
'
;
if
(
comment
.
praiseNames
)
{
praiseNames
=
comment
.
praiseNames
.
toString
();
praiseOpenIds
=
comment
.
praiseOpenIds
.
toString
();
}
if
(
comment
.
from
){
openId
=
comment
.
from
.
uid
||
''
;
nickName
=
comment
.
from
.
nickName
||
'游客'
;
if
(
comment
.
from
)
{
openId
=
comment
.
from
.
uid
||
'暂无'
;
nickName
=
comment
.
from
.
displayName
||
comment
.
from
.
nickName
||
'游客'
;
fromMid
=
comment
.
from
.
mid
||
'暂无'
;
}
var
this_row
=
[
floor
+
''
,
time
,
openId
,
nickName
,
content
,
praiseCount
.
toString
(),
praiseNames
,
praiseOpenIds
,
null
,
null
];
var
this_row
=
[
thisFloor
+
''
,
time
,
contentReplace
(
nickName
),
openId
,
fromMid
.
toString
(),
content
,
praiseCount
.
toString
(),
praiseNames
,
praiseOpenIds
,
null
,
null
];
rows
.
push
(
this_row
);
if
(
comment
.
comments
.
length
>
0
)
{
if
(
!
mid
&&
comment
.
comments
.
length
>
0
)
{
for
(
var
k
=
0
;
k
<
comment
.
comments
.
length
;
k
++
)
{
var
sub_comment
=
comment
.
comments
[
k
];
var
time
=
date_format
(
sub_comment
.
created
),
openId
=
''
,
nickName
=
''
,
content
=
sub_comment
.
content
?
contentReplace
(
sub_comment
.
content
)
:
''
,
to
=
''
;
if
(
sub_comment
.
from
){
openId
=
sub_comment
.
from
.
uid
||
''
;
nickName
=
sub_comment
.
from
.
nickName
||
'游客'
;
}
if
(
sub_comment
.
to
){
to
=
sub_comment
.
to
.
nickName
||
'游客'
;
var
subComment
=
comment
.
comments
[
k
];
var
subTime
=
date_format
(
subComment
.
created
),
subOpenId
=
'暂无'
,
subMid
=
'暂无'
,
subNickName
=
'暂无'
,
subContent
=
subComment
.
content
?
contentReplace
(
subComment
.
content
)
:
'暂无'
,
subTo
=
'暂无'
;
if
(
subComment
.
from
)
{
subOpenId
=
subComment
.
from
.
uid
||
'暂无'
;
subNickName
=
subComment
.
from
.
nickName
||
'游客'
;
subMid
=
subComment
.
from
.
mid
||
'暂无'
;
}
var
this_row
=
[
nickName
+
' 回复 '
+
to
,
time
,
openId
,
nickName
,
content
,
'0'
,
null
,
null
,
null
,
null
];
rows
.
push
(
this_row
);
if
(
subComment
.
to
)
{
subTo
=
contentReplace
(
subComment
.
to
.
nickName
)
||
'游客'
;
}
var
subRow
=
[
subNickName
+
' 回复 '
+
subTo
,
subTime
,
subNickName
,
subOpenId
,
subMid
.
toString
(),
content
,
'0'
,
null
,
null
,
null
,
null
];
rows
.
push
(
subRow
);
};
}
};
...
...
@@ -1208,14 +1335,35 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
res
.
setHeader
(
'Content-Type'
,
'application/vnd.openxmlformats'
);
res
.
setHeader
(
'Content-Disposition'
,
'attachment; filename=commentsReport.xlsx'
);
res
.
end
(
result
,
'binary'
);
}).
fail
(
function
(
cont
,
err
)
{
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
if
(
err
===
'params error'
)
{
if
(
err
===
'params error'
)
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
else
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
BUSY
);
}
});
});
//更新文章质量
router
.
post
(
'/thread/:tid/quality'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
//文章ID
var
quality
=
req
.
body
.
quality
;
if
(
tid
&&
quality
)
{
forumThreadService
.
updateThread
({
_id
:
tid
},
{
quality
:
quality
},
function
(
err
,
thread
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
app/controllers/mobile/forumInfo.js
View file @
0c1302b5
...
...
@@ -157,7 +157,7 @@ router.get('/info/:fid/threads', function(req, res, next) {
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
fid
=
req
.
params
.
fid
;
var
sort
=
'-top -topTime -created'
;
var
sort
=
'-top -topTime -
quality -
created'
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
conditions
=
{
ent_code
:
ent_code
,
...
...
@@ -378,7 +378,7 @@ router.get('/info/:fid/myThreads', function(req, res, next) {
};
}
//获取子话题数据
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-created'
,
function
(
err
,
results
)
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-
quality -
created'
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -431,7 +431,7 @@ router.get('/info/myThreads', function(req, res, next) {
};
}
//获取子话题数据
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-created'
,
function
(
err
,
results
)
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-
quality -
created'
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -482,7 +482,7 @@ router.get('/info/hisThreads/:id', function(req, res, next) {
};
}
//获取子话题数据
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-created'
,
function
(
err
,
results
)
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-
quality -
created'
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/mobile/forumThread.js
View file @
0c1302b5
...
...
@@ -888,6 +888,223 @@ router.post('/thread/:tid/delete', function(req, res, next) {
// });
//文章点赞
// router.post('/thread/:tid/raise', function(req, res, next) {
// var userId = req.session.mobileForumUser.userId;
// var mid = req.session.openUser.mid;
// var tid = req.params.tid || null;
// var ent_code = req.session.user.ent_code;
// if (tid) {
// var integral = req.session.openUser.integral || 0;
// var exp = req.session.openUser.exp || 0;
// //判断是否已经点赞
// forumPraiseLogService.queryPraiseLog(tid, null, user.getMobileUser(req), 1, function(err, doc) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// //1.检查是否有权限
// forumRolePermissionService.checkRolePermiss(ent_code, 'raise', 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) {
// forumThreadService.updateThreadRaiseCount(tid, function(err, cb) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// } else {
// callback('cannot find thread by id', null);
// }
// },
// function(callback) {
// if (doc) { //如果已存在,更新为点赞日志
// forumPraiseLogService.updatePraiseLog(doc._id, 0, function(err, result) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// } else { //不存在,创建点赞日志
// var entity = {
// ent_code: ent_code,
// user: user.getMobileUser(req),
// thread: tid,
// ip: req.ip,
// comment: null,
// type: 1,
// status: 0
// };
// //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 {
// // forumLimitOperationService.checkLimitOperationProhibitionAddIntegral(userId, function(err, flag){
// // if(err){
// // console.error(err);
// // }else{
// // if(!flag){
// // httpService.sendRequest(ent_code, req.session.openUser.mid, 'thread_praise');
// // }
// // }
// // });
// //更新点赞redis
// redisPraiseLog.get(ent_code, userId, 'thread', function(error, docs) {
// var list = docs;
// list.push(tid);
// redisPraiseLog.set(ent_code, userId, 'thread', list, function() {});
// });
// forumThreadService.getThreadById(tid, function(err, doc) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// var rs = {};
// rs.praise_count = doc.praise_count;
// res.json(_.assign(rs, returnCode.SUCCESS));
// }
// });
// }
// });
// }
// });
// } else {
// res.json(returnCode.ACTION_NOT_PERMISSION);
// }
// }
// });
// }
// });
// } else {
// res.json(returnCode.WRONG_PARAM);
// }
// });
//文章取消点赞
// router.post('/thread/:tid/cancelRaise', function(req, res, next) {
// var userId = req.session.mobileForumUser.userId;
// var mid = req.session.openUser.mid;
// var tid = req.params.tid || null;
// var ent_code = req.session.user.ent_code;
// if (tid) {
// var integral = req.session.openUser.integral || 0;
// var exp = req.session.openUser.exp || 0;
// //判断是否已经点赞
// forumPraiseLogService.queryPraiseLog(tid, null, userId, 1, function(err, doc) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// if (doc) {
// var praiseId = doc._id;
// //1.检查是否有权限
// forumRolePermissionService.checkRolePermiss(ent_code, 'raise', 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 && thread.praise_count > 0) {
// forumThreadService.updateThreadRaiseCountDec(tid, function(err, cb) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// } else {
// callback('cannot find thread by id', null);
// }
// },
// function(callback) {
// //4.更新点赞日志
// forumPraiseLogService.updatePraiseLog(praiseId, 1, 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 {
// //更新点赞redis
// redisPraiseLog.get(ent_code, userId, 'thread', function(error, docs) {
// var list = docs;
// for (var i = 0; i < list.length; i++) {
// if (list[i].toString() == tid) {
// list.splice(i, 1);
// break;
// }
// }
// redisPraiseLog.set(ent_code, userId, 'thread', list, function() {});
// });
// forumThreadService.getThreadById(tid, function(err, doc) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// var rs = {};
// rs.praise_count = doc.praise_count;
// res.json(_.assign(rs, returnCode.SUCCESS));
// }
// });
// }
// });
// }
// });
// } else {
// res.json(returnCode.ACTION_NOT_PERMISSION);
// }
// }
// });
// }
// }
// });
// } else {
// res.json(returnCode.WRONG_PARAM);
// }
// });
//文章点赞
router
.
post
(
'/thread/:tid/raise'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
...
...
@@ -933,6 +1150,7 @@ router.post('/thread/:tid/praiseOrCancelPraise', function(req, res, next) {
}
});
//文章分享
router
.
post
(
'/thread/:tid/share'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
...
...
@@ -1839,7 +2057,7 @@ router.get('/thread/:tid/latestPhotos', function(req, res, next) {
};
}
//获取子话题数据
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-created'
,
function
(
err
,
results
)
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-
quality -
created'
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/models/forumThread.js
View file @
0c1302b5
...
...
@@ -113,6 +113,11 @@ var ForumThreadSchema = new Schema({
require
:
true
,
default
:
0
},
quality
:{
//质量 高:100,中:50,低:0
type
:
Number
,
require
:
true
,
default
:
100
},
created
:
{
type
:
Date
,
required
:
true
,
...
...
app/models/forumUser.js
View file @
0c1302b5
...
...
@@ -15,6 +15,12 @@ var ForumUserSchema = new Schema({
unique
:
true
,
require
:
true
},
mid
:
{
//会员ID,这里直接存放会员ID
type
:
Number
,
index
:
true
,
unique
:
true
,
require
:
false
},
nickName
:
{
//用户昵称,这里直接存放用户的nickname
type
:
String
},
...
...
app/service/forumCommentService.js
View file @
0c1302b5
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumComment
=
mongoose
.
model
(
'ForumComment'
);
var
forumUserService
=
require
(
'./forumUserService'
);
var
async
=
require
(
'async'
);
//创建评论
...
...
@@ -181,7 +181,7 @@ function populateComment(doc, callback) {
status
:
1
}).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon'
select
:
'uid nickName icon
mid
'
}).
exec
(
function
(
err
,
c
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -349,6 +349,51 @@ exports.getCommentList = function(conditions, pageNo, pageSize, callback) {
}
});
};
//获取评论列表
exports
.
getCommentListByMid
=
function
(
mid
,
conditions
,
pageNo
,
pageSize
,
callback
)
{
//查询到用户
forumUserService
.
searchMembersByMid
(
mid
,
function
(
err
,
users
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
//查询对应用户的文章
var
user_ids
=
[];
for
(
var
i
in
users
){
user_ids
.
push
(
users
[
i
].
_id
);
}
conditions
.
from
=
{
$in
:
user_ids
}
countAll
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
callback
(
err
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumComment
.
find
(
conditions
).
populate
(
'from'
).
populate
(
'to'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
callback
(
null
,
obj
);
}
});
}
});
}
});
};
exports
.
getCommentParent
=
function
(
cid
,
callback
)
{
ForumComment
.
findOne
({
comments
:
{
...
...
@@ -491,7 +536,7 @@ exports.getAllCommentByThread = function(conditions, callback) {
select
:
'from'
}).
populate
({
path
:
'from to'
,
select
:
'_id uid nickName icon'
select
:
'_id uid nickName icon
mid
'
}).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
app/service/forumThreadService.js
View file @
0c1302b5
...
...
@@ -17,7 +17,7 @@ exports.findThreadByPage = function(pageNo, pageSize, q, callback) {
}).
then
(
function
(
cont
,
count
)
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumThread
.
find
(
q
).
skip
(
skip
).
limit
(
limit
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
ForumThread
.
find
(
q
).
skip
(
skip
).
limit
(
limit
).
sort
(
'-
quality -
created'
).
exec
(
function
(
err
,
docs
)
{
cont
(
err
,
count
,
docs
);
});
...
...
@@ -607,7 +607,7 @@ function getSubThreads(doc, sort, callback) {
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
sortBy
=
'-top -created'
;
var
sortBy
=
'-top -
quality -
created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
...
...
@@ -638,7 +638,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-topTime -tag_topTime -created'
;
var
sortBy
=
'-topTime -tag_topTime -
quality -
created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
...
...
@@ -706,7 +706,7 @@ function getAllThreadByFidHelpNoLimit(conditions, pageNo, pageSize, sort, callba
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-topTime -tag_topTime -created'
;
var
sortBy
=
'-topTime -tag_topTime -
quality -
created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
...
...
@@ -1010,7 +1010,7 @@ exports.remove = function(array,val) {
};
function
getAllThreadByFid
HelpAndNickName
(
user_ids
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
function
getAllThreadByFid
AndUserHelp
(
user_ids
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
conditions
.
from
=
{
"$in"
:
user_ids
};
...
...
@@ -1023,7 +1023,7 @@ function getAllThreadByFidHelpAndNickName(user_ids, conditions, pageNo, pageSize
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-topTime -tag_topTime -created'
;
var
sortBy
=
'-topTime -tag_topTime -
quality -
created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
...
...
@@ -1067,9 +1067,39 @@ exports.getAllThreadByFidAndNickName = function(nickName, conditions, pageNo, pa
for
(
var
i
in
users
){
user_ids
.
push
(
users
[
i
].
_id
);
}
getAllThreadByFid
HelpAndNickName
(
user_ids
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
);
getAllThreadByFid
AndUserHelp
(
user_ids
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
);
}
});
}
//获取某个文章
//获取全部列表数据
exports
.
getAllThreadByFidAndMid
=
function
(
mid
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
//查询到用户
forumUserService
.
searchMembersByMid
(
mid
,
function
(
err
,
users
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
//查询对应用户的文章
var
user_ids
=
[];
for
(
var
i
in
users
){
user_ids
.
push
(
users
[
i
].
_id
);
}
getAllThreadByFidAndUserHelp
(
user_ids
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
);
}
});
}
//更新文章
exports
.
updateThread
=
function
(
condition
,
entity
,
callback
)
{
ForumThread
.
findOneAndUpdate
(
condition
,
entity
,
function
(
err
,
doc
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
doc
);
}
});
};
\ No newline at end of file
app/service/forumUserService.js
View file @
0c1302b5
...
...
@@ -107,6 +107,17 @@ exports.searchMembersByNickName=function(nickName, callback){
});
};
//根据mid查询用户
exports
.
searchMembersByMid
=
function
(
mid
,
callback
){
ForumUser
.
find
({
mid
:
mid
}).
exec
(
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
result
);
}
});
};
//查询用户和行为限制信息
exports
.
searchMembersAndLimitActions
=
function
(
pageNo
,
pageSize
,
q
,
callback
){
then
(
function
(
cont
)
{
...
...
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