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
93e33a85
Commit
93e33a85
authored
Sep 10, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
393b30a6
' into SANDBOX
parents
c4c2a2b7
393b30a6
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
903 additions
and
3 deletions
+903
-3
forumLimitOperationLog.js
app/controllers/admin/forumLimitOperationLog.js
+7
-3
forumModerator.js
app/controllers/admin/forumModerator.js
+80
-0
forumModeratorApply.js
app/controllers/admin/forumModeratorApply.js
+198
-0
forumInfo.js
app/controllers/mobile/forumInfo.js
+1
-0
forumModerator.js
app/controllers/mobile/forumModerator.js
+261
-0
forumModeratorApply.js
app/controllers/mobile/forumModeratorApply.js
+44
-0
forumModerator.js
app/models/forumModerator.js
+40
-0
forumModeratorApply.js
app/models/forumModeratorApply.js
+48
-0
forumModeratorApplyService.js
app/service/forumModeratorApplyService.js
+115
-0
forumModeratorService.js
app/service/forumModeratorService.js
+96
-0
express.js
config/express.js
+13
-0
No files found.
app/controllers/admin/forumLimitOperationLog.js
View file @
93e33a85
...
...
@@ -10,14 +10,18 @@ module.exports = function(app) {
app
.
use
(
'/admin/forum'
,
router
);
};
//根据userId获取论坛行为限制
router
.
get
(
'/limitOperationLogs/get/:userId'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
userId
=
req
.
params
.
userId
;
if
(
userId
)
{
forumLimitOperationLogService
.
getAllLimitAction
(
userId
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
userId
&&
ent_code
)
{
var
conditions
=
{
ent_code
:
ent_code
,
userId
:
userId
}
forumLimitOperationLogService
.
getAllLimitAction
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/admin/forumModerator.js
0 → 100644
View file @
93e33a85
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
),
moment
=
require
(
'moment'
),
nodeExcel
=
require
(
'excel-export'
),
then
=
require
(
'thenjs'
);
var
mongoose
=
require
(
'mongoose'
);
var
forumModeratorService
=
require
(
'../../service/forumModeratorService'
);
var
ForumModerator
=
mongoose
.
model
(
'ForumModerator'
),
ForumPVLog
=
mongoose
.
model
(
'ForumPVLog'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//操作记录列表
router
.
get
(
'/moderator/list'
,
function
(
req
,
res
,
next
){
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
infoId
=
req
.
query
.
infoId
;
var
content
=
req
.
query
.
content
;
var
userName
=
req
.
query
.
userName
;
var
moderatorName
=
req
.
query
.
moderatorName
;
var
behavior
=
req
.
query
.
behavior
;
var
begin
=
req
.
query
.
begin
;
var
end
=
req
.
query
.
end
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
infoId
)
{
conditions
.
info
=
infoId
;
}
if
(
content
)
{
conditions
[
'content.content'
]
=
{
$regex
:
content
,
$options
:
'i'
};
}
if
(
begin
||
end
){
conditions
.
created
=
{};
if
(
begin
){
conditions
.
created
[
'$gte'
]
=
new
Date
(
begin
);
}
if
(
end
){
var
t
=
new
Date
(
end
);
t
.
setDate
(
t
.
getDate
()
+
1
);
conditions
.
created
[
'$lte'
]
=
t
;
}
}
if
(
behavior
)
{
conditions
.
behavior
=
behavior
;
}
if
(
userName
){
forumModeratorService
.
getAllOperationByFidAndNickName
(
userName
,
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
}
else
{
forumModeratorService
.
getAllOperationByFid
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
}
})
\ No newline at end of file
app/controllers/admin/forumModeratorApply.js
0 → 100644
View file @
93e33a85
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
async
=
require
(
'async'
);
var
forumModeratorApplyService
=
require
(
'../../service/forumModeratorApplyService'
);
var
forumUserService
=
require
(
'../../service/forumUserService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//新增或更新
router
.
post
(
'/forumModeratorApply/createOrUpdate'
,
function
(
req
,
res
,
next
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
fuserId
=
req
.
body
.
fuserId
;
var
applyMsg
=
req
.
body
.
applyMsg
;
if
(
fuserId
&&
applyMsg
)
{
var
conditions
=
{
ent_code
:
ent_code
,
forumUser
:
fuserId
}
var
model
=
{
ent_code
:
ent_code
,
forumUser
:
fuserId
,
applyMsg
:
applyMsg
};
forumModeratorApplyService
.
createOrUpdateLimitOperation
(
conditions
,
model
,
function
(
err
,
ModeratorApply
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//更新
router
.
post
(
'/forumModeratorApply/updateById'
,
function
(
req
,
res
,
next
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
id
=
req
.
body
.
id
;
var
entity
=
req
.
body
.
entity
;
if
(
id
&&
entity
)
{
var
conditions
=
{
_id
:
id
}
forumModeratorApplyService
.
createOrUpdateLimitOperation
(
conditions
,
entity
,
function
(
err
,
ModeratorApply
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//根据userId获取
router
.
get
(
'/forumModeratorApply/get/:fuserId'
,
function
(
req
,
res
,
next
)
{
var
fuserId
=
req
.
params
.
fuserId
;
if
(
fuserId
)
{
forumModeratorApplyService
.
getForumModeratorApplyByFUserId
(
fuserId
,
function
(
err
,
ModeratorApply
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
data
=
ModeratorApply
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//删除
router
.
post
(
'/forumModeratorApply/delete/:id'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
if
(
id
)
{
forumModeratorApplyService
.
deleteForumModeratorApplyById
(
id
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//列表
// router.post('/forumModeratorApply/list', function(req, res, next) {
// var pageNo = req.body.pageNo || 1;
// var pageSize = req.body.pageSize || 10;
// var search = req.body.search;
// var conditions = {
// ent_code: req.session.user.ent_code
// };
// if (search) {
// if (search.nickName) { //用户昵称
// conditions.forumUser.nickName = {
// $regex: search.nickName
// };
// }
// if (search.applyMsg) {
// conditions.applyMsg = {
// $regex: search.applyMsg
// };
// }
// }
// if (search.status && Number(search.status) != 3) {
// conditions.status = Number(search.status);
// }
// forumModeratorApplyService.getForumModeratorApplys(conditions, pageNo, pageSize, null, function(err, results) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// res.json(_.assign(results, returnCode.SUCCESS));
// }
// });
// });
//列表
router
.
post
(
'/forumModeratorApply/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
body
.
pageNo
||
1
;
var
pageSize
=
req
.
body
.
pageSize
||
10
;
var
search
=
req
.
body
.
search
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
search
)
{
if
(
search
.
applyMsg
)
{
conditions
.
applyMsg
=
{
$regex
:
search
.
applyMsg
};
}
if
(
search
.
status
&&
Number
(
search
.
status
)
!=
3
)
{
conditions
.
status
=
Number
(
search
.
status
);
}
}
if
(
search
.
nickName
)
{
//如果有用户昵称
forumUserService
.
searchMembersByNickName
(
search
.
nickName
,
function
(
err
,
results
){
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
var
mids
=
[]
if
(
results
&&
results
.
length
>
0
){
results
.
forEach
(
function
(
user
){
mids
.
push
(
user
.
_id
);
});
}
conditions
.
forumUser
=
{
$in
:
mids
}
forumModeratorApplyService
.
getForumModeratorApplys
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
}
});
}
else
{
forumModeratorApplyService
.
getForumModeratorApplys
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
}
});
\ No newline at end of file
app/controllers/mobile/forumInfo.js
View file @
93e33a85
...
...
@@ -499,6 +499,7 @@ router.get('/info/:fid/serachThreads', function(req, res, next) {
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
status
:
1
,
info
:
fid
};
...
...
app/controllers/mobile/forumModerator.js
0 → 100644
View file @
93e33a85
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
),
thenjs
=
require
(
'thenjs'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumModeratorApply
=
mongoose
.
model
(
'ForumModeratorApply'
);
var
user
=
require
(
'../../utils/user'
);
var
ForumThread
=
mongoose
.
model
(
'ForumThread'
);
var
ForumModerator
=
mongoose
.
model
(
'ForumModerator'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
forumLimitOperationService
=
require
(
'../../service/forumLimitOperationService'
);
var
forumModeratorApplyService
=
require
(
'../../service/forumModeratorApplyService'
);
var
request
=
require
(
'request'
);
var
env
=
process
.
env
.
NODE_ENV
;
var
API_ADDRESS
=
'http://localhost:8080'
;
if
(
env
==
'sandbox'
){
API_ADDRESS
=
'http://rest.wxpai.cn'
;
}
else
if
(
env
==
'production'
){
API_ADDRESS
=
'https://rest.wxpai.cn'
;
}
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
function
moderatorOperateLog
(
forumUser
,
thread
,
type
){
var
ent_code
=
thread
.
ent_code
;
var
forumModerator
=
new
ForumModerator
({
ent_code
:
ent_code
,
info
:
thread
.
info
,
userName
:
thread
.
from
.
nickName
||
thread
.
from
.
displayName
,
content
:{
id
:
thread
.
_id
,
content
:
thread
.
content
},
behavior
:
type
,
moderatorName
:
forumUser
.
nickName
||
forumUser
.
displayName
});
forumModerator
.
save
(
function
(
err
,
res
)
{});
}
function
addIntegral
(
thread
){
var
openID
=
thread
.
from
.
uid
;
var
tid
=
thread
.
_id
;
var
ent_code
=
thread
.
ent_code
;
forumLimitOperationService
.
checkLimitOperationProhibitionAddIntegral
(
tid
,
function
(
err
,
flag
){
if
(
!
err
&&
!
flag
){
//获取mid
console
.
log
(
API_ADDRESS
);
request
.
get
({
url
:
API_ADDRESS
+
'/v1.0/internal/member/getMidbyOpenID?entCode='
+
ent_code
+
'&openID='
+
openID
,
json
:
true
},
function
(
e
,
r
,
res
){
console
.
log
(
res
);
if
(
res
&&
res
.
data
){
httpService
.
sendRequest
(
ent_code
,
res
.
data
,
'thread_recomment'
);
}
});
}
});
}
//获取版主为当前用户的板块id数组
router
.
get
(
'/moderators/plates'
,
function
(
req
,
res
,
next
)
{
var
entCode
=
req
.
session
.
user
.
ent_code
;
var
id
=
user
.
getMobileUser
(
req
);
var
q
=
{};
q
.
status
=
1
;
q
.
ent_code
=
entCode
;
q
.
forumUser
=
id
;
ForumModeratorApply
.
findOne
(
q
).
exec
(
function
(
err
,
result
){
if
(
err
){
return
res
.
json
(
returnCode
.
BUSY
);
}
var
items
=
[];
if
(
result
&&
result
.
infoIds
){
items
=
result
.
infoIds
;
}
res
.
json
(
_
.
assign
({
items
:
items
},
returnCode
.
SUCCESS
));
});
});
//版主加精
//1.判断这篇文章是不是后台发的,后台发的不允许操作
//2.判断当前用户是不是这个文章对应板块的版主
router
.
get
(
'/moderators/recommend/:tid'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
,
entCode
=
req
.
session
.
user
.
ent_code
,
id
=
user
.
getMobileUser
(
req
);
//user._id
var
q1
=
{};
//拼装查询条件
q1
.
ent_code
=
entCode
;
q1
.
_id
=
tid
;
q1
.
status
=
1
;
q1
.
$or
=
[{
recommend
:
0
},
{
recommend
:
null
}];
ForumThread
.
findOne
(
q1
).
populate
(
'from'
).
exec
(
function
(
err
,
t
)
{
if
(
err
||
!
t
)
{
return
res
.
json
(
returnCode
.
BUSY
);
}
if
(
t
.
from
&&
!
isNaN
(
t
.
from
.
uid
)){
//是后台发的,没有权限操作
return
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
if
(
!
t
.
info
){
//没有板块id直接返回
return
res
.
json
(
returnCode
.
BUSY
);
}
var
q2
=
{};
//查询当前用户是不是这篇文章的版主
q2
.
status
=
1
;
q2
.
ent_code
=
entCode
;
q2
.
forumUser
=
id
;
q2
.
infoIds
=
{
$all
:[
t
.
info
]};
ForumModeratorApply
.
findOne
(
q2
).
populate
(
'forumUser'
).
exec
(
function
(
err
,
result
){
if
(
err
){
return
res
.
json
(
returnCode
.
BUSY
);
}
if
(
!
result
){
//不是该版主
return
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
//加精
forumThreadService
.
updateRecommendByThreadId
(
tid
,
function
(
err
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
moderatorOperateLog
(
result
.
forumUser
,
t
,
1
);
addIntegral
(
t
);
//根据openid 送积分
}
});
});
});
});
//版主取消加精
router
.
get
(
'/moderators/unrecommend/:tid'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
,
entCode
=
req
.
session
.
user
.
ent_code
,
id
=
user
.
getMobileUser
(
req
);
//user._id
var
q1
=
{};
//拼装查询条件
q1
.
ent_code
=
entCode
;
q1
.
_id
=
tid
;
q1
.
status
=
1
;
q1
.
recommend
=
1
;
ForumThread
.
findOne
(
q1
).
populate
(
'from'
).
exec
(
function
(
err
,
t
)
{
if
(
err
||
!
t
)
{
return
res
.
json
(
returnCode
.
BUSY
);
}
if
(
t
.
from
&&
!
isNaN
(
t
.
from
.
uid
)){
//是后台发的,没有权限操作
return
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
if
(
!
t
.
info
){
//没有板块id直接返回
return
res
.
json
(
returnCode
.
BUSY
);
}
var
q2
=
{};
//查询当前用户是不是这篇文章的版主
q2
.
status
=
1
;
q2
.
ent_code
=
entCode
;
q2
.
forumUser
=
id
;
q2
.
infoIds
=
{
$all
:[
t
.
info
]};
ForumModeratorApply
.
findOne
(
q2
).
populate
(
'forumUser'
).
exec
(
function
(
err
,
result
){
if
(
err
){
return
res
.
json
(
returnCode
.
BUSY
);
}
if
(
!
result
){
//不是该版主
return
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
//取消加精
forumThreadService
.
updateUnRecommendByThreadId
(
tid
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
moderatorOperateLog
(
result
.
forumUser
,
t
,
2
);
}
});
});
});
});
//版主删除帖子
router
.
get
(
'/moderators/delthread/:tid'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
,
entCode
=
req
.
session
.
user
.
ent_code
,
id
=
user
.
getMobileUser
(
req
);
//user._id
var
q1
=
{};
//拼装查询条件
q1
.
ent_code
=
entCode
;
q1
.
_id
=
tid
;
q1
.
status
=
1
;
ForumThread
.
findOne
(
q1
).
populate
(
'from'
).
exec
(
function
(
err
,
t
)
{
if
(
err
||
!
t
)
{
return
res
.
json
(
returnCode
.
BUSY
);
}
if
(
t
.
from
&&
!
isNaN
(
t
.
from
.
uid
)){
//是后台发的,没有权限操作
return
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
if
(
!
t
.
info
){
//没有板块id直接返回
return
res
.
json
(
returnCode
.
BUSY
);
}
var
q2
=
{};
//查询当前用户是不是这篇文章的版主
q2
.
status
=
1
;
q2
.
ent_code
=
entCode
;
q2
.
forumUser
=
id
;
q2
.
infoIds
=
{
$all
:[
t
.
info
]};
ForumModeratorApply
.
findOne
(
q2
).
populate
(
'forumUser'
).
exec
(
function
(
err
,
result
){
if
(
err
){
return
res
.
json
(
returnCode
.
BUSY
);
}
if
(
!
result
){
//不是该版主
return
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
//删除帖子
forumThreadService
.
logicDeleteThreadById
(
tid
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
moderatorOperateLog
(
result
.
forumUser
,
t
,
3
);
}
});
});
});
});
//添加版主申请
router
.
post
(
'/forumModeratorApply/create'
,
function
(
req
,
res
,
next
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
fuserId
=
req
.
session
.
mobileForumUser
.
userId
;
var
applyMsg
=
req
.
body
.
applyMsg
;
if
(
fuserId
&&
applyMsg
)
{
forumModeratorApplyService
.
getForumModeratorApplyByFUserId
(
fuserId
,
function
(
err
,
doc
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
if
(
doc
){
//已申请
res
.
json
({
errorcode
:
0
,
errormsg
:
'已申请,请勿重复申请!'
});
}
else
{
var
conditions
=
{
ent_code
:
ent_code
,
forumUser
:
fuserId
}
var
model
=
{
ent_code
:
ent_code
,
forumUser
:
fuserId
,
applyMsg
:
applyMsg
};
forumModeratorApplyService
.
createOrUpdateLimitOperation
(
conditions
,
model
,
function
(
err
,
ModeratorApply
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
returnCode
.
SUCCESS
));
}
});
}
})
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
app/controllers/mobile/forumModeratorApply.js
0 → 100644
View file @
93e33a85
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
then
=
require
(
'thenjs'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
forumModeratorApplyService
=
require
(
'../../service/forumModeratorApplyService'
);
var
user
=
require
(
'../../utils/user'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
//新增或更新
router
.
post
(
'/forumModeratorApply/create'
,
function
(
req
,
res
,
next
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
fuserId
=
req
.
session
.
mobileForumUser
.
userId
;
var
applyMsg
=
req
.
body
.
applyMsg
;
if
(
fuserId
&&
applyMsg
)
{
var
conditions
=
{
ent_code
:
ent_code
,
forumUser
:
fuserId
}
var
model
=
{
ent_code
:
ent_code
,
forumUser
:
fuserId
,
applyMsg
:
applyMsg
};
forumModeratorApplyService
.
createOrUpdateLimitOperation
(
conditions
,
model
,
function
(
err
,
ModeratorApply
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
app/models/forumModerator.js
0 → 100644
View file @
93e33a85
'use strict'
;
var
mongoose
=
require
(
'mongoose'
),
Schema
=
mongoose
.
Schema
;
var
ForumModeratorSchema
=
new
Schema
({
ent_code
:{
type
:
Number
,
require
:
true
},
info
:
{
type
:
Schema
.
Types
.
ObjectId
,
require
:
false
,
index
:
true
,
ref
:
'ForumInfo'
},
userName
:{
type
:
String
,
require
:
false
},
content
:{
id
:{
type
:
String
},
content
:{
type
:
String
}
},
behavior
:{
//行为:1.加精 2.取消精华 3.删帖
type
:
Number
,
require
:
false
},
moderatorName
:{
type
:
String
,
require
:
false
},
created
:{
type
:
Date
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_moderator_operation'
});
module
.
exports
=
mongoose
.
model
(
'ForumModerator'
,
ForumModeratorSchema
);
\ No newline at end of file
app/models/forumModeratorApply.js
0 → 100644
View file @
93e33a85
'use strict'
;
var
mongoose
=
require
(
'mongoose'
),
Schema
=
mongoose
.
Schema
;
//版主申请
var
ForumModeratorApplySchema
=
new
Schema
({
ent_code
:
{
type
:
Number
,
require
:
true
,
index
:
true
},
forumUser
:
{
type
:
Schema
.
Types
.
ObjectId
,
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
},
applyMsg
:
{
//申请信息
type
:
String
},
applyTime
:
{
//申请时间
type
:
Date
,
require
:
true
,
default
:
Date
.
now
},
throughTime
:
{
//通过时间
type
:
Date
,
require
:
true
},
status
:
{
//状态 1 通过 , 2 不通过
type
:
Number
,
require
:
true
,
default
:
2
},
infoIds
:
[
//板块ids
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumInfo'
}
],
created
:
{
type
:
Date
,
required
:
true
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_moderator_apply'
});
module
.
exports
=
mongoose
.
model
(
'ForumModeratorApply'
,
ForumModeratorApplySchema
);
app/service/forumModeratorApplyService.js
0 → 100644
View file @
93e33a85
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
forumModeratorApply
=
mongoose
.
model
(
'ForumModeratorApply'
);
//添加
function
create
(
entity
,
callback
)
{
var
model
=
new
forumModeratorApply
(
entity
);
model
.
save
(
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
result
);
}
});
}
//获取数量
function
count
(
conditions
,
callback
)
{
forumModeratorApply
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
}
//创建或更新论坛行为限制
exports
.
createOrUpdateLimitOperation
=
function
(
conditions
,
entity
,
callback
)
{
forumModeratorApply
.
findOneAndUpdate
(
conditions
,
entity
,
function
(
err
,
doc
)
{
if
(
err
)
{
console
.
log
(
err
);
callback
(
err
,
null
);
}
else
{
if
(
!
doc
){
create
(
entity
,
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
result
);
}
});
}
else
{
callback
(
null
,
doc
);
}
}
});
};
//获取fuserId获取
exports
.
getForumModeratorApplyByFUserId
=
function
(
fuserId
,
callback
)
{
forumModeratorApply
.
findOne
({
forumUser
:
fuserId
},
function
(
err
,
doc
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
doc
);
}
});
};
//获取fuserId获取
exports
.
deleteForumModeratorApplyById
=
function
(
id
,
callback
)
{
forumModeratorApply
.
remove
({
_id
:
id
},
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
);
}
else
{
callback
(
null
);
}
});
};
//分页获取列表数据
exports
.
getForumModeratorApplys
=
function
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
forumModeratorApply
.
find
(
conditions
).
populate
(
'forumUser'
).
populate
(
'infoIds'
).
limit
(
limit
).
skip
(
skip
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
callback
(
null
,
obj
);
}
});
}
});
};
app/service/forumModeratorService.js
0 → 100644
View file @
93e33a85
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumModerator
=
mongoose
.
model
(
'ForumModerator'
);
var
ForumThread
=
mongoose
.
model
(
'ForumThread'
);
var
ForumComment
=
mongoose
.
model
(
'ForumComment'
);
var
ForumShare
=
mongoose
.
model
(
'ForumShare'
);
var
forumUserService
=
require
(
'./forumUserService'
);
var
forumCommentService
=
require
(
'./forumCommentService'
);
var
async
=
require
(
'async'
);
var
then
=
require
(
'thenjs'
);
exports
.
getAllOperationByFidAndNickName
=
function
(
userName
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
getAllOperationByFidHelpAndNickName
(
userName
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
);
}
exports
.
getAllOperationByFid
=
function
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
getAllOperationByFidHelp
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
);
};
function
getAllOperationByFidHelp
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
countAllByFid
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
ForumModerator
.
find
(
conditions
).
populate
(
'info'
).
limit
(
limit
).
skip
(
skip
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
callback
(
null
,
obj
);
}
});
}
});
}
//获取数量
function
countAllByFid
(
conditions
,
callback
)
{
ForumModerator
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
}
function
getAllOperationByFidHelpAndNickName
(
userName
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
){
conditions
.
userName
=
{
$regex
:
userName
,
$options
:
'i'
};
countAllByFid
(
conditions
,
function
(
err
,
count
)
{
console
.
log
(
count
);
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
ForumModerator
.
find
(
conditions
).
populate
(
'info'
).
limit
(
limit
).
skip
(
skip
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
console
.
log
(
docs
);
callback
(
null
,
obj
);
}
});
}
});
}
\ No newline at end of file
config/express.js
View file @
93e33a85
...
...
@@ -61,6 +61,19 @@ module.exports = function(app, config) {
next
();
});
app
.
use
(
function
(
req
,
res
,
next
)
{
if
(
!
req
.
session
){
req
.
session
=
{}
}
req
.
session
.
user
=
{
ent_code
:
100001
};
req
.
session
.
openUser
=
{
openId
:
'1111'
,
integral
:
'100'
,
exp
:
'100'
};
if
(
!
req
.
session
.
user
&&
req
.
query
.
key
&&
req
.
query
.
key
===
'aiwanpai'
)
{
req
.
session
.
user
=
{
ent_code
:
100041
...
...
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