import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import '../core/api/api_client.dart'; import '../core/exceptions.dart'; import '../models/shop.dart'; class ShopRepository { final ApiClient _client; const ShopRepository(this._client); Future getInfo() async { try { final resp = await _client.get('/shop/info'); return ShopInfo.fromJson(resp.data as Map); } on DioException catch (e) { throw AppException( e.response?.data?['error'] as String? ?? '获取酒行信息失败', statusCode: e.response?.statusCode, ); } } Future updateInfo(Map body) async { try { final resp = await _client.put('/shop/info', data: body); return ShopInfo.fromJson(resp.data as Map); } on DioException catch (e) { throw AppException( e.response?.data?['error'] as String? ?? '更新失败', statusCode: e.response?.statusCode, ); } } Future uploadLogo(Uint8List bytes, String filename) async { try { final formData = FormData.fromMap({ 'file': MultipartFile.fromBytes(bytes, filename: filename), }); final resp = await _client.post('/shop/logo', data: formData); return (resp.data as Map)['logo_url'] as String? ?? ''; } on DioException catch (e) { throw AppException( e.response?.data?['error'] as String? ?? 'Logo 上传失败', statusCode: e.response?.statusCode, ); } } }