Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
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
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
1279b1f1
Commit
1279b1f1
authored
Nov 24, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
needinfo-sub_status
parent
f5e8b9b0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
36 deletions
+84
-36
gsb-marketplat/app/base/api/api.base.js
+1
-1
gsb-marketplat/app/base/api/impl/action/template.js
+4
-4
gsb-marketplat/app/base/db/models/media/needinfo.js
+3
-1
gsb-marketplat/app/base/service/impl/media/needinfoSve.js
+57
-10
gsb-marketplat/app/base/service/impl/template/templatelinkSve.js
+19
-20
No files found.
gsb-marketplat/app/base/api/api.base.js
View file @
1279b1f1
...
@@ -59,7 +59,7 @@ class APIBase {
...
@@ -59,7 +59,7 @@ class APIBase {
this
.
logClient
.
log
(
pobj
,
req
,
rtn
);
this
.
logClient
.
log
(
pobj
,
req
,
rtn
);
if
(
rtn
&&
rtn
.
status
===
0
){
if
(
rtn
&&
rtn
.
status
===
0
){
//保存缓存
//保存缓存
await
this
.
redisClient
.
setWithEx
(
shaStr
,
JSON
.
stringify
(
rtn
),
30
);
//
await this.redisClient.setWithEx(shaStr, JSON.stringify(rtn), 30);
}
}
return
rtn
;
return
rtn
;
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
gsb-marketplat/app/base/api/impl/action/template.js
View file @
1279b1f1
...
@@ -64,22 +64,22 @@ class Template extends APIBase {
...
@@ -64,22 +64,22 @@ class Template extends APIBase {
if
(
this
.
formCache
[
shaStr
]){
if
(
this
.
formCache
[
shaStr
]){
rtn
=
this
.
formCache
[
shaStr
];
rtn
=
this
.
formCache
[
shaStr
];
}
else
{
}
else
{
rtn
=
await
this
.
redisClient
.
get
(
shaStr
);
// 先试图从redis读取数据
rtn
=
await
this
.
redisClient
.
get
(
shaStr
);
// 先试图从redis读取数据
if
(
rtn
){
if
(
rtn
){
this
.
formCache
[
shaStr
]
=
rtn
;
this
.
formCache
[
shaStr
]
=
rtn
;
}
}
}
}
//---- 从redis中读取到数据
//---- 从redis中读取到数据
if
(
rtn
)
{
if
(
rtn
)
{
var
rtnObj
=
JSON
.
parse
(
rtn
);
var
rtnObj
=
JSON
.
parse
(
rtn
);
return
system
.
getResult
(
rtnObj
);
return
system
.
getResult
(
rtnObj
);
}
else
{
}
else
{
let
result
=
await
this
.
forminfoSve
.
findOne
({
id
:
pobj
.
id
},[]);
let
result
=
await
this
.
forminfoSve
.
findOne
({
id
:
pobj
.
id
},[]);
// 将数据保存到redis中
// 将数据保存到redis中
await
this
.
redisClient
.
set
(
shaStr
,
JSON
.
stringify
(
result
));
await
this
.
redisClient
.
set
(
shaStr
,
JSON
.
stringify
(
result
));
this
.
formCache
[
shaStr
]
=
JSON
.
stringify
(
result
);
//
this.formCache[shaStr] = JSON.stringify(result);
return
system
.
getResult
(
result
);
return
system
.
getResult
(
result
);
}
}
}
}
//删除表单缓存
//删除表单缓存
async
delTemplateFormCache
(
key
){
async
delTemplateFormCache
(
key
){
...
...
gsb-marketplat/app/base/db/models/media/needinfo.js
View file @
1279b1f1
...
@@ -28,7 +28,9 @@ module.exports = (db, DataTypes) => {
...
@@ -28,7 +28,9 @@ module.exports = (db, DataTypes) => {
region
:
DataTypes
.
STRING
,
//地区
region
:
DataTypes
.
STRING
,
//地区
business_id
:
DataTypes
.
STRING
,
//云服产品id
business_id
:
DataTypes
.
STRING
,
//云服产品id
push_status
:
DataTypes
.
INTEGER
,
push_status
:
DataTypes
.
INTEGER
,
notes
:
DataTypes
.
STRING
sub_status
:
DataTypes
.
INTEGER
,
notes
:
DataTypes
.
STRING
,
sub_notes
:
DataTypes
.
STRING
},
{
},
{
paranoid
:
true
,
//假的删除
paranoid
:
true
,
//假的删除
underscored
:
true
,
underscored
:
true
,
...
...
gsb-marketplat/app/base/service/impl/media/needinfoSve.js
View file @
1279b1f1
...
@@ -20,42 +20,89 @@ class NeedinfoService extends ServiceBase {
...
@@ -20,42 +20,89 @@ class NeedinfoService extends ServiceBase {
return
res
;
return
res
;
}
}
var
createRes
=
await
this
.
dao
.
create
(
res
);
var
createRes
=
await
this
.
dao
.
create
(
res
);
this
.
pushMediaNeed2Queue
(
createRes
.
id
);
//
this.pushMediaNeed2Queue(createRes.id);
return
system
.
getResultSuccess
();
return
system
.
getResultSuccess
();
}
}
// //校验封装参数
// async checkAndPackageSubmitParams(ab){
// if(!ab.submit_type){
// return system.getResultFail(-101,"提交方式不能为空!")
// }else if(ab.submit_type!="1" && ab.submit_type!="2"){
// return system.getResultFail(-102,"提交方式参数错误!")
// }
// if(!ab.channel_code){
// return system.getResultFail(-103,"渠道编码不能为空!")
// }
// if(!ab.page_code){
// return system.getResultFail(-104,"页面编码不能为空!")
// }
// if(!ab.page_name){
// return system.getResultFail(-105,"页面名称不能为空!")
// }
// if(!ab.original_need){
// return system.getResultFail(-106,"需求信息不能为空!")
// }
// if(!ab.contact_mobile){
// return system.getResultFail(-107,"联系电话不能为空!")
// }
// var reg =/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(14[0-9]{1})|)+\d{8})$/;
// if(ab.contact_mobile.length!=11){
// return system.getResultFail(-108,"联系电话格式错误!")
// }
// var channel = await this.launchchannelDao.model.findOne({
// attributes:["code","name","only_code"],
// where:{code:ab.channel_code},raw:true
// });
// if(!channel || !channel.code){
// return system.getResultFail(-300,"渠道信息不存在")
// }
// ab["channel_name"] = channel.name;
// ab["channel_only_code"] = channel.only_code || "";
// return ab;
// }
//校验封装参数
//校验封装参数
async
checkAndPackageSubmitParams
(
ab
){
async
checkAndPackageSubmitParams
(
ab
){
ab
.
sub_status
=
1
;
if
(
!
ab
.
submit_type
){
if
(
!
ab
.
submit_type
){
return
system
.
getResultFail
(
-
101
,
"提交方式不能为空!"
)
ab
.
sub_status
=
2
;
ab
.
sub_notes
=
"提交方式不能为空!"
;
}
else
if
(
ab
.
submit_type
!=
"1"
&&
ab
.
submit_type
!=
"2"
){
}
else
if
(
ab
.
submit_type
!=
"1"
&&
ab
.
submit_type
!=
"2"
){
return
system
.
getResultFail
(
-
102
,
"提交方式参数错误!"
)
ab
.
sub_status
=
2
;
ab
.
sub_notes
=
"提交方式参数错误!submit_type="
+
ab
.
submit_type
;
}
}
if
(
!
ab
.
channel_code
){
if
(
!
ab
.
channel_code
){
return
system
.
getResultFail
(
-
103
,
"渠道编码不能为空!"
)
ab
.
sub_status
=
2
;
ab
.
sub_notes
=
"渠道编码不能为空!"
;
}
}
if
(
!
ab
.
page_code
){
if
(
!
ab
.
page_code
){
return
system
.
getResultFail
(
-
104
,
"页面编码不能为空!"
)
ab
.
sub_status
=
2
;
ab
.
sub_notes
=
"页面编码不能为空!"
;
}
}
if
(
!
ab
.
page_name
){
if
(
!
ab
.
page_name
){
return
system
.
getResultFail
(
-
105
,
"页面名称不能为空!"
)
ab
.
sub_status
=
2
;
ab
.
sub_notes
=
"页面名称不能为空!"
;
}
}
if
(
!
ab
.
original_need
){
if
(
!
ab
.
original_need
){
return
system
.
getResultFail
(
-
106
,
"需求信息不能为空!"
)
ab
.
sub_status
=
2
;
ab
.
sub_notes
=
"需求信息不能为空!"
;
}
}
if
(
!
ab
.
contact_mobile
){
if
(
!
ab
.
contact_mobile
){
return
system
.
getResultFail
(
-
107
,
"联系电话不能为空!"
)
ab
.
sub_status
=
2
;
ab
.
sub_notes
=
"联系电话不能为空!"
;
}
}
var
reg
=
/^
(((
13
[
0-9
]{1})
|
(
15
[
0-9
]{1})
|
(
18
[
0-9
]{1})
|
(
14
[
0-9
]{1})
|
)
+
\d{8})
$/
;
var
reg
=
/^
(((
13
[
0-9
]{1})
|
(
15
[
0-9
]{1})
|
(
18
[
0-9
]{1})
|
(
14
[
0-9
]{1})
|
)
+
\d{8})
$/
;
if
(
ab
.
contact_mobile
.
length
!=
11
){
if
(
ab
.
contact_mobile
.
length
!=
11
){
return
system
.
getResultFail
(
-
108
,
"联系电话格式错误!"
)
ab
.
sub_status
=
2
;
ab
.
sub_notes
=
"联系电话格式错误!contact_mobile="
+
ab
.
contact_mobile
;
}
}
var
channel
=
await
this
.
launchchannelDao
.
model
.
findOne
({
var
channel
=
await
this
.
launchchannelDao
.
model
.
findOne
({
attributes
:[
"code"
,
"name"
,
"only_code"
],
attributes
:[
"code"
,
"name"
,
"only_code"
],
where
:{
code
:
ab
.
channel_code
},
raw
:
true
where
:{
code
:
ab
.
channel_code
},
raw
:
true
});
});
if
(
!
channel
||
!
channel
.
code
){
if
(
!
channel
||
!
channel
.
code
){
return
system
.
getResultFail
(
-
300
,
"渠道信息不存在"
)
ab
.
sub_status
=
2
;
ab
.
sub_notes
=
"渠道信息不存在"
;
}
}
ab
[
"channel_name"
]
=
channel
.
name
;
ab
[
"channel_name"
]
=
channel
.
name
;
ab
[
"channel_only_code"
]
=
channel
.
only_code
||
""
;
ab
[
"channel_only_code"
]
=
channel
.
only_code
||
""
;
...
...
gsb-marketplat/app/base/service/impl/template/templatelinkSve.js
View file @
1279b1f1
...
@@ -18,7 +18,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -18,7 +18,7 @@ class TemplatelinkService extends ServiceBase {
}
}
/**
/**
* 获取模板链接配置参数
* 获取模板链接配置参数
* @param {*} pobj
* @param {*} pobj
*/
*/
async
getLinkConfigParams
(
pobj
){
async
getLinkConfigParams
(
pobj
){
var
ab
=
pobj
.
actionBody
;
var
ab
=
pobj
.
actionBody
;
...
@@ -46,7 +46,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -46,7 +46,7 @@ class TemplatelinkService extends ServiceBase {
}
}
/**
/**
* 链接列表
* 链接列表
* @param {*} obj
* @param {*} obj
*/
*/
async
findAndCountAll
(
obj
){
async
findAndCountAll
(
obj
){
if
(
!
obj
||
!
obj
.
search
||
!
obj
.
search
.
template_id
){
if
(
!
obj
||
!
obj
.
search
||
!
obj
.
search
.
template_id
){
...
@@ -57,8 +57,8 @@ class TemplatelinkService extends ServiceBase {
...
@@ -57,8 +57,8 @@ class TemplatelinkService extends ServiceBase {
}
}
/**
/**
* 校验封装参数
* 校验封装参数
* @param {*} ab
* @param {*} ab
* @param {*} xctx
* @param {*} xctx
*/
*/
async
checkAndPackageParams
(
ab
,
xctx
){
async
checkAndPackageParams
(
ab
,
xctx
){
var
codeParams
=
{};
var
codeParams
=
{};
...
@@ -156,7 +156,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -156,7 +156,7 @@ class TemplatelinkService extends ServiceBase {
/**
/**
* 创建模板链接数据
* 创建模板链接数据
* @param {*} pobj
* @param {*} pobj
*/
*/
async
createTemplateLink
(
pobj
){
async
createTemplateLink
(
pobj
){
var
ab
=
pobj
;
var
ab
=
pobj
;
...
@@ -175,7 +175,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -175,7 +175,7 @@ class TemplatelinkService extends ServiceBase {
/**
/**
* 修改模板链接
* 修改模板链接
* @param {*} pobj
* @param {*} pobj
*/
*/
async
editTemplateLink
(
pobj
){
async
editTemplateLink
(
pobj
){
var
ab
=
pobj
.
actionBody
;
var
ab
=
pobj
.
actionBody
;
...
@@ -200,7 +200,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -200,7 +200,7 @@ class TemplatelinkService extends ServiceBase {
/**
/**
* 获取模板链接详情数据
* 获取模板链接详情数据
* @param {*} pobj
* @param {*} pobj
*/
*/
async
findOneByCode
(
pobj
){
async
findOneByCode
(
pobj
){
var
ab
=
pobj
.
actionBody
;
var
ab
=
pobj
.
actionBody
;
...
@@ -219,7 +219,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -219,7 +219,7 @@ class TemplatelinkService extends ServiceBase {
/**
/**
* 修改投放状态
* 修改投放状态
* @param {*} pobj
* @param {*} pobj
*/
*/
async
updateLaunchStatus
(
pobj
){
async
updateLaunchStatus
(
pobj
){
var
ab
=
pobj
;
var
ab
=
pobj
;
...
@@ -235,7 +235,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -235,7 +235,7 @@ class TemplatelinkService extends ServiceBase {
if
(
ab
.
is_enabled
!==
0
&&
ab
.
is_enabled
!==
1
){
if
(
ab
.
is_enabled
!==
0
&&
ab
.
is_enabled
!==
1
){
return
system
.
getResultFail
(
-
103
,
"投放状态参数错误"
);
return
system
.
getResultFail
(
-
103
,
"投放状态参数错误"
);
}
}
var
linkinfo
=
await
this
.
dao
.
model
.
findOne
({
var
linkinfo
=
await
this
.
dao
.
model
.
findOne
({
where
:{
code
:
ab
.
code
},
raw
:
true
where
:{
code
:
ab
.
code
},
raw
:
true
});
});
...
@@ -259,7 +259,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -259,7 +259,7 @@ class TemplatelinkService extends ServiceBase {
}
}
/**
/**
* 删除模板链接
* 删除模板链接
* @param {*} pobj
* @param {*} pobj
*/
*/
async
deleteTemplateLink
(
pobj
){
async
deleteTemplateLink
(
pobj
){
var
ab
=
pobj
;
var
ab
=
pobj
;
...
@@ -384,7 +384,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -384,7 +384,7 @@ class TemplatelinkService extends ServiceBase {
return
system
.
getResultSuccess
();
return
system
.
getResultSuccess
();
}
}
async
getTemplateAndLinkInfo2
(
pobj
){
async
getTemplateAndLinkInfo2
(
pobj
){
let
ab
=
pobj
.
actionBody
;
let
ab
=
pobj
.
actionBody
;
// 校验传入的参数
// 校验传入的参数
...
@@ -433,15 +433,15 @@ class TemplatelinkService extends ServiceBase {
...
@@ -433,15 +433,15 @@ class TemplatelinkService extends ServiceBase {
shaStr
=
await
sha256
(
JSON
.
stringify
(
linkObj
));
shaStr
=
await
sha256
(
JSON
.
stringify
(
linkObj
));
shaStr
=
"templink_"
+
ab
.
template_id
+
"_"
+
shaStr
;
shaStr
=
"templink_"
+
ab
.
template_id
+
"_"
+
shaStr
;
if
(
this
.
templateLinkInfoCache
[
shaStr
]){
if
(
this
.
templateLinkInfoCache
[
shaStr
]){
rtn
=
this
.
templateLinkInfoCache
[
shaStr
];
//从内存缓存读取数据
rtn
=
this
.
templateLinkInfoCache
[
shaStr
];
//从内存缓存读取数据
}
else
{
}
else
{
rtn
=
await
this
.
redisClient
.
get
(
shaStr
);
//从redis读取数据
rtn
=
await
this
.
redisClient
.
get
(
shaStr
);
//从redis读取数据
if
(
rtn
){
if
(
rtn
){
this
.
templateLinkInfoCache
[
shaStr
]
=
rtn
;
this
.
templateLinkInfoCache
[
shaStr
]
=
rtn
;
}
}
}
}
//---- 从redis中读取到数据
//---- 从redis中读取到数据
if
(
rtn
)
{
if
(
rtn
)
{
rtnObj
=
JSON
.
parse
(
rtn
);
rtnObj
=
JSON
.
parse
(
rtn
);
linkinfo
=
rtnObj
[
"linkinfo"
];
linkinfo
=
rtnObj
[
"linkinfo"
];
}
else
{
}
else
{
...
@@ -461,7 +461,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -461,7 +461,7 @@ class TemplatelinkService extends ServiceBase {
return
system
.
getResultFail
(
-
300
,
"未知链接或该链接未投放"
);
return
system
.
getResultFail
(
-
300
,
"未知链接或该链接未投放"
);
}
}
// 模板链接存在,获取模板信息
// 模板链接存在,获取模板信息
let
tempObj
=
{
id
:
ab
.
template_id
,
is_enabled
:
1
,};
// 用于查询templateinfo的条件
let
tempObj
=
{
id
:
ab
.
template_id
,
is_enabled
:
1
,};
// 用于查询templateinfo的条件
let
templateinfo
=
await
this
.
templateinfoDao
.
model
.
findOne
({
// 查询结果
let
templateinfo
=
await
this
.
templateinfoDao
.
model
.
findOne
({
// 查询结果
attributes
:[
"title"
,
"keyword"
,
"describe"
,
"pic_url"
,
"template_content"
],
attributes
:[
"title"
,
"keyword"
,
"describe"
,
"pic_url"
,
"template_content"
],
...
@@ -475,7 +475,7 @@ class TemplatelinkService extends ServiceBase {
...
@@ -475,7 +475,7 @@ class TemplatelinkService extends ServiceBase {
linkinfo
linkinfo
};
};
//将数据保存
//将数据保存
this
.
templateLinkInfoCache
[
shaStr
]
=
JSON
.
stringify
(
rtnObj
);
//
this.templateLinkInfoCache[shaStr] = JSON.stringify(rtnObj);
// 将数据保存到redis中
// 将数据保存到redis中
await
this
.
redisClient
.
set
(
shaStr
,
JSON
.
stringify
(
rtnObj
));
await
this
.
redisClient
.
set
(
shaStr
,
JSON
.
stringify
(
rtnObj
));
// await this.redisClient.setWithEx(shaStr, JSON.stringify(rtnObj), 60); // 保存的同时设置过期时间
// await this.redisClient.setWithEx(shaStr, JSON.stringify(rtnObj), 60); // 保存的同时设置过期时间
...
@@ -501,10 +501,10 @@ class TemplatelinkService extends ServiceBase {
...
@@ -501,10 +501,10 @@ class TemplatelinkService extends ServiceBase {
// var localeDateString = date .toLocaleDateString();
// var localeDateString = date .toLocaleDateString();
// var haStr = await sha256(JSON.stringify(addObj));
// var haStr = await sha256(JSON.stringify(addObj));
// shaStr = "browsingrecords_"+localeDateString+"_"+shaStr;
// shaStr = "browsingrecords_"+localeDateString+"_"+shaStr;
// var rtn = await this.redisClient.get(shaStr);//从redis读取数据
// var rtn = await this.redisClient.get(shaStr);//从redis读取数据
// if(!rtn){
// if(!rtn){
// await this.browsingrecordsDao.create(addObj);//添加链接浏览记录
// await this.browsingrecordsDao.create(addObj);//添加链接浏览记录
// this.redisClient.set(shaStr,JSON.stringify(addObj));//从redis读取数据
// this.redisClient.set(shaStr,JSON.stringify(addObj));//从redis读取数据
// }
// }
//await this.browsingrecordsDao.create(addObj);//添加链接浏览记录
//await this.browsingrecordsDao.create(addObj);//添加链接浏览记录
...
@@ -562,4 +562,4 @@ class TemplatelinkService extends ServiceBase {
...
@@ -562,4 +562,4 @@ class TemplatelinkService extends ServiceBase {
}
}
}
}
module
.
exports
=
TemplatelinkService
;
module
.
exports
=
TemplatelinkService
;
\ 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