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
fbac4ee7
Commit
fbac4ee7
authored
Jul 21, 2015
by
陈家荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
111
parent
138ea52e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
268 additions
and
3 deletions
+268
-3
forumLimitAction.js
app/controllers/admin/forumLimitAction.js
+52
-3
forumLimitActionConfig.js
app/controllers/admin/forumLimitActionConfig.js
+48
-0
forumLimitActionRef.js
app/controllers/admin/forumLimitActionRef.js
+168
-0
No files found.
app/controllers/admin/forumLimitAction.js
View file @
fbac4ee7
...
...
@@ -6,6 +6,7 @@ var express = require('express'),
var
mongoose
=
require
(
'mongoose'
);
var
forumLimitActionService
=
require
(
'../../service/forumLimitActionService'
);
var
forumLimitActionConfigService
=
require
(
'../../service/forumLimitActionConfigService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
...
...
@@ -30,13 +31,13 @@ router.post('/limitAction/create', function(req, res, next) {
router
.
get
(
'/limitAction/:rid/get'
,
function
(
req
,
res
,
next
)
{
var
rid
=
req
.
params
.
rid
;
if
(
rid
){
forumLimitActionService
.
getLimitActionById
(
rid
,
function
(
err
,
role
){
forumLimitActionService
.
getLimitActionById
(
rid
,
function
(
err
,
forumLimitAction
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
data
=
role
;
rs
.
data
=
forumLimitAction
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
...
...
@@ -94,7 +95,6 @@ router.get('/limitAction/list', function(req, res, next) {
$options
:
'i'
};
}
forumLimitActionService
.
getAllLimitAction
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
...
...
@@ -104,3 +104,52 @@ router.get('/limitAction/list', function(req, res, next) {
}
});
});
//获取行为限制列表
router
.
get
(
'/limitAction/list/groupByType'
,
function
(
req
,
res
,
next
)
{
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
status
:
1
};
forumLimitActionService
.
getAllLimitActionGroupByType
(
conditions
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumLimitActionConfigService
.
getAllLimitActionConfig
(
function
(
err
,
configs
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
array
=
[];
for
(
var
i
in
results
){
var
limitAction
=
results
[
i
];
var
newObject
=
{
cid
:
limitAction
.
_id
,
name
:
""
};
for
(
var
j
in
configs
){
var
config
=
configs
[
j
];
if
(
limitAction
.
_id
===
config
.
code
){
newObject
.
name
=
config
.
name
;
break
;
}
}
newObject
.
datas
=
[];
if
(
limitAction
.
value
.
datas
){
newObject
.
datas
=
limitAction
.
value
.
datas
;
}
else
{
newObject
.
datas
.
push
(
limitAction
.
value
);
}
array
.
push
(
newObject
);
}
var
obj
=
{
items
:
array
}
res
.
json
(
_
.
assign
(
obj
,
returnCode
.
SUCCESS
));
}
});
}
});
});
\ No newline at end of file
app/controllers/admin/forumLimitActionConfig.js
0 → 100644
View file @
fbac4ee7
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
forumLimitActionConfigService
=
require
(
'../../service/forumLimitActionConfigService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//获取论坛行为限制
router
.
get
(
'/limitActionConfig/:rid/get'
,
function
(
req
,
res
,
next
)
{
var
rid
=
req
.
params
.
rid
;
if
(
rid
){
forumLimitActionConfigService
.
getLimitActionConfigById
(
rid
,
function
(
err
,
forumLimitActionConfig
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
data
=
forumLimitActionConfig
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//获取行为限制列表
router
.
get
(
'/limitActionConfig/list'
,
function
(
req
,
res
,
next
)
{
forumLimitActionConfigService
.
getAllLimitActionConfig
(
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
obj
=
{
item
:
results
}
res
.
json
(
_
.
assign
(
obj
,
returnCode
.
SUCCESS
));
}
});
});
app/controllers/admin/forumLimitActionRef.js
0 → 100644
View file @
fbac4ee7
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
moment
=
require
(
'moment'
);
var
forumLimitActionService
=
require
(
'../../service/forumLimitActionService'
);
var
forumLimitActionRefService
=
require
(
'../../service/forumLimitActionRefService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//格式化日期 (格式:年-月-日)
function
date_format
(
date
)
{
return
moment
(
date
).
format
(
'YYYY/MM/DD'
);
}
//判断时间是否在指定范围
function
compareTime
(
now
,
begin_time
,
end_time
)
{
now
=
date_format
(
now
);
begin_time
=
date_format
(
begin_time
);
end_time
=
date_format
(
end_time
);
if
(
moment
(
now
).
isSame
(
begin_time
)
||
moment
(
now
).
isSame
(
end_time
))
{
//如果等于开始时间或者结束时间
return
true
;
}
else
{
return
moment
(
now
).
isBetween
(
begin_time
,
end_time
);
}
}
//新增或更新论坛行为限制
router
.
post
(
'/limitActionRef/createOrUpdate'
,
function
(
req
,
res
,
next
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
mid
=
req
.
body
.
mid
;
var
selects
=
req
.
body
.
selects
;
var
limit_actions
=
[];
var
conditions
=
{
ent_code
:
ent_code
,
status
:
1
};
forumLimitActionService
.
getAllLimitActionNotPage
(
conditions
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
for
(
var
i
in
selects
)
{
for
(
var
j
in
results
)
{
if
(
selects
[
i
]
===
results
[
j
].
_id
.
toString
())
{
var
begin_time
=
moment
().
format
(
'YYYY-MM-DD'
);
var
end_time
=
moment
().
add
(
results
[
j
].
limit_time
,
'days'
).
format
(
'YYYY-MM-DD'
);
var
obj
=
{
limit_action
:
selects
[
i
],
limit_action_type
:
results
[
j
].
limit_action_type
,
begin_time
:
begin_time
,
end_time
:
end_time
}
limit_actions
.
push
(
obj
);
break
;
}
}
}
var
forumLimitActionRef
=
{
ent_code
:
ent_code
,
mid
:
mid
,
limit_actions
:
limit_actions
}
forumLimitActionRefService
.
createOrUpdateLimitActionRef
({
mid
:
mid
,
ent_code
:
ent_code
,
status
:
1
},
forumLimitActionRef
,
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{
data
:
forum
}
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
})
});
//根据mid获取论坛行为限制
router
.
get
(
'/limitActionRef/:mid/get'
,
function
(
req
,
res
,
next
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
mid
=
req
.
params
.
mid
;
if
(
mid
)
{
forumLimitActionRefService
.
getLimitActionRefByMIdAndEntCode
(
mid
,
ent_code
,
function
(
err
,
forumLimitActionRef
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
data
=
forumLimitActionRef
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//删除论坛行为限制
router
.
post
(
'/limitActionRef/:rid/delete'
,
function
(
req
,
res
,
next
)
{
var
rid
=
req
.
params
.
rid
;
if
(
rid
)
{
forumLimitActionRefService
.
deleteLimitActionRefById
(
rid
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//更新论坛行为限制
router
.
post
(
'/limitActionRef/:rid/update'
,
function
(
req
,
res
,
next
)
{
var
rid
=
req
.
params
.
rid
;
if
(
rid
)
{
forumLimitActionRefService
.
updateLimitActionRefById
(
rid
,
req
.
body
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//获取行为限制列表
router
.
get
(
'/limitActionRef/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
limitActionName
=
req
.
query
.
limitActionName
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
limitActionName
)
{
conditions
.
title
=
{
$regex
:
limitActionName
,
$options
:
'i'
};
}
forumLimitActionRefService
.
getAllLimitActionRef
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
});
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