<?php
/**
 *------Create thems Model------
 *------SCWPHP  Version 1.0.0------
 *------Dev Model Jions------
 *------Create Time 2017-06-12 02:29:22------
 */
namespace App\Commons\Model;
use \System\Model;

class Account_password extends Model {

	protected $table = 'account_password';
	public $timestamps = false;

	/**
	 * 修改用户密码
	 *
	 * @param $identity
	 * @param $pwdData
	 */
	public function updatePassword($identity, $pwdData) {
		$data = ['account_password' => $pwdData['password'], 'encryption' => $pwdData['encryption']];
		$this->where('account_identity', $identity)->update($data);
	}
    //检测密码
    function checkPassword($account_identity,$password){
        $pwd=trim($password);
        if(empty($pwd)){
            return -1010010122;
        }
        $userInfo=$this->where('account_identity',$account_identity)->first();
        if(trim($userInfo->account_password)!=md5(md5($userInfo->encryption.$pwd))){
            return -1010010222;
        }
        return 1;
    }
    //更新
    function updateData($data,$account_identity){
	    $res=$this->where('account_identity',$account_identity)->update($data);
	    if(!$res){
	        return -1050050122;//修改失败
        }
        return 1;
    }
}
