admin: add create-user dialog and API
Some checks failed
build quyun / Build (push) Failing after 1m23s
Some checks failed
build quyun / Build (push) Failing after 1m23s
This commit is contained in:
@@ -92,6 +92,11 @@ type UserPhoneForm struct {
|
||||
Phone string `json:"phone"` // 用户手机号(11 位数字)
|
||||
}
|
||||
|
||||
type UserCreateForm struct {
|
||||
Phone string `json:"phone"` // 用户手机号(必填,11 位数字)
|
||||
Username string `json:"username"` // 用户昵称(可选)
|
||||
}
|
||||
|
||||
// Balance
|
||||
//
|
||||
// @Summary 调整用户余额
|
||||
@@ -123,3 +128,17 @@ func (ctl *users) Balance(ctx fiber.Ctx, user *models.User, balance *UserBalance
|
||||
func (ctl *users) SetPhone(ctx fiber.Ctx, user *models.User, form *UserPhoneForm) error {
|
||||
return services.Users.SetPhone(ctx, user.ID, form.Phone)
|
||||
}
|
||||
|
||||
// Create user
|
||||
//
|
||||
// @Summary 创建用户
|
||||
// @Tags Admin Users
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body UserCreateForm true "请求体"
|
||||
// @Success 200 {object} models.User "成功"
|
||||
// @Router /admin/v1/users [post]
|
||||
// @Bind form body
|
||||
func (ctl *users) Create(ctx fiber.Ctx, form *UserCreateForm) (*models.User, error) {
|
||||
return services.Users.CreateByPhone(ctx, form.Phone, form.Username)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user