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
9c7bab2a
Commit
9c7bab2a
authored
Mar 16, 2015
by
张淼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a37e04de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
10 deletions
+150
-10
forumInfo.js
app/controllers/mobile/forumInfo.js
+36
-8
forumThread.js
app/controllers/mobile/forumThread.js
+48
-2
forumUserThreadControl.js
app/models/forumUserThreadControl.js
+29
-0
forumUserThreadControlService.js
app/service/forumUserThreadControlService.js
+37
-0
No files found.
app/controllers/mobile/forumInfo.js
View file @
9c7bab2a
...
...
@@ -8,6 +8,9 @@ var mongoose = require('mongoose');
var
ForumInfo
=
mongoose
.
model
(
'ForumInfo'
);
var
forumInfoService
=
require
(
'../../service/forumInfoService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
forumUserThreadControlService
=
require
(
'../../service/forumUserThreadControlService'
);
var
user
=
require
(
'../../utils/user'
);
var
async
=
require
(
'async'
);
...
...
@@ -133,14 +136,39 @@ router.get('/info/:fid/threads', function(req, res, next) {
conditions
.
info
=
fid
;
}
if
(
fid
){
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
async
.
waterfall
([
function
(
callback
){
forumUserThreadControlService
.
getUserThreadControlById
(
user
.
getMobileUser
(),
function
(
err
,
doc
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
if
(
doc
){
callback
(
null
,
doc
);
}
else
{
callback
(
null
,
null
);
}
}
});
}
],
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
result
){
conditions
.
_id
=
{
$nin
:
result
.
thread
};
}
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
...
...
app/controllers/mobile/forumThread.js
View file @
9c7bab2a
...
...
@@ -10,6 +10,7 @@ var forumRolePermissionService=require('../../service/forumRolePermissionService
var
forumPraiseLogService
=
require
(
'../../service/forumPraiseLogService'
);
var
forumShareLogService
=
require
(
'../../service/forumShareLogService'
);
var
forumCommentService
=
require
(
'../../service/forumCommentService'
);
var
forumUserThreadControlService
=
require
(
'../../service/forumUserThreadControlService'
);
var
user
=
require
(
'../../utils/user'
);
var
async
=
require
(
'async'
);
...
...
@@ -454,8 +455,6 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
//删除文章评论
router
.
post
(
'/thread/:tid/comment/:cid/delete'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.检查是否有权限
//2.获取论坛文章
...
...
@@ -487,4 +486,51 @@ router.post('/thread/:tid/comment/:cid/:status', function(req, res, next) {
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//用户屏蔽文章
router
.
post
(
'/thread/:tid/userShield'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
if
(
tid
){
forumUserThreadControlService
.
getUserThreadControlById
(
user
.
getMobileUser
(),
function
(
err
,
doc
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
doc
){
var
thread
=
doc
.
thread
;
thread
.
push
(
tid
);
forumUserThreadControlService
.
updateUserThreadControlById
(
user
.
getMobileUser
(),{
thread
:
thread
},
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
var
array
=
[
tid
];
var
entity
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
user
:
user
.
getMobileUser
(),
thread
:
array
};
forumUserThreadControlService
.
createUserThreadControl
(
entity
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
//1.检查是否有权限
//2.获取论坛文章
//3.新增文章评论
//4.更新文章统计数据(评论数)
});
\ No newline at end of file
app/models/forumUserThreadControl.js
0 → 100644
View file @
9c7bab2a
'use strict'
;
var
mongoose
=
require
(
'mongoose'
),
Schema
=
mongoose
.
Schema
;
//用户文章访问控制(各用户看到的文章列表控制)
var
ForumUserThreadCotrolSchema
=
new
Schema
({
ent_code
:
{
type
:
Number
,
require
:
true
,
index
:
true
},
user
:
{
//用户
type
:
String
,
require
:
true
,
},
thread
:
{
//文章集合
type
:
Array
},
created
:
{
type
:
Date
,
required
:
true
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_user_thread_control'
});
module
.
exports
=
mongoose
.
model
(
'ForumUserThreadCotrol'
,
ForumUserThreadCotrolSchema
);
\ No newline at end of file
app/service/forumUserThreadControlService.js
0 → 100644
View file @
9c7bab2a
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumUserThreadCotrol
=
mongoose
.
model
(
'ForumUserThreadCotrol'
);
exports
.
createUserThreadControl
=
function
(
entity
,
callback
){
var
forum
=
new
ForumUserThreadCotrol
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
exports
.
getUserThreadControlById
=
function
(
uid
,
callback
){
ForumUserThreadCotrol
.
find
({
user
:
uid
}).
exec
(
function
(
err
,
docs
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
docs
[
0
]);
}
});
};
exports
.
updateUserThreadControlById
=
function
(
uid
,
entity
,
callback
){
ForumUserThreadCotrol
.
update
({
_id
:
uid
},
entity
,
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
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