Created
January 19, 2020 13:29
-
-
Save yutakahashi114/31596635831aee9ba25d700fe2cd38df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type userForEnableEmpty struct { | |
ID uint64 `xorm:"autoincr"` | |
FirstName *string | |
LastName *string | |
FirstNameKana *string | |
LastNameKana *string | |
Version uint64 `xorm:"version"` | |
CreatedAt time.Time `xorm:"created"` | |
UpdatedAt time.Time `xorm:"updated"` | |
DeletedAt time.Time `xorm:"deleted"` | |
} | |
func (userForEnableEmpty) TableName() string { | |
return "users" | |
} | |
{ | |
ufee := userForEnableEmpty{} | |
has, err = engine. | |
Where("id = ?", id). | |
Get(&ufee) | |
if err != nil { | |
log.Println(err) | |
return | |
} | |
if !has { | |
log.Println("Not Found") | |
return | |
} | |
ufee.FirstName = &u.FirstName | |
ufee.LastName = &u.LastName | |
ufee.FirstNameKana = &u.FirstNameKana | |
affected, err = engine. | |
Where("id = ?", id). | |
Update(&ufee) | |
if err != nil { | |
log.Println(err) | |
return | |
} | |
if affected == 0 { | |
log.Println("Not Found") | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment