package controller import ( "github.com/gin-gonic/gin" "iot_manager_service/app/device/model" "iot_manager_service/app/device/service" "iot_manager_service/util" "net/http" "strconv" ) // 工具服务 var Util = new(utilCtl) type utilCtl struct{} // GetModelList 获取厂家/品牌/型号列表 // 查询类型 type:1-厂家,2-品牌,3-型号 //deviceType 设备类型 //0-摄像头 //1 灯控 //2 信息屏 //3 配电箱 //4 网关 //5 环境监测 //6 ZigBee //7 一键告警终端 //8 一键告警服务端 //11 桥梁传感器 //12 ip音柱 //13 井盖 //14 垃圾桶 func (c *utilCtl) GetModelList(ctx *gin.Context) { t := ctx.Query("type") d := ctx.Query("deviceType") modeType, err := strconv.Atoi(t) if err != nil || modeType < 1 || modeType > 3 { ctx.JSON(http.StatusOK, util.ParamsInvalidResponse("type invalid", nil)) return } deviceType, err := strconv.Atoi(d) if err != nil { ctx.JSON(http.StatusOK, util.ParamsInvalidResponse("deviceType invalid", nil)) return } vendor, err := service.UtilService.GetDeviceVendor(modeType, deviceType) if err != nil { ctx.JSON(http.StatusOK, util.FailResponse(err.Error(), nil)) return } var result []model.VendorDetail if modeType == model.TypeVendor { result = append(result, model.VendorDetail{ Id: vendor.ID, ParentId: vendor.ParentId, Vendor: vendor.VendorValue, Brand: "", Model: "", }) } else if modeType == model.TypeBrand { result = append(result, model.VendorDetail{ Id: vendor.ID, ParentId: vendor.ParentId, Vendor: "", Brand: vendor.VendorValue, Model: "", }) } else if modeType == model.TypeModel { result = append(result, model.VendorDetail{ Id: vendor.ID, ParentId: vendor.ParentId, Vendor: "", Brand: "", Model: vendor.VendorValue, }) } ctx.JSON(http.StatusOK, util.SuccessResponse("", result)) } func (c *utilCtl) GetTenantCode(ctx *gin.Context) { ctx.JSON(http.StatusOK, util.SuccessResponse("", nil)) }