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
8c76be41
Commit
8c76be41
authored
Jan 30, 2015
by
张淼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
2e3739d7
Changes
29
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
1460 additions
and
341 deletions
+1460
-341
forumFavorite.js
app/controllers/admin/forumFavorite.js
+49
-0
forumGroup.js
app/controllers/admin/forumGroup.js
+77
-0
forumInfo.js
app/controllers/admin/forumInfo.js
+107
-0
forumRole.js
app/controllers/admin/forumRole.js
+83
-0
forumRolePermission.js
app/controllers/admin/forumRolePermission.js
+48
-0
forumTag.js
app/controllers/admin/forumTag.js
+135
-0
forumThread.js
app/controllers/admin/forumThread.js
+435
-0
forumRole.js
app/controllers/forumRole.js
+0
-29
forumRolePermission.js
app/controllers/forumRolePermission.js
+0
-24
forumTag.js
app/controllers/forumTag.js
+0
-35
forumThread.js
app/controllers/forumThread.js
+0
-183
forumFavorite.js
app/models/forumFavorite.js
+1
-1
forumRolePermission.js
app/models/forumRolePermission.js
+3
-3
forumThread.js
app/models/forumThread.js
+4
-4
forumCommentService.js
app/service/forumCommentService.js
+40
-0
forumFavoriteService.js
app/service/forumFavoriteService.js
+30
-0
forumGroupService.js
app/service/forumGroupService.js
+52
-0
forumInfoService.js
app/service/forumInfoService.js
+90
-0
forumPraiseLogService.js
app/service/forumPraiseLogService.js
+16
-0
forumRolePermissionService.js
app/service/forumRolePermissionService.js
+129
-0
forumService.js
app/service/forumService.js
+0
-12
forumShareLogService.js
app/service/forumShareLogService.js
+16
-0
forumThreadService.js
app/service/forumThreadService.js
+90
-0
intergal.js
app/service/intergal.js
+0
-6
rolePermission.js
app/service/rolePermission.js
+0
-22
returnCode.js
app/utils/returnCode.js
+4
-0
config.js
config/config.js
+3
-5
express.js
config/express.js
+46
-16
package.json
package.json
+2
-1
No files found.
app/controllers/forumFavorite.js
→
app/controllers/
admin/
forumFavorite.js
View file @
8c76be41
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../utils/returnCode'
),
returnCode
=
require
(
'../
../
utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
forumFavoriteService
=
require
(
'../../service/forumFavoriteService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/forum'
,
router
);
};
//文章收藏
router
.
post
(
'/favorite/create'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.检查是否有权限
//2.校验是否已收藏
//3.新增用户收藏
/**
返回数据:
{
errorcode:0,
errormsg:''
}
**/
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
forumFavoriteService
.
createFavorite
(
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
(
'/favorite/:fid/delete'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.删除用户收藏
/**
返回数据:
{
errorcode:0,
errormsg:''
var
fid
=
req
.
params
.
fid
;
if
(
fid
){
forumFavoriteService
.
deleteFavoriteById
(
fid
,
function
(
err
,
thread
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
**/
});
//更新收藏
router
.
post
(
'/favorite/:fid/update'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.删除用户收藏
/**
返回数据:
{
errorcode:0,
errormsg:''
}
**/
});
//获取当前用户的收藏列表
...
...
@@ -58,7 +47,3 @@ router.get('/favorite/list', function(req, res, next) {
console
.
log
(
''
);
});
//多条件搜索收藏列表
router
.
post
(
'/favorite/search'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
app/controllers/forumGroup.js
→
app/controllers/
admin/
forumGroup.js
View file @
8c76be41
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../utils/returnCode'
),
returnCode
=
require
(
'../
../
utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumGroup
=
mongoose
.
model
(
'ForumGroup'
);
var
ForumInfo
=
mongoose
.
model
(
'ForumInfo'
);
var
forumGroupService
=
require
(
'../../service/forumGroupService'
);
var
forumInfoService
=
require
(
'../../service/forumInfoService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/forum'
,
router
);
app
.
use
(
'/
admin/
forum'
,
router
);
};
//新增论坛组
router
.
post
(
'/group/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
var
group
=
new
mongodb
.
ForumGroup
(
req
.
body
)
;
group
.
save
(
function
(
err
,
group
)
{
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
forumGroupService
.
createGroup
(
req
.
body
,
function
(
err
,
group
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
group
;
rs
.
data
=
{
'id'
:
group
.
_id
}
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//获取目标论坛组信息
router
.
get
(
'/group/
info/:gid
'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/group/
:gid/info
'
,
function
(
req
,
res
,
next
)
{
var
gid
=
req
.
params
.
gid
||
null
;
var
rs
=
{};
if
(
gid
)
{
mongodb
.
ForumGroup
.
findById
(
gid
,
function
(
err
,
group
)
{
forumGroupService
.
getGroupById
(
gid
,
function
(
err
,
group
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -37,29 +44,34 @@ router.get('/group/info/:gid', function(req, res, next) {
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
/**
*
[description]
* @param {[type]}
* @param {[type]}
* @param {
Object}
* @return {[type]}
*
获取板块列表
* @param {[type]}
req [description]
* @param {[type]}
res [description]
* @param {
[type]} next) { var pageNo [description]
* @return {[type]}
[description]
*/
router
.
get
(
'/group/:gid/forumInfos'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
var
group
=
new
mongodb
.
ForumGroup
(
req
.
body
);
group
.
save
(
function
(
err
,
group
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
group
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
gid
=
req
.
params
.
gid
;
if
(
gid
){
forumInfoService
.
getAll
(
req
.
session
.
user
.
ent_code
,
gid
,
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
);
}
});
\ No newline at end of file
app/controllers/forumInfo.js
→
app/controllers/
admin/
forumInfo.js
View file @
8c76be41
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../utils/returnCode'
),
returnCode
=
require
(
'../
../
utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumInfo
=
mongoose
.
model
(
'ForumInfo'
);
var
forumInfoService
=
require
(
'../../service/forumInfoService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/
v1
/forum'
,
router
);
app
.
use
(
'/
admin
/forum'
,
router
);
};
//新增论坛板块
router
.
post
(
'/info/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
var
forum
=
new
mongodb
.
ForumInfo
(
req
.
body
)
;
forum
.
save
(
function
(
err
,
forum
)
{
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
forum
InfoService
.
createInfo
(
req
.
body
,
function
(
err
,
info
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
forum
;
rs
.
data
=
{
'id'
:
info
.
_id
}
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
service
.
create
(
req
.
query
,
req
);
then
(
function
(
defer
){
});
});
//获取目标论坛板块
router
.
get
(
'/info/
get/:fid
'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/info/
:fid/get
'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
||
null
;
var
rs
=
{};
if
(
fid
)
{
mongodb
.
ForumInfo
.
findById
(
fid
,
function
(
err
,
forum
)
{
forumInfoService
.
getInfoById
(
fid
,
function
(
err
,
info
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
group
;
rs
.
data
=
info
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
...
...
@@ -47,13 +49,35 @@ router.get('/info/get/:fid', function(req, res, next) {
});
//更新目标论坛板块
router
.
get
(
'/info/update/:fid'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
router
.
post
(
'/info/:fid/update'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
;
if
(
fid
){
forumInfoService
.
updateInfoById
(
fid
,
req
.
body
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//删除目标论坛板块
router
.
get
(
'/info/delete/:fid'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
router
.
post
(
'/info/:fid/delete'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
;
if
(
fid
){
forumInfoService
.
deleteInfoById
(
fid
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
/**
...
...
@@ -64,28 +88,20 @@ router.get('/info/delete/:fid', function(req, res, next) {
* @return {[type]}
*/
router
.
get
(
'/info/:fid/threads'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
/**
获取目标论坛文章列表及标签列表
输入:文章板块ID
**/
router
.
get
(
'/thread/getAllThreadAndTag/:infoId'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
//1.获取论坛文章
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
fid
=
req
.
params
.
fid
;
//2.获取标签列表
/**返回数据格式:
{
errorcode:0,
errormsg:'xxxxx',
"threads":[{文章对象},{文章对象}],
"tags":[{标签对象},{标签对象}]
if
(
fid
){
forumThreadService
.
getAll
(
req
.
session
.
user
.
ent_code
,
fid
,
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/admin/forumRole.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumRole
=
mongoose
.
model
(
'ForumRole'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//新增论坛角色
router
.
post
(
'/role/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
var
forum
=
new
ForumRole
(
req
.
body
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
forum
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//删除论坛角色
router
.
post
(
'/role/:rid/delete'
,
function
(
req
,
res
,
next
)
{
var
rid
=
req
.
params
.
rid
;
ForumRole
.
remove
({
_id
:
rid
},
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
});
//更新论坛角色
router
.
post
(
'/role/:rid/update'
,
function
(
req
,
res
,
next
)
{
var
rid
=
req
.
params
.
rid
;
ForumRole
.
update
({
_id
:
rid
},
req
.
body
,
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
});
//获取角色列表
router
.
get
(
'/role/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
rs
=
{};
ForumRole
.
count
({
ent_code
:
req
.
session
.
user
.
ent_code
,
status
:
1
},
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumRole
.
find
({
ent_code
:
req
.
session
.
user
.
ent_code
,
status
:
1
},
null
,
{
skip
:
skip
,
limit
:
limit
},
function
(
err
,
docs
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
total
=
count
;
rs
.
pageNo
=
pageNo
;
rs
.
pageSize
=
pageSize
;
rs
.
items
=
docs
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
});
});
app/controllers/admin/forumRolePermission.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumRolePermission
=
mongoose
.
model
(
'ForumRolePermission'
);
var
forumRolePermissionService
=
require
(
'../../service/forumRolePermissionService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//新增角色权限
router
.
post
(
'/rolePermiss/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
var
form
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
var
group
=
new
ForumRolePermission
(
_
.
assign
(
form
,
req
.
body
));
group
.
save
(
function
(
err
,
group
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
{
'id'
:
group
.
_id
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//获取角色权限列表
router
.
get
(
'/rolePermiss/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
forumRolePermissionService
.
getAllRolePermission
(
req
.
session
.
user
.
ent_code
,
pageNo
,
pageSize
,
function
(
err
,
docs
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
docs
,
returnCode
.
SUCCESS
));
}
});
});
app/controllers/admin/forumTag.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumTag
=
mongoose
.
model
(
'ForumTag'
);
var
ForumThread
=
mongoose
.
model
(
'ForumThread'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//新增论坛标签
router
.
post
(
'/tag/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
var
forum
=
new
ForumTag
(
req
.
body
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
{
'id'
:
forum
.
_id
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//删除论坛标签
router
.
post
(
'/tag/:tid/delete'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
ForumTag
.
remove
({
_id
:
tid
},
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
});
//更新论坛标签
router
.
post
(
'/tag/:tid/update'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
ForumTag
.
update
({
_id
:
tid
},
req
.
body
,
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
});
//获取论坛标签
router
.
get
(
'/tag/:tid/get'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
rs
=
{};
if
(
fid
)
{
ForumTag
.
findById
(
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
thread
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//查询所有标签
router
.
get
(
'/tag/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
rs
=
{};
var
group
=
new
ForumGroup
(
req
.
body
);
ForumTag
.
count
({
ent_code
:
req
.
session
.
user
.
ent_code
},
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumTag
.
find
({
ent_code
:
req
.
session
.
user
.
ent_code
},
null
,
{
skip
:
skip
,
limit
:
limit
},
function
(
err
,
docs
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
total
=
count
;
rs
.
pageNo
=
pageNo
;
rs
.
pageSize
=
pageSize
;
rs
.
items
=
docs
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
});
});
//查询标签下的文章列表
router
.
get
(
'/tag/:tid/threads'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
tid
=
req
.
params
.
tid
;
var
rs
=
{};
var
group
=
new
ForumGroup
(
req
.
body
);
ForumThread
.
count
({
ent_code
:
req
.
session
.
user
.
ent_code
,
tag
:
tid
},
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumThread
.
find
({
ent_code
:
req
.
session
.
user
.
ent_code
,
tag
:
tid
},
null
,
{
skip
:
skip
,
limit
:
limit
},
function
(
err
,
docs
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
total
=
count
;
rs
.
pageNo
=
pageNo
;
rs
.
pageSize
=
pageSize
;
rs
.
items
=
docs
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
});
});
\ No newline at end of file
app/controllers/admin/forumThread.js
0 → 100644
View file @
8c76be41
This diff is collapsed.
Click to expand it.
app/controllers/forumRole.js
deleted
100644 → 0
View file @
2e3739d7
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../utils/returnCode'
),
_
=
require
(
'lodash'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/forum'
,
router
);
};
//新增论坛角色
router
.
post
(
'/role/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
var
forum
=
new
mongodb
.
ForumRole
(
req
.
body
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
forum
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//获取角色列表
router
.
get
(
'/role/getAll'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
app/controllers/forumRolePermission.js
deleted
100644 → 0
View file @
2e3739d7
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../utils/returnCode'
),
_
=
require
(
'lodash'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/forum'
,
router
);
};
//新增角色权限
router
.
post
(
'/rolePermiss/create'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
//获取角色权限列表
router
.
get
(
'/rolePermiss/getAll'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
//获取当前用户的操作权限
router
.
get
(
'/rolePermiss/getUserPermission'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
app/controllers/forumTag.js
deleted
100644 → 0
View file @
2e3739d7
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../utils/returnCode'
),
_
=
require
(
'lodash'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
//新增论坛标签
router
.
post
(
'/tag/create'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
router
.
post
(
'/tag/delete/:tid'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
router
.
post
(
'/tag/update/:tid'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
router
.
get
(
'/tag/get/:tid'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
//查询所有标签
router
.
get
(
'/tag/list'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
//查询标签下的文章列表
router
.
get
(
'/tag/:tid/threads'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
\ No newline at end of file
app/controllers/forumThread.js
deleted
100644 → 0
View file @
2e3739d7
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../utils/returnCode'
),
_
=
require
(
'lodash'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
//---------------------文章表单操作---------------------------------
//新增论坛文章
router
.
post
(
'/thread/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
var
forum
=
new
mongodb
.
ForumThread
(
req
.
body
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
forum
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//获取目标论坛文章
router
.
get
(
'/thread/:tid/get'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
//1.获取论坛文章
});
//更新文章状态、如:屏蔽
router
.
post
(
'/thread/:tid/update'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
''
);
});
//删除文章
router
.
post
(
'/thread/:tid/delete'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
var
forum
=
new
mongodb
.
ForumThread
(
req
.
body
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
forum
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//更新文章点赞
router
.
post
(
'/thread/:tid/raise'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.检查是否有权限
//2.获取论坛文章
//3.更新文章统计数据(点赞数)
//4.创建点赞日志
/**
返回数据:
{
errorcode:0,
errormsg:''
}
**/
});
//更新文章分享
router
.
post
(
'/thread/:tid/share'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.检查是否有权限
//2.获取论坛文章
//3.更新文章统计数据(分享数)
//4.创建分享日志
/**
返回数据:
{
errorcode:0,
errormsg:''
}
**/
});
//新增文章评论
/**
**输入:
tid:文章id
pId:评论父id
comment:评论内容
**输出:
操作结果
**/
router
.
post
(
'/thread/:tid/comment/create'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.检查是否有权限
//2.获取论坛文章
//3.新增文章评论
//4.更新文章统计数据(评论数)
/**
返回数据:
{
errorcode:0,
errormsg:''
}
**/
});
//新建文章评论的子评论
router
.
post
(
'/thread/:tid/comment/:cid/create'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.检查是否有权限
//2.获取论坛文章
//3.新增文章评论
//4.更新文章统计数据(评论数)
/**
返回数据:
{
errorcode:0,
errormsg:''
}
**/
});
//删除文章评论
router
.
post
(
'/thread/:tid/comment/:cid/delete'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.检查是否有权限
//2.获取论坛文章
//3.新增文章评论
//4.更新文章统计数据(评论数)
/**
返回数据:
{
errorcode:0,
errormsg:''
}
**/
});
//更新文章评论状态为:显示/不显示
router
.
post
(
'/thread/:tid/comment/:cid/:status'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
console
.
log
(
tid
);
//1.检查是否有权限
//2.获取论坛文章
//3.新增文章评论
//4.更新文章统计数据(评论数)
/**
返回数据:
{
errorcode:0,
errormsg:''
}
**/
});
\ No newline at end of file
app/models/forumFavorite.js
View file @
8c76be41
...
...
@@ -22,7 +22,7 @@ var ForumFavoriteSchema = new Schema({
url
:
{
//收藏链接地址
type
:
String
,
require
:
true
}
}
,
created
:
{
//收藏时间
type
:
Date
,
require
:
true
,
...
...
app/models/forumRolePermission.js
View file @
8c76be41
...
...
@@ -15,16 +15,16 @@ var ForumRolePermissionSchema = new Schema({
index
:
true
,
ref
:
'ForumRole'
},
action
:
{
//动作
permission
:
{
//权限
type
:
Array
},
rules
:{
//角色匹配规则
type
:
String
type
:
Array
},
status
:
{
//权限1,可用,0禁用
type
:
Number
,
require
:
true
,
default
:
0
default
:
1
}
},
{
'collection'
:
'pisns_forum_role_permission'
...
...
app/models/forumThread.js
View file @
8c76be41
...
...
@@ -9,7 +9,7 @@ var ForumThreadSchema = new Schema({
require
:
true
,
index
:
true
},
forumI
nfo
:
{
i
nfo
:
{
type
:
Schema
.
Types
.
ObjectId
,
require
:
true
,
index
:
true
,
...
...
@@ -20,19 +20,19 @@ var ForumThreadSchema = new Schema({
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
}
}
,
title
:
{
//话题标题
type
:
String
,
require
:
true
},
type
:{
//文章类型 1、文章 2、照片墙
type
:
String
,
type
:
Number
,
require
:
true
},
pid
:{
//文章父ID
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumThread'
}
}
,
content
:
{
//话题内容
type
:
String
,
require
:
true
...
...
app/service/forumCommentService.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumComment
=
mongoose
.
model
(
'ForumComment'
);
//创建评论
exports
.
createComment
=
function
(
entity
,
callback
){
var
forum
=
new
ForumComment
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
//根据ID获取评论
exports
.
getCommentById
=
function
(
cid
,
callback
){
ForumComment
.
findById
(
cid
,
function
(
err
,
thread
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
thread
);
}
});
};
//根据ID更新评论
exports
.
updateCommentById
=
function
(
cid
,
entity
,
callback
){
ForumComment
.
update
({
_id
:
cid
},
entity
,
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
\ No newline at end of file
app/service/forumFavoriteService.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumFavorite
=
mongoose
.
model
(
'ForumFavorite'
);
//创建收藏
exports
.
createFavorite
=
function
(
entity
,
callback
){
var
forum
=
new
ForumFavorite
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
//根据ID删除文章
exports
.
deleteFavoriteById
=
function
(
tid
,
callback
){
ForumFavorite
.
remove
({
_id
:
tid
},
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
app/service/forumGroupService.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumGroup
=
mongoose
.
model
(
'ForumGroup'
);
//创建论坛组
exports
.
createGroup
=
function
(
entity
,
callback
){
var
forum
=
new
ForumGroup
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
//根据ID获取论坛组
exports
.
getGroupById
=
function
(
gid
,
callback
){
ForumGroup
.
findById
(
gid
,
function
(
err
,
thread
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
thread
);
}
});
};
//根据ID更新论坛组
exports
.
updateGroupById
=
function
(
gid
,
entity
,
callback
){
ForumGroup
.
update
({
_id
:
gid
},
entity
,
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//根据ID更新论坛组
exports
.
deleteGroupById
=
function
(
gid
,
callback
){
ForumGroup
.
remove
({
_id
:
gid
},
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
app/service/forumInfoService.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumInfo
=
mongoose
.
model
(
'ForumInfo'
);
//创建论坛板块
exports
.
createInfo
=
function
(
entity
,
callback
){
var
forum
=
new
ForumInfo
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
//根据ID获取论坛板块
exports
.
getInfoById
=
function
(
fid
,
callback
){
ForumInfo
.
findById
(
fid
,
function
(
err
,
thread
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
thread
);
}
});
};
//根据ID更新论坛板块
exports
.
updateInfoById
=
function
(
fid
,
entity
,
callback
){
ForumInfo
.
update
({
_id
:
fid
},
entity
,
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//根据ID更新论坛组
exports
.
deleteInfoById
=
function
(
fid
,
callback
){
ForumInfo
.
remove
({
_id
:
fid
},
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//获取数量
function
countAll
(
ent_code
,
gid
,
callback
)
{
ForumRolePermission
.
count
({
ent_code
:
ent_code
,
group
:
gid
},
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
}
//获取全部列表数据
exports
.
getAll
=
function
(
ent_code
,
gid
,
pageNo
,
pageSize
,
callback
)
{
countAll
(
ent_code
,
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
);
ForumRolePermission
.
find
({
ent_code
:
ent_code
,
group
:
gid
},
null
,
{
skip
:
skip
,
limit
:
limit
},
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
);
}
});
}
});
};
app/service/forumPraiseLogService.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumPraiseLog
=
mongoose
.
model
(
'ForumPraiseLog'
);
//创建点赞日志
exports
.
createPraiseLog
=
function
(
entity
,
callback
){
var
forum
=
new
ForumPraiseLog
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
app/service/forumRolePermissionService.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumRolePermission
=
mongoose
.
model
(
'ForumRolePermission'
);
//获取数量
function
countAll
(
ent_code
,
callback
)
{
ForumRolePermission
.
count
({
ent_code
:
ent_code
},
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
}
function
getAllRolePermissionData
(
ent_code
,
pageNo
,
pageSize
,
callback
){
countAll
(
ent_code
,
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
);
ForumRolePermission
.
find
({
ent_code
:
ent_code
},
null
,
{
skip
:
skip
,
limit
:
limit
},
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
.
getAllRolePermission
=
function
(
ent_code
,
pageNo
,
pageSize
,
callback
)
{
getAllRolePermissionData
(
ent_code
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
results
);
}
});
};
//获取用户角色对应的操作权限
function
getRolePermiss
(
ent_code
,
integral
,
exp
,
callback
){
//2.获取角色权限列表
getAllRolePermissionData
(
ent_code
,
1
,
10
,
function
(
err
,
docs
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
//3.根据积分、经验匹配对应的角色
var
obj
=
{};
var
items
=
docs
.
items
;
for
(
var
i
=
0
;
i
<
items
.
length
;
i
=
i
+
1
){
var
rolePermission
=
items
[
i
];
var
rules
=
rolePermission
.
rules
;
if
(
rules
&&
rules
.
length
>
0
){
for
(
var
j
=
0
;
j
<
rules
.
length
;
j
=
j
+
1
){
var
json
=
rules
[
j
];
json
=
JSON
.
parse
(
json
);
var
key
=
json
.
key
;
var
value
=
json
.
value
;
if
(
value
&&
value
!==
''
){
var
defaultValue
=
0
;
if
(
key
===
'integral'
){
//积分
defaultValue
=
integral
;
}
else
if
(
key
===
'exp'
){
//经验
defaultValue
=
exp
;
}
var
array
=
value
.
split
(
'-'
);
var
ge
=
array
[
0
];
var
le
=
array
[
1
];
var
result
=
true
;
if
(
ge
&&
ge
!==
''
){
result
=
Number
(
defaultValue
)
>=
Number
(
ge
);
}
if
(
result
&&
le
&&
le
!==
''
){
result
=
Number
(
defaultValue
)
<=
Number
(
le
);
}
if
(
result
){
obj
=
rolePermission
;
break
;
}
}
}
}
}
callback
(
null
,
obj
);
}
});
}
//检查是否有操作权限
exports
.
checkRolePermiss
=
function
(
ent_code
,
action
,
integral
,
exp
,
callback
){
//1.获取用户角色权限
getRolePermiss
(
ent_code
,
integral
,
exp
,
function
(
err
,
rolePermission
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
var
result
=
false
;
//2.检查用户对应的角色是否有对应的操作权限
if
(
rolePermission
&&
rolePermission
.
permission
){
var
permissions
=
rolePermission
.
permission
;
for
(
var
i
=
0
;
i
<
permissions
.
length
;
i
=
i
+
1
){
var
obj
=
JSON
.
parse
(
permissions
[
i
]);
var
tmpAction
=
obj
.
action
;
var
value
=
obj
.
value
;
if
(
tmpAction
===
action
){
if
(
value
===
'1'
){
result
=
true
;
}
break
;
}
}
}
callback
(
null
,
result
);
}
});
};
\ No newline at end of file
app/service/forumService.js
deleted
100644 → 0
View file @
2e3739d7
'use strict'
;
/**
* 新增社区板块
* @param {[type]}
* @param {Function}
* @return {[type]}
*/
exports
.
create
=
function
(
entity
,
callback
)
{
callback
(
null
,
null
);
};
\ No newline at end of file
app/service/forumShareLogService.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumShareLog
=
mongoose
.
model
(
'ForumShareLog'
);
//创建文章
exports
.
createShareLog
=
function
(
entity
,
callback
){
var
forum
=
new
ForumShareLog
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
app/service/forumThreadService.js
0 → 100644
View file @
8c76be41
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumThread
=
mongoose
.
model
(
'ForumThread'
);
//创建文章
exports
.
createThread
=
function
(
entity
,
callback
){
var
forum
=
new
ForumThread
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
//根据ID获取文章
exports
.
getThreadById
=
function
(
tid
,
callback
){
ForumThread
.
findById
(
tid
,
function
(
err
,
thread
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
thread
);
}
});
};
//根据ID更新文章
exports
.
updateThreadById
=
function
(
tid
,
entity
,
callback
){
ForumThread
.
update
({
_id
:
tid
},
entity
,
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//根据ID更新文章
exports
.
deleteThreadById
=
function
(
tid
,
callback
){
ForumThread
.
remove
({
_id
:
tid
},
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//获取数量
function
countAll
(
ent_code
,
fid
,
callback
)
{
ForumRolePermission
.
count
({
ent_code
:
ent_code
,
info
:
fid
},
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
}
//获取全部列表数据
exports
.
getAll
=
function
(
ent_code
,
fid
,
pageNo
,
pageSize
,
callback
)
{
countAll
(
ent_code
,
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
);
ForumRolePermission
.
find
({
ent_code
:
ent_code
,
info
:
fid
},
null
,
{
skip
:
skip
,
limit
:
limit
},
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
);
}
});
}
});
};
app/service/intergal.js
deleted
100644 → 0
View file @
2e3739d7
'use strict'
;
//根据会员ID获取
exports
.
getIntegralById
=
function
(
mid
,
callback
){
console
.
log
(
''
);
};
\ No newline at end of file
app/service/rolePermission.js
deleted
100644 → 0
View file @
2e3739d7
'use strict'
;
//获取用户角色
exports
.
getRolePermiss
=
function
(
callback
){
//1.获取用户经验、积分
//2.获取角色权限列表
//3.根据积分、经验匹配对应的角色
};
//检查是否有操作权限
exports
.
checkRolePermiss
=
function
(
action
,
callback
){
var
action
=
req
.
query
.
action
||
''
;
//操作
//1.获取用户角色权限
//2.检查用户对应的角色是否有对应的操作权限
console
.
log
(
action
);
};
\ No newline at end of file
app/utils/returnCode.js
View file @
8c76be41
...
...
@@ -29,6 +29,10 @@ module.exports = {
UPDATE_READONLY_ATTR
:
{
errorcode
:
10004
,
errormsg
:
'不允许更新只读属性数据'
},
ACTION_NOT_PERMISSION
:
{
errorcode
:
10005
,
errormsg
:
'没有权限'
}
...
...
config/config.js
View file @
8c76be41
...
...
@@ -11,10 +11,9 @@ var config = {
},
port
:
3011
,
mongodb
:
{
uri
:
'
114.215.206.32:27018'
uri
:
'
mongodb://114.215.206.32:27018/pisns-forum'
,
username
:
''
,
password
:
''
,
dbname
:
'pisns-forum'
,
poolSize
:
5
}
},
...
...
@@ -26,10 +25,9 @@ var config = {
},
port
:
3011
,
mongo
:
{
uri
:
'
114.215.206.32:27018'
uri
:
'
mongodb://114.215.206.32:27018/pisns-forum'
,
username
:
''
,
password
:
''
,
dbname
:
'pisns-forum'
,
poolSize
:
5
}
...
...
@@ -42,7 +40,7 @@ var config = {
},
port
:
3011
,
mongo
:
{
uri
:
'
10.173.226.96:27017'
uri
:
'
mongodb://10.173.226.96:27017/pisns-forum'
,
username
:
'future'
,
password
:
'future123456'
,
dbname
:
'pisns-forum'
,
...
...
config/express.js
View file @
8c76be41
...
...
@@ -5,7 +5,7 @@ var logger = require('morgan');
var
bodyParser
=
require
(
'body-parser'
);
var
compress
=
require
(
'compression'
);
var
methodOverride
=
require
(
'method-override'
);
var
sessionPlugin
=
require
(
'pisns-session-plugin'
);
module
.
exports
=
function
(
app
,
config
)
{
...
...
@@ -21,7 +21,37 @@ module.exports = function(app, config) {
app
.
use
(
compress
());
app
.
use
(
methodOverride
());
var
controllers
=
glob
.
sync
(
config
.
root
+
'/app/controllers/*.js'
);
sessionPlugin
(
app
,
{
storeType
:
'memcache'
,
hosts
:
'115.29.165.17:11211'
,
prefix
:
'pisns.connect.sid.'
,
name
:
'pisns.connect.sid'
,
ttl
:
7200
,
secret
:
'ogoz1t5Zm91rAUeld64d5Wqli10g'
,
options
:
{
idle
:
600000
,
poolSize
:
10
,
timeout
:
600000
}
});
app
.
use
(
function
(
req
,
res
,
next
)
{
if
(
!
req
.
session
.
user
)
{
req
.
session
.
user
=
{
ent_code
:
100001
};
}
if
(
!
req
.
session
.
openUser
){
req
.
session
.
openUser
=
{
openId
:
'54c9e321d5037010b44d4b1f'
,
integral
:
'100'
,
exp
:
'100'
};
}
next
(
null
);
});
var
controllers
=
glob
.
sync
(
config
.
root
+
'/app/controllers/**/*.js'
);
controllers
.
forEach
(
function
(
controller
)
{
require
(
controller
)(
app
);
});
...
...
@@ -32,20 +62,20 @@ module.exports = function(app, config) {
next
(
err
);
});
if
(
app
.
get
(
'env'
)
===
'development'
)
{
app
.
use
(
function
(
err
,
req
,
res
,
next
)
{
res
.
json
({
errorcode
:
-
1
,
errormsg
:
'invalid request'
});
});
}
//
if (app.get('env') === 'development') {
//
app.use(function(err, req, res, next) {
//
res.json({
//
errorcode: -1,
//
errormsg: 'invalid request'
//
});
//
});
//
}
app
.
use
(
function
(
err
,
req
,
res
,
next
)
{
res
.
json
({
errorcode
:
-
1
,
errormsg
:
'invalid request'
});
});
//
app.use(function(err, req, res, next) {
//
res.json({
//
errorcode: -1,
//
errormsg: 'invalid request'
//
});
//
});
};
\ No newline at end of file
package.json
View file @
8c76be41
...
...
@@ -14,7 +14,8 @@
"
lodash
"
:
"
~2.4.1
"
,
"
method-override
"
:
"
~2.3.0
"
,
"
mongoose
"
:
"
^3.8.21
"
,
"
morgan
"
:
"
~1.5.0
"
"
morgan
"
:
"
~1.5.0
"
,
"
pisns-session-plugin
"
:
"
0.0.3
"
},
"devDependencies"
:
{
"
grunt
"
:
"
~0.4.5
"
,
...
...
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