1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-03 04:38:38 -04:00

Remove duplicate *Tx versions of database access methods

Simplify naming to remove "Tx" now that all handlers only have access to
transactions anyway, and always use "tx" as the name of the variable
representing the SQL transactions (to make it less likely to cause
confusion with monetary transactions).
This commit is contained in:
2017-10-14 19:41:13 -04:00
parent 4e53a5e59c
commit 2ff1f47432
8 changed files with 67 additions and 147 deletions

View File

@ -56,16 +56,6 @@ func GetUser(tx *Tx, userid int64) (*User, error) {
return &u, nil
}
func GetUserTx(tx *Tx, userid int64) (*User, error) {
var u User
err := tx.SelectOne(&u, "SELECT * from users where UserId=?", userid)
if err != nil {
return nil, err
}
return &u, nil
}
func GetUserByUsername(tx *Tx, username string) (*User, error) {
var u User
@ -100,7 +90,7 @@ func InsertUser(tx *Tx, u *User) error {
security = *security_template
security.UserId = u.UserId
err = InsertSecurityTx(tx, &security)
err = InsertSecurity(tx, &security)
if err != nil {
return err
}
@ -125,16 +115,8 @@ func GetUserFromSession(tx *Tx, r *http.Request) (*User, error) {
return GetUser(tx, s.UserId)
}
func GetUserFromSessionTx(tx *Tx, r *http.Request) (*User, error) {
s, err := GetSessionTx(tx, r)
if err != nil {
return nil, err
}
return GetUserTx(tx, s.UserId)
}
func UpdateUser(tx *Tx, u *User) error {
security, err := GetSecurityTx(tx, u.DefaultCurrency, u.UserId)
security, err := GetSecurity(tx, u.DefaultCurrency, u.UserId)
if err != nil {
return err
} else if security.UserId != u.UserId || security.SecurityId != u.DefaultCurrency {