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
f285872a
Commit
f285872a
authored
Jan 27, 2016
by
陈家荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 荣誉头衔列表增加排序
parent
363442eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
78 deletions
+31
-78
forumHonorTitle.js
app/controllers/mobile/forumHonorTitle.js
+11
-6
forumUserHonorTimeLineService.js
app/service/forumUserHonorTimeLineService.js
+20
-72
No files found.
app/controllers/mobile/forumHonorTitle.js
View file @
f285872a
...
...
@@ -17,23 +17,28 @@ module.exports = function(app) {
//查询单个头衔信息人员信息
router
.
get
(
'/honorTitle/:hid/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
4
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
honorTitleId
=
req
.
params
.
hid
;
var
user_
conditions
=
{
var
conditions
=
{
ent_code
:
ent_code
,
honorTitles
:
{
$in
:
[
honorTitleId
]
}
honor
:
honorTitleId
};
var
fields
=
"nickName icon"
;
forumUser
Service
.
searchMembersAndFields
(
1
,
10000
,
user_conditions
,
fields
,
function
(
err
,
results
)
{
forumUser
HonorTimeLineService
.
getAll
(
pageNo
,
pageSize
,
conditions
,
fields
,
'_id'
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
cont
(
err
,
null
);
}
else
{
var
users
=
[];
_
.
forEach
(
results
.
datas
,
function
(
one
,
i
)
{
users
.
push
(
one
.
user
);
});
results
.
datas
=
users
;
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
...
...
app/service/forumUserHonorTimeLineService.js
View file @
f285872a
...
...
@@ -80,82 +80,30 @@ function countAll(conditions, callback) {
}
//分页查询
exports
.
getAll
=
function
(
pageNo
,
pageSize
,
conditions
,
fields
,
callback
)
{
// countAll(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);
// ForumUserHonorTimeLine.find(conditions).skip(skip).limit(limit).select(fields).sort('-created').populate({
// path: 'user',
// select: fields,
// options: {
// sort: {
// created: -1
// }
// }
// }).exec(function(err, docs) {
// callback(err, count, docs);
// });
// }
// });
exports
.
getAll
=
function
(
pageNo
,
pageSize
,
conditions
,
fields
,
sort
,
callback
)
{
countAll
(
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
skip
=
(
pageNo
-
1
)
*
pageSize
;
ForumUserHonorTimeLine
.
find
(
conditions
).
skip
(
skip
).
limit
(
pageSize
).
sort
(
'-created'
).
populate
({
path
:
'user'
,
select
:
fields
,
options
:
{
sort
:
{
created
:
-
1
}
ForumUserHonorTimeLine
.
find
(
conditions
).
skip
(
skip
).
limit
(
limit
).
sort
(
sort
).
populate
({
path
:
'user'
,
select
:
fields
}).
exec
(
function
(
err
,
docs
)
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
datas
=
docs
;
callback
(
null
,
obj
);
});
}
}).
exec
(
function
(
err
,
docs
)
{
callback
(
err
,
docs
);
});
};
//获取列表
exports
.
find
=
function
(
conditions
,
callback
)
{
ForumUserHonorTimeLine
.
find
(
conditions
).
sort
({
order_idx
:
-
1
}).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
docs
);
}
});
};
exports
.
getAllOrderIDX
=
function
(
conditions
,
callback
)
{
ForumUserHonorTimeLine
.
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
.
updateIdx
=
function
(
id
,
idx
,
callback
)
{
ForumUserHonorTimeLine
.
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