Commit 24e2f1d4 by 兰国旗

调整修改删除判断

parent f8a3134a
...@@ -10,29 +10,36 @@ class MaininfoService extends ServiceBase { ...@@ -10,29 +10,36 @@ class MaininfoService extends ServiceBase {
async create(pobj) { async create(pobj) {
if (!pobj.name) { if (!pobj.name) {
return system.getResultFail(-101,'name can not be empty'); return system.getResultFail(-101, 'name can not be empty');
} }
if (!pobj.code) { if (!pobj.code) {
return system.getResultFail(-102,'code can not be empty'); return system.getResultFail(-102, 'code can not be empty');
} }
let whereParams = { let whereParams = {
code: pobj.code, code: pobj.code,
} }
let searchResult = await this.findOne(whereParams, []); let searchResult = await this.findOne(whereParams, []);
if (searchResult) { if (searchResult) {
return system.getResultFail(-103,'主体参数已存在,请勿重复添加'); return system.getResultFail(-103, '主体参数已存在,请勿重复添加');
} }
return system.getResultSuccess(this.dao.create(pobj)); return system.getResultSuccess(this.dao.create(pobj));
} }
async update(pobj) { async update(pobj) {
let whereParams = { let whereParams = {
marketing_subject_code: pobj.code id: pobj.id
}
let searchResult = await this.findOne(whereParams, []);
if (searchResult && searchResult.code) {
let linkWhere = {
marketing_subject_code: searchResult.code,
is_enabled: 1
} }
let searchResult = await this.templateLink.findOne(whereParams, []); let searchLink = await this.templateLink.findOne(linkWhere, []);
if (searchResult.is_enabled == 1) { if (searchLink) {
return system.getResultFail(-104, '该业务正在投放中,不能修改'); return system.getResultFail(-104, '该业务正在投放中,不能修改');
} }
}
return system.getResultSuccess(this.dao.update(pobj)); return system.getResultSuccess(this.dao.update(pobj));
} }
...@@ -41,13 +48,16 @@ class MaininfoService extends ServiceBase { ...@@ -41,13 +48,16 @@ class MaininfoService extends ServiceBase {
id: pobj.id id: pobj.id
} }
let searchResult = await this.findOne(whereParams, []); let searchResult = await this.findOne(whereParams, []);
if (searchResult && searchResult.code) {
let linkWhere = { let linkWhere = {
marketing_subject_code: searchResult.code marketing_subject_code: searchResult.code,
is_enabled: 1
} }
let searchLink = await this.templateLink.findOne(linkWhere, []); let searchLink = await this.templateLink.findOne(linkWhere, []);
if (searchLink.is_enabled == 1) { if (searchLink) {
return system.getResultFail(-105, '该业务正在投放中,不能删除'); return system.getResultFail(-105, '该业务正在投放中,不能删除');
} }
}
return system.getResultSuccess(this.dao.delete(pobj)); return system.getResultSuccess(this.dao.delete(pobj));
} }
} }
......
...@@ -26,12 +26,19 @@ class PuttypeService extends ServiceBase { ...@@ -26,12 +26,19 @@ class PuttypeService extends ServiceBase {
async update(pobj) { async update(pobj) {
let whereParams = { let whereParams = {
lauch_type_code: pobj.code id: pobj.id
}
let searchResult = await this.findOne(whereParams, []);
if (searchResult && searchResult.code) {
let linkWhere = {
lauch_type_code: searchResult.code,
is_enabled:1
} }
let searchResult = await this.templateLink.findOne(whereParams, []); let searchLink = await this.templateLink.findOne(linkWhere, []);
if (searchResult.is_enabled == 1) { if (searchLink) {
return system.getResultFail(-104, '该业务正在投放中,不能修改'); return system.getResultFail(-104, '该业务正在投放中,不能修改');
} }
}
return system.getResultSuccess(this.dao.update(pobj)); return system.getResultSuccess(this.dao.update(pobj));
} }
...@@ -40,13 +47,16 @@ class PuttypeService extends ServiceBase { ...@@ -40,13 +47,16 @@ class PuttypeService extends ServiceBase {
id: pobj.id id: pobj.id
} }
let searchResult = await this.findOne(whereParams, []); let searchResult = await this.findOne(whereParams, []);
if (searchResult && searchResult.code) {
let linkWhere = { let linkWhere = {
lauch_type_code: searchResult.code lauch_type_code: searchResult.code,
is_enabled:1
} }
let searchLink = await this.templateLink.findOne(linkWhere, []); let searchLink = await this.templateLink.findOne(linkWhere, []);
if (searchLink.is_enabled == 1) { if (searchLink) {
return system.getResultFail(-105, '该业务正在投放中,不能删除'); return system.getResultFail(-105, '该业务正在投放中,不能删除');
} }
}
return system.getResultSuccess(this.dao.delete(pobj)); return system.getResultSuccess(this.dao.delete(pobj));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment