UndertakeValidate.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace app\api\validate;
  3. use think\Validate;
  4. class UndertakeValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'task_id' => ['require', 'integer', 'get:0'],//任务id
  8. 'bear_id' => ['require', 'integer', 'get:0'],//抽样机构
  9. 'check_id' => ['require', 'integer', 'get:0'],//检测机构
  10. 'report_id' => ['require', 'integer', 'get:0'],//报告上传单位
  11. 'sample_number' => ['require', 'integer', 'get:0'],//样本数量
  12. 'address'=>['require'],
  13. 'year' => ['require', 'date'], //年度
  14. 'ispublic' => ['require', 'in' => '0,1,2,3,4,5'],//任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
  15. 'upload_time' => ['require', 'date'],//报告上传时间
  16. 'starttime' => ['require', 'date'],//任务开始时间
  17. 'endtime' => ['require', 'date'],//任务结束时间
  18. 'task_name' => ['require', 'chsDash', 'length:4,50'],//任务名称
  19. ];
  20. protected $message = [
  21. 'task_id' => [
  22. 'require' => [700000, '传参错误'],//任务id
  23. 'integer' => [700001, '传参错误'],
  24. 'gt' => [700002, '传参错误'],
  25. ],
  26. 'bear_id' => [
  27. 'require' => [700000, '传参错误'],//抽样机构
  28. 'integer' => [700001, '传参错误'],
  29. 'gt' => [700002, '传参错误'],
  30. ],
  31. 'check_id' => [
  32. 'require' => [700000, '传参错误'],//检测机构
  33. 'integer' => [700001, '传参错误'],
  34. 'gt' => [700002, '传参错误'],
  35. ],
  36. 'report_id' => [
  37. 'require' => [700000, '传参错误'],//报告上传单位
  38. 'integer' => [700001, '传参错误'],
  39. 'gt' => [700002, '传参错误'],
  40. ],
  41. 'sample_number' => [
  42. 'require' => [700000, '传参错误'],//样本数量
  43. 'integer' => [700001, '传参错误'],
  44. 'gt' => [700002, '传参错误'],
  45. ],
  46. 'address'=>[
  47. 'require'=>[700100,'地址必须']//地址
  48. ],
  49. 'year' => [
  50. 'require' => [700400, '任务年度不能为空'],//年度
  51. 'date' => [700401, '任务年度格式错误'],
  52. ],
  53. 'ispublic' => [
  54. 'require' => [700500, '任务状态不能为空'],//任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
  55. 'in' => [700501, '任务状态选择错误'],
  56. ],
  57. 'upload_time' => [
  58. 'require' => [700600, '上传时间错误'],//任务开始时间
  59. 'date' => [700600, '上传时间错误'],//任务开始时间
  60. ],
  61. 'starttime' => [
  62. 'require' => [700600, '任务开始时间不能为空'],//任务开始时间
  63. 'date' => [700601, '任务开始时间格式错误'],
  64. ],
  65. 'endtime' => [
  66. 'require' => [700600, '任务结束时间不能为空'],//任务结束时间
  67. 'date' => [700601, '任务结束时间格式错误'],
  68. ],
  69. 'task_name' => [
  70. 'require' => [700800, '任务名称不能为空'],//任务名称
  71. 'chsDash' => [700801, '任务名称只能是汉字、字母、数字和下划线_及破折号-'],//任务名称
  72. 'length' => [700802, '任务名称长度在4至50个字符之间'],//任务名称
  73. ],
  74. ];
  75. public function sceneCreateUnderTaker()
  76. {
  77. return $this->only(['task_id', 'bear_id', 'check_id', 'report_id', 'address', 'upload_time', 'sample_number',]);
  78. }
  79. }