userService = $userService; } /** * 用户注册 * * @return \Illuminate\Http\JsonResponse * * @description 用户注册接口 * * @bodyParam mobile string required 手机号 Example: 13800138000 * @bodyParam code string required 验证码 Example: 123456 * @bodyParam invite_code string optional 邀请码 Example: ABC123 * @bodyParam invite_id integer optional 邀请人ID Example: 1 * @bodyParam invite_role string optional 邀请人角色(user) Example: user * * @response { * "code": 200, * "message": "注册成功", * "data": { * "user_id": 1, * "mobile": "13800138000", * "invite_code": "ABC123" * } * } */ public function register(Request $request) { $validated = $request->validate([ 'mobile' => 'required|string|size:11|regex:/^1[3-9]\d{9}$/', 'code' => 'required|string|size:6', 'invite_code' => 'nullable|string|size:6', 'invite_id' => 'nullable|integer|exists:member_users,id', 'invite_role' => 'nullable|string|in:user', ]); return $this->userService->register( $validated['mobile'], $validated['code'], $validated['invite_code'] ?? null, $validated['invite_id'] ?? null, $validated['invite_role'] ?? null ); } }