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
dc86d020
Commit
dc86d020
authored
Feb 09, 2015
by
张淼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
1cad2611
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
946 additions
and
0 deletions
+946
-0
forumFavorite.js
app/controllers/mobile/forumFavorite.js
+61
-0
forumGroup.js
app/controllers/mobile/forumGroup.js
+77
-0
forumInfo.js
app/controllers/mobile/forumInfo.js
+107
-0
forumRole.js
app/controllers/mobile/forumRole.js
+83
-0
forumRolePermission.js
app/controllers/mobile/forumRolePermission.js
+48
-0
forumTag.js
app/controllers/mobile/forumTag.js
+135
-0
forumThread.js
app/controllers/mobile/forumThread.js
+435
-0
No files found.
app/controllers/mobile/forumFavorite.js
0 → 100644
View file @
dc86d020
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
forumFavoriteService
=
require
(
'../../service/forumFavoriteService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
//文章收藏
router
.
post
(
'/favorite/create'
,
function
(
req
,
res
,
next
)
{
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
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
.
get
(
'/favorite/list'
,
function
(
req
,
res
,
next
)
{
var
user
=
req
.
query
.
user
;
if
(
fid
){
forumThreadService
.
getAll
(
req
.
session
.
user
.
ent_code
,
user
,
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/forumGroup.js
0 → 100644
View file @
dc86d020
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
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
(
'/v1/forum'
,
router
);
};
//新增论坛组
router
.
post
(
'/group/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
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
=
{
'id'
:
group
.
_id
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//获取目标论坛组信息
router
.
get
(
'/group/:gid/info'
,
function
(
req
,
res
,
next
)
{
var
gid
=
req
.
params
.
gid
||
null
;
var
rs
=
{};
if
(
gid
)
{
forumGroupService
.
getGroupById
(
gid
,
function
(
err
,
group
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
group
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
/**
* 获取板块列表
* @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
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/mobile/forumInfo.js
0 → 100644
View file @
dc86d020
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
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
);
};
//新增论坛板块
router
.
post
(
'/info/create'
,
function
(
req
,
res
,
next
)
{
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
forumInfoService
.
createInfo
(
req
.
body
,
function
(
err
,
info
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
{
'id'
:
info
.
_id
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
//获取目标论坛板块
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
){
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
info
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//更新目标论坛板块
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
.
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
);
}
});
/**
* [description]
* @param {[type]}
* @param {[type]}
* @param {[type]}
* @return {[type]}
*/
router
.
get
(
'/info/:fid/threads'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
fid
=
req
.
params
.
fid
;
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/mobile/forumRole.js
0 → 100644
View file @
dc86d020
'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/forumRolePermission.js
0 → 100644
View file @
dc86d020
'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
(
'/v1/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/mobile/forumTag.js
0 → 100644
View file @
dc86d020
'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
(
'/v1/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/mobile/forumThread.js
0 → 100644
View file @
dc86d020
This diff is collapsed.
Click to expand it.
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