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
5f6d3c8e
Commit
5f6d3c8e
authored
Aug 31, 2015
by
陈志良
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Gabriel_0831' into SANDBOX
Conflicts: app/service/forumThreadService.js
parents
55018dfb
13e85e0e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
25 deletions
+81
-25
forumInfo.js
app/controllers/mobile/forumInfo.js
+1
-1
forumThread.js
app/controllers/mobile/forumThread.js
+55
-10
forumThreadService.js
app/service/forumThreadService.js
+22
-11
config.js
config/config.js
+3
-3
No files found.
app/controllers/mobile/forumInfo.js
View file @
5f6d3c8e
...
...
@@ -567,7 +567,7 @@ router.get('/info/myAttend', function(req, res, next) {
});
cont
(
null
,
threadIds
);
}
else
{
res
.
json
(
_
.
assign
({
data
:[],
total
:
0
},
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
({
items
:[],
total
:
0
},
returnCode
.
SUCCESS
));
}
}
});
...
...
app/controllers/mobile/forumThread.js
View file @
5f6d3c8e
...
...
@@ -32,6 +32,8 @@ function create(req, callback) {
entity
.
pid
=
null
;
}
var
address
=
entity
.
address
||
null
;
if
(
address
)
{
entity
.
address
=
JSON
.
parse
(
address
);
...
...
@@ -54,15 +56,39 @@ function create(req, callback) {
entity
.
images
=
array
;
}
//-----------处理前端上传图片结束
forumThreadService
.
createThread
(
entity
,
function
(
err
,
entity
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
entity
);
}
});
if
(
entity
.
pid
&&
entity
.
type
==
3
){
forumThreadService
.
getByConditions
({
type
:
3
,
level
:
'2'
,
pid
:
entity
.
pid
,
from
:
entity
.
from
},
function
(
err
,
doc
){
if
(
doc
){
var
update
=
{
$set
:{
images
:
entity
.
images
,
content
:
entity
.
content
}
};
forumThreadService
.
updateThreadById
(
doc
.
_id
,
update
,
function
(
err
,
updatedDoc
){
callback
(
err
,
entity
);
});
}
else
{
forumThreadService
.
createThread
(
entity
,
function
(
err
,
entity
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
entity
);
}
});
}
});
}
else
{
forumThreadService
.
createThread
(
entity
,
function
(
err
,
entity
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
entity
);
}
});
}
}
//根据发帖者分页查询话题列表
...
...
@@ -235,6 +261,26 @@ router.get('/thread/:tid/get', function(req, res, next) {
}
});
//获取目标论坛文章
router
.
get
(
'/thread/photo/:pid/get'
,
function
(
req
,
res
,
next
)
{
var
pid
=
req
.
params
.
pid
||
null
,
userId
=
req
.
session
.
mobileForumUser
.
userId
;;
if
(
pid
)
{
forumThreadService
.
getByConditions
({
type
:
3
,
level
:
'2'
,
pid
:
pid
,
from
:
userId
},
function
(
err
,
thread
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
data
=
thread
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//更新文章状态、如:屏蔽
router
.
post
(
'/thread/:tid/update'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
...
...
@@ -1339,4 +1385,3 @@ router.post('/thread/:tid/disable', function(req, res, next) {
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
app/service/forumThreadService.js
View file @
5f6d3c8e
...
...
@@ -122,7 +122,17 @@ exports.getById = function(id, callback) {
}
});
}
//根据ID获取文章记录,不查评论,子话题
exports
.
getByConditions
=
function
(
conditions
,
callback
)
{
ForumThread
.
findOne
(
conditions
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
result
);
}
});
}
//根据ID获取文章
exports
.
getThreadById
=
function
(
tid
,
callback
)
{
async
.
parallel
([
...
...
@@ -145,7 +155,7 @@ exports.getThreadById = function(tid, callback) {
level
:
'1'
// status:1
};
//获取最新10条评论
//获取最新10条评论
forumCommentService
.
getAllComment
(
conditions
,
1
,
10
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
...
...
@@ -178,7 +188,7 @@ exports.getThreadById = function(tid, callback) {
pid
:
tid
,
type
:
3
,
status
:
1
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
getAllThreadByFidHelp
(
conditions
,
1
,
10
,
'-created'
,
function
(
err
,
threads
)
{
if
(
err
)
{
...
...
@@ -195,7 +205,7 @@ exports.getThreadById = function(tid, callback) {
pid
:
tid
,
type
:
3
,
status
:
1
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
getAllThreadByFidHelp
(
conditions
,
1
,
10
,
'-praise_count'
,
function
(
err
,
threads
)
{
if
(
err
)
{
...
...
@@ -273,7 +283,7 @@ exports.getThreadByIdNoLimit = function(tid, callback) {
level
:
'1'
// status:1
};
//获取最新10条评论
//获取最新10条评论
forumCommentService
.
getAllComment
(
conditions
,
1
,
999
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
...
...
@@ -306,7 +316,7 @@ exports.getThreadByIdNoLimit = function(tid, callback) {
pid
:
tid
,
type
:
3
,
status
:
1
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
getAllThreadByFidHelp
(
conditions
,
1
,
10
,
'-created'
,
function
(
err
,
threads
)
{
if
(
err
)
{
...
...
@@ -323,7 +333,7 @@ exports.getThreadByIdNoLimit = function(tid, callback) {
pid
:
tid
,
type
:
3
,
status
:
1
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
getAllThreadByFidHelp
(
conditions
,
1
,
10
,
'-praise_count'
,
function
(
err
,
threads
)
{
if
(
err
)
{
...
...
@@ -632,7 +642,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
path
:
'comments'
,
options
:
{
where
:{
status
:
1
},
limit
:
3
,
limit
:
5
,
sort
:
'-created'
},
select
:
'from to created content level'
...
...
@@ -910,7 +920,7 @@ exports.updateThreadCommentCountInc = function(threadId, callback) {
});
};
//更新文章评论数
//更新文章评论数
exports
.
updateThreadCommentCount
=
function
(
threadId
,
callback
)
{
ForumThread
.
update
({
_id
:
threadId
...
...
@@ -995,7 +1005,7 @@ function getAllThreadByFidHelpAndNickName(user_ids, conditions, pageNo, pageSize
path
:
'comments'
,
options
:
{
where
:{
status
:
1
},
limit
:
3
,
limit
:
5
,
sort
:
'-created'
},
select
:
'from to created content'
...
...
@@ -1031,6 +1041,7 @@ exports.getAllThreadByFidAndNickName = function(nickName, conditions, pageNo, pa
}
getAllThreadByFidHelpAndNickName
(
user_ids
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
);
}
});
}
//获取某个文章
config/config.js
View file @
5f6d3c8e
...
...
@@ -67,7 +67,7 @@ var config = {
app
:
{
name
:
'pisns-forum-api'
},
service
:
'http://pi
sn
s.wxpai.cn'
,
service
:
'http://pi
plu
s.wxpai.cn'
,
port
:
3011
,
mongodb
:
{
...
...
@@ -86,9 +86,9 @@ var config = {
devCDNURL
:
'http://dev.fs.wxpai.cn/'
},
sessionStore
:
{
password
:
'
future123456
'
,
password
:
'
a39131f8d598429f:GuangZhouhdp123
'
,
port
:
6379
,
host
:
'
10.168.27.179
'
,
host
:
'
a39131f8d598429f.m.cnhza.kvstore.aliyuncs.com
'
,
db
:
2
}
}
...
...
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