<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 模型AdminModel.class.php ~~~php <?php /** * Created by dh2y * email: xiaodai54_long@163.com * Date: 2017/6/22 12:33 * describ: admin表操作模型 */ namespace Admin\Model; use Common\Model\BaseModel; class AdminModel extends BaseModel { protected $tableName = 'admin'; //protected $labels = ['username'=>'','password'=>'','status'=>1,'create_time'];有驗證場景此處可以忽略 //自動驗證 protected $_validate = array( ['username','require',['tag'=>'username','error'=>'用戶名必須!']], //默認情況下用正則進行驗證 ['username','',['tag'=>'username','error'=>'帳號名稱已經存在!'],0,'unique'], ['role_id','require',['tag'=>'role_id','error'=>'請選擇角色!']], ['status',[0,1],['tag'=>'status','error'=>'狀態不合法!'],2,'in'], ['email','email',['tag'=>'email','error'=>'郵箱不合法!']], ['password','require',['tag'=>'password','error'=>'密碼不能為空!'],], ['password','checkPsw',['tag'=>'password','error'=>'請輸入6~16位有效字符'],2,'callback',3], ); //驗證場景-(yii2中的特性 ^!^借鑒一下它的思想,沒有辦法。隊員奶不起,帶不動。不會yii2) //############這樣用法說明############ //# 用$labels作為默認值設定是 因為用了vueJS的數據綁定提交的 //# 沒有數據就不會傳相應的字段,這意味著將無法驗證,這算是tp驗證的一個Bug吧 //################################# public function scenarios(){ return [ 'add' => ['username'=>'','password'=>'','status'=>1,'create_time'=>time(),'role_id'=>''], 'save' => ['username'=>'','password'=>'','status'=>1,'create_time'=>'','role_id'=>''], ]; } //數據操作 public function store($data){ //指定驗證場景 $action = isset($data[$this->pk]) ? "save" : "add"; $this->scenario = $action; //密碼沒有改變操作 if(($this->scenario=='save')&&(strlen($data['password'])==32)){ $data['password'] = 'noChange'; } if ($this->create($data)) { //密碼沒有改變操作 if($this->labels['password']== 'noChange'){ unset($this->labels['password']); }else{ $this->labels['password'] = md5($this->labels['password']); } $this->labels['status'] = ($this->labels['status']=='true')?1:0; $user_id = $this->$action($this->labels); //角色賦予操作 $user_id=($this->scenario=='save')?$this->labels[$this->pk]:$user_id; $this->figure($user_id,$this->labels['role_id']); if($user_id){ return ['status' => true, 'message' => '數據操作成功']; } } $error = $this->getError(); return ['status' => false,'tag'=>$error['tag'], 'message' => $error['error']]; } /** * 用戶授予角色 */ public function figure($user_id,$role_id){ M('role_user')->where(['user_id'=>$user_id])->delete(); return M('role_user')->add(['user_id'=>$user_id,'role_id'=>$role_id]); } //驗證密碼規則 public function checkPsw($password){ $pattern = '/^[\S]{6,16}$/'; if(!preg_match($pattern,$password)) return false; else return true; } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看