add more fields to device data
This commit is contained in:
parent
342834dfe9
commit
a6746c0562
|
@ -14,8 +14,8 @@ func (s Service) GetStaffPermissionsByToken(token string) (doc StaffPermissions)
|
||||||
stm, args, _ := s.Builder.
|
stm, args, _ := s.Builder.
|
||||||
Select("dm.id AS device_id, s.id, s.name, s.account_type, s.active, sr.permissions").
|
Select("dm.id AS device_id, s.id, s.name, s.account_type, s.active, sr.permissions").
|
||||||
From(fmt.Sprintf("%s AS dm", TableDeviceMngt)).
|
From(fmt.Sprintf("%s AS dm", TableDeviceMngt)).
|
||||||
Join(fmt.Sprintf("LEFT JOIN %s s ON s.id = dm.owner_id", TableStaff)).
|
LeftJoin(fmt.Sprintf("%s AS s ON s.id = dm.owner_id", TableStaff)).
|
||||||
Join(fmt.Sprintf("LEFT JOIN %s sr ON s.role_id = sr.id", TableStaffRole)).
|
LeftJoin(fmt.Sprintf("%s AS sr ON s.role_id = sr.id", TableStaffRole)).
|
||||||
Where("dm.auth_token = ?", token).
|
Where("dm.auth_token = ?", token).
|
||||||
ToSql()
|
ToSql()
|
||||||
if err := s.DB.GetContext(ctx, &doc, stm, args...); err != nil {
|
if err := s.DB.GetContext(ctx, &doc, stm, args...); err != nil {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package devicemngt
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Selly-Modules/logger"
|
"github.com/Selly-Modules/logger"
|
||||||
|
@ -73,7 +74,8 @@ func (s Service) Upsert(payload UpsertPayload) {
|
||||||
|
|
||||||
// Auth token
|
// Auth token
|
||||||
if headerData.AuthToken != "" {
|
if headerData.AuthToken != "" {
|
||||||
authToken = headerData.AuthToken
|
// Get token only, remove "Bearer "
|
||||||
|
authToken = strings.Split(headerData.AuthToken, " ")[1]
|
||||||
} else {
|
} else {
|
||||||
authToken = payload.AuthToken
|
authToken = payload.AuthToken
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue