add more fields to device data

This commit is contained in:
Nam Huynh 2021-08-21 19:46:28 +07:00
parent 342834dfe9
commit a6746c0562
2 changed files with 5 additions and 3 deletions

View File

@ -14,8 +14,8 @@ func (s Service) GetStaffPermissionsByToken(token string) (doc StaffPermissions)
stm, args, _ := s.Builder.
Select("dm.id AS device_id, s.id, s.name, s.account_type, s.active, sr.permissions").
From(fmt.Sprintf("%s AS dm", TableDeviceMngt)).
Join(fmt.Sprintf("LEFT JOIN %s 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 s ON s.id = dm.owner_id", TableStaff)).
LeftJoin(fmt.Sprintf("%s AS sr ON s.role_id = sr.id", TableStaffRole)).
Where("dm.auth_token = ?", token).
ToSql()
if err := s.DB.GetContext(ctx, &doc, stm, args...); err != nil {

View File

@ -3,6 +3,7 @@ package devicemngt
import (
"context"
"net/http"
"strings"
"time"
"github.com/Selly-Modules/logger"
@ -73,7 +74,8 @@ func (s Service) Upsert(payload UpsertPayload) {
// Auth token
if headerData.AuthToken != "" {
authToken = headerData.AuthToken
// Get token only, remove "Bearer "
authToken = strings.Split(headerData.AuthToken, " ")[1]
} else {
authToken = payload.AuthToken
}