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
ce39b4d9
Commit
ce39b4d9
authored
Apr 15, 2016
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'newfunc_0321_personal_site'
parents
fb5f5398
6867bbc2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
20 deletions
+67
-20
forumMessage.js
app/controllers/mobile/forumMessage.js
+1
-1
forumThread.js
app/controllers/mobile/forumThread.js
+3
-3
forumMessageService.js
app/service/forumMessageService.js
+4
-2
forumThreadService.js
app/service/forumThreadService.js
+59
-14
No files found.
app/controllers/mobile/forumMessage.js
View file @
ce39b4d9
...
...
@@ -21,7 +21,7 @@ module.exports = function(app) {
//分页用户查询消息
router
.
get
(
'/message/searchMesage'
,
function
(
req
,
res
,
next
)
{
//参数
var
pageNo
=
req
.
query
.
pageNo
||
1
,
var
pageNo
=
req
.
query
.
pageNo
||
0
,
pageSize
=
req
.
query
.
pageSize
||
10
,
from
=
user
.
getMobileUser
(
req
),
ent_code
=
req
.
session
.
user
.
ent_code
;
...
...
app/controllers/mobile/forumThread.js
View file @
ce39b4d9
...
...
@@ -1896,7 +1896,7 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) {
});
//
逻辑删除
文章
//
屏蔽
文章
router
.
post
(
'/thread/:tid/disable'
,
function
(
req
,
res
,
next
)
{
var
user_id
=
user
.
getMobileUser
(
req
);
var
tid
=
req
.
params
.
tid
;
...
...
@@ -1904,11 +1904,11 @@ router.post('/thread/:tid/disable', function(req, res, next) {
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
if
(
thread
.
from
&&
user_id
)
{
if
(
thread
.
from
.
_id
.
toString
()
==
user_id
.
toString
())
{
forumThreadService
.
logicDeleteThreadById
(
tid
,
function
(
err
,
flag
)
{
forumThreadService
.
updateThreadById_2
(
tid
,
{
status
:
0
},
function
(
err
,
flag
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
updateThreadStatus
(
tid
,
3
);
forumAboutMEService
.
updateThreadStatus
(
tid
,
0
);
res
.
json
(
returnCode
.
SUCCESS
);
}
});
...
...
app/service/forumMessageService.js
View file @
ce39b4d9
...
...
@@ -196,7 +196,6 @@ exports.getMessages= function(conditions, status, pageNo, pageSize, callback) {
var
skip
=
pageNo
*
pageSize
;
var
limit
=
total
-
skip
>
pageSize
?
pageSize
:
(
total
-
skip
);
limit
=
parseInt
(
limit
)
+
parseInt
(
skip
);
//获取分页后的数组
messages
=
messages
.
slice
(
skip
,
limit
);
callback
(
null
,
total
,
messages
);
...
...
@@ -249,7 +248,10 @@ exports.updateUserMessageStatus= function(condition,msgID, status,callback) {
//前端根据ID获取
exports
.
getByIdWithSelect
=
function
(
mid
,
callback
){
ForumMessage
.
findOne
({
_id
:
mid
}).
select
(
'_id fromNickName from title content created status'
).
exec
(
function
(
err
,
doc
)
{
ForumMessage
.
findOne
({
_id
:
mid
}).
select
(
'_id fromNickName from title content created status'
).
populate
({
path
:
'from'
,
select
:
'nickName icon'
}).
exec
(
function
(
err
,
doc
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
app/service/forumThreadService.js
View file @
ce39b4d9
...
...
@@ -634,18 +634,6 @@ exports.updateThreadById = function(tid, entity, callback) {
//逻辑删除文章
exports
.
logicDeleteThreadById
=
function
(
tid
,
callback
)
{
// ForumThread.update({
// _id: mongoose.Types.ObjectId(tid)
// }, {
// status : 3
// }, null, function(err, result) {
// if (err) {
// console.error(err);
// callback(err, false);
// } else {
// callback(null, true);
// }
// });
findOneAndUpdate
({
_id
:
mongoose
.
Types
.
ObjectId
(
tid
)},
{
status
:
3
},
'updateRedisRecommentThreads'
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -656,6 +644,18 @@ exports.logicDeleteThreadById = function(tid, callback) {
});
};
//更新文章
exports
.
updateThreadById_2
=
function
(
tid
,
entity
,
callback
)
{
findOneAndUpdate
({
_id
:
tid
},
entity
,
'updateRedisRecommentThreads'
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
false
);
}
else
{
callback
(
null
,
true
);
}
});
};
//根据ID删除文章
exports
.
deleteThreadById
=
function
(
tid
,
callback
)
{
...
...
@@ -776,7 +776,51 @@ exports.getAllCountByFid = function(conditions, callback) {
function
getSubThreads
(
doc
,
sort
,
callback
)
{
var
conditions
=
{
pid
:
doc
.
_id
,
status
:
1
status
:
{
'$ne'
:
3
},
level
:
2
,
ent_code
:
doc
.
ent_code
};
var
sortBy
=
'-top -quality -created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
ForumThread
.
find
(
conditions
,
subThreadFields
).
populate
(
'from'
,
'icon'
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
list
=
[];
//用户去重
_
.
forEach
(
docs
,
function
(
one
,
i
)
{
var
flag
=
true
;
_
.
forEach
(
list
,
function
(
two
,
k
)
{
if
(
one
.
from
.
_id
==
two
.
from
.
_id
){
flag
=
false
;
}
});
if
(
flag
){
list
.
push
(
one
);
}
});
var
obj
=
{};
obj
.
docTotal
=
docs
.
length
;
obj
.
total
=
list
.
length
;
obj
.
items
=
list
;
var
newDoc
=
doc
.
toObject
();
newDoc
.
subThreads
=
obj
;
callback
(
null
,
newDoc
);
}
});
}
//获取话题、照片墙子文章数据
function
getMobileSubThreads
(
doc
,
sort
,
callback
)
{
var
conditions
=
{
pid
:
doc
.
_id
,
status
:
1
,
level
:
2
,
ent_code
:
doc
.
ent_code
};
var
sortBy
=
'-top -quality -created'
;
if
(
sort
)
{
...
...
@@ -800,6 +844,7 @@ function getSubThreads(doc, sort, callback) {
}
});
var
obj
=
{};
obj
.
docTotal
=
docs
.
length
;
obj
.
total
=
list
.
length
;
obj
.
items
=
list
;
...
...
@@ -1409,7 +1454,7 @@ exports.getThreadWithNotPopulateComment = function(conditions, pageNo, pageSize,
});
}
else
{
asyncTasks
.
push
(
function
(
callback
)
{
getSubThreads
(
doc
,
null
,
callback
);
get
Mobile
SubThreads
(
doc
,
null
,
callback
);
});
}
});
...
...
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