diff --git a/internal/web/fillup.go b/internal/web/fillup.go index d83d641..3fb93af 100644 --- a/internal/web/fillup.go +++ b/internal/web/fillup.go @@ -20,8 +20,10 @@ import ( // fillupHint 是一次高德查询给出的建议(按地点 id 缓存在内存里,页面重载仍能看到)。 type fillupHint struct { - Act string - Cat string + Act string + Cat string + Type string // 高德给的原始类型(「餐饮服务;咖啡厅」),没映射上时给站长看 + Poi string // 最近的 POI 名字,同样只作参考 } var ( @@ -57,6 +59,8 @@ type FillupRow struct { ActID int64 // 建议命中现有活动时的 id;0 表示得新建 CatHint string // 建议的类别 Source string // 建议从哪来 + AmapType string // 高德给出的类型原文,供人工判断(可能没映射出建议) + AmapPoi string // 高德找到的最近 POI 名字 } func (r FillupRow) Missing() string { @@ -75,7 +79,7 @@ type FillupData struct { Page Rows []FillupRow Activities []activityOption // 下拉选项 - Categories []string // 类别下拉选项 + Categories []fillupCategory // 类别下拉选项 Total int WithHint int } @@ -149,6 +153,7 @@ func (s *Server) fillupRows(ctx context.Context, datasetID int64) ([]FillupRow, if out[i].NoCat && h.Cat != "" { out[i].CatHint = h.Cat } + out[i].AmapType, out[i].AmapPoi = h.Type, h.Poi } } sort.SliceStable(out, func(i, j int) bool { @@ -212,8 +217,16 @@ func (s *Server) activityOptions(ctx context.Context, datasetID int64) ([]activi return out, rows.Err() } +// fillupCategory 是类别下拉的一项。Label 用中文,并标出这一种真机到底用过没有—— +// ZCATEGORY_ 那列真机存的就是这些 MKPOICategory 枚举串,写错名字不会损坏数据, +// 但会显示不出类别,所以优先选「真机用过」的那几种。 +type fillupCategory struct { + Value string + Label string +} + // fillupCategories 是类别下拉的选项:真机用过的 12 种在前,其余常见 MapKit 类别在后。 -func fillupCategories() []string { +func fillupCategories() []fillupCategory { known := []string{ "MKPOICategoryRestaurant", "MKPOICategoryStore", "MKPOICategoryPublicTransport", "MKPOICategoryHotel", "MKPOICategoryLandmark", "MKPOICategoryFoodMarket", @@ -228,7 +241,14 @@ func fillupCategories() []string { "MKPOICategoryNationalPark", "MKPOICategoryAquarium", "MKPOICategoryAmusementPark", "MKPOICategoryGasStation", "MKPOICategoryCarRental", "MKPOICategoryMarina", } - return append(known, extra...) + out := make([]fillupCategory, 0, len(known)+len(extra)) + for _, c := range known { + out = append(out, fillupCategory{c, poiName(c) + "(真机用过)"}) + } + for _, c := range extra { + out = append(out, fillupCategory{c, poiName(c)}) + } + return out } // adminFillupApply 执行补全。表单里每行两个字段: @@ -411,9 +431,10 @@ func (s *Server) adminFillupAmap(w http.ResponseWriter, r *http.Request) { if n >= fillupAmapBatch { break } - _, typ, _, ok := s.amapAround(ctx, row.Lat, row.Lon) + poi, typ, _, ok := s.amapAround(ctx, row.Lat, row.Lon) var h fillupHint if ok { + h.Type, h.Poi = typ, poi h.Act = guessActivityFromAmapType(typ) h.Cat = guessCategoryFromAmapType(typ) if h.Act != "" || h.Cat != "" { diff --git a/internal/web/templates/admin/fillup.html b/internal/web/templates/admin/fillup.html index 1c2b78d..25d46dd 100644 --- a/internal/web/templates/admin/fillup.html +++ b/internal/web/templates/admin/fillup.html @@ -20,7 +20,9 @@