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
03e05b77
Commit
03e05b77
authored
Apr 15, 2015
by
邓军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.增加分享默认配置功能
2.微信分享接口调整
parent
ea1dfe8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
144 additions
and
53 deletions
+144
-53
forumShare.js
app/controllers/mobile/forumShare.js
+55
-25
forumShareConfig.js
app/controllers/mobile/forumShareConfig.js
+60
-0
forumShareConfigService.js
app/service/forumShareConfigService.js
+29
-28
No files found.
app/controllers/mobile/forumShare.js
View file @
03e05b77
...
@@ -13,7 +13,7 @@ var then = require('thenjs');
...
@@ -13,7 +13,7 @@ var then = require('thenjs');
//var forumInfoService = require('../../service/forumInfoService');
//var forumInfoService = require('../../service/forumInfoService');
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/forum
S
hare'
,
router
);
app
.
use
(
'/forum
/s
hare'
,
router
);
};
};
function
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
)
{
function
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
)
{
...
@@ -44,29 +44,35 @@ router.get('/:ent_code/share.js', function(req, res, next) {
...
@@ -44,29 +44,35 @@ router.get('/:ent_code/share.js', function(req, res, next) {
var
rs
=
{};
var
rs
=
{};
var
type
=
req
.
query
.
type
;
var
type
=
req
.
query
.
type
;
var
id
=
req
.
query
.
id
;
var
id
=
req
.
query
.
id
;
var
mid
=
req
.
session
.
openUser
.
mid
||
0
;
var
mid
=
0
;
if
(
req
.
session
.
openUser
&&
req
.
session
.
openUser
.
mid
)
{
mid
=
req
.
session
.
openUser
.
mid
;
}
var
ent_code
=
req
.
params
.
ent_code
;
var
ent_code
=
req
.
params
.
ent_code
;
var
link
=
'/app/forum/'
+
ent_code
+
'/index?pageUrl='
;
var
link
=
'/app/forum/'
+
ent_code
+
'/index?pageUrl='
;
if
(
type
)
{
if
(
type
)
{
//板块微信接口
//板块微信接口
if
(
type
===
'Info'
)
{
if
(
type
===
'Info'
)
{
then
(
function
(
cont
)
{
then
(
function
(
cont
)
{
forumShareConfigService
.
getBy
EntCode
(
ent_code
,
function
(
err
,
result
)
{
forumShareConfigService
.
getBy
Key
(
ent_code
,
'share'
,
function
(
err
,
result
)
{
var
title
=
''
,
var
title
=
''
,
desc
=
''
,
desc
=
''
,
imgUrl
=
''
;
imgUrl
=
''
;
if
(
result
)
{
if
(
result
)
{
result
=
result
.
meta_value
;
for
(
var
i
=
0
;
i
<
result
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
result
.
length
;
i
++
)
{
if
(
result
[
i
].
meta_key
===
'share_info_title'
)
{
if
(
result
[
i
].
type
===
'info'
)
{
title
=
result
[
i
].
meta_value
;
title
=
result
[
i
].
title
;
}
else
if
(
result
[
i
].
meta_key
===
'share_info_description'
)
{
desc
=
result
[
i
].
desc
;
desc
=
result
[
i
].
meta_value
;
imgUrl
=
result
[
i
].
imgUrl
;
}
else
if
(
result
[
i
].
meta_key
===
'share_info_icon'
)
{
imgUrl
=
result
[
i
].
meta_value
;
}
}
}
}
link
=
link
+
'index&infoId='
+
id
;
if
(
id
)
{
link
=
link
+
'index&infoId='
+
id
;
}
else
{
link
=
link
+
'index'
;
}
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
}
else
{
}
else
{
cont
(
err
);
cont
(
err
);
...
@@ -100,36 +106,60 @@ router.get('/:ent_code/share.js', function(req, res, next) {
...
@@ -100,36 +106,60 @@ router.get('/:ent_code/share.js', function(req, res, next) {
//如果没有share值则用默认值
//如果没有share值则用默认值
if
(
!
result
.
share
)
{
if
(
!
result
.
share
)
{
forumShareConfigService
.
getBy
EntCode
(
ent_code
,
function
(
err
,
sc
)
{
forumShareConfigService
.
getBy
Key
(
ent_code
,
'share'
,
function
(
err
,
sc
)
{
var
title
=
''
,
var
title
=
''
,
desc
=
''
,
desc
=
''
,
imgUrl
=
''
;
imgUrl
=
''
;
if
(
sc
)
{
if
(
sc
)
{
var
key
=
''
;
//1、文章 2、话题 3、照片墙
if
(
result
.
type
===
1
||
(
result
.
type
===
2
&&
result
.
level
===
2
))
{
if
(
result
.
type
===
1
||
(
result
.
type
===
2
&&
result
.
level
===
2
))
{
link
=
link
+
'thread&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
link
=
link
+
'thread&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
key
=
'article'
;
}
else
if
(
result
.
type
===
2
&&
result
.
level
===
1
)
{
}
else
if
(
result
.
type
===
2
&&
result
.
level
===
1
)
{
link
=
link
+
'topicList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
link
=
link
+
'topicList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
key
=
'topic'
;
}
else
if
(
result
.
type
===
3
)
{
}
else
if
(
result
.
type
===
3
)
{
link
=
link
+
'photoList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
link
=
link
+
'photoList&infoId='
+
result
.
info
+
'&ent_code='
+
ent_code
+
'&id='
+
result
.
_id
;
key
=
'photo'
;
}
}
//1、文章 2、话题 3、照片墙
sc
=
sc
.
meta_value
;
for
(
var
i
=
0
;
i
<
sc
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
sc
.
length
;
i
++
)
{
if
(
sc
[
i
].
meta_key
===
'share_'
+
key
+
'_title'
)
{
title
=
sc
[
i
].
meta_value
;
if
(
result
.
type
===
1
||
(
result
.
type
===
2
&&
result
.
level
===
2
))
{
}
else
if
(
sc
[
i
].
meta_key
===
'share_'
+
key
+
'_description'
)
{
console
.
log
(
'article'
);
desc
=
sc
[
i
].
meta_value
;
if
(
sc
[
i
].
type
===
'article'
)
{
}
else
if
(
sc
[
i
].
meta_key
===
'share_'
+
key
+
'_icon'
)
{
console
.
log
(
sc
[
i
]);
imgUrl
=
sc
[
i
].
meta_value
;
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
imgUrl
=
sc
[
i
].
imgUrl
;
}
}
else
if
(
result
.
type
===
2
&&
result
.
level
===
1
)
{
if
(
sc
[
i
].
type
===
'topic'
)
{
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
imgUrl
=
sc
[
i
].
imgUrl
;
}
}
else
if
(
result
.
type
===
3
)
{
console
.
log
(
'photo'
);
if
(
sc
[
i
].
type
===
'photo'
)
{
title
=
sc
[
i
].
title
;
desc
=
sc
[
i
].
desc
;
imgUrl
=
sc
[
i
].
imgUrl
;
}
}
}
}
}
console
.
log
(
result
.
type
+
':'
+
result
.
level
);
console
.
log
(
title
+
':'
+
desc
+
'imgUrl'
);
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
getWX
(
res
,
title
,
desc
,
link
,
imgUrl
,
mid
);
}
else
{
}
else
{
cont
(
err
);
cont
(
err
);
...
...
app/controllers/mobile/forumShareConfig.js
0 → 100644
View file @
03e05b77
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
//var forumThreadService = require('../../service/forumThreadService');
var
forumShareConfigService
=
require
(
'../../service/forumShareConfigService'
);
//var forumShareService = require('../../service/forumShareService');
//var config = require('../../../config/config');
var
then
=
require
(
'thenjs'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
//type:类型(板块,照片墙等); key:类型里面的标题(title,desc等);value:值
function
getForumConfig
(
key
,
value
,
ent_code
)
{
var
forumConfig
=
{};
forumConfig
.
meta_key
=
key
;
forumConfig
.
meta_value
=
value
;
forumConfig
.
ent_code
=
ent_code
;
return
forumConfig
;
}
//批量创建默认分享设置
router
.
post
(
'/forumConfig/put'
,
function
(
req
,
res
,
next
)
{
var
model
=
req
.
body
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
model
.
ent_code
=
ent_code
;
if
(
model
.
ent_code
)
{
forumShareConfigService
.
create
(
model
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
}
else
{
res
.
json
(
returnCode
.
BUSY
);
}
});
//初始化默认分享数据
router
.
get
(
'/forumConfig/getConfig'
,
function
(
req
,
res
,
next
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
forumShareConfigService
.
getByKey
(
ent_code
,
req
.
query
.
meta_key
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
({
message
:
'success'
,
data
:
result
});
}
});
});
app/service/forumShareConfigService.js
View file @
03e05b77
...
@@ -8,40 +8,41 @@ var then = require('thenjs');
...
@@ -8,40 +8,41 @@ var then = require('thenjs');
exports
.
create
=
function
(
entity
,
callback
)
{
exports
.
create
=
function
(
entity
,
callback
)
{
var
forumShareConfig
=
new
ForumShareConfig
(
entity
);
var
forumShareConfig
=
new
ForumShareConfig
(
entity
);
ForumShareConfig
.
findOne
({
then
(
function
(
cont
)
{
meta_key
:
entity
.
meta_key
ForumShareConfig
.
find
({
},
function
(
err
,
result
)
{
ent_code
:
entity
.
ent_code
,
var
meta_value
=
result
.
meta_value
;
meta_key
:
entity
.
meta_key
for
(
var
i
=
0
;
i
<
meta_value
.
length
;
i
+=
1
)
{
}).
exec
(
cont
);
for
(
var
j
=
0
;
j
<
entity
.
meta_value
.
length
;
j
+=
1
)
{
}).
then
(
function
(
cont
,
config
)
{
if
(
meta_value
[
i
].
type
===
entity
.
meta_value
[
j
].
type
)
{
if
(
config
.
length
>
0
)
{
//更新
}
ForumShareConfig
.
update
({
}
meta_key
:
entity
.
meta_key
,
}
ent_code
:
entity
.
ent_code
if
(
result
)
{
},
{
forumShareConfig
.
update
({
meta_value
:
entity
.
meta_value
meta_key
:
entity
.
meta_key
},
{
},
entity
,
null
,
function
(
err
,
result
)
{
multi
:
false
console
.
log
(
result
);
},
if
(
err
)
{
function
(
affected
,
result
)
{
console
.
error
(
err
);
cont
(
null
,
result
);
callback
(
err
,
null
);
});
}
else
{
callback
(
null
,
result
);
}
});
}
else
{
}
else
{
//增加
forumShareConfig
.
save
(
function
(
err
,
result
)
{
forumShareConfig
.
save
(
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
cont
(
err
);
callback
(
err
,
null
);
}
else
{
}
else
{
c
allback
(
null
,
result
);
c
ont
(
null
,
result
);
}
}
})
})
;
}
}
})
}).
then
(
function
(
cont
,
result
)
{
callback
(
null
,
result
);
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
callback
(
err
,
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