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
0c94acb8
Commit
0c94acb8
authored
Sep 08, 2015
by
陈家荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版主申请
parent
a2ab33a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
364 additions
and
1 deletion
+364
-1
forumModeratorApply.js
app/controllers/admin/forumModeratorApply.js
+200
-0
forumModeratorApply.js
app/controllers/mobile/forumModeratorApply.js
+44
-0
forumModeratorApply.js
app/models/forumModeratorApply.js
+1
-1
forumModeratorApplyService.js
app/service/forumModeratorApplyService.js
+119
-0
No files found.
app/controllers/admin/forumModeratorApply.js
0 → 100644
View file @
0c94acb8
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
// var moment = require('moment');
var
async
=
require
(
'async'
);
// var then = require('thenjs');
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/forumModeratorApply.js
0 → 100644
View file @
0c94acb8
'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/forumModeratorApply.js
View file @
0c94acb8
...
@@ -33,7 +33,7 @@ var ForumModeratorApplySchema = new Schema({
...
@@ -33,7 +33,7 @@ var ForumModeratorApplySchema = new Schema({
default
:
0
default
:
0
},
},
infoIds
:
[
//板块ids
infoIds
:
[
//板块ids
{
type
:
S
tring
}
{
type
:
S
chema
.
Types
.
ObjectId
,
ref
:
'ForumInfo'
}
],
],
created
:
{
created
:
{
type
:
Date
,
type
:
Date
,
...
...
app/service/forumModeratorApplyService.js
0 → 100644
View file @
0c94acb8
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
forumModeratorApply
=
mongoose
.
model
(
'ForumModeratorApply'
);
// var async = require('async');
// var then = require('thenjs');
// var moment = require('moment');
//添加
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
);
}
});
}
});
};
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