const system=require("../../system");
const ServiceBase=require("../sve.base");
var settings=require("../../../config/settings");
class OfflinecompanyService extends ServiceBase{
    constructor(){
        super(ServiceBase.getDaoName(OfflinecompanyService));
    }

    async updateCreate(params){
        var offlinecompany = await this.dao.findOne({company_name : params.company_name});
        if(null != offlinecompany){
            // params.id = offlinecompany.id;
            // var saveId = await this.dao.update(params);
            offlinecompany.contact_man = params.contact_man;
            offlinecompany.contact_mobile = params.contact_mobile;
            offlinecompany.contact_email = params.contact_email;
            offlinecompany.contact_addr = params.contact_addr;
            var updates = await offlinecompany.save();
            if(updates.id > 0){
                return updates;
            }
            return system.getErrResult2("修改失败");
        }
       var saves = await this.dao.create(params);
       if(saves.id > 0){
            return saves;
       }
        return system.getErrResult2("保存失败");
    }

}
module.exports=OfflinecompanyService;
