feat(client): #14/#18 产地/保质期/储存方式/描述文档 provider & repo 及公开页意见反馈

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-08 08:20:00 +08:00
parent 0d17533120
commit 8a87d4a82c
5 changed files with 429 additions and 67 deletions
@@ -141,6 +141,33 @@ class ProductOptionRepository {
}
}
Future<void> createOrigin(Map<String, dynamic> data) async {
try {
await _client.post('/product-options/origins', data: data);
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '创建失败',
statusCode: e.response?.statusCode);
}
}
Future<void> updateOrigin(int id, Map<String, dynamic> data) async {
try {
await _client.put('/product-options/origins/$id', data: data);
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '更新失败',
statusCode: e.response?.statusCode);
}
}
Future<void> deleteOrigin(int id) async {
try {
await _client.delete('/product-options/origins/$id');
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '删除失败',
statusCode: e.response?.statusCode);
}
}
// ── 保质期 ──────────────────────────────────────────────────
Future<List<ProductShelfLifeOption>> listShelfLives() async {
@@ -154,6 +181,33 @@ class ProductOptionRepository {
}
}
Future<void> createShelfLife(Map<String, dynamic> data) async {
try {
await _client.post('/product-options/shelf-lives', data: data);
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '创建失败',
statusCode: e.response?.statusCode);
}
}
Future<void> updateShelfLife(int id, Map<String, dynamic> data) async {
try {
await _client.put('/product-options/shelf-lives/$id', data: data);
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '更新失败',
statusCode: e.response?.statusCode);
}
}
Future<void> deleteShelfLife(int id) async {
try {
await _client.delete('/product-options/shelf-lives/$id');
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '删除失败',
statusCode: e.response?.statusCode);
}
}
// ── 储存方式 ─────────────────────────────────────────────────
Future<List<ProductStorageOption>> listStorages() async {
@@ -167,6 +221,33 @@ class ProductOptionRepository {
}
}
Future<void> createStorage(Map<String, dynamic> data) async {
try {
await _client.post('/product-options/storages', data: data);
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '创建失败',
statusCode: e.response?.statusCode);
}
}
Future<void> updateStorage(int id, Map<String, dynamic> data) async {
try {
await _client.put('/product-options/storages/$id', data: data);
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '更新失败',
statusCode: e.response?.statusCode);
}
}
Future<void> deleteStorage(int id) async {
try {
await _client.delete('/product-options/storages/$id');
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '删除失败',
statusCode: e.response?.statusCode);
}
}
// ── 描述文档 ─────────────────────────────────────────────────
Future<List<ProductDescriptionDoc>> listDescriptionDocs() async {
@@ -179,4 +260,31 @@ class ProductOptionRepository {
statusCode: e.response?.statusCode);
}
}
Future<void> createDescriptionDoc(Map<String, dynamic> data) async {
try {
await _client.post('/product-options/description-docs', data: data);
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '创建失败',
statusCode: e.response?.statusCode);
}
}
Future<void> updateDescriptionDoc(int id, Map<String, dynamic> data) async {
try {
await _client.put('/product-options/description-docs/$id', data: data);
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '更新失败',
statusCode: e.response?.statusCode);
}
}
Future<void> deleteDescriptionDoc(int id) async {
try {
await _client.delete('/product-options/description-docs/$id');
} on DioException catch (e) {
throw AppException(e.response?.data?['error'] as String? ?? '删除失败',
statusCode: e.response?.statusCode);
}
}
}