update delete action
This commit is contained in:
parent
1c4cbb1868
commit
d5d0979321
|
@ -2,6 +2,7 @@ package devicemngmt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Selly-Modules/logger"
|
"github.com/Selly-Modules/logger"
|
||||||
|
@ -18,6 +19,11 @@ func (s Service) DeleteByDeviceID(deviceID string) error {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
total, _ := col.CountDocuments(ctx, cond)
|
||||||
|
if total == 0 {
|
||||||
|
return errors.New("deviceId not found")
|
||||||
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if _, err := col.DeleteOne(ctx, cond); err != nil {
|
if _, err := col.DeleteOne(ctx, cond); err != nil {
|
||||||
logger.Error("devicemngmt - deleteByDeviceID", logger.LogData{
|
logger.Error("devicemngmt - deleteByDeviceID", logger.LogData{
|
||||||
|
|
|
@ -2,6 +2,7 @@ package devicemngmt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Selly-Modules/logger"
|
"github.com/Selly-Modules/logger"
|
||||||
|
@ -30,6 +31,11 @@ func (s Service) UpdateByDeviceID(deviceID string, payload UpdateOptions) error
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
total, _ := col.CountDocuments(ctx, cond)
|
||||||
|
if total == 0 {
|
||||||
|
return errors.New("deviceId not found")
|
||||||
|
}
|
||||||
|
|
||||||
// Validate payload
|
// Validate payload
|
||||||
err := payload.validate()
|
err := payload.validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue