service = $service; } /** * [用户]获取用户信息 * * 获取当前用户的信息 * * @authenticated * * @response { * "code": 200, * "message": "获取成功", * "data": { * "id": 1, * "mobile": "13800138000", * "nickname": "用户昵称" * } * } */ public function show() { return $this->service->getUserInfo(); } /** * [用户]用户注册 * * @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: memberUser * * @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', 'invite_role' => 'nullable|string|in:memberUser', ]); return $this->service->register( $validated['mobile'], $validated['code'], $validated['invite_code'] ?? null, $validated['invite_id'] ?? null, $validated['invite_role'] ?? null ); } /** * [用户]修改用户信息 * * 修改当前用户的信息 * * @authenticated * * @bodyParam nickname string 用户昵称. Example: 用户昵称 * @bodyParam avatar string 用户头像. Example: https://example.com/avatar.jpg * * @response { * "code": 200, * "message": "修改成功", * "data": null * } */ public function update(Request $request) { $data = $request->all(); $result = $this->service->updateUserInfo($data); return $result; } /** * [用户]用户反馈 * * 提交用户的反馈信息 * * @authenticated * * @bodyParam content string 反馈内容. Example: 这是一个反馈信息 * * @response { * "code": 200, * "message": "提交成功", * "data": null * } */ public function feedback(Request $request) { $content = $request->input('content'); $result = $this->service->feedback($content); return $result; } /** * [用户]申请成为技师 * * 申请成为技师 * * @authenticated * * @bodyParam mobile string 手机号. Example: 13800138000 * @bodyParam gender string 性别. Example: male * @bodyParam work_years string 工作年限. Example: 5 * @bodyParam intention_city string 意向城市. Example: 杭州 * * @response { * "code": 200, * "message": "申请成功", * "data": null * } */ public function applyCoach(Request $request) { $mobile = $request->input('mobile'); $gender = $request->input('gender'); $work_years = $request->input('work_years'); $intention_city = $request->input('intention_city'); $result = $this->service->applyCoach($mobile, $gender, $work_years, $intention_city); return $result; } /** * [用户]生成二维码 * * @description 生成当前用户的邀请码和对应的二维码 * * @response { * "code": 200, * "message": "生成成功", * "data": { * "invite_code": "ABC123", * "qr_code": "data:image/png;base64,..." * } * } */ public function generateInviteCode() { // 调用服务层生成邀请码 return $this->service->generateInviteCode(); } }