diff --git a/apps/device/api/device.go b/apps/device/api/device.go index 7d28d61..5dd5fb9 100644 --- a/apps/device/api/device.go +++ b/apps/device/api/device.go @@ -205,7 +205,7 @@ func (p *DeviceApi) InsertDevice(rc *restfulx.ReqCtx) { // UpdateDevice 修改Device func (p *DeviceApi) UpdateDevice(rc *restfulx.ReqCtx) { var data entity.Device - restfulx.BindJsonAndValid(rc, &data) + restfulx.BindQuery(rc, &data) product := p.ProductApp.FindOne(data.Pid) biz.NotNil(product, "未查到所属产品信息") data.Protocol = product.ProtocolName diff --git a/apps/device/services/device.go b/apps/device/services/device.go index b71df32..e698bda 100644 --- a/apps/device/services/device.go +++ b/apps/device/services/device.go @@ -52,13 +52,13 @@ func (m *deviceModelImpl) Insert(data entity.Device) *entity.Device { } //3 添加设备 err := tx.Table(m.table).Create(&data).Error - biz.ErrIsNil(err, "添加设备失败") + biz.ErrIsNilAppendErr(err, "添加设备失败") // 创建超级表 失败就 if data.Pid != "" { err = createDeviceTable(data.Pid, data.Name) if err != nil { tx.Rollback() - biz.ErrIsNil(err, "添加设备失败,设备表创建失败") + biz.ErrIsNil(err, "时序数据设备表创建失败") } } tx.Commit() diff --git a/apps/device/services/product.go b/apps/device/services/product.go index a8e1e62..7afd2a6 100644 --- a/apps/device/services/product.go +++ b/apps/device/services/product.go @@ -63,6 +63,7 @@ func (m *productModelImpl) FindListPage(page, pageSize int, data entity.Product) db = db.Where("device_type = ?", data.DeviceType) } if data.ProductCategoryId != "" { + db = db.Where("product_category_id = ?", data.ProductCategoryId) } if data.ProtocolName != "" { diff --git a/apps/device/services/product_category.go b/apps/device/services/product_category.go index 0236890..1812574 100644 --- a/apps/device/services/product_category.go +++ b/apps/device/services/product_category.go @@ -128,6 +128,19 @@ func (m *productCategoryModelImpl) SelectProductCategory(data entity.ProductCate return sd } +func (m *productCategoryModelImpl) SelectProductCategoryById(data entity.ProductCategory, id string) []string { + list := m.FindList(data) + sd := make([]string, 0) + li := *list + for i := 0; i < len(li); i++ { + if li[i].Pid == id { + info := DiGuiProductCategoryId(list, li[i]) + sd = append(sd, info...) + } + } + return sd +} + func (m *productCategoryModelImpl) SelectProductCategoryLabel(data entity.ProductCategory) []entity.ProductCategoryLabel { list := m.FindList(data) @@ -170,6 +183,30 @@ func DiGuiProductCategory(sglist *[]entity.ProductCategory, menu entity.ProductC menu.Children = min return menu } + +func DiGuiProductCategoryId(sglist *[]entity.ProductCategory, menu entity.ProductCategory) []string { + list := *sglist + + min := make([]string, 0) + for j := 0; j < len(list); j++ { + + if menu.Id != list[j].Pid { + continue + } + mi := entity.ProductCategory{} + mi.Id = list[j].Id + mi.Pid = list[j].Pid + mi.Path = list[j].Path + mi.Name = list[j].Name + mi.Sort = list[j].Sort + mi.Status = list[j].Status + mi.Description = list[j].Description + ms := DiGuiProductCategoryId(sglist, mi) + min = append(min, ms...) + } + return min +} + func DiGuiProductCategoryLabel(sglist *[]entity.ProductCategory, organization entity.ProductCategoryLabel) entity.ProductCategoryLabel { list := *sglist