This commit is contained in:
parent
11e0059631
commit
b33f6c2af7
8 changed files with 3609 additions and 7 deletions
|
@ -6,6 +6,7 @@ package dbgen
|
|||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||
"gorm.io/gorm"
|
||||
|
@ -1346,6 +1347,25 @@ type IUserDo interface {
|
|||
Returning(value interface{}, columns ...string) IUserDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
|
||||
GetByUsername(username string) (result *models.User, err error)
|
||||
}
|
||||
|
||||
// Get a user by a username
|
||||
//
|
||||
// SELECT * FROM @@table WHERE username = @username LIMIT 1
|
||||
func (u userDo) GetByUsername(username string) (result *models.User, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, username)
|
||||
generateSQL.WriteString("SELECT * FROM users WHERE username = ? LIMIT 1 ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
||||
err = executeSQL.Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (u userDo) Debug() IUserDo {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue