package handler import ( "city_chips/internal/model" "city_chips/internal/service" "city_chips/pkg/helper/resp" "fmt" "github.com/gin-gonic/gin" "github.com/spf13/viper" "math/rand" "time" ) type PropertyHandler struct { *Handler propertyService service.PropertyService conf *viper.Viper } func NewPropertyHandler( handler *Handler, propertyService service.PropertyService, conf *viper.Viper, ) *PropertyHandler { return &PropertyHandler{ Handler: handler, propertyService: propertyService, conf: conf, } } // GetProperty 获取物业管理系统数据 func (h *PropertyHandler) GetProperty(ctx *gin.Context) { m := make(map[string]any) access := make(map[string]any) garageCount := make(map[string]any) var accessData model.AccessData var accessRecords []model.AccessRecords var garRecords []model.GarRecords var garage model.Garage m["HousesCount"] = rand.Intn(100) //房屋数 m["HouseholdCount"] = rand.Intn(100) //住户数 m["DrivewayCount"] = rand.Intn(100) //车位数 m["PopulationCount"] = rand.Intn(100) //人口总数 m["Under30"] = rand.Intn(100) //30以下 m["Under40"] = rand.Intn(100) //40以下 m["Under50"] = rand.Intn(100) //50以下 m["More60"] = rand.Intn(100) //60以上 for i := 0; i < 7; i++ { date := fmt.Sprintf("2025-5-%v", i+1) accessData.Remote = rand.Intn(100) accessData.CreditCard = rand.Intn(100) accessData.BrushFace = rand.Intn(100) garage.Storage = rand.Intn(100) garage.OutboundShipments = rand.Intn(100) access[date] = accessData garageCount[date] = garage } for i := 0; i < 10; i++ { name := fmt.Sprintf("人员%v", i+1) records := model.AccessRecords{ Name: name, State: 0, Date: time.Now().Format("2006-01-02 15:04:05"), } accessRecords = append(accessRecords, records) } for i := 0; i < 10; i++ { name := fmt.Sprintf("贵A%v", i+1) records := model.GarRecords{ GarName: name, State: 0, GarImag: "https://img95.699pic.com/photo/40041/1120.jpg_wh860.jpg", Date: time.Now().Format("2006-01-02 15:04:05"), } garRecords = append(garRecords, records) } m["HousesCount"] = rand.Intn(100) //房屋数 m["HouseholdCount"] = rand.Intn(100) //住户数 m["DrivewayCount"] = rand.Intn(100) //车位数 m["PopulationCount"] = rand.Intn(100) //人口总数 m["Under30"] = rand.Intn(100) //30以下 m["Under40"] = rand.Intn(100) //40以下 m["Under50"] = rand.Intn(100) //50以下 m["More60"] = rand.Intn(100) //60以上 m["AccessRecords"] = accessRecords //人员出入记录 m["GarRecords"] = garRecords //车辆出入记录 m["Access"] = access //门禁管理 m["GarageCount"] = access //车库流动管理 resp.HandleSuccess(ctx, m) }