fix: user api

This commit is contained in:
email
2022-02-04 21:24:21 +08:00
parent 3fa918169e
commit 825bea59f0
9 changed files with 82 additions and 21 deletions

View File

@@ -57,7 +57,11 @@ func createUser(db *DB, create *api.UserCreate) (*api.User, error) {
)
VALUES (?, ?, ?)
RETURNING id, name, password, open_id, created_ts, updated_ts
`)
`,
create.Name,
create.Password,
create.OpenId,
)
if err != nil {
return nil, FormatError(err)
}
@@ -83,14 +87,15 @@ func patchUser(db *DB, patch *api.UserPatch) (*api.User, error) {
set, args := []string{}, []interface{}{}
if v := patch.Name; v != nil {
set, args = append(set, "name = ?"), append(args, *v)
set, args = append(set, "name = ?"), append(args, v)
}
if v := patch.Password; v != nil {
set, args = append(set, "password = ?"), append(args, *v)
set, args = append(set, "password = ?"), append(args, v)
}
if v := patch.OpenId; v != nil {
set, args = append(set, "open_id = ?"), append(args, *v)
set, args = append(set, "open_id = ?"), append(args, v)
}
args = append(args, patch.Id)
row, err := db.Db.Query(`