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
0fb26aa0
Commit
0fb26aa0
authored
Mar 18, 2016
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
196ded65
'
parents
941423a0
196ded65
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
162 additions
and
116 deletions
+162
-116
app.js
app.js
+1
-0
forumInfo.js
app/controllers/mobile/forumInfo.js
+21
-21
forumShare.js
app/controllers/mobile/forumShare.js
+3
-3
forumTag.js
app/controllers/mobile/forumTag.js
+3
-3
forumThread.js
app/controllers/mobile/forumThread.js
+12
-12
forumThread.js
app/models/forumThread.js
+5
-1
cacheConfig.js
app/utils/cacheConfig.js
+0
-6
cacheable.js
app/utils/cacheable.js
+38
-22
loadUserLevel.js
app/utils/loadUserLevel.js
+26
-0
redisThreadList.js
app/utils/redisThreadList.js
+5
-5
util.js
app/utils/util.js
+40
-43
cacheConfig.js
config/cacheConfig.js
+8
-0
No files found.
app.js
View file @
0fb26aa0
...
@@ -39,4 +39,5 @@ mongoModels.forEach(function(model) {
...
@@ -39,4 +39,5 @@ mongoModels.forEach(function(model) {
global
.
mongodb
=
mongodb
;
global
.
mongodb
=
mongodb
;
require
(
'./config/express'
)(
app
,
config
);
require
(
'./config/express'
)(
app
,
config
);
require
(
'./config/cacheConfig'
);
app
.
listen
(
config
.
port
);
app
.
listen
(
config
.
port
);
\ No newline at end of file
app/controllers/mobile/forumInfo.js
View file @
0fb26aa0
...
@@ -90,9 +90,9 @@ router.get('/info/:fid/get', function(req, res, next) {
...
@@ -90,9 +90,9 @@ router.get('/info/:fid/get', function(req, res, next) {
level
:
1
,
level
:
1
,
status
:
1
,
status
:
1
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
@@ -183,9 +183,9 @@ router.get('/info/:fid/threads', function(req, res, next) {
...
@@ -183,9 +183,9 @@ router.get('/info/:fid/threads', function(req, res, next) {
level
:
1
,
level
:
1
,
status
:
1
,
status
:
1
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
@@ -266,9 +266,9 @@ router.get('/info/:fid/hotThreads', function(req, res, next) {
...
@@ -266,9 +266,9 @@ router.get('/info/:fid/hotThreads', function(req, res, next) {
$ne
:
3
$ne
:
3
},
},
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
@@ -331,9 +331,9 @@ router.get('/info/:fid/photoThreads', function(req, res, next) {
...
@@ -331,9 +331,9 @@ router.get('/info/:fid/photoThreads', function(req, res, next) {
$ne
:
3
$ne
:
3
},
},
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
@@ -628,9 +628,9 @@ router.get('/info/:fid/serachThreads', function(req, res, next) {
...
@@ -628,9 +628,9 @@ router.get('/info/:fid/serachThreads', function(req, res, next) {
status
:
1
,
status
:
1
,
info
:
fid
,
info
:
fid
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
@@ -832,9 +832,9 @@ router.get('/info/list/allWithThreadCount', function(req, res, next) {
...
@@ -832,9 +832,9 @@ router.get('/info/list/allWithThreadCount', function(req, res, next) {
level
:
1
,
level
:
1
,
status
:
1
,
status
:
1
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
@@ -883,9 +883,9 @@ router.get('/info/serachThreads', function(req, res, next) {
...
@@ -883,9 +883,9 @@ router.get('/info/serachThreads', function(req, res, next) {
ent_code
:
ent_code
,
ent_code
:
ent_code
,
status
:
1
,
status
:
1
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
...
app/controllers/mobile/forumShare.js
View file @
0fb26aa0
...
@@ -333,14 +333,14 @@ router.get('/sharev2.js', function(req, res, next) {
...
@@ -333,14 +333,14 @@ router.get('/sharev2.js', function(req, res, next) {
//type为index时的,默认link
//type为index时的,默认link
link
=
config
.
service
+
'/app/forum/'
+
ent_code
+
'/mediashequn'
link
=
config
.
service
+
'/app/forum/'
+
ent_code
+
'/mediashequn'
request
.
get
({
url
:
config
.
rest_api
+
'/v1.0/internal/forum/config/enter/byentcode?entCode='
+
ent_code
,
body
:{},
json
:
true
},
function
(
e
,
r
,
result
)
{
request
.
get
({
url
:
config
.
rest_api
+
'/v1.0/internal/forum/config/enter/byentcode?entCode='
+
ent_code
,
body
:{},
json
:
true
},
function
(
e
,
r
,
result
)
{
if
(
result
.
data
){
if
(
result
&&
result
.
data
){
link
=
result
.
data
;
link
=
result
.
data
;
}
}
cont
();
cont
();
});
});
},
function
(
cont
){
},
function
(
cont
){
request
.
get
({
url
:
config
.
rest_api
+
'/v1.0/internal/forum/config/share/byentcode?entCode='
+
ent_code
,
body
:{},
json
:
true
},
function
(
e
,
r
,
result
)
{
request
.
get
({
url
:
config
.
rest_api
+
'/v1.0/internal/forum/config/share/byentcode?entCode='
+
ent_code
,
body
:{},
json
:
true
},
function
(
e
,
r
,
result
)
{
if
(
result
.
data
){
if
(
result
&&
result
.
data
){
try
{
try
{
var
obj
=
JSON
.
parse
(
result
.
data
);
var
obj
=
JSON
.
parse
(
result
.
data
);
title
=
obj
.
shareTitle
||
''
;
title
=
obj
.
shareTitle
||
''
;
...
@@ -381,7 +381,7 @@ router.get('/sharev2.js', function(req, res, next) {
...
@@ -381,7 +381,7 @@ router.get('/sharev2.js', function(req, res, next) {
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
WRONG_PARAM
));
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
WRONG_PARAM
));
}
else
if
(
type
===
'notice'
){
}
else
if
(
type
===
'notice'
){
Notice
.
findOne
({
_id
:
id
},
function
(
err
,
result
){
Notice
.
findOne
({
_id
:
id
},
function
(
err
,
result
){
if
(
err
)
{
if
(
err
||
!
result
)
{
console
.
error
(
err
);
console
.
error
(
err
);
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
BUSY
));
res
.
json
(
_
.
assign
({
result
:
false
},
returnCode
.
BUSY
));
}
}
...
...
app/controllers/mobile/forumTag.js
View file @
0fb26aa0
...
@@ -79,9 +79,9 @@ router.get('/tag/:tid/threads', function(req, res, next) {
...
@@ -79,9 +79,9 @@ router.get('/tag/:tid/threads', function(req, res, next) {
status
:
1
,
status
:
1
,
level
:
1
,
level
:
1
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
...
app/controllers/mobile/forumThread.js
View file @
0fb26aa0
...
@@ -417,9 +417,9 @@ router.get('/thread/searchThread', function(req, res, next) {
...
@@ -417,9 +417,9 @@ router.get('/thread/searchThread', function(req, res, next) {
status
:
status
,
status
:
status
,
from
:
from
,
from
:
from
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
},
'event.eventStartTime'
:
{
$lte
:
today
},
...
@@ -1932,9 +1932,9 @@ router.get('/thread/getThreadWithNotPopulateComment', function(req, res, next) {
...
@@ -1932,9 +1932,9 @@ router.get('/thread/getThreadWithNotPopulateComment', function(req, res, next) {
level
:
1
,
level
:
1
,
status
:
1
,
status
:
1
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
@@ -1987,9 +1987,9 @@ router.get('/thread/getThreadWithEssence', function(req, res, next) {
...
@@ -1987,9 +1987,9 @@ router.get('/thread/getThreadWithEssence', function(req, res, next) {
status
:
1
,
status
:
1
,
new_recommend
:
1
,
new_recommend
:
1
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
@@ -2103,9 +2103,9 @@ router.get('/thread/getThreadWithNotPopulateComment/hot', function(req, res, nex
...
@@ -2103,9 +2103,9 @@ router.get('/thread/getThreadWithNotPopulateComment/hot', function(req, res, nex
level
:
1
,
level
:
1
,
status
:
1
,
status
:
1
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
...
...
app/models/forumThread.js
View file @
0fb26aa0
...
@@ -140,7 +140,7 @@ var ForumThreadSchema = new Schema({
...
@@ -140,7 +140,7 @@ var ForumThreadSchema = new Schema({
type
:
Schema
.
Types
.
ObjectId
,
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumUser'
ref
:
'ForumUser'
}],
}],
isEvent
:{
//是否活动
0否 1是
isEvent
:{
//是否活动
改为0立即发布,1活动,2定时发布(到了发布时间才在手机端显示) by lws 20160317
type
:
Number
,
type
:
Number
,
require
:
true
,
require
:
true
,
default
:
0
default
:
0
...
@@ -155,6 +155,10 @@ var ForumThreadSchema = new Schema({
...
@@ -155,6 +155,10 @@ var ForumThreadSchema = new Schema({
required
:
false
required
:
false
}
}
},
},
release_time
:{
//发布时间,如果isEvent为2就是定时发布,需要发布时间
type
:
Date
,
required
:
false
},
created
:
{
created
:
{
type
:
Date
,
type
:
Date
,
required
:
true
,
required
:
true
,
...
...
app/utils/cacheConfig.js
deleted
100644 → 0
View file @
941423a0
var
cache
=
require
(
'./cacheable'
);
var
forumAboutMEService
=
require
(
'../service/forumAboutMEService'
);
cache
.
cacheable
(
forumAboutMEService
,
'me2other'
,
{
ns
:
'forum.service.forumAboutMEService222'
,
dur
:
10000
});
//cache.clear(forumAboutMEService,'me2other','forum.service.forumAboutMEService222')
\ No newline at end of file
app/utils/cacheable.js
View file @
0fb26aa0
...
@@ -5,36 +5,52 @@ var async=require('async');
...
@@ -5,36 +5,52 @@ var async=require('async');
/**=====<1.缓存实现开始==========**/
/**=====<1.缓存实现开始==========**/
function
toCache
(
dur
,
k
,
v
)
{
function
toCache
(
dur
,
k
,
v
)
{
if
(
v
){
if
(
v
){
var
str
=
''
;
redis
.
hset
(
dur
.
ns
,
k
,
1
,
function
(
err
)
{
try
{
if
(
!
err
){
str
=
JSON
.
stringify
(
v
);
redis
.
expire
(
dur
.
ns
,
dur
.
dur
);
if
(
str
){
var
str
=
''
;
redis
.
hset
(
dur
.
ns
,
k
,
str
,
function
(
err
)
{
try
{
redis
.
expire
(
k
,
dur
.
dur
);
str
=
JSON
.
stringify
(
v
);
});
}
catch
(
e
){
console
.
log
(
e
);
}
if
(
str
){
redis
.
set
(
k
,
str
,
function
(
err
){
if
(
!
err
){
redis
.
expire
(
k
,
dur
.
dur
);
}
});
}
}
}
}
catch
(
e
){
});
console
.
log
(
e
);
}
}
}
}
}
function
fromCache
(
dur
,
k
,
cb
){
function
fromCache
(
dur
,
k
,
cb
){
redis
.
hget
(
dur
.
ns
,
k
,
function
(
err
,
v
){
redis
.
hget
(
dur
.
ns
,
k
,
function
(
err
,
hit
){
if
(
err
){
if
(
err
){
return
cb
(
err
);
console
.
log
(
err
);
return
cb
();
}
if
(
!
hit
){
return
cb
();
}
}
if
(
v
){
redis
.
get
(
k
,
function
(
err
,
data
){
if
(
err
){
console
.
log
(
err
);
return
cb
();
}
if
(
!
data
){
return
cb
();
}
var
obj
=
null
;
var
obj
=
null
;
try
{
try
{
obj
=
JSON
.
parse
(
v
);
obj
=
JSON
.
parse
(
data
);
cb
(
null
,
obj
);
}
catch
(
e
){
}
catch
(
e
){
c
b
(
e
);
c
onsole
.
log
(
err
);
}
}
}
else
{
cb
(
null
,
obj
);
cb
(
null
,
null
);
});
}
});
});
}
}
...
@@ -53,8 +69,8 @@ function loadAndCacheData(dur, key, fn, args, cb) {
...
@@ -53,8 +69,8 @@ function loadAndCacheData(dur, key, fn, args, cb) {
}
}
function
getKey
(
ns
,
args
)
{
function
getKey
(
ns
,
args
)
{
var
key
=
Array
.
prototype
.
join
.
call
(
arguments
,
'
,
'
);
var
key
=
Array
.
prototype
.
join
.
call
(
arguments
,
'
_
'
);
return
ns
+
':'
+
key
;
return
'cacheable_'
+
key
;
}
}
function
withCache
(
dur
,
keyBuilder
,
fn
)
{
function
withCache
(
dur
,
keyBuilder
,
fn
)
{
...
@@ -130,7 +146,7 @@ module.exports = {
...
@@ -130,7 +146,7 @@ module.exports = {
throw
'opts.ns 不能为空'
;
throw
'opts.ns 不能为空'
;
}
}
if
(
!
opts
.
dur
||
isNaN
(
opts
.
dur
)){
//默认缓存一小时
if
(
!
opts
.
dur
||
isNaN
(
opts
.
dur
)){
//默认缓存一小时
opts
.
dur
=
1000
*
60
*
60
;
opts
.
dur
=
60
*
60
;
}
}
m
[
fn
]
=
cacheable
(
m
[
fn
],
opts
);
m
[
fn
]
=
cacheable
(
m
[
fn
],
opts
);
},
},
...
...
app/utils/loadUserLevel.js
0 → 100644
View file @
0fb26aa0
var
_
=
require
(
'lodash'
);
var
request
=
require
(
'request'
);
var
env
=
process
.
env
.
NODE_ENV
;
var
API_ADDRESS
=
'http://localhost:8080'
;
if
(
env
==
'sandbox'
)
{
API_ADDRESS
=
'http://rest.wxpai.cn'
;
}
else
if
(
env
==
'production'
)
{
API_ADDRESS
=
'https://rest.wxpai.cn'
;
}
exports
.
loadLevelFromAPI
=
function
(
ent_code
,
open_id
,
callback
){
if
(
!
ent_code
||
!
open_id
){
return
callback
&&
callback
(
null
,
null
);
}
var
url
=
API_ADDRESS
+
'/v1.0/internal/member/exp/byopenid?openId='
+
open_id
+
'&entCode='
+
ent_code
;
request
.
get
({
url
:
url
,
json
:
{}
},
function
(
e
,
r
,
body
)
{
if
(
e
)
{
console
.
log
(
e
)
}
return
callback
&&
callback
(
null
,(
body
&&
body
.
data
)
||
null
);
});
};
\ No newline at end of file
app/utils/redisThreadList.js
View file @
0fb26aa0
...
@@ -53,11 +53,11 @@ function getEsenceThreads(ent_code, salt,callback){
...
@@ -53,11 +53,11 @@ function getEsenceThreads(ent_code, salt,callback){
level
:
1
,
level
:
1
,
status
:
1
,
status
:
1
,
new_recommend
:
1
,
new_recommend
:
1
,
$or
:
[{
$or
:
[{
isEvent
:
0
isEvent
:
{
},
{
$ne
:
1
isEvent
:
null
}
},
{
},
{
isEvent
:
1
,
isEvent
:
1
,
'event.eventStartTime'
:
{
$lte
:
today
}
'event.eventStartTime'
:
{
$lte
:
today
}
}]
}]
...
...
app/utils/util.js
View file @
0fb26aa0
'use strict'
;
'use strict'
;
var
_
=
require
(
'lodash'
);
var
_
=
require
(
'lodash'
);
var
request
=
require
(
'request'
);
var
loadUserLevel
=
require
(
'./loadUserLevel'
);
var
env
=
process
.
env
.
NODE_ENV
;
var
async
=
require
(
'async'
);
var
API_ADDRESS
=
'http://localhost:8080'
;
if
(
env
==
'sandbox'
)
{
API_ADDRESS
=
'http://rest.wxpai.cn'
;
}
else
if
(
env
==
'production'
)
{
API_ADDRESS
=
'https://rest.wxpai.cn'
;
}
exports
.
loadLevel
=
function
(
ent_code
,
items
,
callback
){
exports
.
loadLevel
=
function
(
ent_code
,
items
,
callback
){
var
openIds
=
[];
var
openIds
=
[];
...
@@ -30,33 +24,35 @@ exports.loadLevel=function(ent_code,items,callback){
...
@@ -30,33 +24,35 @@ exports.loadLevel=function(ent_code,items,callback){
}
}
});
});
request
.
post
({
var
tasks
=
[];
url
:
API_ADDRESS
+
'/v1.0/internal/member/list/byopenids'
,
_
.
forEach
(
openIds
,
function
(
open_id
)
{
json
:
{
tasks
.
push
(
function
(
cont
)
{
"entCode"
:
ent_code
,
loadUserLevel
.
loadLevelFromAPI
(
ent_code
,
open_id
,
cont
);
"openIds"
:
openIds
});
}
});
},
function
(
e
,
r
,
body
)
{
async
.
parallel
(
tasks
,
function
(
err
,
results
)
{
if
(
body
&&
body
.
data
)
{
if
(
results
&&
results
.
length
>
0
)
{
//results: [{'egwegweg':1},{'gergergerg':3}]
_
.
forEach
(
items
,
function
(
d
,
i
)
{
_
.
forEach
(
items
,
function
(
d
,
i
)
{
if
(
items
[
i
].
toObject
)
{
if
(
items
[
i
].
toObject
)
{
items
[
i
]
=
items
[
i
].
toObject
();
items
[
i
]
=
items
[
i
].
toObject
();
}
}
_
.
forEach
(
body
.
data
,
function
(
r
,
j
)
{
_
.
forEach
(
results
,
function
(
r
,
j
)
{
if
(
d
.
from
&&
d
.
from
.
uid
===
r
.
user
.
openId
){
if
(
r
){
items
[
i
].
from
.
exp
=
r
.
exp
;
if
(
d
.
from
&&
d
.
from
.
uid
&&
r
[
d
.
from
.
uid
]){
}
items
[
i
].
from
.
exp
=
r
[
d
.
from
.
uid
];
if
(
d
.
to
&&
d
.
to
.
uid
===
r
.
user
.
openId
){
}
items
[
i
].
to
.
exp
=
r
.
exp
;
if
(
d
.
to
&&
d
.
to
.
uid
&&
r
[
d
.
to
.
uid
]){
}
items
[
i
].
to
.
exp
=
r
[
d
.
to
.
uid
];
if
(
d
.
commentLevel1From
&&
d
.
commentLevel1From
.
uid
===
r
.
user
.
openId
){
}
items
[
i
].
commentLevel1From
.
exp
=
r
.
exp
;
if
(
d
.
commentLevel1From
&&
d
.
commentLevel1From
.
uid
&&
r
[
d
.
commentLevel1From
.
uid
]){
}
items
[
i
].
commentLevel1From
.
exp
=
r
[
d
.
commentLevel1From
.
uid
];
if
(
d
.
commentLevel2From
&&
d
.
commentLevel2From
.
uid
===
r
.
user
.
openId
){
}
items
[
i
].
commentLevel2From
.
exp
=
r
.
exp
;
if
(
d
.
commentLevel2From
&&
d
.
commentLevel2From
.
uid
&&
r
[
d
.
commentLevel2From
.
uid
]){
}
items
[
i
].
commentLevel2From
.
exp
=
r
[
d
.
commentLevel2From
.
uid
];
if
(
d
.
commentLevel2ThreadFrom
&&
d
.
commentLevel2ThreadFrom
.
uid
===
r
.
user
.
openId
){
}
items
[
i
].
commentLevel2ThreadFrom
.
exp
=
r
.
exp
;
if
(
d
.
commentLevel2ThreadFrom
&&
d
.
commentLevel2ThreadFrom
.
uid
&&
r
[
d
.
commentLevel2ThreadFrom
.
uid
]){
items
[
i
].
commentLevel2ThreadFrom
.
exp
=
r
[
d
.
commentLevel2ThreadFrom
.
uid
];
}
}
}
});
});
...
@@ -88,22 +84,23 @@ exports.loadLevelByUser=function(ent_code,items,callback){
...
@@ -88,22 +84,23 @@ exports.loadLevelByUser=function(ent_code,items,callback){
openIds
.
push
(
d
.
uid
);
openIds
.
push
(
d
.
uid
);
}
}
});
});
var
tasks
=
[];
request
.
post
({
_
.
forEach
(
openIds
,
function
(
open_id
)
{
url
:
API_ADDRESS
+
'/v1.0/internal/member/list/byopenids'
,
tasks
.
push
(
function
(
cont
){
json
:
{
loadUserLevel
.
loadLevelFromAPI
(
ent_code
,
open_id
,
cont
);
"entCode"
:
ent_code
,
});
"openIds"
:
openIds
});
}
async
.
parallel
(
tasks
,
function
(
err
,
results
){
},
function
(
e
,
r
,
body
)
{
if
(
results
&&
results
.
length
>
0
)
{
//results: [{'egwegweg':1},{'gergergerg':3}]
if
(
body
&&
body
.
data
)
{
_
.
forEach
(
items
,
function
(
d
,
i
)
{
_
.
forEach
(
items
,
function
(
d
,
i
)
{
if
(
items
[
i
].
toObject
)
{
if
(
items
[
i
].
toObject
)
{
items
[
i
]
=
items
[
i
].
toObject
();
items
[
i
]
=
items
[
i
].
toObject
();
}
}
_
.
forEach
(
body
.
data
,
function
(
r
,
j
)
{
_
.
forEach
(
results
,
function
(
r
)
{
if
(
d
.
uid
===
r
.
user
.
openId
){
if
(
r
){
items
[
i
].
exp
=
r
.
exp
;
if
(
d
.
uid
&&
r
[
d
.
uid
]){
items
[
i
].
exp
=
r
[
d
.
uid
];
}
}
}
});
});
...
...
config/cacheConfig.js
0 → 100644
View file @
0fb26aa0
var
cache
=
require
(
'./../app/utils/cacheable'
);
var
forumAboutMEService
=
require
(
'./../app/service/forumAboutMEService'
);
var
loadUserLevel
=
require
(
'./../app/utils/loadUserLevel'
);
//cache.cacheable(forumAboutMEService, 'me2other', { ns: 'forum.service.forumAboutMEService.me2other', dur: 60 * 10 });
cache
.
cacheable
(
loadUserLevel
,
'loadLevelFromAPI'
,
{
ns
:
'forum.utils.loadUserLevel.loadLevelFromAPI'
,
dur
:
60
*
60
});
//cache.clear(service1,'method1','forum.service.service1.method1')
\ 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