新增线下收款记录和 ai 修图优化

This commit is contained in:
han xin
2026-08-21 15:51:52 +08:00
parent 6fe9928b49
commit 5cf4409bad
40 changed files with 5482 additions and 56 deletions
@@ -60,12 +60,44 @@ final class TravelAlbumOTGStorageTests: XCTestCase {
XCTAssertEqual(store.absoluteURL(for: loaded.first?.localPath ?? "", albumId: 33), file)
}
func testLoadNormalizesInterruptedRetouchToUploadedFailure() throws {
let root = try makeTempDirectory()
defer { try? FileManager.default.removeItem(at: root) }
let store = makeStore(root: root)
let file = try store.uniqueOriginalFileURL(filename: "A.JPG", albumId: 33)
try Data([1, 2, 3]).write(to: file)
let record = TravelAlbumOTGPhotoRecord(
id: "retouching",
fileName: "A.JPG",
localPath: file.path,
capturedAt: "2026-07-07 10:00:00",
fileSizeBytes: 3,
status: .uploading,
progress: 100,
albumId: 33,
userId: "u1",
remoteUrl: "https://cdn/a.jpg",
materialId: 10,
autoRetouchState: .processing,
autoRetouchTemplateId: "brocade"
)
store.save([record], albumId: 33)
let loaded = try XCTUnwrap(store.load(albumId: 33).first)
XCTAssertEqual(loaded.status, .uploaded)
XCTAssertEqual(loaded.progress, 100)
XCTAssertEqual(loaded.autoRetouchState, .failed)
XCTAssertEqual(loaded.autoRetouchTemplateId, "brocade")
}
func testRemoveAndClearAlbumDeleteFiles() throws {
let root = try makeTempDirectory()
defer { try? FileManager.default.removeItem(at: root) }
let store = makeStore(root: root)
let file = try store.uniqueOriginalFileURL(filename: "A.JPG", albumId: 33)
try Data([1]).write(to: file)
let retouchedFile = try store.writeRetouchedImage(Data([2]), filename: "A.JPG", albumId: 33)
let record = TravelAlbumOTGPhotoRecord(
id: "1",
fileName: "A.JPG",
@@ -74,13 +106,17 @@ final class TravelAlbumOTGStorageTests: XCTestCase {
fileSizeBytes: 1,
status: .pending,
albumId: 33,
userId: "u1"
userId: "u1",
autoRetouchState: .completed,
autoRetouchTemplateId: "brocade",
retouchedPath: retouchedFile.path
)
store.save([record], albumId: 33)
store.remove(albumId: 33, photoId: "1")
XCTAssertFalse(FileManager.default.fileExists(atPath: file.path))
XCTAssertFalse(FileManager.default.fileExists(atPath: retouchedFile.path))
XCTAssertTrue(store.load(albumId: 33).isEmpty)
let another = try store.uniqueOriginalFileURL(filename: "B.JPG", albumId: 33)