Esempio n. 1
0
 /**
  * 更新设备信息
  * @param ShakeAroundClient $shakeAroundClient
  * @param DeviceService $deviceService
  * @param null $sn
  * @return string
  * @author zhengqian@dajiayao.cc
  */
 public function updateComment(ShakeAroundClient $shakeAroundClient, DeviceService $deviceService, $sn = null)
 {
     if (!$sn) {
         return RestHelp::parametersIllegal("sn is required");
     }
     $requestData = json_decode($this->inputData, true);
     if (!isset($requestData['comment'])) {
         return RestHelp::parametersIllegal("comment is required");
     }
     $objDevice = Device::where('sn', $sn)->first();
     if (!$objDevice) {
         return RestHelp::encodeResult(24001, sprintf("sn: %s not foun", $sn));
     }
     try {
         $dev = new DeviceIdentifier($objDevice->weixinDevice->device_id, $objDevice->weixinDevice->uuid, $objDevice->weixinDevice->major, $objDevice->weixinDevice->minor);
         $deviceService->updateWeixinDevice($dev, $shakeAroundClient, $requestData['comment']);
     } catch (\Exception $e) {
         return RestHelp::encodeResult($e->getCode(), $e->getMessage());
     }
     $objDevice->comment = $requestData['comment'];
     $objDevice->save();
     return RestHelp::success();
 }
Esempio n. 2
0
 /**
  * 修改备注
  * @param ShakeAroundClient $shakeAroundClient
  * @param DeviceService $deviceService
  * @return \Illuminate\Http\RedirectResponse
  * @author zhengqian@dajiayao.cc
  */
 public function update(ShakeAroundClient $shakeAroundClient, DeviceService $deviceService)
 {
     $deviceId = Input::get('device_id');
     $objDevice = WeixinDevice::find($deviceId);
     $comment = Input::get('comment');
     if (!$comment) {
         return redirect(route('adminGetUpdate'))->with('result', false)->with('msg', "备注不能为空");
     }
     $device = new DeviceIdentifier($objDevice->device_id, $objDevice->uuid, $objDevice->major, $objDevice->minor);
     try {
         $deviceService->updateWeixinDevice($device, $shakeAroundClient, $comment, $objDevice->mp->appid, $objDevice->mp->appsecret);
     } catch (\Exception $e) {
         return redirect(route('adminWxDevicesIndex'))->with('result', false)->with('msg', $e->getMessage());
     }
     $objDevice->comment = $comment;
     $objDevice->save();
     return redirect(route('adminWxDevicesIndex'))->with('result', true)->with('msg', '操作成功');
 }