TaskValidate.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\admin\validate\sys_manage;
  3. use support\Validate;
  4. class TaskValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'task_id' => 'require|integer',
  8. 'join_task_apply_user_id|申请用户' => 'require|regex:/^[0-9a-zA-Z]+$/',
  9. 'join_task_assign_user_id|处理用户' => 'regex:/^[0-9a-zA-Z]+$/',
  10. 'task_status|工单状态' => 'require|in:INIT,PENDING,RESERVING,PROCESSING,DONE,CONFIRM',
  11. 'task_classify|归类' => 'in:订单工单,工作工单,服务工单,维保工单',
  12. 'task_category|分类' => 'in:安装,维修,其他',
  13. 'join_task_order_id|订单' => 'regex:/^[0-9a-zA-Z]+$/',
  14. 'join_task_order_json|订单信息' => 'isJson',
  15. 'join_task_appointment_id|预约ID' => 'regex:/^[0-9a-zA-Z]+$/',
  16. 'join_task_appointment_json|预约信息' => 'isJson',
  17. 'task_assign_datetimes|分配时间' => 'date',
  18. 'task_accept_datetimes|受理时间' => 'date',
  19. 'task_reserv_datetimes|预约时间' => 'date',
  20. 'task_name|名称' => 'require|max:64',
  21. 'task_config_json|配置信息' => 'isJson',
  22. 'task_notify_json|回调信息' => 'isJson',
  23. 'task_extend_json' => 'isJson',
  24. 'task_process_status' => 'in:NONE,START,PAUSE,COMPLETE'
  25. ];
  26. protected $scene = [
  27. 'update' => ['task_id', 'join_task_apply_user_id', 'join_task_assign_user_id', 'task_status', 'task_classify', 'task_category', 'join_task_order_id'
  28. , 'join_task_order_json', 'join_task_appointment_id', 'join_task_appointment_json', 'task_assign_datetimes', 'task_accept_datetimes',
  29. 'task_reserv_datetimes', 'task_name', 'task_config_json', 'task_notify_json', 'task_extend_json'],
  30. 'info' => ['task_id'],
  31. 'process' => ['task_id', 'task_status', 'task_process_status']
  32. ];
  33. /**
  34. * @Desc 验证json
  35. * @Author Gorden
  36. * @Date 2024/4/7 14:06
  37. *
  38. * @param $value
  39. * @return bool
  40. */
  41. public function isJson($value)
  42. {
  43. if (is_json($value)) {
  44. return true;
  45. }
  46. return false;
  47. }
  48. }