You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.4 KiB

  1. <?php
  2. namespace App\Controller;
  3. use Hyperf\Di\Annotation\Inject;
  4. use App\Constants\ErrorCode;
  5. use App\Exception\BusinessException;
  6. use App\Service\DeviceServiceInterFace;
  7. class DeviceController extends BaseController
  8. {
  9. /**
  10. * @Inject
  11. * @var DeviceServiceInterFace
  12. */
  13. protected $deviceService;
  14. public function bind()
  15. {
  16. $validator = $this->validationFactory->make(
  17. $this->request->all(),
  18. [
  19. 'store_id' => 'required|nonempty|integer',
  20. 'device_name' => 'required|nonempty|alpha_num',
  21. ],
  22. [
  23. 'store_id.required' => '参数不正确',
  24. 'store_id.nonempty' => '参数不正确',
  25. 'store_id.integer' => '参数不正确',
  26. 'device_name.required' => '参数不正确',
  27. 'device_name.nonempty' => '参数不正确',
  28. 'device_name.alpha_num' => '参数不正确',
  29. ]
  30. );
  31. if ($validator->fails()){
  32. // Handle exception
  33. $errorMessage = $validator->errors()->first();
  34. $this->result(200,[],$errorMessage);
  35. }
  36. $store_id = $this->request->input('store_id');
  37. $device_name = $this->request->input('device_name');
  38. $sd = $this->deviceService->bindByStoreId($device_name,$store_id);
  39. return $this->result(0,[$sd],'绑定成功');
  40. }
  41. public function list()
  42. {
  43. }
  44. }