// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: user.sql package repo import ( "context" ) const findUserByOpenID = `-- name: FindUserByOpenID :one SELECT u.id AS user_id, u.nickname, u.avatar, u.status, o.type AS login_type, o.openid FROM user_oauth o JOIN "user" u ON u.id = o.user_id WHERE o.openid = $1 AND o.type = $2 LIMIT 1 ` type FindUserByOpenIDParams struct { Openid string Type int16 } type FindUserByOpenIDRow struct { UserID int64 Nickname string Avatar string Status int16 LoginType int16 Openid string } func (q *Queries) FindUserByOpenID(ctx context.Context, arg FindUserByOpenIDParams) (FindUserByOpenIDRow, error) { row := q.db.QueryRow(ctx, findUserByOpenID, arg.Openid, arg.Type) var i FindUserByOpenIDRow err := row.Scan( &i.UserID, &i.Nickname, &i.Avatar, &i.Status, &i.LoginType, &i.Openid, ) return i, err } const getUserById = `-- name: GetUserById :one SELECT id, nickname, avatar, status, last_login_time, create_time, update_time FROM "user" WHERE id = $1 ` func (q *Queries) GetUserById(ctx context.Context, id int64) (User, error) { row := q.db.QueryRow(ctx, getUserById, id) var i User err := row.Scan( &i.ID, &i.Nickname, &i.Avatar, &i.Status, &i.LastLoginTime, &i.CreateTime, &i.UpdateTime, ) return i, err } const insertUser = `-- name: InsertUser :exec INSERT INTO "user" ( id, nickname, avatar, status, create_time, update_time, last_login_time ) VALUES ( $1, $2, $3,$4, NOW(), NOW(),now() ) ` type InsertUserParams struct { ID int64 Nickname string Avatar string Status int16 } func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) error { _, err := q.db.Exec(ctx, insertUser, arg.ID, arg.Nickname, arg.Avatar, arg.Status, ) return err } const updateUserLastLoginTime = `-- name: UpdateUserLastLoginTime :exec UPDATE "user" SET last_login_time = NOW() WHERE id = $1 ` func (q *Queries) UpdateUserLastLoginTime(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, updateUserLastLoginTime, id) return err }