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
27630325
Commit
27630325
authored
Apr 03, 2015
by
陈志良
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development
parents
72d9328c
e9c1ede1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
4 deletions
+95
-4
forumIdentifyUser.js
app/controllers/admin/forumIdentifyUser.js
+54
-0
forumThread.js
app/controllers/admin/forumThread.js
+0
-2
forumThread.js
app/controllers/mobile/forumThread.js
+5
-0
forumThread.js
app/models/forumThread.js
+5
-0
forumThreadService.js
app/service/forumThreadService.js
+31
-2
No files found.
app/controllers/admin/forumIdentifyUser.js
0 → 100644
View file @
27630325
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
forumUserService
=
require
(
'../../service/forumUserService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
async
=
require
(
'async'
);
var
user
=
require
(
'../../utils/user'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//验证用户身份
router
.
post
(
'/user/identifyUser'
,
function
(
req
,
res
,
next
){
var
entity
=
req
.
body
;
req
.
session
.
mobileForumUser
=
null
;
if
(
!
req
.
session
.
mobileForumUser
){
forumUserService
.
getUserByUid
(
entity
.
uid
,
function
(
err
,
doc
){
if
(
err
){
console
.
log
(
err
);
res
.
json
(
'error'
);
}
else
{
if
(
doc
){
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
};
res
.
json
(
'success'
);
}
else
{
forumUserService
.
createUser
(
entity
,
function
(
err
,
doc
){
if
(
err
){
console
.
log
(
err
);
res
.
json
(
'error'
);
}
else
{
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
};
res
.
json
(
'success'
);
}
});
}
}
});
}
else
{
res
.
json
(
'success'
);
}
});
\ No newline at end of file
app/controllers/admin/forumThread.js
View file @
27630325
...
@@ -42,8 +42,6 @@ router.post('/thread/create', function(req, res, next) {
...
@@ -42,8 +42,6 @@ router.post('/thread/create', function(req, res, next) {
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
if
(
user
){
if
(
user
){
//put forumUser to session
userUtil
.
setUserSession
(
req
,
user
);
req
.
body
.
from
=
user
.
_id
;
req
.
body
.
from
=
user
.
_id
;
forumThreadService
.
createThread
(
req
.
body
,
function
(
err
,
entity
){
forumThreadService
.
createThread
(
req
.
body
,
function
(
err
,
entity
){
if
(
err
)
{
if
(
err
)
{
...
...
app/controllers/mobile/forumThread.js
View file @
27630325
...
@@ -30,6 +30,11 @@ function create(req,callback){
...
@@ -30,6 +30,11 @@ function create(req,callback){
entity
.
pid
=
null
;
entity
.
pid
=
null
;
}
}
var
address
=
entity
.
address
||
null
;
if
(
address
){
entity
.
address
=
JSON
.
parse
(
address
);
}
entity
.
ent_code
=
req
.
session
.
user
.
ent_code
;
entity
.
ent_code
=
req
.
session
.
user
.
ent_code
;
entity
.
from
=
user
.
getMobileUser
(
req
);
entity
.
from
=
user
.
getMobileUser
(
req
);
...
...
app/models/forumThread.js
View file @
27630325
...
@@ -43,6 +43,11 @@ var ForumThreadSchema = new Schema({
...
@@ -43,6 +43,11 @@ var ForumThreadSchema = new Schema({
icon
:
{
//话题图标
icon
:
{
//话题图标
type
:
String
type
:
String
},
},
address
:
{
//地址
country
:{
type
:
String
,
default
:
''
},
province
:{
type
:
String
,
default
:
''
},
city
:{
type
:
String
,
default
:
''
},
},
order_idx
:
{
//论坛排序
order_idx
:
{
//论坛排序
type
:
Number
,
type
:
Number
,
require
:
true
,
require
:
true
,
...
...
app/service/forumThreadService.js
View file @
27630325
...
@@ -68,6 +68,7 @@ exports.getThreadById=function(tid,callback){
...
@@ -68,6 +68,7 @@ exports.getThreadById=function(tid,callback){
console
.
error
(
err
);
console
.
error
(
err
);
cb
(
err
,
null
);
cb
(
err
,
null
);
}
else
{
}
else
{
// console.log(threads);
cb
(
null
,
threads
);
cb
(
null
,
threads
);
}
}
});
});
...
@@ -102,6 +103,29 @@ exports.getThreadById=function(tid,callback){
...
@@ -102,6 +103,29 @@ exports.getThreadById=function(tid,callback){
}
}
});
});
},
},
function
(
cb
){
//获取发帖人数
ForumThread
.
aggregate
(
{
$match
:
{
pid
:
mongoose
.
Types
.
ObjectId
(
tid
)
}
},
{
$group
:
{
_id
:
{
from
:
'$from'
},
count
:
{
$sum
:
1
}
}
},
function
(
err
,
data
){
if
(
err
)
{
cb
(
err
,
null
);
}
else
{
cb
(
null
,
data
.
length
);
}
});
}
],
function
(
err
,
results
){
],
function
(
err
,
results
){
if
(
err
){
if
(
err
){
callback
(
err
,
null
);
callback
(
err
,
null
);
...
@@ -111,12 +135,15 @@ exports.getThreadById=function(tid,callback){
...
@@ -111,12 +135,15 @@ exports.getThreadById=function(tid,callback){
var
subThreads
=
results
[
2
]
||
[];
//话题子文章列表
var
subThreads
=
results
[
2
]
||
[];
//话题子文章列表
var
latestPhotos
=
results
[
3
]
||
[];
//最新照片墙列表
var
latestPhotos
=
results
[
3
]
||
[];
//最新照片墙列表
var
hotPhotos
=
results
[
4
]
||
[];
//最热照片墙列表
var
hotPhotos
=
results
[
4
]
||
[];
//最热照片墙列表
var
canyuPeopleCount
=
results
[
5
]
||
0
;
//参与人数
var
threadObj
=
thread
.
toObject
();
var
threadObj
=
thread
.
toObject
();
threadObj
.
comments
=
comments
;
threadObj
.
comments
=
comments
;
threadObj
.
subThreads
=
subThreads
;
threadObj
.
subThreads
=
subThreads
;
threadObj
.
latestPhotos
=
latestPhotos
;
threadObj
.
latestPhotos
=
latestPhotos
;
threadObj
.
hotPhotos
=
hotPhotos
;
threadObj
.
hotPhotos
=
hotPhotos
;
threadObj
.
canyuPeopleCount
=
canyuPeopleCount
;
callback
(
null
,
threadObj
);
callback
(
null
,
threadObj
);
}
}
});
});
...
@@ -152,11 +179,12 @@ function populateComment(doc, callback){
...
@@ -152,11 +179,12 @@ function populateComment(doc, callback){
var
asyncTasks
=
[];
var
asyncTasks
=
[];
doc
.
comments
.
forEach
(
function
(
comment
){
doc
.
comments
.
forEach
(
function
(
comment
){
asyncTasks
.
push
(
function
(
callback
)
{
asyncTasks
.
push
(
function
(
callback
)
{
ForumComment
.
populate
(
comment
,
{
path
:
'from to'
,
select
:
'uid nickName icon comments'
}
,
function
(
err
,
c
){
ForumComment
.
populate
(
comment
,
{
path
:
'from to'
,
select
:
'uid nickName icon
displayName displayIcon
comments'
}
,
function
(
err
,
c
){
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
null
,
null
);
callback
(
null
,
null
);
}
else
{
}
else
{
// console.log(comment);
if
(
comment
.
comments
){
if
(
comment
.
comments
){
populateSubComment
(
comment
,
function
(
err
,
results
){
populateSubComment
(
comment
,
function
(
err
,
results
){
if
(
err
){
if
(
err
){
...
@@ -300,7 +328,8 @@ function getAllThreadByFidHelp(conditions,pageNo,pageSize,sort,callback){
...
@@ -300,7 +328,8 @@ function getAllThreadByFidHelp(conditions,pageNo,pageSize,sort,callback){
var
asyncTasks
=
[];
var
asyncTasks
=
[];
docs
.
forEach
(
function
(
doc
){
docs
.
forEach
(
function
(
doc
){
if
(
doc
.
type
===
1
){
// console.log(doc);
if
(
doc
.
type
===
1
||
doc
.
level
!==
1
){
//非照片墙或文章时获取评论
asyncTasks
.
push
(
function
(
callback
)
{
asyncTasks
.
push
(
function
(
callback
)
{
populateComment
(
doc
,
callback
);
populateComment
(
doc
,
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