newUser := model.User{
            Phone:    phone,
            Password: string(hasedPassword),
        }

        //开始事务
        tx := global.DB.Begin()
        if tx = tx.Create(&newUser); tx.Error != nil {
            tx.Rollback()
            global.Response(ctx, http.StatusInternalServerError, 500, nil, "注册数据库更新失败")
            return
        }
        tx.Commit()
        //注册成功 需要发放token

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Captcha Code