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
13cf76cf
Commit
13cf76cf
authored
Oct 27, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
公告 板块 标签 自定义排序
parent
45f78b27
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
6 deletions
+68
-6
forumInfo.js
app/controllers/admin/forumInfo.js
+10
-0
forumNotice.js
app/controllers/admin/forumNotice.js
+17
-1
forumTag.js
app/controllers/admin/forumTag.js
+16
-0
forumNotice.js
app/controllers/mobile/forumNotice.js
+3
-3
forumNotice.js
app/models/forumNotice.js
+5
-0
forumInfoService.js
app/service/forumInfoService.js
+16
-1
forumTagService.js
app/service/forumTagService.js
+1
-1
No files found.
app/controllers/admin/forumInfo.js
View file @
13cf76cf
...
...
@@ -224,6 +224,16 @@ router.get('/infos/list', function(req, res, next) {
});
});
//板块上移
router
.
put
(
'/infos/moveUP/:id'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
forumInfoService
.
updateInfoIdx
(
id
,
function
(
err
,
result
){
if
(
err
||
!
result
){
return
res
.
json
(
returnCode
.
BUSY
);
}
return
res
.
json
(
_
.
assign
({
data
:
true
},
returnCode
.
SUCCESS
));
});
});
//子板块报表
router
.
post
(
'/info/report/:id'
,
function
(
req
,
res
,
next
)
{
...
...
app/controllers/admin/forumNotice.js
View file @
13cf76cf
...
...
@@ -72,6 +72,22 @@ function update(obj,callback){
});
}
//上移
router
.
put
(
'/notice/moveUP/:id'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
Notice
.
update
(
{
_id
:
id
},
{
$inc
:
{
order_idx
:
1
}},
{
w
:
1
,
safe
:
true
},
function
(
err
,
result
){
if
(
err
){
return
res
.
json
({
err
:
err
});
}
else
{
res
.
json
({
result
:
true
});
}
});
});
router
.
post
(
'/notice'
,
function
(
req
,
res
,
next
)
{
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
var
notice
=
new
Notice
(
req
.
body
);
...
...
@@ -112,7 +128,7 @@ router.post('/notice/search', function(req, res, next) {
//如果sort为空
if
(
!
sort
)
{
_sort
=
{
top
:
-
1
,
createtime
:
-
1
};
_sort
=
{
top
:
-
1
,
order_idx
:
-
1
,
createtime
:
-
1
};
}
if
(
sort
){
_sort
[
sort
]
=
-
1
;
//降序
...
...
app/controllers/admin/forumTag.js
View file @
13cf76cf
...
...
@@ -95,6 +95,22 @@ router.get('/tag/:tid/get', function(req, res, next) {
}
});
//上移
router
.
put
(
'/tag/moveUP/:id'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
ForumTag
.
update
(
{
_id
:
id
},
{
$inc
:
{
order_idx
:
1
}},
{
w
:
1
,
safe
:
true
},
function
(
err
,
result
){
if
(
err
){
return
res
.
json
({
err
:
err
});
}
else
{
res
.
json
({
result
:
true
});
}
});
});
//查询所有标签
router
.
get
(
'/tag/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
,
...
...
app/controllers/mobile/forumNotice.js
View file @
13cf76cf
...
...
@@ -94,7 +94,7 @@ router.get('/notice/newestMsg', function(req, res, next) {
pageSize
=
req
.
query
.
pageSize
,
plate
=
req
.
query
.
plate
;
var
_condition
=
{
status
:
1
,
type
:
2
,
ent_code
:
req
.
session
.
user
.
ent_code
},
_sort
=
{
top
:
-
1
,
createtime
:
-
1
};
var
_condition
=
{
status
:
1
,
type
:
2
,
ent_code
:
req
.
session
.
user
.
ent_code
},
_sort
=
{
top
:
-
1
,
order_idx
:
-
1
,
createtime
:
-
1
};
if
(
plate
){
_condition
.
$or
=
[{
plate
:
plate
},{
plate
:
null
}];
}
else
{
...
...
@@ -128,7 +128,7 @@ router.get('/notice/newestAct', function(req, res, next) {
ent_code
:
req
.
session
.
user
.
ent_code
,
startdate
:{
$lte
:
curdate
},
indate
:{
$gte
:
curdate
},
},
_sort
=
{
top
:
-
1
,
createtime
:
-
1
};
},
_sort
=
{
top
:
-
1
,
order_idx
:
-
1
,
createtime
:
-
1
};
if
(
plate
){
_condition
.
$or
=
[{
plate
:
plate
},{
plate
:
null
}];
}
else
{
...
...
@@ -157,7 +157,7 @@ router.get('/notice/oldAct', function(req, res, next) {
plate
=
req
.
query
.
plate
,
curdate
=
new
Date
(),
_condition
=
{
status
:
1
,
type
:
1
,
ent_code
:
req
.
session
.
user
.
ent_code
,
$or
:[{
indate
:{
$lt
:
curdate
}},{
finished
:
1
}]},
_sort
=
{
top
:
-
1
,
createtime
:
-
1
};
_sort
=
{
top
:
-
1
,
order_idx
:
-
1
,
createtime
:
-
1
};
if
(
plate
){
_condition
.
$or
=
[{
plate
:
plate
},{
plate
:
null
}];
}
else
{
...
...
app/models/forumNotice.js
View file @
13cf76cf
...
...
@@ -62,6 +62,11 @@ var ForumNoticeSchema = new Schema({
default
:
0
,
index
:
true
},
order_idx
:
{
//排序
type
:
Number
,
require
:
true
,
default
:
0
},
status
:
{
//是否显示 0/1 隐藏/显示
type
:
Number
,
require
:
true
,
...
...
app/service/forumInfoService.js
View file @
13cf76cf
...
...
@@ -72,7 +72,7 @@ exports.getAllByGid= function(conditions,pageNo,pageSize,callback) {
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumInfo
.
find
(
conditions
).
populate
(
'group'
).
skip
(
skip
).
limit
(
limit
).
sort
(
'created'
).
exec
(
function
(
err
,
docs
)
{
ForumInfo
.
find
(
conditions
).
populate
(
'group'
).
skip
(
skip
).
limit
(
limit
).
sort
(
{
order_idx
:
-
1
}
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
@@ -105,6 +105,21 @@ exports.updateInfoPvCount=function(fid,callback){
});
};
//上移
exports
.
updateInfoIdx
=
function
(
fid
,
callback
){
ForumInfo
.
update
(
{
_id
:
fid
},
{
$inc
:
{
order_idx
:
1
}},
{
w
:
1
,
safe
:
true
},
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
true
);
}
});
};
//获取板块
//获取全部列表数据
...
...
app/service/forumTagService.js
View file @
13cf76cf
...
...
@@ -72,7 +72,7 @@ exports.getAllTag= function(conditions,pageNo,pageSize,callback) {
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumTag
.
find
(
conditions
,
null
,
{
skip
:
skip
,
limit
:
limit
,
sort
:
'created'
,
populate
:
'info'
},
function
(
err
,
docs
){
ForumTag
.
find
(
conditions
,
null
,
{
skip
:
skip
,
limit
:
limit
,
sort
:
{
order_idx
:
-
1
}
,
populate
:
'info'
},
function
(
err
,
docs
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
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