2 lines
1.5 KiB
JavaScript
2 lines
1.5 KiB
JavaScript
const e={create_date:{rules:[{format:"timestamp"}]},device_uuid:{rules:[{format:"string"}]},ip:{rules:[{format:"string"}]},state:{rules:[{format:"int"}]},type:{rules:[{format:"string"},{range:[{value:"logout",text:"logout"},{value:"login",text:"login"},{value:"register",text:"register"},{value:"reset-pwd",text:"reset-pwd"},{value:"bind-mobile",text:"bind-mobile"},{value:"bind-weixin",text:"bind-weixin"},{value:"bind-qq",text:"bind-qq"},{value:"bind-apple",text:"bind-apple"},{value:"bind-alipay",text:"bind-alipay"}]}]},ua:{rules:[{format:"string"}]},user_id:{rules:[{required:!0},{format:"string"}]},username:{rules:[{format:"string"}]},email:{rules:[{format:"string"}]},mobile:{rules:[{format:"string"}]},appid:{rules:[{format:"string"}]}},t={type_valuetotext:{logout:"logout",login:"login",register:"register","reset-pwd":"reset-pwd","bind-mobile":"bind-mobile","bind-weixin":"bind-weixin","bind-qq":"bind-qq","bind-apple":"bind-apple","bind-alipay":"bind-alipay"}};function i(e,t){let i={};for(let a in e){let{type:r,value:l}=e[a];switch(r){case"search":"string"==typeof l&&l.length&&(i[a]=new RegExp(l));break;case"select":if(l.length){let e=[];for(let i of l)e.push(t.eq(i));i[a]=t.or(e)}break;case"range":if(l.length){let e=l[0],r=l[1];i[a]=t.and([t.gte(e),t.lte(r)])}break;case"date":if(l.length){let[e,r]=l,n=new Date(e),s=new Date(r);i[a]=t.and([t.gte(n),t.lte(s)])}break;case"timestamp":if(l.length){let[e,r]=l;i[a]=t.and([t.gte(e),t.lte(r)])}}}return i}export{t as e,i as f,e as v};
|