修改为sql数据库

This commit is contained in:
bjdgyc
2021-07-15 18:17:37 +08:00
parent 6daf9cbfa3
commit 884f41d2f8
19 changed files with 351 additions and 175 deletions

View File

@@ -11,8 +11,8 @@ import (
)
type User struct {
Id int `json:"id" storm:"id,increment"`
Username string `json:"username" storm:"unique"`
Id int `json:"id" xorm:"pk autoincr not null"`
Username string `json:"username" storm:"not null unique"`
Nickname string `json:"nickname"`
Email string `json:"email"`
// Password string `json:"password"`
@@ -57,7 +57,11 @@ func SetUser(v *User) error {
v.Groups = ng
v.UpdatedAt = time.Now()
err = Save(v)
if v.Id > 0 {
err = Set(v)
} else {
err = Add(v)
}
return err
}