Commit 3d281a9b by 兰国旗

加验证,去重

parent 9f77482d
...@@ -9,7 +9,7 @@ class MainInfoCtl extends CtlBase { ...@@ -9,7 +9,7 @@ class MainInfoCtl extends CtlBase {
async create(pobj, qobj, req) { async create(pobj, qobj, req) {
pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : ""; pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : "";
const up = await this.service.create(pobj); const up = await this.service.create(pobj);
return system.getResult(up); return up;
} }
} }
module.exports = MainInfoCtl; module.exports = MainInfoCtl;
...@@ -9,7 +9,7 @@ class PutTypeCtl extends CtlBase { ...@@ -9,7 +9,7 @@ class PutTypeCtl extends CtlBase {
async create(pobj, qobj, req) { async create(pobj, qobj, req) {
pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : ""; pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : "";
const up = await this.service.create(pobj); const up = await this.service.create(pobj);
return system.getResult(up); return up;
} }
} }
module.exports = PutTypeCtl; module.exports = PutTypeCtl;
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const { getResultSuccess } = require("../../../system");
class MaininfoService extends ServiceBase { class MaininfoService extends ServiceBase {
constructor() { constructor() {
super("configmag", ServiceBase.getDaoName(MaininfoService)); super("configmag", ServiceBase.getDaoName(MaininfoService));
} }
async create(pobj){ async create(pobj) {
// var code = await this.getBusUid("main"); if (!pobj.name) {
// pobj.code = code; return system.getResultFail(-101,'name can not be empty');
return this.dao.create(pobj); }
if (!pobj.code) {
return system.getResultFail(-102,'code can not be empty');
}
let whereParams = {
code: pobj.code,
}
let searchResult = await this.findOne(whereParams, []);
if (searchResult) {
return system.getResultFail(-103,'主体参数已存在,请勿重复添加');
}
return system.getResultSuccess(this.dao.create(pobj));
} }
} }
module.exports = MaininfoService; module.exports = MaininfoService;
\ No newline at end of file
...@@ -7,9 +7,20 @@ class PuttypeService extends ServiceBase { ...@@ -7,9 +7,20 @@ class PuttypeService extends ServiceBase {
} }
async create(pobj){ async create(pobj){
var code = await this.getBusUid("put"); if (!pobj.name) {
pobj.code = code; return system.getResultFail(-101, 'name can not be empty');
return this.dao.create(pobj); }
if (!pobj.code) {
return system.getResultFail(-102, 'code can not be empty');
}
let whereParams = {
code: pobj.code
}
let searchResult = await this.findOne(whereParams, []);
if (searchResult) {
return system.getResultFail(-103, '投放方式参数已存在,请勿重复添加');
}
return system.getResultSuccess(this.dao.create(pobj));
} }
} }
module.exports = PuttypeService; module.exports = PuttypeService;
\ No newline at end of file
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