/* uglified */
"use strict";var exports=process.mainModule.exports;const utils=require("../../utils/functions"),_=require("../../utils/Underscore"),isUseMockData=!1,login=(e,o)=>{if(!e)throw new Error("参数：缺少参数params");if(!_.isObject(e))throw new Error("参数：传入的参数必须是对象");if(!e.userName)throw new Error("用户名不能为空");if(!e.password)throw new Error("密码不能为空");let s="";s=utils.isMobile(e.userName)?"SELECT * FROM LOGIN_INFO WHERE MOBILE = ? AND PASSWORD = ? ":"SELECT * FROM LOGIN_INFO WHERE USERNAME = ? AND PASSWORD = ? ",nw.process.mainModule.exports.api.db.select(s,[e.userName,e.password],function(e){0==e.length?_.isFunction(o)&&o({code:401,message:"用户名或密码错误"}):_.isFunction(o)&&o({code:200,data:e[0],message:"成功"})})},save=e=>{if(!e)throw new Error("参数：缺少参数params");if(!_.isObject(e))throw new Error("参数：传入的参数必须是对象");if(!e.account)throw new Error("参数：params缺少account");if(!_.isObject(e.account))throw new Error("参数：account必须是对象");let o=null;o="boss"===e.role?e.account.userName:e.account.loginName;let s={ID:e.account.id,USERNAME:o,MOBILE:e.account.mobile,PASSWORD:e.account.password,ROLE:e.role,ROLE_INFO:null===e.roleInfo?null:JSON.stringify(e.roleInfo),PERMISSION_INFO:null===e.permissionInfo?null:JSON.stringify(e.permissionInfo),ACCOUNT:JSON.stringify(e.account),BUSINESS:null===e.business?null:JSON.stringify(e.business),SHOP:null===e.shop?null:JSON.stringify(e.shop),SHOP_SET:null===e.shopSet?null:JSON.stringify(e.shopSet)},r=new Date(e.createTime).format("yyyy-MM-dd hh:mm:ss");nw.process.mainModule.exports.api.db.select("SELECT count(1) count FROM LOGIN_INFO WHERE ID = ? ",[s.ID],function(e){e[0].count>0?(s.MODIFY_TIME=r,nw.process.mainModule.exports.api.db.update("LOGIN_INFO",s,"ID=?",[s.ID])):(s.CREATE_TIME=r,s.MODIFY_TIME=r,nw.process.mainModule.exports.api.db.insert("LOGIN_INFO",s))})};module.exports={login:login,save:save};