2021-08-17 04:03:50 +00:00
|
|
|
package devicemngt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-08-19 08:48:05 +00:00
|
|
|
"net/http"
|
2021-08-17 04:03:50 +00:00
|
|
|
|
2022-10-10 03:22:40 +00:00
|
|
|
"git.selly.red/Selly-Modules/logger"
|
2021-08-17 04:03:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// findByDeviceID ...
|
|
|
|
func (s Service) findByDeviceID(ctx context.Context, id string) (result Device) {
|
2021-08-17 04:38:27 +00:00
|
|
|
stm, args, _ := s.Builder.Select("*").From(TableDeviceMngt).Where("device_id = ?", id).ToSql()
|
2021-08-17 04:03:50 +00:00
|
|
|
|
2021-08-19 08:43:28 +00:00
|
|
|
if err := s.DB.GetContext(ctx, &result, stm, args...); err != nil {
|
2021-08-17 04:03:50 +00:00
|
|
|
logger.Error("devicemngt - findByDeviceID", logger.LogData{
|
|
|
|
"device_id": id,
|
|
|
|
"error": err.Error(),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2021-08-19 08:48:05 +00:00
|
|
|
|
|
|
|
// getHeaderData ...
|
|
|
|
func getHeaderData(headers http.Header) HeaderData {
|
|
|
|
return HeaderData{
|
|
|
|
UserAgent: headers.Get("User-Agent"),
|
|
|
|
DeviceID: headers.Get("Deviceid"),
|
|
|
|
AppVersion: headers.Get("App-Version"),
|
|
|
|
AppVersionCode: headers.Get("App-Version-Code"),
|
|
|
|
OSName: headers.Get("Os-Name"),
|
|
|
|
OSVersion: headers.Get("Os-Version"),
|
2021-08-19 08:51:09 +00:00
|
|
|
AuthToken: headers.Get("Authorization"),
|
2021-08-19 08:48:05 +00:00
|
|
|
}
|
|
|
|
}
|