123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- 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++ {
- acce := model.AccessRecords{
- Name: model.Names[i],
- State: 0,
- Date: time.Now().Format("2006-01-02 15:04:05"),
- }
- records := model.GarRecords{
- GarName: model.GetRandomItem(model.Names),
- State: 0,
- Context: model.GetRandomItem(model.ResidentToPropertyContents),
- Date: time.Now().Format("2006-01-02 15:04:05"),
- }
- garRecords = append(garRecords, records)
- accessRecords = append(accessRecords, acce)
- }
- 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)
- }
|