2021-11-05 07:21:57 +00:00
|
|
|
package devicemngmt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2021-11-05 08:40:07 +00:00
|
|
|
ua "github.com/mssola/user_agent"
|
2021-11-05 07:21:57 +00:00
|
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
|
|
)
|
|
|
|
|
|
|
|
// getDeviceCollection ...
|
|
|
|
func (s Service) getDeviceCollection() *mongo.Collection {
|
2021-11-05 08:40:07 +00:00
|
|
|
return s.DB.Collection(fmt.Sprintf("%s-%s", s.TablePrefix, tableDevice))
|
|
|
|
}
|
|
|
|
|
|
|
|
func getOSName(userAgent string) string {
|
|
|
|
uaData := ua.New(userAgent)
|
|
|
|
return uaData.OSInfo().Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func getOSVersion(userAgent string) string {
|
|
|
|
uaData := ua.New(userAgent)
|
|
|
|
return uaData.OSInfo().Version
|
|
|
|
}
|
|
|
|
|
|
|
|
func getLanguage(lang string) string {
|
|
|
|
// Language, default is vietnamese(vi)
|
|
|
|
if lang == langEn {
|
|
|
|
return langEn
|
|
|
|
}
|
|
|
|
return langVi
|
2021-11-05 07:21:57 +00:00
|
|
|
}
|