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
075b79ef
Commit
075b79ef
authored
Dec 15, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
ff5b00a8
' into SANDBOX
# Conflicts: # app/service/forumUserService.js
parents
68fa8baa
ff5b00a8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
412 additions
and
8 deletions
+412
-8
forumHonorTitle.js
app/controllers/admin/forumHonorTitle.js
+191
-0
forumMember.js
app/controllers/admin/forumMember.js
+23
-0
forumHonorTitle.js
app/models/forumHonorTitle.js
+40
-0
forumUser.js
app/models/forumUser.js
+4
-0
forumHonorTitleService.js
app/service/forumHonorTitleService.js
+130
-0
forumUserService.js
app/service/forumUserService.js
+24
-8
No files found.
app/controllers/admin/forumHonorTitle.js
0 → 100644
View file @
075b79ef
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumHonorTitle
=
mongoose
.
model
(
'ForumHonorTitle'
);
var
forumHonorTitleService
=
require
(
'../../service/forumHonorTitleService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//新增
router
.
post
(
'/honorTitle/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
forumHonorTitleService
.
create
(
req
.
body
,
function
(
err
,
entity
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
{
'id'
:
entity
.
_id
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//删除
router
.
post
(
'/honorTitle/:id/delete'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
if
(
id
){
forumHonorTitleService
.
deleteById
(
id
,
function
(
err
,
entity
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//更新
router
.
post
(
'/honorTitle/:id/update'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
var
entity
=
req
.
body
;
if
(
id
&&
entity
){
forumHonorTitleService
.
updateById
(
id
,
entity
,
function
(
err
,
entity
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//获取
router
.
get
(
'/honorTitle/:id/get'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
||
null
;
var
rs
=
{};
if
(
id
)
{
forumHonorTitleService
.
getById
(
id
,
function
(
err
,
entity
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
entity
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//直接修改序号
router
.
put
(
'/honorTitle/orderIDX/:id/:order'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
var
idx
=
req
.
params
.
order
;
forumHonorTitleService
.
updateIdx
(
id
,
idx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
return
res
.
json
(
returnCode
.
BUSY
);
}
return
res
.
json
(
_
.
assign
({
data
:
true
},
returnCode
.
SUCCESS
));
});
});
//上移
router
.
put
(
'/honorTitle/moveUP/:id/:order'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
var
idx
=
req
.
params
.
order
;
var
titleName
=
req
.
query
.
titleName
||
''
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
tagName
){
conditions
.
title
=
{
$regex
:
titleName
,
$options
:
'i'
};
}
forumHonorTitleService
.
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
;
}
forumHonorTitleService
.
updateIdx
(
id
,
preidx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
return
res
.
json
(
returnCode
.
BUSY
);
}
forumHonorTitleService
.
updateIdx
(
preObj
.
_id
,
idx
,
function
(
err
,
result
){
if
(
err
||
!
result
){
return
res
.
json
(
returnCode
.
BUSY
);
}
return
res
.
json
(
_
.
assign
({
data
:
true
},
returnCode
.
SUCCESS
));
});
});
});
});
//查询列表
router
.
get
(
'/honorTitle/searchList'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
,
pageSize
=
req
.
query
.
pageSize
||
10
,
titleName
=
req
.
query
.
titleName
||
''
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
titleName
){
conditions
.
title
=
{
$regex
:
titleName
,
$options
:
'i'
};
}
forumHonorTitleService
.
getAll
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
});
//获取状态为启用的
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
));
}
});
});
app/controllers/admin/forumMember.js
View file @
075b79ef
...
...
@@ -65,6 +65,11 @@ router.post('/member/searchMembers', function(req, res, next) {
if
(
search
.
status
)
{
q
.
status
=
search
.
status
;
}
if
(
search
.
honorTitleId
)
{
q
.
honorTitles
=
{
$in
:
[
search
.
honorTitleId
]
};
}
forumUserService
.
searchMembersAndLimitActions
(
pageNo
,
pageSize
,
q
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -136,3 +141,21 @@ router.get('/member/getMidByUid/:uid', function(req, res, next) {
});
}
});
//更新
router
.
post
(
'/member/:mid/update'
,
function
(
req
,
res
,
next
)
{
var
mid
=
req
.
params
.
mid
;
var
entity
=
req
.
body
;
if
(
mid
&&
entity
){
forumUserService
.
updateUserById
(
mid
,
entity
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
\ No newline at end of file
app/models/forumHonorTitle.js
0 → 100644
View file @
075b79ef
'use strict'
;
var
mongoose
=
require
(
'mongoose'
),
Schema
=
mongoose
.
Schema
;
//荣誉头衔
var
ForumHonorTitleSchema
=
new
Schema
({
ent_code
:
{
type
:
Number
,
require
:
true
,
index
:
true
},
title
:
{
//荣誉头衔标题
type
:
String
,
require
:
true
,
},
icon
:
{
//荣誉头衔图片
type
:
String
},
order_idx
:
{
//荣誉头衔排序
type
:
Number
,
require
:
true
,
default
:
0
},
status
:
{
//荣誉头衔状态,1启用,0停用
type
:
Number
,
require
:
true
,
default
:
1
},
created
:
{
type
:
Date
,
required
:
true
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_honor_title'
});
module
.
exports
=
mongoose
.
model
(
'ForumHonorTitle'
,
ForumHonorTitleSchema
);
\ No newline at end of file
app/models/forumUser.js
View file @
075b79ef
...
...
@@ -52,6 +52,10 @@ var ForumUserSchema = new Schema({
require
:
true
,
default
:
1
},
honorTitles
:
[{
//荣誉头衔数组
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumHonorTitle'
}],
created
:
{
type
:
Date
,
required
:
true
,
...
...
app/service/forumHonorTitleService.js
0 → 100644
View file @
075b79ef
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumHonorTitle
=
mongoose
.
model
(
'ForumHonorTitle'
);
//创建
exports
.
create
=
function
(
entity
,
callback
){
var
forum
=
new
ForumHonorTitle
(
entity
);
forum
.
save
(
function
(
err
,
doc
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
doc
);
}
});
};
//根据ID获取
exports
.
getById
=
function
(
tid
,
callback
){
ForumHonorTitle
.
findById
(
tid
,
function
(
err
,
doc
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
doc
);
}
});
};
//根据ID更新
exports
.
updateById
=
function
(
tid
,
entity
,
callback
){
ForumHonorTitle
.
update
({
_id
:
tid
},
entity
,
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//根据ID删除
exports
.
deleteById
=
function
(
tid
,
callback
){
ForumHonorTitle
.
remove
({
_id
:
tid
},
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//获取数量
function
countAll
(
conditions
,
callback
)
{
ForumHonorTitle
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
}
//分页查询
exports
.
getAll
=
function
(
conditions
,
pageNo
,
pageSize
,
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
);
ForumHonorTitle
.
find
(
conditions
,
null
,
{
skip
:
skip
,
limit
:
limit
,
sort
:{
order_idx
:
1
}},
function
(
err
,
docs
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
callback
(
null
,
obj
);
}
});
}
});
};
//获取列表
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
){
ForumHonorTitle
.
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
){
ForumHonorTitle
.
update
(
{
_id
:
id
},
{
order_idx
:
idx
},
null
,
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
true
);
}
});
};
app/service/forumUserService.js
View file @
075b79ef
...
...
@@ -3,8 +3,6 @@ var mongoose = require('mongoose');
var
ForumUser
=
mongoose
.
model
(
'ForumUser'
);
var
then
=
require
(
'thenjs'
);
var
async
=
require
(
'async'
);
// var forumLimitActionRefService = require('../service/forumLimitActionRefService');
// var forumLimitActionConfigService = require('../service/forumLimitActionConfigService');
var
forumLimitOperationService
=
require
(
'../service/forumLimitOperationService'
);
...
...
@@ -23,7 +21,10 @@ exports.createUser=function(entity,callback){
//根据Uid获取用户
exports
.
getUserByUid
=
function
(
uid
,
callback
){
ForumUser
.
findOne
({
uid
:
uid
}).
exec
(
function
(
err
,
result
){
ForumUser
.
findOne
({
uid
:
uid
}).
populate
({
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}}
}).
exec
(
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
...
...
@@ -38,7 +39,10 @@ exports.getUserByUid=function(uid,callback){
//根据id获取用户
exports
.
getUserById
=
function
(
id
,
callback
){
ForumUser
.
findOne
({
_id
:
id
}).
exec
(
function
(
err
,
result
){
ForumUser
.
findOne
({
_id
:
id
}).
populate
({
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}}
}).
exec
(
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
...
...
@@ -70,7 +74,10 @@ exports.searchMembers=function(pageNo, pageSize, q, callback){
}).
then
(
function
(
cont
,
count
)
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumUser
.
find
(
q
).
skip
(
skip
).
limit
(
limit
).
sort
(
'-created'
).
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
);
});
}).
then
(
function
(
cont
,
count
,
members
)
{
...
...
@@ -98,7 +105,10 @@ exports.searchMembersByNickName=function(nickName, callback){
{
displayName
:
{
$regex
:
nickName
,
$options
:
'i'
}}
]
};
ForumUser
.
find
(
name
).
exec
(
function
(
err
,
result
){
ForumUser
.
find
(
name
).
populate
({
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}}
}).
exec
(
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
...
...
@@ -109,7 +119,10 @@ exports.searchMembersByNickName=function(nickName, callback){
//根据mid查询用户
exports
.
searchMembersByMid
=
function
(
mid
,
callback
){
ForumUser
.
find
({
mid
:
mid
}).
exec
(
function
(
err
,
result
){
ForumUser
.
find
({
mid
:
mid
}).
populate
({
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}}
}).
exec
(
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
...
...
@@ -125,7 +138,10 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
}).
then
(
function
(
cont
,
count
)
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumUser
.
find
(
q
).
skip
(
skip
).
limit
(
limit
).
sort
(
'-created'
).
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
);
});
}).
then
(
function
(
cont
,
count
,
members
)
{
...
...
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