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
50b9f172
Commit
50b9f172
authored
Nov 20, 2015
by
陈家荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
在社区帖子中增加quality字段
parent
1bd68356
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
183 additions
and
110 deletions
+183
-110
forumThread.js
app/controllers/admin/forumThread.js
+160
-105
forumThread.js
app/models/forumThread.js
+5
-0
forumThreadService.js
app/service/forumThreadService.js
+18
-5
No files found.
app/controllers/admin/forumThread.js
View file @
50b9f172
...
...
@@ -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'
);
...
...
@@ -386,6 +386,7 @@ router.get('/threads/list', function(req, res, next) {
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
,
...
...
@@ -421,7 +422,10 @@ router.get('/threads/list', function(req, res, next) {
if
(
status
)
{
conditions
.
status
=
status
;
}
if
(
mid
){
if
(
quality
)
{
conditions
.
quality
=
quality
;
}
if
(
mid
)
{
forumThreadService
.
getAllThreadByFidAndMid
(
mid
,
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -438,7 +442,7 @@ router.get('/threads/list', function(req, res, next) {
}
}
});
}
else
if
(
nickName
)
{
}
else
if
(
nickName
)
{
forumThreadService
.
getAllThreadByFidAndNickName
(
nickName
,
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -596,7 +600,7 @@ router.get('/thread/:tid/comment/list/member/:mid', function(req, res, next) {
};
}
if
(
tid
&&
mid
)
{
forumCommentService
.
getCommentListByMid
(
mid
,
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
forumCommentService
.
getCommentListByMid
(
mid
,
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -1076,20 +1080,26 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
mid
=
req
.
query
.
mid
,
floor
=
req
.
query
.
floor
,
content
=
req
.
query
.
content
;
then
(
function
(
cont
){
if
(
tid
&&
ent_code
)
{
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
)
{
if
(
e
.
user
)
{
praiseNames
.
push
(
e
.
user
.
nickName
||
'游客'
);
praiseOpenIds
.
push
(
e
.
user
.
uid
);
}
...
...
@@ -1097,76 +1107,76 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
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
};
if
(
content
)
{
if
(
content
)
{
conditions
.
content
=
{
$regex
:
content
,
$options
:
'i'
};
}
if
(
mid
)
{
forumCommentService
.
getCommentListByMid
(
mid
,
conditions
,
1
,
10000
,
function
(
err
,
results
)
{
cont2
(
err
,
results
?
results
.
items
:
[]);
if
(
mid
)
{
forumCommentService
.
getCommentListByMid
(
mid
,
conditions
,
1
,
10000
,
function
(
err
,
results
)
{
cont2
(
err
,
results
?
results
.
items
:
[]);
});
}
else
if
(
floor
)
{
}
else
if
(
floor
)
{
conditions
.
level
=
'1'
;
conditions
.
floor
=
floor
;
forumCommentService
.
getAllComment
(
conditions
,
1
,
1
,
function
(
err
,
results
)
{
cont2
(
err
,
results
?
results
.
items
:
[]);
cont2
(
err
,
results
?
results
.
items
:
[]);
});
}
else
{
}
else
{
conditions
.
level
=
'1'
;
//查询所有评论
forumCommentService
.
getAllCommentByThread
(
conditions
,
function
(
err
,
docs
)
{
cont2
(
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
)
{
if
(
e2
.
user
)
{
praiseNames
.
push
(
e2
.
user
.
nickName
||
'游客'
);
praiseOpenIds
.
push
(
e2
.
user
.
uid
);
}
...
...
@@ -1181,41 +1191,62 @@ 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
:
'点赞人'
,
type
:
'string'
},
{
caption
:
'点赞点赞人openId'
,
type
:
'string'
}
];
var
contentReplace
=
function
(
str
){
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
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u
0CDD
\u
0CDF
\u
0CE4
\u
0CE5
\u
0CF0
\u
0CF3-
\u
0D01
\u
0D04
\u
0D0D
\u
0D11
\u
0D3B
\u
0D3C
\u
0D45
\u
0D49
\u
0D4F-
\u
0D56
\u
0D58-
\u
0D5F
\u
0D64
\u
0D65
\u
0D76-
\u
0D78
\u
0D80
\u
0D81
\u
0D84
\u
0D97-
\u
0D99
\u
0DB2
\u
0DBC
\u
0DBE
\u
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-
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FFB
\u
FFFE
\u
FFFF
]
/g
if
(
str
)
{
strAfter
=
str
.
replace
(
/<
[^
>
]
+>/g
,
''
).
replace
(
regex
,
''
);
if
(
str
)
{
strAfter
=
str
.
replace
(
/<
[^
>
]
+>/g
,
''
).
replace
(
regex
,
''
);
}
return
strAfter
;
}
//文章内容
var
t_title
=
thread
.
title
==
'发话题'
?
'无标题'
:
thread
.
title
,
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_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
:
'暂无'
;
t_from_mid
=
thread
.
from
?
thread
.
from
.
mid
:
'暂无'
;
rows
.
push
([
...
...
@@ -1223,15 +1254,16 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
t_time
,
t_from
,
t_from_openId
,
t_from_mid
?
t_from_mid
.
toString
():
'暂无'
,
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
thisFloor
=
comment
.
floor
||
'互动'
,
...
...
@@ -1239,15 +1271,15 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
openId
=
'暂无'
,
nickName
=
'暂无'
,
fromMid
=
'暂无'
,
content
=
comment
.
content
?
contentReplace
(
comment
.
content
)
:
'暂无'
,
content
=
comment
.
content
?
contentReplace
(
comment
.
content
)
:
'暂无'
,
praiseCount
=
comment
.
praiseCount
||
0
,
praiseNames
=
'暂无'
,
praiseOpenIds
=
'暂无'
;
if
(
comment
.
praiseNames
)
{
if
(
comment
.
praiseNames
)
{
praiseNames
=
comment
.
praiseNames
.
toString
();
praiseOpenIds
=
comment
.
praiseOpenIds
.
toString
();
}
if
(
comment
.
from
)
{
if
(
comment
.
from
)
{
openId
=
comment
.
from
.
uid
||
'暂无'
;
nickName
=
comment
.
from
.
displayName
||
comment
.
from
.
nickName
||
'游客'
;
fromMid
=
comment
.
from
.
mid
||
'暂无'
;
...
...
@@ -1263,23 +1295,24 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
praiseCount
.
toString
(),
praiseNames
,
praiseOpenIds
,
null
,
null
];
null
,
null
];
rows
.
push
(
this_row
);
if
(
!
mid
&&
comment
.
comments
.
length
>
0
)
{
if
(
!
mid
&&
comment
.
comments
.
length
>
0
)
{
for
(
var
k
=
0
;
k
<
comment
.
comments
.
length
;
k
++
)
{
var
subComment
=
comment
.
comments
[
k
];
var
subTime
=
date_format
(
subComment
.
created
),
subOpenId
=
'暂无'
,
subMid
=
'暂无'
,
subNickName
=
'暂无'
,
subContent
=
subComment
.
content
?
contentReplace
(
subComment
.
content
)
:
'暂无'
,
subContent
=
subComment
.
content
?
contentReplace
(
subComment
.
content
)
:
'暂无'
,
subTo
=
'暂无'
;
if
(
subComment
.
from
)
{
if
(
subComment
.
from
)
{
subOpenId
=
subComment
.
from
.
uid
||
'暂无'
;
subNickName
=
subComment
.
from
.
nickName
||
'游客'
;
subMid
=
subComment
.
from
.
mid
||
'暂无'
;
}
if
(
subComment
.
to
)
{
if
(
subComment
.
to
)
{
subTo
=
contentReplace
(
subComment
.
to
.
nickName
)
||
'游客'
;
}
var
subRow
=
[
...
...
@@ -1290,7 +1323,8 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
subMid
.
toString
(),
content
,
'0'
,
null
,
null
,
null
,
null
];
null
,
null
,
null
,
null
];
rows
.
push
(
subRow
);
};
}
...
...
@@ -1301,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
{
}
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/models/forumThread.js
View file @
50b9f172
...
...
@@ -113,6 +113,11 @@ var ForumThreadSchema = new Schema({
require
:
true
,
default
:
0
},
quality
:{
//质量 高:100,中:50,低:0
type
:
Number
,
require
:
true
,
default
:
50
},
created
:
{
type
:
Date
,
required
:
true
,
...
...
app/service/forumThreadService.js
View file @
50b9f172
...
...
@@ -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
;
}
...
...
@@ -1023,7 +1023,7 @@ function getAllThreadByFidAndUserHelp(user_ids, conditions, pageNo, pageSize, so
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
;
}
...
...
@@ -1090,3 +1090,16 @@ exports.getAllThreadByFidAndMid = function(mid, conditions, pageNo, pageSize, so
});
}
//更新文章
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
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