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
a37e04de
Commit
a37e04de
authored
Mar 13, 2015
by
张淼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
3365ec11
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
464 additions
and
198 deletions
+464
-198
forumGroup.js
app/controllers/admin/forumGroup.js
+15
-1
forumInfo.js
app/controllers/admin/forumInfo.js
+14
-2
forumRole.js
app/controllers/admin/forumRole.js
+60
-52
forumRolePermission.js
app/controllers/admin/forumRolePermission.js
+2
-1
forumTag.js
app/controllers/admin/forumTag.js
+11
-1
forumThread.js
app/controllers/admin/forumThread.js
+71
-9
forumUploadFile.js
app/controllers/admin/forumUploadFile.js
+1
-1
forumGroup.js
app/controllers/mobile/forumGroup.js
+4
-1
forumInfo.js
app/controllers/mobile/forumInfo.js
+38
-3
forumRole.js
app/controllers/mobile/forumRole.js
+0
-83
forumTag.js
app/controllers/mobile/forumTag.js
+4
-2
forumThread.js
app/controllers/mobile/forumThread.js
+34
-4
forumUploadFile.js
app/controllers/mobile/forumUploadFile.js
+19
-0
forumGroup.js
app/models/forumGroup.js
+0
-1
forumImage.js
app/models/forumImage.js
+32
-0
forumThread.js
app/models/forumThread.js
+3
-0
forumUser.js
app/models/forumUser.js
+5
-0
forumGroupService.js
app/service/forumGroupService.js
+5
-5
forumInfoService.js
app/service/forumInfoService.js
+7
-17
forumRoleService.js
app/service/forumRoleService.js
+90
-0
forumTagService.js
app/service/forumTagService.js
+5
-5
forumThreadService.js
app/service/forumThreadService.js
+5
-10
forumUserService.js
app/service/forumUserService.js
+31
-0
user.js
app/utils/user.js
+8
-0
No files found.
app/controllers/admin/forumGroup.js
View file @
a37e04de
...
...
@@ -95,7 +95,21 @@ router.get('/group/:gid/info', function(req, res, next) {
router
.
get
(
'/group/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
forumGroupService
.
getAll
(
req
.
session
.
user
.
ent_code
,
pageNo
,
pageSize
,
function
(
err
,
results
){
var
groupName
=
req
.
query
.
groupName
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
groupName
){
conditions
.
name
=
{
$regex
:
groupName
,
$options
:
'i'
};
}
forumGroupService
.
getAll
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/admin/forumInfo.js
View file @
a37e04de
...
...
@@ -121,8 +121,20 @@ router.get('/infos/list', function(req, res, next) {
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
groupId
=
req
.
query
.
groupId
||
null
;
forumInfoService
.
getAllByGid
(
req
.
session
.
user
.
ent_code
,
groupId
,
pageNo
,
pageSize
,
function
(
err
,
results
){
var
infoName
=
req
.
query
.
infoName
||
null
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
groupId
){
conditions
.
group
=
groupId
;
}
if
(
infoName
){
conditions
.
name
=
{
$regex
:
infoName
,
$options
:
'i'
};
}
forumInfoService
.
getAllByGid
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/admin/forumRole.js
View file @
a37e04de
...
...
@@ -4,7 +4,9 @@ var express = require('express'),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumRole
=
mongoose
.
model
(
'ForumRole'
);
var
forumRoleService
=
require
(
'../../service/forumRoleService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
...
...
@@ -13,8 +15,7 @@ module.exports = function(app) {
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
)
{
forumRoleService
.
createRole
(
req
.
body
,
function
(
err
,
forum
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -28,72 +29,79 @@ router.post('/role/create', function(req, res, next) {
//删除论坛角色
router
.
get
(
'/role/:rid/get'
,
function
(
req
,
res
,
next
)
{
var
rid
=
req
.
params
.
rid
;
ForumRole
.
findById
(
rid
,
function
(
err
,
role
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
data
=
role
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
if
(
rid
){
forumRoleService
.
getRoleById
(
rid
,
function
(
err
,
role
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
data
=
role
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//删除论坛角色
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
);
}
});
if
(
rid
){
forumRoleService
.
deleteRoleById
(
rid
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//更新论坛角色
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
);
}
});
if
(
rid
){
forumRoleService
.
updateRoleById
(
rid
,
req
.
body
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//获取角色列表
router
.
get
(
'/role/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
roleName
=
req
.
query
.
roleName
;
var
rs
=
{};
ForumRole
.
count
({
ent_code
:
req
.
session
.
user
.
ent_code
,
status
:
1
},
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
status
:
1
};
if
(
roleName
){
conditions
.
title
=
{
$regex
:
roleName
,
$options
:
'i'
};
}
forumRoleService
.
getAllRole
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
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
));
}
});
}
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
});
app/controllers/admin/forumRolePermission.js
View file @
a37e04de
...
...
@@ -45,7 +45,7 @@ router.get('/rolePermiss/:pid/get', function(req, res, next) {
var
json
=
{};
json
.
_id
=
permiss
.
_id
;
json
.
role
=
permiss
.
role
;
json
.
permission
List
=
permiss
.
permission
;
json
.
permission
=
permiss
.
permission
;
var
rules
=
permiss
.
rules
;
var
integral
=
''
,
exp
=
''
;
...
...
@@ -136,6 +136,7 @@ function buildField(entity){
}
permissions
[
i
]
=
obj
;
}
console
.
log
(
permissions
);
entity
.
permission
=
permissions
;
//-----------------------------设置操作权限结束
...
...
app/controllers/admin/forumTag.js
View file @
a37e04de
...
...
@@ -84,8 +84,18 @@ router.get('/tag/:tid/get', function(req, res, next) {
router
.
get
(
'/tag/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
tagName
=
req
.
query
.
tagName
||
''
;
forumTagService
.
getAllTag
(
req
.
session
.
user
.
ent_code
,
pageNo
,
pageSize
,
function
(
err
,
results
){
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
if
(
tagName
){
conditions
.
title
=
{
$regex
:
tagName
,
$options
:
'i'
};
}
forumTagService
.
getAllTag
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/admin/forumThread.js
View file @
a37e04de
...
...
@@ -11,7 +11,11 @@ var forumPraiseLogService=require('../../service/forumPraiseLogService');
var
forumShareLogService
=
require
(
'../../service/forumShareLogService'
);
var
forumCommentService
=
require
(
'../../service/forumCommentService'
);
var
forumTagService
=
require
(
'../../service/forumTagService'
);
var
forumUserService
=
require
(
'../../service/forumUserService'
);
var
userUtil
=
require
(
'../../utils/user'
);
var
async
=
require
(
'async'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
...
...
@@ -21,17 +25,75 @@ module.exports = function(app) {
//新增论坛文章
router
.
post
(
'/thread/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
forumThreadService
.
createThread
(
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
));
}
});
var
uid
=
'abcdefdfddfssfds'
;
if
(
userUtil
.
getUserSession
(
req
)){
req
.
body
.
from
=
userUtil
.
getUserSession
.
_id
;
forumThreadService
.
createThread
(
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
));
}
});
}
else
{
async
.
waterfall
([
function
(
callback
){
forumUserService
.
getUserByUid
(
uid
,
callback
);
}
],
function
(
err
,
user
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
user
){
//put forumUser to session
userUtil
.
setUserSession
(
req
,
user
);
req
.
body
.
from
=
user
.
_id
;
forumThreadService
.
createThread
(
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
));
}
});
}
else
{
var
entity
=
{
uid
:
uid
,
nickName
:
'管理员'
,
icon
:
'http://fs.wxpai.cn/aofei/youyouqiu.png'
};
forumUserService
.
createUser
(
entity
,
function
(
err
,
doc
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
//put forumUser to session
userUtil
.
setUserSession
(
req
,
doc
);
req
.
body
.
from
=
doc
.
_id
;
forumThreadService
.
createThread
(
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
));
}
});
}
});
}
}
});
}
});
//获取目标论坛文章
...
...
app/controllers/admin/forumUploadFile.js
View file @
a37e04de
...
...
@@ -12,7 +12,7 @@ module.exports = function(app) {
app
.
use
(
'/admin/forum'
,
router
);
};
//文章
收藏
//文章
上传
router
.
post
(
'/uploadFile'
,
uploadFile
(
'oss'
,
'forum'
),
function
(
req
,
res
,
next
)
{
res
.
json
(
req
.
uploadFile
);
});
...
...
app/controllers/mobile/forumGroup.js
View file @
a37e04de
...
...
@@ -63,7 +63,10 @@ router.get('/group/:gid/info', function(req, res, next) {
router
.
get
(
'/group/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
forumGroupService
.
getAll
(
req
.
session
.
user
.
ent_code
,
pageNo
,
pageSize
,
function
(
err
,
results
){
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
forumGroupService
.
getAll
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/mobile/forumInfo.js
View file @
a37e04de
...
...
@@ -9,6 +9,7 @@ var ForumInfo = mongoose.model('ForumInfo');
var
forumInfoService
=
require
(
'../../service/forumInfoService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
async
=
require
(
'async'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
...
...
@@ -32,20 +33,54 @@ router.post('/info/create', function(req, res, next) {
//获取目标论坛板块
router
.
get
(
'/info/:fid/get'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
||
null
;
var
rs
=
{};
if
(
fid
)
{
forumInfoService
.
getInfoById
(
fid
,
function
(
err
,
info
){
async
.
waterfall
([
function
(
callback
){
forumInfoService
.
getInfoById
(
fid
,
function
(
err
,
info
){
if
(
err
)
{
callback
(
err
,
null
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
callback
(
null
,
info
);
}
});
},
function
(
info
,
callback
){
var
pv_count
=
info
.
pv_count
+
1
;
info
.
pv_count
=
pv_count
;
forumInfoService
.
updateInfoById
(
fid
,{
pv_count
:
pv_count
},
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
info
);
}
});
},
function
(
info
,
callback
){
forumThreadService
.
getAllCountByFid
({
info
:
fid
},
function
(
err
,
threadCount
){
if
(
err
){
callback
(
err
,
null
,
null
);
}
else
{
callback
(
null
,
info
,
threadCount
);
}
});
}
],
function
(
err
,
info
,
threadCount
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
data
=
info
;
rs
.
data
.
threadCount
=
threadCount
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//更新目标论坛板块
...
...
app/controllers/mobile/forumRole.js
deleted
100644 → 0
View file @
3365ec11
'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
(
'/v1/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/mobile/forumTag.js
View file @
a37e04de
...
...
@@ -18,8 +18,10 @@ module.exports = function(app) {
router
.
get
(
'/tag/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
forumTagService
.
getAllTag
(
req
.
session
.
user
.
ent_code
,
pageNo
,
pageSize
,
function
(
err
,
results
){
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
forumTagService
.
getAllTag
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/mobile/forumThread.js
View file @
a37e04de
...
...
@@ -10,6 +10,8 @@ var forumRolePermissionService=require('../../service/forumRolePermissionService
var
forumPraiseLogService
=
require
(
'../../service/forumPraiseLogService'
);
var
forumShareLogService
=
require
(
'../../service/forumShareLogService'
);
var
forumCommentService
=
require
(
'../../service/forumCommentService'
);
var
user
=
require
(
'../../utils/user'
);
var
async
=
require
(
'async'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
...
...
@@ -22,6 +24,8 @@ module.exports = function(app) {
router
.
post
(
'/thread/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
req
.
body
.
from
=
user
.
getMobileUser
();
forumThreadService
.
createThread
(
req
.
body
,
function
(
err
,
entity
){
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -61,17 +65,39 @@ router.get('/threads/list', function(req, res, next) {
//获取目标论坛文章
router
.
get
(
'/thread/:tid/get'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
rs
=
{};
if
(
tid
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
){
if
(
tid
){
async
.
waterfall
([
function
(
callback
){
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
// console.log(thread);
callback
(
null
,
thread
);
}
});
},
function
(
thread
,
callback
){
var
pv_count
=
thread
.
pv_count
+
1
;
thread
.
pv_count
=
pv_count
;
forumThreadService
.
updateThreadById
(
tid
,{
pv_count
:
pv_count
},
function
(
err
,
doc
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
callback
(
null
,
thread
);
}
});
}
],
function
(
err
,
thread
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
data
=
thread
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
...
...
@@ -265,6 +291,8 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
var
integral
=
req
.
session
.
openUser
.
integral
||
0
;
var
exp
=
req
.
session
.
openUser
.
exp
||
0
;
var
destination
=
req
.
body
.
destination
||
'1'
;
req
.
body
.
from
=
user
.
getMobileUser
();
//1.检查是否有权限
forumRolePermissionService
.
checkRolePermiss
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
action
,
integral
,
exp
,
function
(
err
,
result
){
if
(
err
){
...
...
@@ -356,6 +384,8 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
var
integral
=
req
.
session
.
openUser
.
integral
||
0
;
var
exp
=
req
.
session
.
openUser
.
exp
||
0
;
var
destination
=
req
.
body
.
destination
||
'1'
;
req
.
body
.
from
=
user
.
getMobileUser
();
//1.检查是否有权限
forumRolePermissionService
.
checkRolePermiss
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
action
,
integral
,
exp
,
function
(
err
,
result
){
if
(
err
){
...
...
app/controllers/mobile/forumUploadFile.js
0 → 100644
View file @
a37e04de
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
uploadFile
=
require
(
'../../utils/uploadfile'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
//文章上传
router
.
post
(
'/uploadFile'
,
uploadFile
(
'oss'
,
'forum'
),
function
(
req
,
res
,
next
)
{
res
.
json
(
req
.
uploadFile
);
});
app/models/forumGroup.js
View file @
a37e04de
...
...
@@ -32,7 +32,6 @@ var ForumGroupSchema = new Schema({
required
:
true
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_group'
});
...
...
app/models/forumImage.js
0 → 100644
View file @
a37e04de
'use strict'
;
var
mongoose
=
require
(
'mongoose'
),
Schema
=
mongoose
.
Schema
;
//论坛图片
var
ForumImageSchema
=
new
Schema
({
ent_code
:
{
type
:
Number
,
require
:
true
,
index
:
true
},
name
:
{
//图片名称
type
:
String
},
url
:
{
//图片路径
type
:
String
,
require
:
true
},
type
:
{
//类型 1、文章图片 2、评论图片
type
:
String
},
created
:
{
type
:
Date
,
required
:
true
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_image'
});
module
.
exports
=
mongoose
.
model
(
'ForumImage'
,
ForumImageSchema
);
\ No newline at end of file
app/models/forumThread.js
View file @
a37e04de
...
...
@@ -53,6 +53,9 @@ var ForumThreadSchema = new Schema({
},
tag
:
[{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumTag'
}],
//话题归属标签,
comments
:
[{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumComment'
}],
//评论内容列表
images
:
{
//文章图片列表
type
:
Array
},
share
:
{
//自定义分享
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumShare'
...
...
app/models/forumUser.js
View file @
a37e04de
...
...
@@ -36,6 +36,11 @@ var ForumUserSchema = new Schema({
type
:
Number
,
require
:
true
,
default
:
1
},
created
:
{
type
:
Date
,
required
:
true
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_user'
...
...
app/service/forumGroupService.js
View file @
a37e04de
...
...
@@ -76,8 +76,8 @@ exports.deleteGroupById=function(gid,callback){
};
//获取数量
function
countAll
(
ent_code
,
callback
)
{
ForumGroup
.
count
(
{
ent_code
:
ent_code
}
,
function
(
err
,
count
)
{
function
countAll
(
conditions
,
callback
)
{
ForumGroup
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
@@ -88,15 +88,15 @@ function countAll(ent_code,callback) {
}
//获取全部列表数据
exports
.
getAll
=
function
(
ent_code
,
pageNo
,
pageSize
,
callback
)
{
countAll
(
ent_code
,
function
(
err
,
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
);
ForumGroup
.
find
(
{
ent_code
:
ent_code
}
,
null
,
{
skip
:
skip
,
limit
:
limit
,
sort
:
'created'
},
function
(
err
,
docs
){
ForumGroup
.
find
(
conditions
,
null
,
{
skip
:
skip
,
limit
:
limit
,
sort
:
'created'
},
function
(
err
,
docs
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
app/service/forumInfoService.js
View file @
a37e04de
...
...
@@ -52,13 +52,8 @@ exports.deleteInfoById=function(fid,callback){
};
//获取数量
function
countAllByGid
(
ent_code
,
gid
,
callback
)
{
var
condition
=
{};
condition
.
ent_code
=
ent_code
;
if
(
gid
){
condition
.
group
=
gid
;
}
ForumInfo
.
count
(
condition
,
function
(
err
,
count
)
{
function
countAllByGid
(
conditions
,
callback
)
{
ForumInfo
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
@@ -69,21 +64,16 @@ function countAllByGid(ent_code,gid,callback) {
}
//获取全部列表数据
exports
.
getAllByGid
=
function
(
ent_code
,
gid
,
pageNo
,
pageSize
,
callback
)
{
countAllByGid
(
ent_code
,
gid
,
function
(
err
,
count
){
exports
.
getAllByGid
=
function
(
conditions
,
pageNo
,
pageSize
,
callback
)
{
countAllByGid
(
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
);
var
condition
=
{};
condition
.
ent_code
=
ent_code
;
if
(
gid
){
condition
.
group
=
gid
;
}
ForumInfo
.
find
(
condition
,
null
,
{
skip
:
skip
,
limit
:
limit
,
sort
:
'created'
},
function
(
err
,
docs
){
if
(
err
)
{
ForumInfo
.
find
(
conditions
).
populate
(
'group'
).
skip
(
skip
).
limit
(
limit
).
sort
(
'created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
...
...
@@ -94,7 +84,7 @@ exports.getAllByGid= function(ent_code,gid,pageNo,pageSize,callback) {
obj
.
items
=
docs
;
callback
(
null
,
obj
);
}
});
});
}
});
};
app/service/forumRoleService.js
0 → 100644
View file @
a37e04de
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumRole
=
mongoose
.
model
(
'ForumRole'
);
//创建论坛角色
exports
.
createRole
=
function
(
entity
,
callback
){
var
forum
=
new
ForumRole
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
//根据ID获取论坛角色
exports
.
getRoleById
=
function
(
rid
,
callback
){
ForumRole
.
findById
(
rid
,
function
(
err
,
role
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
role
);
}
});
};
//根据ID更新论坛角色
exports
.
updateRoleById
=
function
(
rid
,
entity
,
callback
){
ForumRole
.
update
({
_id
:
rid
},
entity
,
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//根据ID更新论坛角色
exports
.
deleteRoleById
=
function
(
rid
,
callback
){
ForumRole
.
remove
({
_id
:
rid
},
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//获取数量
function
countAll
(
conditions
,
callback
)
{
ForumRole
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
}
//获取全部列表数据
exports
.
getAllRole
=
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
);
ForumRole
.
find
(
conditions
).
skip
(
skip
).
limit
(
limit
).
sort
(
'created'
).
exec
(
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/forumTagService.js
View file @
a37e04de
...
...
@@ -52,8 +52,8 @@ exports.deleteTagById=function(tid,callback){
};
//获取数量
function
countAll
(
ent_code
,
callback
)
{
ForumTag
.
count
(
{
ent_code
:
ent_code
}
,
function
(
err
,
count
)
{
function
countAll
(
conditions
,
callback
)
{
ForumTag
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
@@ -64,15 +64,15 @@ function countAll(ent_code,callback) {
}
//获取全部列表数据
exports
.
getAllTag
=
function
(
ent_code
,
pageNo
,
pageSize
,
callback
)
{
countAll
(
ent_code
,
function
(
err
,
count
){
exports
.
getAllTag
=
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
);
ForumTag
.
find
(
{
ent_code
:
ent_code
}
,
null
,
{
skip
:
skip
,
limit
:
limit
,
sort
:
'created'
},
function
(
err
,
docs
){
ForumTag
.
find
(
conditions
,
null
,
{
skip
:
skip
,
limit
:
limit
,
sort
:
'created'
},
function
(
err
,
docs
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
app/service/forumThreadService.js
View file @
a37e04de
...
...
@@ -45,16 +45,6 @@ exports.getThreadById=function(tid,callback){
}
}
});
// ForumThread.findById(tid, function(err, thread) {
// if (err) {
// console.error(err);
// callback(err,null);
// } else {
// callback(null,thread);
// }
// });
};
//根据ID更新文章
...
...
@@ -125,6 +115,11 @@ function countAllByFid(conditions,callback) {
});
}
//导出获取数量函数
exports
.
getAllCountByFid
=
function
(
conditions
,
callback
){
countAllByFid
(
conditions
,
callback
);
}
//获取全部列表数据
exports
.
getAllThreadByFid
=
function
(
conditions
,
pageNo
,
pageSize
,
callback
)
{
countAllByFid
(
conditions
,
function
(
err
,
count
){
...
...
app/service/forumUserService.js
0 → 100644
View file @
a37e04de
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumUser
=
mongoose
.
model
(
'ForumUser'
);
//创建用户
exports
.
createUser
=
function
(
entity
,
callback
){
var
forum
=
new
ForumUser
(
entity
);
forum
.
save
(
function
(
err
,
forum
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
forum
);
}
});
};
//根据Uid获取用户
exports
.
getUserByUid
=
function
(
uid
,
callback
){
ForumUser
.
find
({
uid
:
uid
}).
exec
(
function
(
err
,
results
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
if
(
results
&&
results
.
length
>
0
){
callback
(
null
,
results
[
0
]);
}
else
{
callback
(
null
,
null
);
}
}
});
};
app/utils/user.js
View file @
a37e04de
...
...
@@ -6,4 +6,12 @@ exports.setUserSession=function(req,user){
exports
.
getUserSession
=
function
(
req
){
return
req
.
session
.
forumUser
;
}
exports
.
getMobileUser
=
function
(
req
){
return
"55015675868b65a028187c49"
;
}
exports
.
setMobileUser
=
function
(
req
){
}
\ No newline at end of file
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