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
4c352a78
Commit
4c352a78
authored
Oct 30, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'newfunc_1027_plate_sort'
parents
aa7484db
c07708d1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
343 additions
and
19 deletions
+343
-19
forumInfo.js
app/controllers/admin/forumInfo.js
+63
-0
forumNotice.js
app/controllers/admin/forumNotice.js
+152
-14
forumTag.js
app/controllers/admin/forumTag.js
+66
-0
forumNotice.js
app/controllers/mobile/forumNotice.js
+3
-3
forumNotice.js
app/models/forumNotice.js
+5
-0
forumInfoService.js
app/service/forumInfoService.js
+26
-1
forumTagService.js
app/service/forumTagService.js
+28
-1
No files found.
app/controllers/admin/forumInfo.js
View file @
4c352a78
...
...
@@ -224,6 +224,69 @@ router.get('/infos/list', function(req, res, next) {
});
});
//直接修改序号
router
.
put
(
'/infos/orderIDX/:id/:order'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
var
idx
=
req
.
params
.
order
;
forumInfoService
.
updateInfoIdx
(
id
,
idx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
return
res
.
json
(
returnCode
.
BUSY
);
}
return
res
.
json
(
_
.
assign
({
data
:
true
},
returnCode
.
SUCCESS
));
});
});
//板块上移
router
.
put
(
'/infos/moveUP/:id/:order'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
var
idx
=
req
.
params
.
order
;
var
groupId
=
req
.
body
.
groupId
||
null
;
var
infoName
=
req
.
body
.
infoName
||
null
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
groupId
){
conditions
.
group
=
groupId
;
}
if
(
infoName
){
conditions
.
name
=
{
$regex
:
infoName
,
$options
:
'i'
};
}
forumInfoService
.
getAllOrderIDX
(
conditions
,
function
(
err
,
results
){
if
(
err
){
return
res
.
json
(
returnCode
.
BUSY
);
}
var
index
=-
1
;
_
.
forEach
(
results
,
function
(
r
,
i
){
if
(
r
.
_id
.
toString
()
===
id
.
toString
()){
index
=
i
;
}
});
if
(
index
===
-
1
){
return
res
.
json
(
returnCode
.
BUSY
);
}
var
preObj
=
results
[
index
-
1
];
if
(
!
preObj
){
return
res
.
json
(
returnCode
.
BUSY
);
}
var
preidx
=
preObj
.
order_idx
;
if
(
preidx
.
toString
()
===
idx
.
toString
()){
preidx
=
Number
(
preidx
)
+
1
;
}
forumInfoService
.
updateInfoIdx
(
id
,
preidx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
return
res
.
json
(
returnCode
.
BUSY
);
}
forumInfoService
.
updateInfoIdx
(
preObj
.
_id
,
idx
,
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 @
4c352a78
...
...
@@ -31,6 +31,29 @@ function getPageInfo(pageNo,pageSize,count){
};
}
function
updateNoticIdx
(
id
,
idx
,
callback
){
Notice
.
update
(
{
_id
:
id
},
{
order_idx
:
idx
},
null
,
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
true
);
}
});
}
function
getAllOrderIDX
(
condition
,
sort
,
callback
){
Notice
.
find
(
condition
).
select
(
'_id order_idx'
).
sort
(
sort
).
exec
(
function
(
err
,
results
){
//分页查询
if
(
err
){
return
callback
&&
callback
(
err
);
}
return
callback
&&
callback
(
false
,
results
);
});
}
function
queryList
(
condition
,
sort
,
pageNo
,
pageSize
,
callback
){
condition
=
condition
||
{};
sort
=
sort
||
{};
...
...
@@ -50,6 +73,14 @@ function queryList(condition,sort,pageNo,pageSize,callback){
if
(
err
){
return
callback
&&
callback
({
err
:
err
});
}
_
.
forEach
(
results
,
function
(
o
,
i
){
if
(
o
.
populated
(
'plate'
)
&&
!
o
.
plate
){
//对应的板块不存在
results
[
i
]
=
o
.
toObject
();
results
[
i
].
plate
=
{
deleted
:
true
};
}
});
return
callback
&&
callback
(
false
,{
data
:
results
,
total
:
count
});
});
})
...
...
@@ -100,25 +131,13 @@ router.post('/notice/search', function(req, res, next) {
title
=
req
.
body
.
title
,
label
=
req
.
body
.
label
,
plate
=
req
.
body
.
plate
,
//createtime=req.body.createtime;
sort
=
req
.
body
.
sort
,
begin_time
=
req
.
body
.
begin_time
,
end_time
=
req
.
body
.
end_time
,
top
=
req
.
body
.
top
,
status
=
req
.
body
.
status
,
finished
=
req
.
body
.
finished
;
var
_condition
=
{
ent_code
:
req
.
session
.
user
.
ent_code
},
_sort
=
{};
//如果sort为空
if
(
!
sort
)
{
_sort
=
{
top
:
-
1
,
createtime
:
-
1
};
}
if
(
sort
){
_sort
[
sort
]
=
-
1
;
//降序
// console.log("改了排序");
//_sort = {top:-1,createtime:-1};
}
var
_condition
=
{
ent_code
:
req
.
session
.
user
.
ent_code
},
_sort
=
{
top
:
-
1
,
order_idx
:
-
1
,
createtime
:
-
1
};
if
(
title
){
_condition
.
title
=
new
RegExp
(
title
,
'i'
);
...
...
@@ -178,14 +197,133 @@ router.post('/notice/search', function(req, res, next) {
}
queryList
(
_condition
,
_sort
,
pageNo
,
pageSize
,
function
(
err
,
result
){
console
.
log
(
err
);
if
(
err
){
console
.
log
(
err
);
return
res
.
json
(
err
);
}
return
res
.
json
(
result
);
});
});
//直接修改序号
router
.
put
(
'/notice/orderIDX/:id/:order'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
var
idx
=
req
.
params
.
order
;
updateNoticIdx
(
id
,
idx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
console
.
log
(
err
);
return
res
.
json
(
returnCode
.
BUSY
);
}
return
res
.
json
(
_
.
assign
({
data
:
true
},
returnCode
.
SUCCESS
));
});
});
//上移
router
.
put
(
'/notice/moveUP/:id/:order'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
var
idx
=
req
.
params
.
order
;
var
type
=
req
.
body
.
type
,
title
=
req
.
body
.
title
,
label
=
req
.
body
.
label
,
plate
=
req
.
body
.
plate
,
begin_time
=
req
.
body
.
begin_time
,
end_time
=
req
.
body
.
end_time
,
top
=
req
.
body
.
top
,
status
=
req
.
body
.
status
,
finished
=
req
.
body
.
finished
;
var
_condition
=
{
ent_code
:
req
.
session
.
user
.
ent_code
},
_sort
=
{
top
:
-
1
,
order_idx
:
-
1
,
createtime
:
-
1
};
if
(
title
){
_condition
.
title
=
new
RegExp
(
title
,
'i'
);
}
if
(
label
){
_condition
.
label
=
new
RegExp
(
label
,
'i'
);
}
if
(
begin_time
){
if
(
!!!
_condition
.
createtime
){
_condition
.
createtime
=
{};
}
var
gte
=
'$gte'
;
_condition
.
createtime
[
gte
]
=
begin_time
;
}
if
(
end_time
){
if
(
!!!
_condition
.
createtime
){
_condition
.
createtime
=
{};
}
var
lte
=
'$lte'
;
_condition
.
createtime
[
lte
]
=
end_time
;
}
try
{
if
(
!!
type
){
_condition
.
type
=
Number
(
type
);
}
}
catch
(
err
){
delete
_condition
.
type
;
}
try
{
if
(
!!
top
){
_condition
.
top
=
Number
(
top
);
}
}
catch
(
err
){
delete
_condition
.
top
;
}
try
{
if
(
!!
status
){
_condition
.
status
=
Number
(
status
);
}
}
catch
(
err
){
delete
_condition
.
status
;
}
try
{
if
(
!!
finished
){
_condition
.
finished
=
Number
(
finished
);
}
}
catch
(
err
){
delete
_condition
.
finished
;
}
if
(
!!
plate
){
_condition
.
plate
=
plate
;
}
getAllOrderIDX
(
_condition
,
_sort
,
function
(
err
,
results
){
if
(
err
){
console
.
log
(
err
);
return
res
.
json
(
returnCode
.
BUSY
);
}
var
index
=-
1
;
_
.
forEach
(
results
,
function
(
r
,
i
){
if
(
r
.
_id
.
toString
()
===
id
.
toString
()){
index
=
i
;
}
});
if
(
index
===
-
1
){
return
res
.
json
(
returnCode
.
BUSY
);
}
var
preObj
=
results
[
index
-
1
];
if
(
!
preObj
){
return
res
.
json
(
returnCode
.
BUSY
);
}
var
preidx
=
preObj
.
order_idx
;
if
(
preidx
.
toString
()
===
idx
.
toString
()){
preidx
=
Number
(
preidx
)
+
1
;
}
updateNoticIdx
(
id
,
preidx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
console
.
log
(
err
);
return
res
.
json
(
returnCode
.
BUSY
);
}
updateNoticIdx
(
preObj
.
_id
,
idx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
console
.
log
(
err
);
return
res
.
json
(
returnCode
.
BUSY
);
}
return
res
.
json
(
_
.
assign
({
data
:
true
},
returnCode
.
SUCCESS
));
});
});
});
});
router
.
get
(
'/notice/:id'
,
function
(
req
,
res
,
next
)
{
Notice
.
findById
(
req
.
params
.
id
,
function
(
err
,
result
){
if
(
err
){
...
...
app/controllers/admin/forumTag.js
View file @
4c352a78
...
...
@@ -95,6 +95,72 @@ router.get('/tag/:tid/get', function(req, res, next) {
}
});
//直接修改序号
router
.
put
(
'/tag/orderIDX/:id/:order'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
var
idx
=
req
.
params
.
order
;
forumTagService
.
updateTagIdx
(
id
,
idx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
return
res
.
json
(
returnCode
.
BUSY
);
}
return
res
.
json
(
_
.
assign
({
data
:
true
},
returnCode
.
SUCCESS
));
});
});
//上移
router
.
put
(
'/tag/moveUP/:id/:order'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
var
idx
=
req
.
params
.
order
;
var
tagName
=
req
.
query
.
tagName
||
''
;
var
info
=
req
.
query
.
info
||
''
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
tagName
){
conditions
.
title
=
{
$regex
:
tagName
,
$options
:
'i'
};
}
if
(
info
){
conditions
.
info
=
info
;
}
forumTagService
.
getAllOrderIDX
(
conditions
,
function
(
err
,
results
){
if
(
err
){
return
res
.
json
(
returnCode
.
BUSY
);
}
var
index
=-
1
;
_
.
forEach
(
results
,
function
(
r
,
i
){
if
(
r
.
_id
.
toString
()
===
id
.
toString
()){
index
=
i
;
}
});
if
(
index
===
-
1
){
return
res
.
json
(
returnCode
.
BUSY
);
}
var
preObj
=
results
[
index
-
1
];
if
(
!
preObj
){
return
res
.
json
(
returnCode
.
BUSY
);
}
var
preidx
=
preObj
.
order_idx
;
if
(
preidx
.
toString
()
===
idx
.
toString
()){
preidx
=
Number
(
preidx
)
+
1
;
}
forumTagService
.
updateTagIdx
(
id
,
preidx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
return
res
.
json
(
returnCode
.
BUSY
);
}
forumTagService
.
updateTagIdx
(
preObj
.
_id
,
idx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
return
res
.
json
(
returnCode
.
BUSY
);
}
return
res
.
json
(
_
.
assign
({
data
:
true
},
returnCode
.
SUCCESS
));
});
});
});
});
//查询所有标签
router
.
get
(
'/tag/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
,
...
...
app/controllers/mobile/forumNotice.js
View file @
4c352a78
...
...
@@ -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 @
4c352a78
...
...
@@ -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 @
4c352a78
...
...
@@ -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
);
...
...
@@ -89,6 +89,16 @@ exports.getAllByGid= function(conditions,pageNo,pageSize,callback) {
});
};
exports
.
getAllOrderIDX
=
function
(
conditions
,
callback
){
ForumInfo
.
find
(
conditions
).
select
(
'_id order_idx'
).
sort
({
order_idx
:
-
1
}).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
docs
);
}
});
};
//更新板块浏览数
exports
.
updateInfoPvCount
=
function
(
fid
,
callback
){
ForumInfo
.
update
(
...
...
@@ -105,6 +115,21 @@ exports.updateInfoPvCount=function(fid,callback){
});
};
//上移
exports
.
updateInfoIdx
=
function
(
fid
,
idx
,
callback
){
ForumInfo
.
update
(
{
_id
:
fid
},
{
order_idx
:
idx
},
null
,
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
true
);
}
});
};
//获取板块
//获取全部列表数据
...
...
app/service/forumTagService.js
View file @
4c352a78
...
...
@@ -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
);
...
...
@@ -89,3 +89,30 @@ exports.getAllTag= function(conditions,pageNo,pageSize,callback) {
});
};
exports
.
getAllOrderIDX
=
function
(
conditions
,
callback
){
ForumTag
.
find
(
conditions
).
select
(
'_id order_idx'
).
sort
({
order_idx
:
-
1
}).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
docs
);
}
});
};
//修改序号
exports
.
updateTagIdx
=
function
(
id
,
idx
,
callback
){
ForumTag
.
update
(
{
_id
:
id
},
{
order_idx
:
idx
},
null
,
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
true
);
}
});
};
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