This commit is contained in:
PandaX
2024-03-15 15:22:35 +08:00
parent 7a25d49846
commit 00577ba627
5 changed files with 55 additions and 51 deletions

View File

@@ -2,7 +2,6 @@ package services
import (
"pandax/apps/device/entity"
"pandax/pkg/cache"
"pandax/pkg/global"
)
@@ -118,12 +117,6 @@ func (m *productModelImpl) Delete(ids []string) error {
if err := global.Db.Table(m.table).Delete(&entity.Product{}, "id in (?)", ids).Error; err != nil {
return err
}
for _, id := range ids {
// 删除超级表
deleteDeviceStable(id)
// 删除所有缓存
cache.DelProductRule(id)
}
return nil
}
@@ -139,18 +132,6 @@ func createDeviceStable(productId string) error {
return nil
}
func deleteDeviceStable(productId string) error {
err := global.TdDb.DropStable(productId + "_" + entity.ATTRIBUTES_TSL)
if err != nil {
return err
}
err = global.TdDb.DropStable(productId + "_" + entity.TELEMETRY_TSL)
if err != nil {
return err
}
return nil
}
// 获取产品数量统计
func (m *productModelImpl) FindProductCount() (count entity.DeviceCount, err error) {
sql := `SELECT COUNT(*) AS total, (SELECT COUNT(*) FROM products WHERE DATE(create_time) = CURDATE()) AS today FROM products`