import * as bcrypt from 'bcryptjs' ; import * as moment from 'moment' ; import * as meeko from 'meeko' ; moment . locale ( 'zh-cn' ) ; export = { method param { String } str returns { String } bhash ( str ) { return bcrypt . hashSync ( str , 10 ) ; } , param { String } str param { String } hash returns { Boolean } bcompare ( str , hash ) { return bcrypt . compareSync ( str , hash ) ; } , method param { ( string | number ) [ ] } arrA param { ( string | number ) [ ] } arrB returns { [ increase : ( string | number ) [ ] , decrease : ( string | number ) [ ] ] } arrayDiff ( arrA , arrB ) { const intersect = meeko . array . intersect ( arrA , arrB ) ; const increase = meeko . array . except ( arrA , intersect ) ; const decrease = meeko . array . except ( arrB , intersect ) ; return [ increase , decrease ] ; } , method param { any } result param { String } message param { Number } status example success ( this , result = null , message = '请求成功' , status = 200 ) { this . ctx . body = { code : status , message , data : result , } ; this . ctx . status = status ; } , } ;