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
1981c34d
Commit
1981c34d
authored
Apr 22, 2015
by
陈家荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development
Conflicts: app/controllers/admin/forumThread.js
parents
c917666e
5e7e080d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
145 additions
and
44 deletions
+145
-44
forumBlackList.js
app/controllers/admin/forumBlackList.js
+3
-3
forumTag.js
app/controllers/admin/forumTag.js
+15
-0
forumInfo.js
app/controllers/mobile/forumInfo.js
+2
-1
forumTag.js
app/controllers/mobile/forumTag.js
+4
-1
forumThread.js
app/models/forumThread.js
+8
-0
forumBlackListService.js
app/service/forumBlackListService.js
+85
-3
forumThreadService.js
app/service/forumThreadService.js
+22
-2
forumUserService.js
app/service/forumUserService.js
+0
-34
returnCode.js
app/utils/returnCode.js
+6
-0
No files found.
app/controllers/admin/forumBlackList.js
View file @
1981c34d
...
...
@@ -5,7 +5,6 @@ var express = require('express'),
_
=
require
(
'lodash'
);
var
ForumBlackListService
=
require
(
'../../service/forumBlackListService'
);
var
ForumUserService
=
require
(
'../../service/forumUserService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
...
...
@@ -16,7 +15,7 @@ router.post('/blacklist', function(req, res, next) {
var
ent_code
=
req
.
session
.
user
.
ent_code
;
ForumBlackListService
.
addBlack
(
req
.
body
,
ent_code
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
)
);
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
...
...
@@ -104,7 +103,8 @@ router.post('/blacklist/:id', function(req, res, next) {
router
.
get
(
'/userList'
,
function
(
req
,
res
,
next
)
{
var
obj
=
{
total
:
0
};
obj
.
items
=
[];
ForumUserService
.
getUsers
(
req
.
query
.
pageNo
,
req
.
query
.
pageSize
,
var
ent_code
=
req
.
session
.
user
.
ent_code
;
ForumBlackListService
.
getNotBlackUsers
(
ent_code
,
req
.
query
.
pageNo
,
req
.
query
.
pageSize
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/admin/forumTag.js
View file @
1981c34d
...
...
@@ -7,6 +7,7 @@ var mongoose = require('mongoose');
var
ForumTag
=
mongoose
.
model
(
'ForumTag'
);
var
forumTagService
=
require
(
'../../service/forumTagService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
...
...
@@ -27,6 +28,20 @@ router.post('/tag/create', function(req, res, next) {
});
});
//标签置顶
router
.
get
(
'/tag/:tid/top'
,
function
(
req
,
res
,
next
){
var
tid
=
req
.
params
.
tid
;
var
tag_top
=
req
.
query
.
tag_top
;
forumThreadService
.
updateTagTop
(
tid
,
tag_top
,
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
//删除论坛标签
router
.
post
(
'/tag/:tid/delete'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
...
...
app/controllers/mobile/forumInfo.js
View file @
1981c34d
...
...
@@ -133,6 +133,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
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
level
:
1
...
...
@@ -165,7 +166,7 @@ router.get('/info/:fid/threads', function(req, res, next) {
$nin
:
result
.
thread
};
}
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
sort
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/mobile/forumTag.js
View file @
1981c34d
...
...
@@ -51,11 +51,14 @@ router.get('/tag/mobileList', function(req, res, next) {
});
});
//查询标签下的文章列表
router
.
get
(
'/tag/:tid/threads'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
tid
=
req
.
params
.
tid
;
var
sort
=
'-tag_top -tag_topTime -created'
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
...
...
@@ -84,7 +87,7 @@ router.get('/tag/:tid/threads', function(req, res, next) {
if
(
result
){
conditions
.
_id
=
{
$nin
:
result
.
thread
};
}
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
){
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
sort
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/models/forumThread.js
View file @
1981c34d
...
...
@@ -60,6 +60,14 @@ var ForumThreadSchema = new Schema({
},
topTime
:{
//置顶时间
type
:
Date
}
,
tag_top
:
{
//标签话题是否置顶0否,1是
type
:
Number
,
require
:
true
,
default
:
0
},
tag_topTime
:{
//标签话题置顶时间
type
:
Date
},
tag
:
[{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumTag'
}],
//话题归属标签,
comments
:
[{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumComment'
}],
//评论内容列表
...
...
app/service/forumBlackListService.js
View file @
1981c34d
...
...
@@ -2,6 +2,7 @@
var
mongoose
=
require
(
'mongoose'
);
var
BlackList
=
mongoose
.
model
(
'BlackList'
);
var
ForumUserService
=
require
(
"./forumUserService"
);
var
ForumUser
=
mongoose
.
model
(
'ForumUser'
);
var
async
=
require
(
'async'
);
...
...
@@ -49,7 +50,35 @@ exports.addBlack = function(blackList,entcode,callback){
return
callback
&&
callback
(
'bad args'
);
}
blackList
.
ent_code
=
entcode
;
async
.
waterfall
([
function
(
cb
)
{
async
.
waterfall
([
function
(
cb
){
//判断是否存在openid
var
condition
=
{
ent_code
:
entcode
};
if
(
blackList
.
blackOpenId
){
condition
.
blackOpenId
=
blackList
.
blackOpenId
;
BlackList
.
count
(
condition
,
function
(
err
,
count
){
if
(
count
&&
count
>
0
){
console
.
log
(
condition
);
return
callback
&&
callback
(
'已经存在的记录'
);
}
cb
();
});
}
else
{
cb
();
}
},
function
(
cb
){
//判断是否存在uid
var
condition
=
{
ent_code
:
entcode
};
if
(
blackList
.
uid
){
condition
.
blackUser
=
blackList
.
uid
;
BlackList
.
count
(
condition
,
function
(
err
,
count
){
if
(
count
&&
count
>
0
){
console
.
log
(
condition
);
return
callback
&&
callback
(
'已经存在的记录'
);
}
cb
();
});
}
else
{
cb
();
}
},
function
(
cb
)
{
var
uid
=
blackList
.
uid
;
delete
blackList
.
uid
;
if
(
!!!
uid
){
...
...
@@ -70,7 +99,7 @@ exports.addBlack = function(blackList,entcode,callback){
console
.
error
(
err
);
return
callback
&&
callback
(
err
);
}
return
callback
&&
callback
(
null
,
black
);
return
callback
&&
callback
(
null
,
{
_id
:
black
.
_id
}
);
});
}],
function
(
err
,
result
)
{
...
...
@@ -162,4 +191,57 @@ exports.removeBlackById = function(id,callback){
}
return
callback
&&
callback
(
null
,
result
);
});
}
\ No newline at end of file
};
exports
.
getNotBlackUsers
=
function
(
entcode
,
pageNo
,
pageSize
,
callback
){
var
pageNo
=
pageNo
||
1
;
var
pageSize
=
pageSize
||
10
;
var
getPageList
=
function
(
count
,
nins
){
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumUser
.
find
({
ent_code
:
entcode
,
_id
:{
$nin
:
nins
}}).
limit
(
limit
).
skip
(
skip
)
.
exec
(
function
(
err
,
results
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
if
(
results
){
callback
(
null
,{
total
:
count
,
items
:
results
});
}
else
{
callback
(
null
,{
total
:
count
,
items
:[]});
}
}
});
};
async
.
waterfall
([
function
(
cb
){
//获取黑名单
BlackList
.
find
({
ent_code
:
entcode
})
.
select
(
'blackUser'
).
exec
(
function
(
err
,
results
){
var
nins
=
[];
if
(
results
&&
results
.
length
>
0
){
for
(
var
i
=
0
,
len
=
results
.
length
;
i
<
len
;
i
++
){
if
(
results
[
i
].
blackUser
){
nins
.
push
(
results
[
i
].
blackUser
);
}
}
}
cb
(
null
,
nins
);
});
},
function
(
n
,
cb
)
{
console
.
log
(
n
);
ForumUser
.
count
({
ent_code
:
entcode
,
_id
:{
$nin
:
n
}}).
exec
(
function
(
err
,
count
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
if
(
count
>
0
){
getPageList
(
count
,
n
);
}
else
{
callback
(
null
,{
total
:
0
,
items
:[]});
}
}
});
}],
function
(
err
,
result
)
{
return
callback
&&
callback
(
err
);
});
};
\ No newline at end of file
app/service/forumThreadService.js
View file @
1981c34d
...
...
@@ -9,7 +9,7 @@ var forumCommentService = require('./forumCommentService');
var
async
=
require
(
'async'
);
var
then
=
require
(
'thenjs'
);
//
查询帖子
//
根据发帖者分页查询话题列表
exports
.
findThreadByPage
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
then
(
function
(
cont
)
{
ForumThread
.
find
(
q
).
populate
(
'from'
).
count
(
cont
);
...
...
@@ -476,7 +476,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 -created'
;
var
sortBy
=
'-topTime -
tag_topTime -
created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
...
...
@@ -585,6 +585,26 @@ exports.updateUnTopByThreadId = function(infoId, threadId, callback) {
});
};
//根据板块ID更新标签置顶(置顶)
exports
.
updateTagTop
=
function
(
tid
,
tag_top
,
callback
){
var
time
=
''
;
if
(
tag_top
==
1
){
time
=
new
Date
();
}
ForumThread
.
findOneAndUpdate
({
_id
:
tid
},
{
tag_top
:
tag_top
,
tag_topTime
:
time
},
function
(
err
,
doc
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
doc
);
}
});
};
//更新文章点赞数
exports
.
updateThreadRaiseCount
=
function
(
threadId
,
callback
)
{
ForumThread
.
update
({
...
...
app/service/forumUserService.js
View file @
1981c34d
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumUser
=
mongoose
.
model
(
'ForumUser'
);
//创建用户
exports
.
createUser
=
function
(
entity
,
callback
){
var
forum
=
new
ForumUser
(
entity
);
...
...
@@ -56,36 +55,3 @@ exports.updateUserById=function(uid,entity,callback){
}
});
};
exports
.
getUsers
=
function
(
pageNo
,
pageSize
,
callback
){
var
pageNo
=
pageNo
||
1
;
var
pageSize
=
pageSize
||
10
;
var
getPageList
=
function
(
count
){
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumUser
.
find
({}).
limit
(
limit
).
skip
(
skip
)
.
exec
(
function
(
err
,
results
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
if
(
results
){
callback
(
null
,{
total
:
count
,
items
:
results
});
}
else
{
callback
(
null
,{
total
:
count
,
items
:[]});
}
}
});
};
ForumUser
.
count
({}).
exec
(
function
(
err
,
count
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
if
(
count
>
0
){
getPageList
(
count
);
}
else
{
callback
(
null
,{
total
:
0
,
items
:[]});
}
}
});
};
app/utils/returnCode.js
View file @
1981c34d
...
...
@@ -37,6 +37,12 @@ module.exports = {
CAN_NOT_RAISE_REPEAT
:
{
errorcode
:
10006
,
errormsg
:
'不能重复点赞'
},
UNCHECK_ERROR
:
function
(
msg
){
return
{
errorcode
:
9999
,
errormsg
:
msg
};
}
...
...
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