mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[fix]修改减少验证
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 != "" {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user