1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package account
import (
"fmt"
"nexus/models"
"nexus/repositories/account"
"nexus/utils/logger"
"nexus/utils/shortcuts"
"github.com/gofiber/fiber/v2"
"github.com/google/uuid"
)
func GetByID(id uuid.UUID) (*models.Account, *fiber.Error) {
a, err := account.FindByID(id)
if err != nil {
return nil, shortcuts.ServiceError(fiber.StatusNotFound, ErrAccountNotFound)
}
return a, nil
}
func Disable(id uuid.UUID) *fiber.Error {
if _, err := account.FindByID(id); err != nil {
return shortcuts.ServiceError(fiber.StatusNotFound, ErrAccountNotFound)
}
if err := account.Disable(id); err != nil {
logger.Errorf(LogPrefix, AccountDisableFailed, err)
return shortcuts.ServiceError(fiber.StatusInternalServerError, fmt.Sprintf(AccountDisableFailed, err))
}
return nil
}
func Delete(id uuid.UUID) *fiber.Error {
if _, err := account.FindByID(id); err != nil {
return shortcuts.ServiceError(fiber.StatusNotFound, ErrAccountNotFound)
}
if err := account.Delete(id); err != nil {
logger.Errorf(LogPrefix, AccountDeleteFailed, err)
return shortcuts.ServiceError(fiber.StatusInternalServerError, fmt.Sprintf(AccountDeleteFailed, err))
}
return nil
}
|