Commit 3d281a9b by 兰国旗

加验证,去重

parent 9f77482d
......@@ -9,7 +9,7 @@ class MainInfoCtl extends CtlBase {
async create(pobj, qobj, req) {
pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : "";
const up = await this.service.create(pobj);
return system.getResult(up);
return up;
}
}
module.exports = MainInfoCtl;
......@@ -9,7 +9,7 @@ class PutTypeCtl extends CtlBase {
async create(pobj, qobj, req) {
pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : "";
const up = await this.service.create(pobj);
return system.getResult(up);
return up;
}
}
module.exports = PutTypeCtl;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const { getResultSuccess } = require("../../../system");
class MaininfoService extends ServiceBase {
constructor() {
super("configmag", ServiceBase.getDaoName(MaininfoService));
}
async create(pobj){
// var code = await this.getBusUid("main");
// pobj.code = code;
return this.dao.create(pobj);
async create(pobj) {
if (!pobj.name) {
return system.getResultFail(-101,'name can not be empty');
}
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;
\ No newline at end of file
......@@ -7,9 +7,20 @@ class PuttypeService extends ServiceBase {
}
async create(pobj){
var code = await this.getBusUid("put");
pobj.code = code;
return this.dao.create(pobj);
if (!pobj.name) {
return system.getResultFail(-101, 'name can not be empty');
}
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;
\ 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