From 4da1944f3b58bfe89a3c60cec6ed704716f24ae0 Mon Sep 17 00:00:00 2001 From: dindang Date: Mon, 27 Jul 2026 17:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B3=A8=E9=87=8A=E4=B9=B1?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/handler/floor_handler.go | 32 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/internal/handler/floor_handler.go b/internal/handler/floor_handler.go index 9a37e89..60b5d83 100644 --- a/internal/handler/floor_handler.go +++ b/internal/handler/floor_handler.go @@ -16,7 +16,7 @@ import ( "floorvisualizer/internal/repository" ) -// 閳光偓閳光偓 Floor options 閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓 +// --- Floor options --- type FloorOption struct { ID string `json:"id"` @@ -50,8 +50,8 @@ type RoomOption struct { var woodPatterns = []PatternOption{ {Code: 1, Name: "直铺(工字拼)Straight Lay", Category: "wood", Pattern: "planks running from bottom-left toward top-right of the image, joints staggered randomly, at least 6 inch offset between rows"}, {Code: 2, Name: "横铺 Horizontal Lay", Category: "wood", Pattern: "planks running horizontally left to right, parallel to the bottom edge of the image, joints staggered randomly, at least 6 inch offset"}, - {Code: 3, Name: "人字铺 Herringbone", Category: "wood", Pattern: "ALL planks must be IDENTICAL width - no piece may appear narrower. Planks at 90 degrees forming continuous zigzag V-lines from bottom-left to top-right of the image. At far distance, planks remain distinct with visible seams - NOT merging into a solid mass."}, - {Code: 4, Name: "鱼骨铺 Chevron", Category: "wood", Pattern: "planks with 45 degree mitered ends forming continuous V-points aligned from bottom-left to top-right of the image"}, + {Code: 3, Name: "人字拼 Herringbone", Category: "wood", Pattern: "ALL planks must be IDENTICAL width - no piece may appear narrower. Planks at 90° forming continuous zigzag V-lines from bottom-left to top-right of the image. At far distance, planks remain distinct with visible seams - NOT merging into a solid mass."}, + {Code: 4, Name: "鱼骨拼 Chevron", Category: "wood", Pattern: "planks with 45° mitered ends forming continuous V-points aligned from bottom-left to top-right of the image"}, } var tilePatterns = []PatternOption{ @@ -59,7 +59,7 @@ var tilePatterns = []PatternOption{ {Code: 6, Name: "工字铺(1/2错缝)Running Bond", Category: "tile", Pattern: "rows parallel to bottom edge of image, each row offset 50% from previous, horizontal grout lines continuous, vertical grout lines staggered"}, {Code: 7, Name: "三七错铺 1/3 Offset", Category: "tile", Pattern: "rows parallel to bottom edge of image, each row offset exactly 33% of tile length, every third row aligns"}, {Code: 8, Name: "六边形 Hexagonal", Category: "tile", Pattern: "six-sided tiles interlocked in honeycomb mesh, flat edges horizontal (parallel to bottom edge of image), grout follows hexagonal edges"}, - {Code: 9, Name: "斜铺(60度对角)Diagonal", Category: "tile", Pattern: "tiles rotated 60 degrees to the image frame, grout lines run diagonally at 60 and 150 degrees to the bottom edge, no lines parallel to image edges"}, + {Code: 9, Name: "斜铺(60度对角)Diagonal", Category: "tile", Pattern: "tiles rotated 60° to the image frame, grout lines run diagonally at 60 and 150 degrees to the bottom edge, no lines parallel to image edges"}, } var roomOptions = []RoomOption{ @@ -113,7 +113,7 @@ func loadFloorOptions(db *sql.DB) ([]FloorOption, error) { return nil, err } type key struct{ brand, style string } - seen := map[key]int{} // key 閳?index in out slice + seen := map[key]int{} // key → index in out slice var out []FloorOption for _, p := range prods { k := key{p.Brand, p.StyleName} @@ -199,7 +199,7 @@ func findFloorBySKU(db *sql.DB, sku string) *FloorOption { return f } -// 閳光偓閳光偓 Public accessors for worker 閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓 +// --- Public accessors for worker --- func FindFloorBySKUPublic(db *sql.DB, sku string) *FloorOption { return findFloorBySKU(db, sku) } func FindPatternByCodePublic(code string) *PatternOption { @@ -218,7 +218,7 @@ func BuildFloorPromptPublic(f FloorOption, p PatternOption, room *RoomOption) st } // BuildCombinedFloorPrompt builds a single prompt that identifies the floor area AND replaces it. -// No separate mask generation step 閳?the AI does both in one pass. +// No separate mask generation step — the AI does both in one pass. var baseboardColorNames = map[string]string{ "white": "白色", "floor": "与地板同色", "cream": "米白", "lightgray": "浅灰", "darkgray": "深灰", "wood": "木色(深棕)", @@ -258,7 +258,7 @@ func buildPatternConstraint(code int) string { } } -// 閳光偓閳光偓 Floor Generate Handler (Redis queue) 閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓 +// --- Floor Generate Handler (Redis queue) --- func SetQueue(enqueue func(ctx context.Context, jobID string, payload map[string]string) error) { generateQueue = enqueue @@ -346,9 +346,9 @@ func FloorGenerate(client *openrouter.Client, db *sql.DB) http.HandlerFunc { } } -// 閳光偓閳光偓 Progress 閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓 +// --- Progress --- -// 閳光偓閳光偓 Floor Status Query 閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓 +// --- Floor Status Query --- func FloorStatus(w http.ResponseWriter, r *http.Request) { jobID := r.URL.Query().Get("job_id") @@ -368,7 +368,7 @@ func FloorStatus(w http.ResponseWriter, r *http.Request) { writeJSON(w, 200, js) } -// 閳光偓閳光偓 Options 閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓 +// --- Options --- func FloorOptions(db *sql.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { @@ -400,7 +400,7 @@ func FloorOptions(db *sql.DB) http.HandlerFunc { } } -// materialIndex caches SKU 閳?material description from MaterialAssets JSON files. +// materialIndex caches SKU → material description from MaterialAssets JSON files. var materialIndex map[string]string // LoadMaterialIndex loads the material description index from a JSON file. @@ -450,13 +450,13 @@ func loadSpecialFloors(db *sql.DB) []FloorOption { continue } f.FloorDescription = r.Description - // Keep f.ImageURL from DB (canonical smallest) 閳?do NOT override with local path + // Keep f.ImageURL from DB (canonical smallest) — do NOT override with local path out = append(out, *f) } return out } -// 閳光偓閳光偓 Prompts 閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓閳光偓 +// --- Prompts --- func buildMaskPrompt(room *RoomOption) string { base := "你是精确的地面分割工具。请为这张室内照片生成纯黑白遮罩图。\n\n" + @@ -585,10 +585,6 @@ func buildFloorPrompt(floor FloorOption, pattern PatternOption, room *RoomOption return buildCompactFloorPrompt(floor, pattern, room) } -func buildProductNameGuard(floor FloorOption) string { - return compactProductNameGuard(floor) -} - func validateContent(client *openrouter.Client, ctx context.Context, imagePath string) (bool, int) { imgData, err := os.ReadFile(imagePath) if err != nil {