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
593d7733
Commit
593d7733
authored
Sep 09, 2015
by
许文聪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加版主操作记录node接口
parent
68d1a9d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
184 additions
and
6 deletions
+184
-6
forumModerator.js
app/controllers/admin/forumModerator.js
+90
-0
forumModerator.js
app/models/forumModerator.js
+0
-6
forumModeratorService.js
app/service/forumModeratorService.js
+94
-0
No files found.
app/controllers/admin/forumModerator.js
0 → 100644
View file @
593d7733
'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/models/forumModerator.js
View file @
593d7733
...
...
@@ -17,12 +17,6 @@ var ForumModeratorSchema=new Schema({
type
:
String
,
require
:
false
},
// contentId:{
// type: Schema.Types.ObjectId,
// require: false,
// index: true,
// ref: 'ForumThread'
// },
content
:{
id
:{
type
:
String
},
content
:{
type
:
String
}
...
...
app/service/forumModeratorService.js
0 → 100644
View file @
593d7733
'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
);
ForumModerator
.
find
(
conditions
).
populate
(
'info'
).
skip
(
skip
).
limit
(
limit
).
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
=
'-topTime -tag_topTime -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
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