|
@@ -29,6 +29,7 @@ type Model struct {
|
|
|
LastLoginTime *utils.Time `json:"last_login_time"`
|
|
|
Status int `json:"status"`
|
|
|
Description string `json:"description"`
|
|
|
+ Phone string `json:"phone"`
|
|
|
}
|
|
|
|
|
|
func (m *Model) IsDisabled() bool {
|
|
@@ -60,23 +61,23 @@ func (m Model) RequestIds() []int {
|
|
|
return requestRelate.RequestIds(m.AuthIds())
|
|
|
}
|
|
|
|
|
|
-func Add(username, password string, status int, description string) error {
|
|
|
+func Add(username, password string, status int, description string, phone string) error {
|
|
|
exist, _ := GetByUserName(username)
|
|
|
if exist.Id > 0 {
|
|
|
return errors.New(fmt.Sprintf("[%s] 用户已经存在", username))
|
|
|
}
|
|
|
_, err := models.Db.Insert("admin_user").Rows(
|
|
|
- goqu.Record{"username": username, "password": password, "status": status, "description": description},
|
|
|
+ goqu.Record{"username": username, "password": password, "status": status, "description": description, "phone": phone},
|
|
|
).Executor().Exec()
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
-func Updata(id int, username, password string, status int, description string) error {
|
|
|
+func Updata(id int, username, password string, status int, description string, phone string) error {
|
|
|
exist, _ := GetByUserName(username)
|
|
|
if exist.Id > 0 && exist.Id != id {
|
|
|
return errors.New(fmt.Sprintf("[%s] 用户已经存在", username))
|
|
|
}
|
|
|
- record := goqu.Record{"username": username, "status": status, "description": description}
|
|
|
+ record := goqu.Record{"username": username, "status": status, "description": description, "phone": phone}
|
|
|
|
|
|
if password != "" {
|
|
|
record["password"] = password
|