feat: 新增相册自动修图与OTG状态预览

支持相册修图配置、模板选择和传输模式选择;上传后自动提交修图并展示状态角标及精修预览。补充接口文档与相关测试。
This commit is contained in:
2026-08-27 16:03:40 +08:00
parent 9fce6ef713
commit d04641b623
17 changed files with 2523 additions and 26 deletions
+63 -2
View File
@@ -36,7 +36,11 @@ final class TravelAlbumAPITests: XCTestCase {
materialNum: 2,
materialPrice: 10.5,
materialPackagePrice: 88,
photoPrice: 0
photoPrice: 0,
autoRetouchConfiguration: TravelAlbumAutoRetouchConfiguration(
enabled: true,
refinedTemplateId: 12
)
)
)
@@ -48,6 +52,60 @@ final class TravelAlbumAPITests: XCTestCase {
XCTAssertEqual(body?["type"] as? Int, 1)
XCTAssertEqual(body?["material_num"] as? Int, 2)
XCTAssertEqual(body?["material_price"] as? Double, 10.5)
let retouchConfiguration = body?["auto_retouch_config"] as? [String: Any]
XCTAssertEqual(retouchConfiguration?["enabled"] as? Bool, true)
XCTAssertEqual(retouchConfiguration?["refined_template_id"] as? Int, 12)
XCTAssertNil(retouchConfiguration?["version"])
XCTAssertNil(retouchConfiguration?["updated_at"])
}
func testInfoDecodesNewConfigurationAndDefaultsOldAlbumToDisabled() async throws {
let configuredAlbum = envelopeJSON(
#"{"id":8,"store_user_id":1,"name":"配置相册","type":1,"order_number":"","material_num":1,"material_price":10,"material_package_price":0,"photo_price":0,"cover_url":"","user_id":2,"status":1,"created_at":"","updated_at":"","auto_retouch_config":{"enabled":true,"refined_template_id":12}}"#
)
let legacyAlbum = envelopeJSON(
#"{"id":9,"store_user_id":1,"name":"旧相册","type":1,"order_number":"","material_num":1,"material_price":10,"material_package_price":0,"photo_price":0,"cover_url":"","user_id":2,"status":1,"created_at":"","updated_at":""}"#
)
let session = MockURLSession(responses: [configuredAlbum, legacyAlbum])
let api = TravelAlbumAPI(client: APIClient(environment: .testing, session: session))
let configured = try await api.info(id: 8)
let legacy = try await api.info(id: 9)
XCTAssertEqual(
configured.autoRetouchConfiguration,
TravelAlbumAutoRetouchConfiguration(
enabled: true,
refinedTemplateId: 12
)
)
XCTAssertEqual(legacy.autoRetouchConfiguration, .disabled)
}
func testUpdateAutoRetouchConfigurationEncodesBodyAndDecodesNormalizedResponse() async throws {
let data = envelopeJSON(
#"{"enabled":true,"refined_template_id":18}"#
)
let session = MockURLSession(responses: [data])
let api = TravelAlbumAPI(client: APIClient(environment: .testing, session: session))
let response = try await api.updateAutoRetouchConfiguration(
TravelAlbumAutoRetouchConfigurationRequest(
userEquityTravelId: 6,
enabled: true,
refinedTemplateId: 18
)
)
XCTAssertEqual(response.refinedTemplateId, 18)
let request = try XCTUnwrap(session.requests.first)
XCTAssertEqual(request.httpMethod, "POST")
XCTAssertEqual(request.url?.path, "/api/yf-handset-app/photog/travel-album/auto-retouch-config")
let body = try JSONSerialization.jsonObject(with: try XCTUnwrap(request.httpBody)) as? [String: Any]
XCTAssertEqual(body?["user_equity_travel_id"] as? Int, 6)
XCTAssertEqual(body?["enabled"] as? Bool, true)
XCTAssertEqual(body?["refined_template_id"] as? Int, 18)
XCTAssertNil(body?["expected_version"])
}
func testMaterialListAndDeleteAndMpCode() async throws {
@@ -192,7 +250,8 @@ final class TravelAlbumAPITests: XCTestCase {
materialIds: [11, 12, 13, 14],
refinedTemplateId: 21,
atmosphereTemplateId: 22,
coverTemplateId: 31
coverTemplateId: 31,
clientRequestId: "auto-6-11-tpl21-a0"
)
)
@@ -205,12 +264,14 @@ final class TravelAlbumAPITests: XCTestCase {
XCTAssertEqual(body?["refined_template_id"] as? Int, 21)
XCTAssertEqual(body?["atmosphere_template_id"] as? Int, 22)
XCTAssertEqual(body?["cover_template_id"] as? Int, 31)
XCTAssertEqual(body?["client_request_id"] as? String, "auto-6-11-tpl21-a0")
XCTAssertEqual(Set(body?.keys.map { $0 } ?? []), [
"user_equity_travel_id",
"material_ids",
"refined_template_id",
"atmosphere_template_id",
"cover_template_id",
"client_request_id",
])
}