Commit ff5b00a8 authored by 陈家荣's avatar 陈家荣

update荣誉头衔管理功能

parent 7e5261d4
...@@ -145,8 +145,8 @@ router.put('/honorTitle/moveUP/:id/:order', function(req, res, next) { ...@@ -145,8 +145,8 @@ router.put('/honorTitle/moveUP/:id/:order', function(req, res, next) {
}); });
}); });
//查询所有 //查询列表
router.get('/honorTitle/list', function(req, res, next) { router.get('/honorTitle/searchList', function(req, res, next) {
var pageNo = req.query.pageNo || 1, var pageNo = req.query.pageNo || 1,
pageSize = req.query.pageSize || 10, pageSize = req.query.pageSize || 10,
titleName=req.query.titleName || ''; titleName=req.query.titleName || '';
...@@ -170,3 +170,22 @@ router.get('/honorTitle/list', function(req, res, next) { ...@@ -170,3 +170,22 @@ router.get('/honorTitle/list', function(req, res, next) {
}); });
}); });
//获取状态为启用的
router.get('/honorTitle/list', function(req, res, next) {
var conditions={
ent_code:req.session.user.ent_code,
status:1
};
forumHonorTitleService.find(conditions, function(err,results){
if(err){
console.error(err);
res.json(returnCode.BUSY);
}else{
var rs = {
data:results
};
res.json(_.assign(rs, returnCode.SUCCESS));
}
});
});
...@@ -52,6 +52,10 @@ var ForumUserSchema = new Schema({ ...@@ -52,6 +52,10 @@ var ForumUserSchema = new Schema({
require: true, require: true,
default: 1 default: 1
}, },
honorTitles: [{ //荣誉头衔数组
type: Schema.Types.ObjectId,
ref: 'ForumHonorTitle'
}],
created: { created: {
type: Date, type: Date,
required: true, required: true,
......
...@@ -63,7 +63,7 @@ function countAll(conditions,callback) { ...@@ -63,7 +63,7 @@ function countAll(conditions,callback) {
}); });
} }
//获取全部列表数据 //分页查询
exports.getAll= function(conditions,pageNo,pageSize,callback) { exports.getAll= function(conditions,pageNo,pageSize,callback) {
countAll(conditions,function(err,count){ countAll(conditions,function(err,count){
if(err){ if(err){
...@@ -89,6 +89,18 @@ exports.getAll= function(conditions,pageNo,pageSize,callback) { ...@@ -89,6 +89,18 @@ exports.getAll= function(conditions,pageNo,pageSize,callback) {
}); });
}; };
//获取列表
exports.find=function(conditions,callback){
ForumHonorTitle.find(conditions, function(err, docs) {
if (err) {
console.error(err);
callback(err,null);
} else {
callback(null,docs);
}
});
};
exports.getAllOrderIDX=function(conditions,callback){ exports.getAllOrderIDX=function(conditions,callback){
ForumHonorTitle.find(conditions).select('_id order_idx').sort({order_idx:-1}).exec(function(err, docs) { ForumHonorTitle.find(conditions).select('_id order_idx').sort({order_idx:-1}).exec(function(err, docs) {
if (err) { if (err) {
......
...@@ -3,8 +3,6 @@ var mongoose = require('mongoose'); ...@@ -3,8 +3,6 @@ var mongoose = require('mongoose');
var ForumUser = mongoose.model('ForumUser'); var ForumUser = mongoose.model('ForumUser');
var then = require('thenjs'); var then = require('thenjs');
var async = require('async'); var async = require('async');
// var forumLimitActionRefService = require('../service/forumLimitActionRefService');
// var forumLimitActionConfigService = require('../service/forumLimitActionConfigService');
var forumLimitOperationService = require('../service/forumLimitOperationService'); var forumLimitOperationService = require('../service/forumLimitOperationService');
...@@ -23,7 +21,10 @@ exports.createUser=function(entity,callback){ ...@@ -23,7 +21,10 @@ exports.createUser=function(entity,callback){
//根据Uid获取用户 //根据Uid获取用户
exports.getUserByUid=function(uid,callback){ exports.getUserByUid=function(uid,callback){
ForumUser.findOne({uid:uid}).populate('honorTitles').exec(function(err,result){ ForumUser.findOne({uid:uid}).populate({
path: 'honorTitles',
match: { status: { $ne: 0 }}
}).exec(function(err,result){
if(err){ if(err){
callback(err,null); callback(err,null);
}else{ }else{
...@@ -38,7 +39,10 @@ exports.getUserByUid=function(uid,callback){ ...@@ -38,7 +39,10 @@ exports.getUserByUid=function(uid,callback){
//根据id获取用户 //根据id获取用户
exports.getUserById=function(id,callback){ exports.getUserById=function(id,callback){
ForumUser.findOne({_id:id}).populate('honorTitles').exec(function(err,result){ ForumUser.findOne({_id:id}).populate({
path: 'honorTitles',
match: { status: { $ne: 0 }}
}).exec(function(err,result){
if(err){ if(err){
callback(err,null); callback(err,null);
}else{ }else{
...@@ -70,7 +74,10 @@ exports.searchMembers=function(pageNo, pageSize, q, callback){ ...@@ -70,7 +74,10 @@ exports.searchMembers=function(pageNo, pageSize, q, callback){
}).then(function(cont, count) { }).then(function(cont, count) {
var skip = (pageNo - 1) * pageSize; var skip = (pageNo - 1) * pageSize;
var limit = count - skip > pageSize ? pageSize : (count - skip); var limit = count - skip > pageSize ? pageSize : (count - skip);
ForumUser.find(q).skip(skip).limit(limit).sort('-created').populate('honorTitles').exec(function(err, docs) { ForumUser.find(q).skip(skip).limit(limit).sort('-created').populate({
path: 'honorTitles',
match: { status: { $ne: 0 }}
}).exec(function(err, docs) {
cont(err, count, docs); cont(err, count, docs);
}); });
}).then(function(cont, count, members) { }).then(function(cont, count, members) {
...@@ -98,7 +105,10 @@ exports.searchMembersByNickName=function(nickName, callback){ ...@@ -98,7 +105,10 @@ exports.searchMembersByNickName=function(nickName, callback){
{displayName : { $regex: nickName, $options: 'i' }} {displayName : { $regex: nickName, $options: 'i' }}
] ]
}; };
ForumUser.find(name).populate('honorTitles').exec(function(err,result){ ForumUser.find(name).populate({
path: 'honorTitles',
match: { status: { $ne: 0 }}
}).exec(function(err,result){
if(err){ if(err){
callback(err,null); callback(err,null);
}else{ }else{
...@@ -109,7 +119,10 @@ exports.searchMembersByNickName=function(nickName, callback){ ...@@ -109,7 +119,10 @@ exports.searchMembersByNickName=function(nickName, callback){
//根据mid查询用户 //根据mid查询用户
exports.searchMembersByMid=function(mid, callback){ exports.searchMembersByMid=function(mid, callback){
ForumUser.find({mid:mid}).populate('honorTitles').exec(function(err,result){ ForumUser.find({mid:mid}).populate({
path: 'honorTitles',
match: { status: { $ne: 0 }}
}).exec(function(err,result){
if(err){ if(err){
callback(err,null); callback(err,null);
}else{ }else{
...@@ -125,7 +138,10 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){ ...@@ -125,7 +138,10 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
}).then(function(cont, count) { }).then(function(cont, count) {
var skip = (pageNo - 1) * pageSize; var skip = (pageNo - 1) * pageSize;
var limit = count - skip > pageSize ? pageSize : (count - skip); var limit = count - skip > pageSize ? pageSize : (count - skip);
ForumUser.find(q).skip(skip).limit(limit).sort('-created').populate('honorTitles').exec(function(err, docs) { ForumUser.find(q).skip(skip).limit(limit).sort('-created').populate({
path: 'honorTitles',
match: { status: { $ne: 0 }}
}).exec(function(err, docs) {
cont(err, count, docs); cont(err, count, docs);
}); });
}).then(function(cont, count, members) { }).then(function(cont, count, members) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment