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
5c98671d
Commit
5c98671d
authored
Aug 07, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
link
parent
e1629844
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
343 additions
and
1 deletions
+343
-1
gsb-marketplat/app/base/api/impl/action/template.js
+1
-0
gsb-marketplat/app/base/api/impl/action/templatelink.js
+57
-0
gsb-marketplat/app/base/db/impl/template/templateinfoDao.js
+14
-0
gsb-marketplat/app/base/db/impl/template/templatelinkDao.js
+15
-0
gsb-marketplat/app/base/db/models/template/templatelink.js
+74
-0
gsb-marketplat/app/base/service/impl/template/templateinfoSve.js
+4
-1
gsb-marketplat/app/base/service/impl/template/templatelinkSve.js
+178
-0
No files found.
gsb-marketplat/app/base/api/impl/action/template.js
View file @
5c98671d
...
@@ -40,6 +40,7 @@ class Template extends APIBase {
...
@@ -40,6 +40,7 @@ class Template extends APIBase {
opResult
=
await
this
.
templateinfoSve
.
updateSwitchStatus
(
pobj
);
opResult
=
await
this
.
templateinfoSve
.
updateSwitchStatus
(
pobj
);
break
;
break
;
case
"findAndCountAll"
:
//模板列表查询
case
"findAndCountAll"
:
//模板列表查询
pobj
.
actionBody
.
company_id
=
pobj
.
company_id
;
opResult
=
await
this
.
templateinfoSve
.
findAndCountAll
(
pobj
.
actionBody
);
opResult
=
await
this
.
templateinfoSve
.
findAndCountAll
(
pobj
.
actionBody
);
break
;
break
;
case
"findOneByCode"
:
//模板查询
case
"findOneByCode"
:
//模板查询
...
...
gsb-marketplat/app/base/api/impl/action/templatelink.js
0 → 100644
View file @
5c98671d
const
APIBase
=
require
(
"../../api.base"
);
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
/**
* 用户端调用订单相关接口
*/
class
Templatelink
extends
APIBase
{
constructor
()
{
super
();
this
.
templatelinkSve
=
system
.
getObject
(
"service.template.templatelinkSve"
);
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async
springBoard
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
actionType
)
{
return
system
.
getResult
(
null
,
"actionType参数不能为空"
);
}
var
result
=
await
this
.
opActionProcess
(
pobj
,
pobj
.
actionType
,
req
);
return
result
;
}
async
opActionProcess
(
pobj
,
action_type
,
req
)
{
var
opResult
=
null
;
var
self
=
this
;
pobj
.
xctx
=
req
.
xctx
;
switch
(
action_type
)
{
case
"test"
:
//测试
opResult
=
system
.
getResultSuccess
(
"测试接口"
);
break
;
case
"createTemplateLink"
:
//创建模板链接
opResult
=
await
this
.
templatelinkSve
.
createTemplateLink
(
pobj
);
break
;
case
"editTemplateLink"
:
//修改模板链接
opResult
=
await
this
.
templatelinkSve
.
editTemplateLink
(
pobj
);
break
;
case
"updateLaunchStatus"
:
//修改投放状态
opResult
=
await
this
.
templatelinkSve
.
updateLaunchStatus
(
pobj
);
break
;
case
"findAndCountAll"
:
//链接列表查询
pobj
.
actionBody
.
company_id
=
pobj
.
company_id
;
opResult
=
await
this
.
templatelinkSve
.
findAndCountAll
(
pobj
.
actionBody
);
break
;
case
"findOneByCode"
:
//获取模板链接详情数据
opResult
=
await
this
.
templatelinkSve
.
findOneByCode
(
pobj
);
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
}
return
opResult
;
}
}
module
.
exports
=
Templatelink
;
gsb-marketplat/app/base/db/impl/template/templateinfoDao.js
0 → 100644
View file @
5c98671d
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
TemplateinfoDao
extends
Dao
{
constructor
(){
super
(
Dao
.
getModelName
(
TemplateinfoDao
));
}
extraWhere
(
obj
,
w
,
qc
,
linkAttrs
){
w
[
"company_id"
]
=
obj
.
company_id
;
return
w
;
}
}
module
.
exports
=
TemplateinfoDao
;
\ No newline at end of file
gsb-marketplat/app/base/db/impl/template/templatelinkDao.js
0 → 100644
View file @
5c98671d
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
TemplatelinkDao
extends
Dao
{
constructor
(){
super
(
Dao
.
getModelName
(
TemplatelinkDao
));
}
extraWhere
(
obj
,
w
,
qc
,
linkAttrs
){
w
[
"company_id"
]
=
obj
.
company_id
;
return
w
;
}
}
module
.
exports
=
TemplatelinkDao
;
\ No newline at end of file
gsb-marketplat/app/base/db/models/template/templatelink.js
0 → 100644
View file @
5c98671d
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
appconfig
=
system
.
getSysConfig
();
/**
* 模板信息表
*/
module
.
exports
=
(
db
,
DataTypes
)
=>
{
//TODO:
return
db
.
define
(
"templatelink"
,
{
code
:
DataTypes
.
STRING
,
name
:
DataTypes
.
STRING
,
delivery_word
:
DataTypes
.
STRING
,
else_channel_param
:
DataTypes
.
STRING
,
template_id
:
DataTypes
.
INTEGER
,
channel_id
:
DataTypes
.
INTEGER
,
business_type_id
:
DataTypes
.
INTEGER
,
lauch_type_id
:
DataTypes
.
INTEGER
,
marketing_subject_id
:
DataTypes
.
INTEGER
,
template_name
:
DataTypes
.
STRING
,
channel_name
:
DataTypes
.
STRING
,
business_type_name
:
DataTypes
.
STRING
,
lauch_type_name
:
DataTypes
.
STRING
,
marketing_subject_name
:
DataTypes
.
STRING
,
is_enabled
:
DataTypes
.
INTEGER
,
link_url
:
DataTypes
.
STRING
,
notes
:
DataTypes
.
STRING
,
user_id
:
DataTypes
.
STRING
(
100
),
user_name
:
DataTypes
.
STRING
(
100
),
//user_name 用户名称
company_id
:
DataTypes
.
INTEGER
,
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'b_template_link'
,
validate
:
{
},
indexes
:
[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
gsb-marketplat/app/base/service/impl/template/templateinfoSve.js
View file @
5c98671d
...
@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base");
...
@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base");
const
settings
=
require
(
"../../../../config/settings"
);
const
settings
=
require
(
"../../../../config/settings"
);
class
TemplateinfoService
extends
ServiceBase
{
class
TemplateinfoService
extends
ServiceBase
{
constructor
()
{
constructor
()
{
super
(
"
common
"
,
ServiceBase
.
getDaoName
(
TemplateinfoService
));
super
(
"
template
"
,
ServiceBase
.
getDaoName
(
TemplateinfoService
));
}
}
async
findAndCountAll
(
obj
){
async
findAndCountAll
(
obj
){
...
@@ -64,6 +64,9 @@ class TemplateinfoService extends ServiceBase {
...
@@ -64,6 +64,9 @@ class TemplateinfoService extends ServiceBase {
if
(
!
templateInfo
||
!
templateInfo
.
id
){
if
(
!
templateInfo
||
!
templateInfo
.
id
){
return
system
.
getResultFail
(
-
300
,
"未知模板"
);
return
system
.
getResultFail
(
-
300
,
"未知模板"
);
}
}
// if(templateInfo.is_enabled===1){
// return system.getResultFail(-301,"该模板正在使用中,不能执行此操作");
// }
await
this
.
dao
.
update
({
id
:
templateInfo
.
id
,
template_content
:
ab
.
template_content
});
await
this
.
dao
.
update
({
id
:
templateInfo
.
id
,
template_content
:
ab
.
template_content
});
return
system
.
getResultSuccess
();
return
system
.
getResultSuccess
();
}
}
...
...
gsb-marketplat/app/base/service/impl/template/templatelinkSve.js
0 → 100644
View file @
5c98671d
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
settings
=
require
(
"../../../../config/settings"
);
class
TemplatelinkService
extends
ServiceBase
{
constructor
()
{
super
(
"template"
,
ServiceBase
.
getDaoName
(
TemplatelinkService
));
}
async
findAndCountAll
(
obj
){
var
res
=
await
this
.
dao
.
findAndCountAll
(
obj
);
return
system
.
getResultSuccess
(
res
);
}
async
checkAndPackageParams
(
ab
,
xctx
){
if
(
!
ab
.
channel_id
){
return
system
.
getResultFail
(
-
101
,
"渠道主体不能为空"
);
}
if
(
!
ab
.
business_type_id
){
return
system
.
getResultFail
(
-
102
,
"业务类型不能为空"
);
}
if
(
!
ab
.
lauch_type_id
){
return
system
.
getResultFail
(
-
103
,
"投放方式不能为空"
);
}
if
(
!
ab
.
marketing_subject_id
){
return
system
.
getResultFail
(
-
104
,
"营销主体不能为空"
);
}
if
(
!
ab
.
delivery_word
){
return
system
.
getResultFail
(
-
105
,
"投放词不能为空"
);
}
if
(
!
ab
.
else_channel_param
){
return
system
.
getResultFail
(
-
106
,
"其它渠道参数不能为空"
);
}
if
(
!
ab
.
template_id
){
return
system
.
getResultFail
(
-
107
,
"模板参数不能为空"
);
}
if
(
!
ab
.
name
){
return
system
.
getResultFail
(
-
107
,
"任务名称不能为空"
);
}
if
(
!
ab
.
code
){
//新增
ab
.
code
=
await
this
.
getBusUid
(
"tl"
);
ab
.
user_id
=
xctx
.
credid
;
ab
.
user_name
=
xctx
.
username
;
ab
.
company_id
=
xctx
.
companyid
;
ab
.
is_enabled
=
0
;
}
else
{
//修改
var
linkinfo
=
await
this
.
dao
.
model
.
findOne
({
where
:{
code
:
ab
.
code
},
raw
:
true
});
if
(
!
linkinfo
||
!
linkinfo
.
id
){
return
system
.
getResultFail
(
-
300
,
"未知模板"
);
}
if
(
linkinfo
.
is_enabled
===
1
){
return
system
.
getResultFail
(
-
301
,
"该链接正在投放中,不能执行此操作"
);
}
ab
.
id
=
linkinfo
.
id
;
}
return
ab
;
}
/**
* 创建模板链接数据
* @param {*} pobj
*/
async
createTemplateLink
(
pobj
){
var
ab
=
pobj
.
actionBody
;
var
xctx
=
pobj
.
xctx
;
if
(
!
ab
){
return
system
.
getResultFail
(
-
100
,
"参数错误"
);
}
var
checkres
=
await
this
.
checkAndPackageParams
(
ab
,
xctx
);
if
(
checkres
&&
checkres
.
status
<
0
){
return
checkres
;
}
ab
=
checkres
;
var
res
=
await
this
.
create
(
ab
);
return
system
.
getResultSuccess
(
res
);
}
/**
* 修改模板链接
* @param {*} pobj
*/
async
editTemplateLink
(
pobj
){
var
ab
=
pobj
.
actionBody
;
var
xctx
=
pobj
.
xctx
;
if
(
!
ab
){
return
system
.
getResultFail
(
-
100
,
"参数错误"
);
}
if
(
!
ab
.
code
){
return
system
.
getResultFail
(
-
100
,
"模板编码不能为空"
);
}
var
checkres
=
await
this
.
checkAndPackageParams
(
ab
,
xctx
);
if
(
checkres
&&
checkres
.
status
<
0
){
return
checkres
;
}
ab
=
checkres
;
await
this
.
dao
.
update
(
ab
);
return
system
.
getResultSuccess
();
}
/**
* 获取模板链接详情数据
* @param {*} pobj
*/
async
findOneByCode
(
pobj
){
var
ab
=
pobj
.
actionBody
;
var
xctx
=
pobj
.
xctx
;
if
(
!
ab
){
return
system
.
getResultFail
(
-
100
,
"参数错误"
);
}
if
(
!
ab
.
code
){
return
system
.
getResultFail
(
-
101
,
"模板编码不能为空"
);
}
var
templateInfo
=
await
this
.
dao
.
model
.
findOne
({
where
:{
code
:
ab
.
code
},
raw
:
true
});
return
system
.
getResultSuccess
(
templateInfo
);
}
/**
* 修改投放状态
* @param {*} pobj
*/
async
updateLaunchStatus
(
pobj
){
var
ab
=
pobj
.
actionBody
;
var
xctx
=
pobj
.
xctx
;
if
(
!
ab
){
return
system
.
getResultFail
(
-
100
,
"参数错误"
);
}
if
(
!
ab
.
code
){
return
system
.
getResultFail
(
-
101
,
"链接编码不能为空"
);
}
if
(
!
ab
.
hasOwnProperty
(
"is_enabled"
)){
return
system
.
getResultFail
(
-
102
,
"投放状态不能为空"
);
}
if
(
ab
.
is_enabled
!==
0
&&
ab
.
is_enabled
!==
1
){
return
system
.
getResultFail
(
-
103
,
"投放状态参数错误"
);
}
var
linkinfo
=
await
this
.
dao
.
model
.
findOne
({
where
:{
code
:
ab
.
code
},
raw
:
true
});
if
(
!
linkinfo
||
!
linkinfo
.
id
){
return
system
.
getResultFail
(
-
300
,
"未知链接"
);
}
await
this
.
dao
.
update
({
id
:
linkinfo
.
id
,
is_enabled
:
ab
.
is_enabled
});
return
system
.
getResultSuccess
();
}
/**
* 删除模板链接
* @param {*} pobj
*/
async
deleteTemplateLink
(
pobj
){
var
ab
=
pobj
.
actionBody
;
var
xctx
=
pobj
.
xctx
;
if
(
!
ab
){
return
system
.
getResultFail
(
-
100
,
"参数错误"
);
}
if
(
!
ab
.
code
){
return
system
.
getResultFail
(
-
101
,
"链接编码不能为空"
);
}
var
linkinfo
=
await
this
.
dao
.
model
.
findOne
({
where
:{
code
:
ab
.
code
},
raw
:
true
});
if
(
!
linkinfo
||
!
linkinfo
.
id
){
return
system
.
getResultFail
(
-
300
,
"未知模板链接"
);
}
if
(
linkinfo
.
is_enabled
===
1
){
return
system
.
getResultFail
(
-
301
,
"该链接正在投放中,不能执行此操作"
);
}
await
this
.
dao
.
delete
({
id
:
linkinfo
.
id
});
return
system
.
getResultSuccess
();
}
}
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