Browse Source

fix:验获员申请详情要求不是必填项

super-yimizi 1 month ago
parent
commit
28ffb24375

+ 2 - 2
application/api/validate/Inspection.php

@@ -11,7 +11,7 @@ class Inspection extends Validate
      */
      */
     protected $rule = [
     protected $rule = [
         // 基础信息
         // 基础信息
-        'id'                => 'require|integer|gt:0',
+        'id'                => 'integer|gt:0',
         'name'              => 'require|length:1,50|chsAlpha',
         'name'              => 'require|length:1,50|chsAlpha',
         'phone'             => 'require|mobile|checkPhoneUnique',
         'phone'             => 'require|mobile|checkPhoneUnique',
         'province_adcode'   => 'require|max:50',
         'province_adcode'   => 'require|max:50',
@@ -27,7 +27,7 @@ class Inspection extends Validate
      */
      */
     protected $message = [
     protected $message = [
         // 基础信息
         // 基础信息
-        'id.require'            => '申请ID不能为空',
+        // 'id.require'            => '申请ID不能为空',
         'id.integer'            => '申请ID必须是整数',
         'id.integer'            => '申请ID必须是整数',
         'id.gt'                 => '申请ID必须大于0',
         'id.gt'                 => '申请ID必须大于0',
         'name.require'          => '姓名不能为空',
         'name.require'          => '姓名不能为空',

+ 9 - 3
application/common/Service/InspectionService.php

@@ -60,10 +60,16 @@ class InspectionService
      * @return InspectionApplication|null
      * @return InspectionApplication|null
      * @throws Exception
      * @throws Exception
      */
      */
-    public static function getApplicationDetail($applicationId, $userId)
+    public static function getApplicationDetail($applicationId = 0, $userId = 0)
     {
     {
-        $application = InspectionApplication::where('inspection_application.id', $applicationId)
-            ->where('inspection_application.user_id', $userId)
+        $application = InspectionApplication::where(function($query) use ($applicationId,$userId){
+            if($applicationId){
+                $query->where('inspection_application.id', $applicationId);
+            }
+            if($userId){
+                $query->where('inspection_application.user_id', $userId);
+            }
+        })
             ->find();
             ->find();
 
 
         if (!$application) {
         if (!$application) {