refactor(backend): rename user functions in db.go
also rename Quote region to Quotes in db.go
This commit is contained in:
parent
2049121e2a
commit
68d5063dd9
@ -32,31 +32,31 @@ func InitDB(connString string) error {
|
|||||||
|
|
||||||
//#region User
|
//#region User
|
||||||
|
|
||||||
func Authorize(ctx context.Context, login string, password string) (user models.User, err error) {
|
func UserAuth(ctx context.Context, login string, password string) (user models.User, err error) {
|
||||||
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_auth($1, $2)", login, password)
|
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_auth($1, $2)", login, password)
|
||||||
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateUserName(ctx context.Context, user_id string, new_name string) (user models.User, err error) {
|
func UserUpdateName(ctx context.Context, user_id string, new_name string) (user models.User, err error) {
|
||||||
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_update($1, $2)", user_id, new_name)
|
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_update($1, $2)", user_id, new_name)
|
||||||
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateUserLogin(ctx context.Context, user_id string, new_login string) (user models.User, err error) {
|
func UserUpdateLogin(ctx context.Context, user_id string, new_login string) (user models.User, err error) {
|
||||||
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_update($1, NULL, $2)", user_id, new_login)
|
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_update($1, NULL, $2)", user_id, new_login)
|
||||||
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateUserTelegramID(ctx context.Context, user_id string, new_telegram_id int64) (user models.User, err error) {
|
func UserUpdateTelegramID(ctx context.Context, user_id string, new_telegram_id int64) (user models.User, err error) {
|
||||||
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_update($1, NULL, NULL, $2)", user_id, new_telegram_id)
|
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_update($1, NULL, NULL, $2)", user_id, new_telegram_id)
|
||||||
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateUserPassword(ctx context.Context, user_id string, new_password string) (user models.User, err error) {
|
func UserUpdatePassword(ctx context.Context, user_id string, new_password string) (user models.User, err error) {
|
||||||
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_update($1, NULL, NULL, NULL, $2)", user_id, new_password)
|
row := ConnPool.QueryRow(ctx, "SELECT * FROM user_update($1, NULL, NULL, NULL, $2)", user_id, new_password)
|
||||||
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
err = row.Scan(&user.ID, &user.Name, &user.Login, &user.Role, &user.TelegramID)
|
||||||
return
|
return
|
||||||
@ -64,7 +64,7 @@ func UpdateUserPassword(ctx context.Context, user_id string, new_password string
|
|||||||
|
|
||||||
//#endregion User
|
//#endregion User
|
||||||
|
|
||||||
//#region Quote
|
//#region Quotes
|
||||||
|
|
||||||
func QuotesGet(ctx context.Context, user_id string, filter string, sort string, limit int, offset int) (quotes []models.Quote, err error) {
|
func QuotesGet(ctx context.Context, user_id string, filter string, sort string, limit int, offset int) (quotes []models.Quote, err error) {
|
||||||
query := "SELECT * FROM quotes_get($1) WHERE position($2 in text)>0 OR position($2 in author)>0"
|
query := "SELECT * FROM quotes_get($1) WHERE position($2 in text)>0 OR position($2 in author)>0"
|
||||||
@ -163,4 +163,4 @@ func QuoteDelete(ctx context.Context, user_id string, quote_id string) (err erro
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endregion Quote
|
//#endregion Quotes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user