fusenapi/model/gmodel/fsusermodel.go
laodaming b1393950f2 fix
2023-06-12 16:47:48 +08:00

52 lines
2.9 KiB
Go
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
type FsUser struct {
Id int64 `gorm:"primary_key" json:"id"` // ID
FaceId int64 `gorm:"default:0" json:"face_id"` // facebook的userid
Sub int64 `gorm:"default:0" json:"sub"` // google的sub
FirstName string `gorm:"default:''" json:"first_name"` // FirstName
LastName string `gorm:"default:''" json:"last_name"` // LastName
Username string `gorm:"default:''" json:"username"` // 用户名
Company string `gorm:"default:''" json:"company"` // 公司名称
Mobile string `gorm:"default:''" json:"mobile" ` // 手机号码
AuthKey string `gorm:"default:''" json:"auth_key"`
PasswordHash string `gorm:"default:''" json:"password_hash"`
VerificationToken string `gorm:"default:''" json:"verification_token"`
PasswordResetToken string `gorm:"default:''" json:"password_reset_token"`
Email string `gorm:"default:''" json:"email"` // 邮箱
Type int64 `gorm:"default:1" json:"type"` // 1普通餐厅 2连锁餐厅
Status int64 `gorm:"default:1" json:"status"` // 1正常 0不正常
IsDel int64 `gorm:"default:0" json:"is_del"` // 是否删除 1删除
CreatedAt int64 `gorm:"default:0" json:"created_at"` // 添加时间
UpdatedAt int64 `gorm:"default:0" json:"updated_at"` // 更新时间
IsOrderStatusEmail int64 `gorm:"default:0" json:"is_order_status_email"` // 订单状态改变时是否接收邮件
IsEmailAdvertisement int64 `gorm:"default:0" json:"is_email_advertisement"` // 是否接收邮件广告
IsOrderStatusPhone int64 `gorm:"default:0" json:"is_order_status_phone"` // 订单状态改变是是否接收电话
IsPhoneAdvertisement int64 `gorm:"default:0" json:"is_phone_advertisement"` // 是否接收短信广告
IsOpenRender int64 `gorm:"default:0" json:"is_open_render"` // 是否打开个性化渲染1开启0关闭
IsThousandFace int64 `gorm:"default:0" json:"is_thousand_face"` // 是否已经存在千人千面1存在0不存在
IsLowRendering int64 `gorm:"default:0" json:"is_low_rendering"` // 是否开启低渲染模型渲染
IsRemoveBg int64 `gorm:"default:1" json:"is_remove_bg"` // 用户上传logo是否去除背景
}
type FsUserModel struct {
db *gorm.DB
}
func NewFsUserModel(db *gorm.DB) *FsUserModel {
return &FsUserModel{db}
}
func (u *FsUserModel) FindOne(ctx context.Context, id int64) (resp FsUser, err error) {
err = u.db.WithContext(ctx).Model(&FsUserModel{}).Where("`id` = ? and is_del = ?", id, 0).First(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsUser{}, err
}
return
}