admin: add create-user dialog and API
Some checks failed
build quyun / Build (push) Failing after 1m23s

This commit is contained in:
2025-12-22 15:57:32 +08:00
parent 4704cf6949
commit 859d628cd6
5 changed files with 139 additions and 0 deletions

View File

@@ -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)
}