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
7962c279
Commit
7962c279
authored
Dec 14, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'remould_1210_icon_diff'
parents
c389a8e2
24a6cf70
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
110 deletions
+136
-110
forumIdentifyUser.js
app/controllers/admin/forumIdentifyUser.js
+71
-32
forumThread.js
app/controllers/admin/forumThread.js
+1
-1
forumUser.js
app/controllers/admin/forumUser.js
+50
-0
forumUserService.js
app/service/forumUserService.js
+14
-77
No files found.
app/controllers/admin/forumIdentifyUser.js
View file @
7962c279
...
...
@@ -63,48 +63,87 @@ var updateUser = function(user,entity){
console
.
log
(
err
);
}
else
{
console
.
log
(
'用户:'
+
user
.
_id
+
'---------更新成功'
);
console
.
log
(
updateObj
);
//
console.log(updateObj);
}
});
}
}
}
//验证用户身份
// router.post('/user/identifyUser',function(req,res,next){
// var entity=req.body;
// if(req.session.mobileForumUser && req.session.mobileForumUser.openId === entity.openId){
// res.json({result:'success',userId:req.session.mobileForumUser.userId});
// }else if(!req.session.mobileForumUser || req.session.mobileForumUser.openId !== entity.openId){
// forumUserService.getUserByUid(entity.uid,function(err,doc){
// if(err){
// console.error(err);
// res.json('error');
// }else{
// if(doc){
// updateUser(doc,entity);
// req.session.mobileForumUser={
// userId:doc._id,
// openId:doc.uid,
// mid:doc.mid || entity.mid
// };
// res.json({result:'success',userId:doc._id});
// }else{
// forumUserService.createUser(entity,function(err,doc){
// if(err){
// console.error(err);
// res.json('error');
// }else{
// req.session.mobileForumUser={
// userId:doc._id,
// openId:doc.uid,
// mid:doc.mid
// };
// res.json({result:'success',userId:doc._id});
// }
// });
// }
// }
// });
// }else{
// res.json({result:'success',userId:req.session.mobileForumUser.userId});
// }
// });
//验证用户身份
router
.
post
(
'/user/identifyUser'
,
function
(
req
,
res
,
next
){
var
entity
=
req
.
body
;
if
(
req
.
session
.
mobileForumUser
&&
req
.
session
.
mobileForumUser
.
openId
===
entity
.
openId
){
res
.
json
({
result
:
'success'
,
userId
:
req
.
session
.
mobileForumUser
.
userId
});
}
else
if
(
!
req
.
session
.
mobileForumUser
||
req
.
session
.
mobileForumUser
.
openId
!==
entity
.
openId
){
forumUserService
.
getUserByUid
(
entity
.
uid
,
function
(
err
,
doc
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
'error'
);
if
(
entity
){
forumUserService
.
getUserByUid
(
entity
.
uid
,
function
(
err
,
doc
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
'error'
);
}
else
{
if
(
doc
){
updateUser
(
doc
,
entity
);
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
,
mid
:
doc
.
mid
||
entity
.
mid
};
res
.
json
({
result
:
'success'
,
userId
:
doc
.
_id
});
}
else
{
if
(
doc
){
updateUser
(
doc
,
entity
);
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
,
mid
:
doc
.
mid
||
entity
.
mid
};
res
.
json
({
result
:
'success'
,
userId
:
doc
.
_id
});
}
else
{
forumUserService
.
createUser
(
entity
,
function
(
err
,
doc
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
'error'
);
}
else
{
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
,
mid
:
doc
.
mid
};
res
.
json
({
result
:
'success'
,
userId
:
doc
.
_id
});
}
});
}
forumUserService
.
createUser
(
entity
,
function
(
err
,
doc
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
'error'
);
}
else
{
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
openId
:
doc
.
uid
,
mid
:
doc
.
mid
};
res
.
json
({
result
:
'success'
,
userId
:
doc
.
_id
});
}
});
}
});
}
});
}
else
{
res
.
json
({
result
:
'success'
,
userId
:
req
.
session
.
mobileForumUser
.
userId
});
}
...
...
app/controllers/admin/forumThread.js
View file @
7962c279
...
...
@@ -58,7 +58,7 @@ router.post('/thread/create', function(req, res, next) {
var
rs
=
{},
ent_code
=
req
.
session
.
user
.
ent_code
,
icon
=
req
.
session
.
user
.
headPic
,
nickName
=
req
.
session
.
user
.
name
;
nickName
=
req
.
session
.
user
.
n
ickN
ame
;
if
(
icon
&&
icon
.
indexOf
(
'http://'
)
==
-
1
)
{
if
(
process
.
env
.
NODE_ENV
===
'production'
)
{
icon
=
'http://fs.wxpai.cn/'
+
icon
;
...
...
app/controllers/admin/forumUser.js
0 → 100644
View file @
7962c279
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
forumUserService
=
require
(
'../../service/forumUserService'
);
var
async
=
require
(
'async'
);
var
user
=
require
(
'../../utils/user'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//更新管理员信息
router
.
post
(
'/user/updateByUid'
,
function
(
req
,
res
,
next
)
{
var
uid
=
req
.
body
.
uid
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
nickName
=
req
.
body
.
nickName
;
var
icon
=
req
.
body
.
pic
;
if
(
uid
&&
ent_code
){
var
entity
=
{};
if
(
nickName
){
entity
.
nickName
=
nickName
;
}
if
(
icon
){
if
(
icon
&&
icon
.
indexOf
(
'http://'
)
==
-
1
)
{
if
(
process
.
env
.
NODE_ENV
===
'production'
)
{
icon
=
'http://fs.wxpai.cn/'
+
icon
;
}
else
{
icon
=
'http://dev.fs.wxpai.cn/'
+
icon
;
}
}
entity
.
icon
=
icon
;
}
forumUserService
.
updateUserByUIdAndEntCode
(
uid
,
ent_code
,
entity
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
\ No newline at end of file
app/service/forumUserService.js
View file @
7962c279
...
...
@@ -197,81 +197,18 @@ exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
});
};
//查询用户和行为限制信息
// exports.searchMembersAndLimitActions=function(pageNo, pageSize, q, callback){
// then(function(cont) {
// ForumUser.find(q).count(cont);
// }).then(function(cont, count) {
// var skip = (pageNo - 1) * pageSize;
// var limit = count - skip > pageSize ? pageSize : (count - skip);
// ForumUser.find(q).skip(skip).limit(limit).sort('-created').exec(function(err, docs) {
// cont(err, count, docs);
// });
// }).then(function(cont, count, members) {
// forumLimitActionConfigService.getAllLimitActionConfig(function(err, configs) {
// cont(err, count, members, configs);
// });
// }).then(function(cont, count, members, configs) {
// if (count > 0 && configs.length > 0) {
// var asyncTasks = [];
// members.forEach(function(member) {
// asyncTasks.push(function(callback) {
// forumLimitActionRefService.getLimitActionRefByMIdAndEntCode(member._id, member.ent_code, function(err, forumLimitActionRef) {
// if (err) {
// console.error(err);
// callback(null, null);
// } else {
// if(forumLimitActionRef){
// var limit_actions = forumLimitActionRef.limit_actions;
// var array = [];
// for (var i = 0; i < limit_actions.length; i += 1) {
// var limit_action = limit_actions[i];
// for(var k = 0; k < configs.length; k+=1){
// if(limit_action.limit_action_type === configs[k].code){
// array.push(configs[k].name);
// break;
// }
// }
// }
// member = member.toObject();
// member.limitActions = array;
// callback(null, member);
// }else{
// callback(null, member);
// }
// }
// });
// });
// });
// async.parallel(asyncTasks, function(err, results) {
// if (err) {
// console.log(err);
// callback(null, null);
// } else {
// // callback(null, results);
// var rsJson = {
// result: true,
// total: count,
// datas: results
// };
// callback(null, rsJson);
// }
// });
// } else {
// var rsJson = {
// result: true,
// total: count,
// datas: members
// };
// callback(null, rsJson);
// }
// }).fail(function(cont, err) {
// console.error(err);
// var rsJson = {
// result: false,
// err: err
// };
// callback(err, rsJson);
// });
// };
//根据UID和entCode更新用户信息
exports
.
updateUserByUIdAndEntCode
=
function
(
uid
,
ent_code
,
entity
,
callback
){
ForumUser
.
update
({
uid
:
uid
,
ent_code
:
ent_code
},
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