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
8efcbaec
Commit
8efcbaec
authored
Jan 08, 2016
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
b30b1406
'
# Conflicts: # app/models/forumThread.js
parents
2741cdb0
b30b1406
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
681 additions
and
214 deletions
+681
-214
forumMember.js
app/controllers/admin/forumMember.js
+27
-0
forumUser.js
app/controllers/mobile/forumUser.js
+346
-56
forumInfo.js
app/models/forumInfo.js
+4
-0
forumThread.js
app/models/forumThread.js
+4
-0
forumUser.js
app/models/forumUser.js
+16
-0
forumInfoService.js
app/service/forumInfoService.js
+12
-0
forumThreadService.js
app/service/forumThreadService.js
+12
-0
forumUserService.js
app/service/forumUserService.js
+260
-158
No files found.
app/controllers/admin/forumMember.js
View file @
8efcbaec
...
@@ -159,3 +159,30 @@ router.post('/member/:mid/update', function(req, res, next) {
...
@@ -159,3 +159,30 @@ router.post('/member/:mid/update', function(req, res, next) {
res
.
json
(
returnCode
.
WRONG_PARAM
);
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
}
});
});
//获取用户收藏记录
router
.
get
(
'/member/:uid/favors'
,
function
(
req
,
res
,
next
)
{
var
uid
=
req
.
params
.
uid
||
null
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
uid
)
{
var
condition
=
{
_id
:
uid
,
ent_code
:
ent_code
}
forumUserService
.
getFavors
(
condition
,
function
(
err
,
result
){
if
(
err
){
console
.
log
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{
data
:
result
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
console
.
error
(
'params error'
);
res
.
json
({
result
:
false
,
err
:
'params error'
});
}
});
\ No newline at end of file
app/controllers/mobile/forumUser.js
View file @
8efcbaec
This diff is collapsed.
Click to expand it.
app/models/forumInfo.js
View file @
8efcbaec
...
@@ -50,6 +50,10 @@ var ForumInfoSchema = new Schema({
...
@@ -50,6 +50,10 @@ var ForumInfoSchema = new Schema({
type
:
Object
,
type
:
Object
,
default
:{}
default
:{}
},
},
favor_by
:
[{
//被收藏用户列表
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumUser'
}],
created
:
{
created
:
{
type
:
Date
,
type
:
Date
,
required
:
true
,
required
:
true
,
...
...
app/models/forumThread.js
View file @
8efcbaec
...
@@ -126,6 +126,10 @@ var ForumThreadSchema = new Schema({
...
@@ -126,6 +126,10 @@ var ForumThreadSchema = new Schema({
new_recommend_time
:{
//推荐时间
new_recommend_time
:{
//推荐时间
type
:
Date
type
:
Date
},
},
favor_by
:
[{
//被收藏用户列表
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumUser'
}],
created
:
{
created
:
{
type
:
Date
,
type
:
Date
,
required
:
true
,
required
:
true
,
...
...
app/models/forumUser.js
View file @
8efcbaec
...
@@ -56,6 +56,22 @@ var ForumUserSchema = new Schema({
...
@@ -56,6 +56,22 @@ var ForumUserSchema = new Schema({
type
:
Schema
.
Types
.
ObjectId
,
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumHonorTitle'
ref
:
'ForumHonorTitle'
}],
}],
favor_by
:
[{
//被收藏用户列表
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumUser'
}],
favor_users
:
[{
//收藏用户列表
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumUser'
}],
favor_infos
:
[{
//收藏板块列表
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumInfo'
}],
favor_threads
:
[{
//收藏文章列表
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumThread'
}],
created
:
{
created
:
{
type
:
Date
,
type
:
Date
,
required
:
true
,
required
:
true
,
...
...
app/service/forumInfoService.js
View file @
8efcbaec
...
@@ -39,6 +39,18 @@ exports.updateInfoById=function(fid,entity,callback){
...
@@ -39,6 +39,18 @@ exports.updateInfoById=function(fid,entity,callback){
});
});
};
};
//根据ID更新论坛板块2
exports
.
updateByIdWithOptions
=
function
(
condition
,
entity
,
options
,
callback
){
ForumInfo
.
findOneAndUpdate
(
condition
,
entity
,
options
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//根据ID更新论坛组
//根据ID更新论坛组
exports
.
deleteInfoById
=
function
(
fid
,
callback
){
exports
.
deleteInfoById
=
function
(
fid
,
callback
){
ForumInfo
.
remove
({
_id
:
fid
},
function
(
err
,
result
){
ForumInfo
.
remove
({
_id
:
fid
},
function
(
err
,
result
){
...
...
app/service/forumThreadService.js
View file @
8efcbaec
...
@@ -1242,3 +1242,15 @@ exports.updateThread = function(condition, entity, callback) {
...
@@ -1242,3 +1242,15 @@ exports.updateThread = function(condition, entity, callback) {
}
}
});
});
};
};
//根据ID更新文章2
exports
.
updateByIdWithOptions
=
function
(
condition
,
entity
,
options
,
callback
)
{
ForumThread
.
findOneAndUpdate
(
condition
,
entity
,
options
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
\ No newline at end of file
app/service/forumUserService.js
View file @
8efcbaec
...
@@ -7,70 +7,104 @@ var async = require('async');
...
@@ -7,70 +7,104 @@ var async = require('async');
var
forumLimitOperationService
=
require
(
'../service/forumLimitOperationService'
);
var
forumLimitOperationService
=
require
(
'../service/forumLimitOperationService'
);
//创建用户
//创建用户
exports
.
createUser
=
function
(
entity
,
callback
)
{
exports
.
createUser
=
function
(
entity
,
callback
)
{
var
forum
=
new
ForumUser
(
entity
);
var
forum
=
new
ForumUser
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
callback
(
null
,
forum
);
callback
(
null
,
forum
);
}
}
});
});
};
};
//根据Uid获取用户
//根据Uid获取用户
exports
.
getUserByUid
=
function
(
uid
,
callback
){
exports
.
getUserByUid
=
function
(
uid
,
callback
)
{
ForumUser
.
findOne
({
uid
:
uid
}).
populate
({
ForumUser
.
findOne
({
uid
:
uid
}).
populate
({
path
:
'honorTitles'
,
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}},
match
:
{
options
:
{
sort
:{
order_idx
:
-
1
}
}
status
:
{
}).
exec
(
function
(
err
,
result
){
$ne
:
0
if
(
err
){
}
callback
(
err
,
null
);
},
}
else
{
options
:
{
if
(
result
){
sort
:
{
callback
(
null
,
result
);
order_idx
:
-
1
}
else
{
}
callback
(
null
,
null
);
}
}).
exec
(
function
(
err
,
result
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
if
(
result
)
{
callback
(
null
,
result
);
}
else
{
callback
(
null
,
null
);
}
}
}
}
});
});
};
};
//根据id获取用户
//根据id获取用户
exports
.
getUserById
=
function
(
id
,
callback
){
exports
.
getUserById
=
function
(
id
,
callback
)
{
ForumUser
.
findOne
({
_id
:
id
}).
populate
({
ForumUser
.
findOne
({
_id
:
id
}).
populate
({
path
:
'honorTitles'
,
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}},
match
:
{
options
:
{
sort
:{
order_idx
:
-
1
}
}
status
:
{
}).
exec
(
function
(
err
,
result
){
$ne
:
0
if
(
err
){
}
callback
(
err
,
null
);
},
}
else
{
options
:
{
if
(
result
){
sort
:
{
callback
(
null
,
result
);
order_idx
:
-
1
}
else
{
}
callback
(
null
,
null
);
}
}).
exec
(
function
(
err
,
result
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
if
(
result
)
{
callback
(
null
,
result
);
}
else
{
callback
(
null
,
null
);
}
}
}
}
});
});
};
};
//根据ID更新用户信息
//根据ID更新用户信息
exports
.
updateUserById
=
function
(
uid
,
entity
,
callback
){
exports
.
updateUserById
=
function
(
uid
,
entity
,
callback
)
{
ForumUser
.
update
({
_id
:
uid
},
entity
,
null
,
function
(
err
,
result
){
ForumUser
.
update
({
_id
:
uid
},
entity
,
null
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//根据ID更新用户信息2
exports
.
updateByIdWithOptions
=
function
(
condition
,
entity
,
options
,
callback
)
{
ForumUser
.
findOneAndUpdate
(
condition
,
entity
,
options
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
callback
(
null
,
null
);
callback
(
null
,
result
.
_id
);
}
}
});
});
};
};
//查询用户信息
//查询用户信息
exports
.
searchMembers
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
exports
.
searchMembers
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
then
(
function
(
cont
)
{
then
(
function
(
cont
)
{
ForumUser
.
find
(
q
).
count
(
cont
);
ForumUser
.
find
(
q
).
count
(
cont
);
}).
then
(
function
(
cont
,
count
)
{
}).
then
(
function
(
cont
,
count
)
{
...
@@ -78,8 +112,16 @@ exports.searchMembers=function(pageNo, pageSize, q, callback){
...
@@ -78,8 +112,16 @@ exports.searchMembers=function(pageNo, pageSize, q, callback){
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
({
ForumUser
.
find
(
q
).
skip
(
skip
).
limit
(
limit
).
sort
(
'-created'
).
populate
({
path
:
'honorTitles'
,
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}},
match
:
{
options
:
{
sort
:{
order_idx
:
-
1
}
}
status
:
{
$ne
:
0
}
},
options
:
{
sort
:
{
order_idx
:
-
1
}
}
}).
exec
(
function
(
err
,
docs
)
{
}).
exec
(
function
(
err
,
docs
)
{
cont
(
err
,
count
,
docs
);
cont
(
err
,
count
,
docs
);
});
});
...
@@ -101,43 +143,68 @@ exports.searchMembers=function(pageNo, pageSize, q, callback){
...
@@ -101,43 +143,68 @@ exports.searchMembers=function(pageNo, pageSize, q, callback){
};
};
//根据nickName查询用户
//根据nickName查询用户
exports
.
searchMembersByNickName
=
function
(
nickName
,
callback
)
{
exports
.
searchMembersByNickName
=
function
(
nickName
,
callback
)
{
var
name
=
{
var
name
=
{
$or
:
[
$or
:
[{
{
nickName
:
{
$regex
:
nickName
,
$options
:
'i'
}},
nickName
:
{
{
displayName
:
{
$regex
:
nickName
,
$options
:
'i'
}}
$regex
:
nickName
,
]
$options
:
'i'
}
},
{
displayName
:
{
$regex
:
nickName
,
$options
:
'i'
}
}]
};
};
ForumUser
.
find
(
name
).
populate
({
ForumUser
.
find
(
name
).
populate
({
path
:
'honorTitles'
,
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}},
match
:
{
options
:
{
sort
:{
order_idx
:
-
1
}
}
status
:
{
}).
exec
(
function
(
err
,
result
){
$ne
:
0
if
(
err
){
}
callback
(
err
,
null
);
},
}
else
{
options
:
{
callback
(
null
,
result
);
sort
:
{
order_idx
:
-
1
}
}
}).
exec
(
function
(
err
,
result
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
result
);
}
}
});
});
};
};
//根据mid查询用户
//根据mid查询用户
exports
.
searchMembersByMid
=
function
(
mid
,
callback
){
exports
.
searchMembersByMid
=
function
(
mid
,
callback
)
{
ForumUser
.
find
({
mid
:
mid
}).
populate
({
ForumUser
.
find
({
mid
:
mid
}).
populate
({
path
:
'honorTitles'
,
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}},
match
:
{
options
:
{
sort
:{
order_idx
:
-
1
}
}
status
:
{
}).
exec
(
function
(
err
,
result
){
$ne
:
0
if
(
err
){
}
callback
(
err
,
null
);
},
}
else
{
options
:
{
callback
(
null
,
result
);
sort
:
{
order_idx
:
-
1
}
}
}).
exec
(
function
(
err
,
result
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
result
);
}
}
});
});
};
};
//查询用户和行为限制信息
//查询用户和行为限制信息
exports
.
searchMembersAndLimitActions
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
exports
.
searchMembersAndLimitActions
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
then
(
function
(
cont
)
{
then
(
function
(
cont
)
{
ForumUser
.
find
(
q
).
count
(
cont
);
ForumUser
.
find
(
q
).
count
(
cont
);
}).
then
(
function
(
cont
,
count
)
{
}).
then
(
function
(
cont
,
count
)
{
...
@@ -145,8 +212,16 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
...
@@ -145,8 +212,16 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
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
({
ForumUser
.
find
(
q
).
skip
(
skip
).
limit
(
limit
).
sort
(
'-created'
).
populate
({
path
:
'honorTitles'
,
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}},
match
:
{
options
:
{
sort
:{
order_idx
:
-
1
}
}
status
:
{
$ne
:
0
}
},
options
:
{
sort
:
{
order_idx
:
-
1
}
}
}).
exec
(
function
(
err
,
docs
)
{
}).
exec
(
function
(
err
,
docs
)
{
cont
(
err
,
count
,
docs
);
cont
(
err
,
count
,
docs
);
});
});
...
@@ -160,14 +235,13 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
...
@@ -160,14 +235,13 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
null
,
null
);
callback
(
null
,
null
);
}
else
{
}
else
{
if
(
forumLimitOperation
)
{
if
(
forumLimitOperation
)
{
var
limit_actions
=
forumLimitOperation
.
limit_actions
;
var
limit_actions
=
forumLimitOperation
.
limit_actions
;
var
array
=
[];
var
array
=
[];
for
(
var
i
=
0
;
i
<
limit_actions
.
length
;
i
+=
1
)
{
for
(
var
i
=
0
;
i
<
limit_actions
.
length
;
i
+=
1
)
{
var
limit_action
=
limit_actions
[
i
];
var
limit_action
=
limit_actions
[
i
];
var
name
=
''
;
var
name
=
''
;
switch
(
limit_action
.
limit_type
)
switch
(
limit_action
.
limit_type
)
{
{
case
1
:
case
1
:
name
=
'禁言'
;
name
=
'禁言'
;
break
;
break
;
...
@@ -180,7 +254,7 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
...
@@ -180,7 +254,7 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
member
=
member
.
toObject
();
member
=
member
.
toObject
();
member
.
limitActions
=
array
;
member
.
limitActions
=
array
;
callback
(
null
,
member
);
callback
(
null
,
member
);
}
else
{
}
else
{
callback
(
null
,
member
);
callback
(
null
,
member
);
}
}
}
}
...
@@ -221,13 +295,41 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
...
@@ -221,13 +295,41 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
//根据UID和entCode更新用户信息
//根据UID和entCode更新用户信息
exports
.
updateUserByUIdAndEntCode
=
function
(
condition
,
entity
,
callback
)
{
exports
.
updateUserByUIdAndEntCode
=
function
(
condition
,
entity
,
callback
)
{
ForumUser
.
update
(
condition
,
entity
,
null
,
function
(
err
,
result
)
{
ForumUser
.
update
(
condition
,
entity
,
null
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//查询用户收藏记录
exports
.
getFavors
=
function
(
condition
,
callback
)
{
ForumUser
.
findOne
(
condition
).
populate
({
path
:
'favor_by'
,
select
:
'_id nickName displayName'
}).
populate
({
path
:
'favor_users'
,
select
:
'_id nickName displayName'
}).
populate
({
path
:
'favor_infos'
,
select
:
'_id name'
,
options
:
{
sort
:
{
created
:
-
1
}}
}).
populate
({
path
:
'favor_threads'
,
select
:
'_id title info from created status type'
,
options
:
{
sort
:
{
created
:
-
1
},
populate
:
"info from"
//继续查文章里面的板块信息
}
}).
exec
(
function
(
err
,
result
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
}
else
{
callback
(
null
,
null
);
callback
(
null
,
result
);
}
}
});
});
};
};
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