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) {
    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;