chore: clean binary entries

This commit is contained in:
Steven
2023-12-11 22:16:39 +08:00
parent 52f399a154
commit c608877c3e
33 changed files with 20 additions and 954 deletions

View File

@ -11,37 +11,6 @@ func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, e
fields := []string{"`username`", "`role`", "`email`", "`nickname`", "`password_hash`"}
placeholder := []string{"?", "?", "?", "?", "?"}
args := []any{create.Username, create.Role, create.Email, create.Nickname, create.PasswordHash}
if create.AvatarURL != "" {
fields = append(fields, "`avatar_url`")
placeholder = append(placeholder, "?")
args = append(args, create.AvatarURL)
}
if create.RowStatus != "" {
fields = append(fields, "`row_status`")
placeholder = append(placeholder, "?")
args = append(args, create.RowStatus)
}
if create.CreatedTs != 0 {
fields = append(fields, "`created_ts`")
placeholder = append(placeholder, "?")
args = append(args, create.CreatedTs)
}
if create.UpdatedTs != 0 {
fields = append(fields, "`updated_ts`")
placeholder = append(placeholder, "?")
args = append(args, create.UpdatedTs)
}
if create.ID != 0 {
fields = append(fields, "`id`")
placeholder = append(placeholder, "?")
args = append(args, create.ID)
}
stmt := "INSERT INTO user (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING id, avatar_url, created_ts, updated_ts, row_status"
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
&create.ID,