You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.6 KiB
66 lines
1.6 KiB
2 months ago
|
package mysqlbusiness
|
||
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
"time"
|
||
|
"wss-pool/internal"
|
||
|
"wss-pool/internal/data"
|
||
|
"wss-pool/logging/applogger"
|
||
|
"wss-pool/pkg/model/sqlmodel"
|
||
|
)
|
||
|
|
||
|
// SaveBoUserSms
|
||
|
func SaveBoUserSms(userSms sqlmodel.BoUserSms) error {
|
||
|
boUserSms := &sqlmodel.BoUserSms{
|
||
|
From: userSms.From,
|
||
|
To: userSms.To,
|
||
|
Message: userSms.Message,
|
||
|
TaskId: userSms.TaskId,
|
||
|
MessageResult: userSms.MessageResult,
|
||
|
CreateTime: time.Now(),
|
||
|
UpdateTime: time.Now(),
|
||
|
}
|
||
|
if _, err := data.Engine.Table("bo_user_sms").Insert(boUserSms); err != nil {
|
||
|
applogger.Error("SaveBoUserSms info err: %v", err)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// SaveBoUsers
|
||
|
func SaveBoUsers(phoneNumber string, password string, InvitationCode string) (string, error) {
|
||
|
token, err := internal.GetToken()
|
||
|
if err != nil {
|
||
|
applogger.Error("select token err:%v", err)
|
||
|
return "生成token失败,请联系管理员", err
|
||
|
}
|
||
|
uid := internal.Captcha(10)
|
||
|
phone, err := strconv.Atoi(phoneNumber)
|
||
|
if err != nil {
|
||
|
applogger.Error("Atoi err: %v", err)
|
||
|
return "电话号码解析失败,请联系管理员", err
|
||
|
}
|
||
|
bom := sqlmodel.BoUsers{
|
||
|
Uid: uid,
|
||
|
Phonenumber: int64(phone),
|
||
|
Loginpassword: password,
|
||
|
Invitecode: InvitationCode,
|
||
|
Accesstoken: token,
|
||
|
Status: 1,
|
||
|
Addtime: time.Now(),
|
||
|
Updatetime: time.Now(),
|
||
|
}
|
||
|
checkInt, err := data.Engine.Table("bo_users").Insert(&bom)
|
||
|
if err != nil {
|
||
|
applogger.Error("SaveBoUsers Insert err: %v", err)
|
||
|
return "", err
|
||
|
}
|
||
|
applogger.Debug("新增数据:%v", checkInt)
|
||
|
if checkInt == 0 {
|
||
|
return "注册用户失败", nil
|
||
|
}
|
||
|
|
||
|
return "注册用户成功", nil
|
||
|
}
|