Exemple #1
0
 /**
  * 获取打印店详情
  * @param [type] $id [description]
  */
 public function GET_infoAction($id)
 {
     $this->authPrinter($id);
     $field = 'id,name,sch_id,account,address,email,phone,qq,wechat,profile,image,open,status,price,other';
     if ($printer = PrinterModel::field($field)->find($id)) {
         $printer['price'] = json_decode($printer['price']);
         $this->response(1, $printer);
     } else {
         $this->response(0, '无效用户');
     }
 }
 /**
  * 获取价格
  * GET /printers/123/price
  * @method GET_priceAction
  * @param  integer         $id [description]
  * @author NewFuture
  */
 public function GET_priceAction($id = 0)
 {
     $this->auth();
     if ($printer = PrinterModel::field('price,other')->find($id)) {
         $price = json_decode($printer['price']);
         $price->other = $printer['other'];
         $this->response(1, $price);
     } else {
         $this->response(0, '不存在此店');
     }
 }
 /**
  * 重置密码
  * @method POST_printerAction
  * @author NewFuture
  */
 public function PUT_indexAction($id)
 {
     $this->auth($id);
     $response['status'] = 0;
     if (!Input::put('password', $password, 'isMd5')) {
         $response['info'] = '新的密码格式不对';
     } elseif (!Input::put('old', $old_pwd, 'isMd5')) {
         $response['info'] = '请输入原密码';
     } else {
         /*数据库中读取用户数据*/
         $printer = PrinterModel::field('password,account')->find($id);
         $account = $printer['account'];
         if (!$printer || Encrypt::encryptPwd($old_pwd, $account) != $printer['password']) {
             $response['info'] = '原密码错误';
         } elseif ($printer->update(['password' => Encrypt::encryptPwd($password, $account)]) >= 0) {
             $response['info'] = '修改成功';
             $response['status'] = 1;
         } else {
             $response['info'] = '修改失败';
         }
     }
     $this->response = $response;
 }
Exemple #4
0
 /**
  * printer 生成token
  * @method printerToken
  * @param  [type]       $printer [description]
  * @return [type]                [description]
  * @author NewFuture
  */
 public static function printerToken($printer)
 {
     if ($printer && (is_numeric($printer) && ($data = PrinterModel::field('id,name,password,sch_id')->find($printer))) || isset($printer['id']) && ($data['id'] = $printer['id'] && isset($printer['name']) && ($data['name'] = $printer['name'] && isset($printer['password']) && ($data['password'] = $printer['password'] && isset($printer['sch_id']) && ($data['sch_id'] = $printer['sch_id']))))) {
         return self::createBaseToken($data);
     }
 }