update() 通過(guò)傳入的參數(shù)創(chuàng)建或修改管理員用戶。
以下是 update() 的語(yǔ)法:
update(id=0, username=None, password=None, phone='', email='', image='', role=0, period=0, allow=1, notes='')
● id [int]:用戶id,為0時(shí)創(chuàng)建用戶,其它數(shù)值時(shí)修改用戶。
● username [str]:用戶名。
● password [str]:密碼,未加密前的原始密碼 md5(passowrd + encryption)。
● phone [str]:手機(jī)號(hào)。
● email [str]:E-Mail。
● image [str]:圖像url。
● role [int]:角色表關(guān)聯(lián)ID。
● period [int]:賬號(hào)有效時(shí)間戳,0表示永久。
● allow [int]:是否允許登錄,0表示禁止,1表示允許。
● note [str]:用戶備注信息。
返回一個(gè)字典。
以下展示了使用 update() 的實(shí)例:
from kyger.admin import admin return admin(self.db, self.kg).update(0, 'kgcms', 'test', '', '', period=0, allow=1) # 創(chuàng)建管理員用戶
以上實(shí)例運(yùn)行后輸出的結(jié)果為:
{'state': 'SUCCESS', 'id': 7} # 成功返回ID,失敗返回錯(cuò)誤消息:{'state': 'FAILURE', 'msg': ''}