add AppVersion and AppVersionCode in model

This commit is contained in:
Nam Huynh 2021-08-19 15:29:17 +07:00
parent 56598f41fa
commit 9edabb1140
2 changed files with 18 additions and 7 deletions

View File

@ -71,13 +71,14 @@ func (s Service) Upsert(payload UpsertPayload) {
appVersionCode = headerData.AppVersionCode
}
pretty.Println("platform", platform)
pretty.Println("osName", osName)
pretty.Println("osVersion", osVersion)
pretty.Println("appVersion", appVersion)
pretty.Println("appVersionCode", appVersionCode)
pretty.Println("browserName", browserName)
pretty.Println("browserVersion", browserVersion)
pretty.Println("- platform", platform)
pretty.Println("- osName", osName)
pretty.Println("- osVersion", osVersion)
pretty.Println("- appVersion", appVersion)
pretty.Println("- appVersionCode", appVersionCode)
pretty.Println("- browserName", browserName)
pretty.Println("- browserVersion", browserVersion)
pretty.Println("----------------")
// Find device id existed or not
device := s.findByDeviceID(ctx, deviceID)
@ -97,6 +98,10 @@ func (s Service) Upsert(payload UpsertPayload) {
payload.FirstSignInAt, now(),
).ToSql()
pretty.Println("Create new")
pretty.Println("stm -", stm)
pretty.Println("args -", args)
if _, err := s.DB.ExecContext(ctx, stm, args); err != nil {
logger.Error("devicemngt - Upsert: Create new", logger.LogData{
"payload": payload,
@ -122,6 +127,10 @@ func (s Service) Upsert(payload UpsertPayload) {
Where("device_id = ?", deviceID).
ToSql()
pretty.Println("Update")
pretty.Println("stm -", stm)
pretty.Println("args -", args)
if _, err := s.DB.ExecContext(ctx, stm, args); err != nil {
logger.Error("devicemngt - Upsert: Update", logger.LogData{
"payload": payload,

View File

@ -10,6 +10,8 @@ type Device struct {
Platform string `db:"platform"`
OSName string `db:"os_name"`
OSVersion string `db:"os_version"`
AppVersion string `db:"app_version"`
AppVersionCode string `db:"app_version_code"`
BrowserName string `db:"browser_name"`
BrowserVersion string `db:"browser_version"`
AuthToken string `db:"auth_token"`