|
@@ -66,6 +66,10 @@ func Add(username, password string, status int, description string, phone string
|
|
|
if exist.Id > 0 {
|
|
|
return errors.New(fmt.Sprintf("[%s] 用户已经存在", username))
|
|
|
}
|
|
|
+ phoneExist, _ := GetByPhone(phone)
|
|
|
+ if phoneExist.Id > 0 {
|
|
|
+ return errors.New(fmt.Sprintf("[%s] 手机号已经存在", phone))
|
|
|
+ }
|
|
|
_, err := models.Db.Insert("admin_user").Rows(
|
|
|
goqu.Record{"username": username, "password": password, "status": status, "description": description, "phone": phone},
|
|
|
).Executor().Exec()
|
|
@@ -77,6 +81,10 @@ func Updata(id int, username, password string, status int, description string, p
|
|
|
if exist.Id > 0 && exist.Id != id {
|
|
|
return errors.New(fmt.Sprintf("[%s] 用户已经存在", username))
|
|
|
}
|
|
|
+ phoneExist, _ := GetByPhone(phone)
|
|
|
+ if phoneExist.Id > 0 && phoneExist.Id != id {
|
|
|
+ return errors.New(fmt.Sprintf("[%s] 手机号已经存在", phone))
|
|
|
+ }
|
|
|
record := goqu.Record{"username": username, "status": status, "description": description, "phone": phone}
|
|
|
|
|
|
if password != "" {
|