From c6292a97dd29b5dc14f96ed71adc82e9ead8ef28 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 16 Jun 2023 18:48:05 +0800 Subject: [PATCH] fix --- model/gmodel/fs_address_gen.go | 39 +++++++++++--------- model/gmodel/fs_address_logic.go | 35 +++++++----------- model/gmodel/fs_canteen_type_gen.go | 11 +++--- model/gmodel/fs_font_gen.go | 11 +++--- model/gmodel/fs_user_gen.go | 57 ++++++++++++++--------------- 5 files changed, 76 insertions(+), 77 deletions(-) diff --git a/model/gmodel/fs_address_gen.go b/model/gmodel/fs_address_gen.go index c8bf6600..0c53c219 100755 --- a/model/gmodel/fs_address_gen.go +++ b/model/gmodel/fs_address_gen.go @@ -1,23 +1,28 @@ package gmodel -import ( - "context" - "errors" - "gorm.io/gorm" -) +import "gorm.io/gorm" -func (a *FsAddressModel) GetOne(ctx context.Context, id int64, userId int64) (resp FsAddress, err error) { - err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`id` = ? and `user_id` = ? and `status` = ? ", id, userId, 1).First(&resp).Error - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return FsAddress{}, err - } - return resp, nil +type FsAddress struct { + Id int64 `gorm:"primary_key" json:"id"` + UserId *int64 `gorm:"default:0" json:"user_id"` // 用户ID + Name *string `gorm:"default:''" json:"name"` // 地址名称 + FirstName *string `gorm:"default:''" json:"first_name"` // FirstName + LastName *string `gorm:"default:''" json:"last_name"` // LastName + Mobile *string `gorm:"default:''" json:"mobile"` // 手机号码 + Street *string `gorm:"default:''" json:"street"` // 街道 + Suite *string `gorm:"default:''" json:"suite"` // 房号 + City *string `gorm:"default:''" json:"city"` // 城市 + State *string `gorm:"default:''" json:"state"` // 州名 + Country *string `gorm:"default:''" json:"country"` // 国家 + ZipCode *string `gorm:"default:''" json:"zip_code"` // 邮编 + Status *int64 `gorm:"default:1" json:"status"` // 1正常 0异常 + IsDefault *int64 `gorm:"default:0" json:"is_default"` // 1默认地址,0非默认地址 } -func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []FsAddress, err error) { - err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`user_id` = ? and `status` = ?", userId, 1).Order("`id` DESC").Find(&resp).Error - if err != nil { - return nil, err - } - return +type FsAddressModel struct { + db *gorm.DB +} + +func NewFsAddressModel(db *gorm.DB) *FsAddressModel { + return &FsAddressModel{db} } diff --git a/model/gmodel/fs_address_logic.go b/model/gmodel/fs_address_logic.go index b1931af7..c8bf6600 100755 --- a/model/gmodel/fs_address_logic.go +++ b/model/gmodel/fs_address_logic.go @@ -1,30 +1,23 @@ package gmodel import ( + "context" + "errors" "gorm.io/gorm" ) -type FsAddress struct { - Id int64 `gorm:"primary_key" json:"id"` - UserId *int64 `gorm:"default:0" json:"user_id"` // 用户ID - Name *string `gorm:"default:''" json:"name"` // 地址名称 - FirstName *string `gorm:"default:''" json:"first_name"` // FirstName - LastName *string `gorm:"default:''" json:"last_name"` // LastName - Mobile *string `gorm:"default:''" json:"mobile"` // 手机号码 - Street *string `gorm:"default:''" json:"street"` // 街道 - Suite *string `gorm:"default:''" json:"suite"` // 房号 - City *string `gorm:"default:''" json:"city"` // 城市 - State *string `gorm:"default:''" json:"state"` // 州名 - Country *string `gorm:"default:''" json:"country"` // 国家 - ZipCode *string `gorm:"default:''" json:"zip_code"` // 邮编 - Status *int64 `gorm:"default:1" json:"status"` // 1正常 0异常 - IsDefault *int64 `gorm:"default:0" json:"is_default"` // 1默认地址,0非默认地址 +func (a *FsAddressModel) GetOne(ctx context.Context, id int64, userId int64) (resp FsAddress, err error) { + err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`id` = ? and `user_id` = ? and `status` = ? ", id, userId, 1).First(&resp).Error + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + return FsAddress{}, err + } + return resp, nil } -type FsAddressModel struct { - db *gorm.DB -} - -func NewFsAddressModel(db *gorm.DB) *FsAddressModel { - return &FsAddressModel{db} +func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []FsAddress, err error) { + err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`user_id` = ? and `status` = ?", userId, 1).Order("`id` DESC").Find(&resp).Error + if err != nil { + return nil, err + } + return } diff --git a/model/gmodel/fs_canteen_type_gen.go b/model/gmodel/fs_canteen_type_gen.go index 787c7b20..04611065 100644 --- a/model/gmodel/fs_canteen_type_gen.go +++ b/model/gmodel/fs_canteen_type_gen.go @@ -5,12 +5,13 @@ import ( ) type FsCanteenType struct { - Id int64 `gorm:"primary_key" json:"id"` // ID - Name *string `gorm:"-" json:"name"` // 餐厅名字 - Sort *int64 `gorm:"-" json:"sort"` // 排序 - Status *int64 `gorm:"-" json:"status"` // 状态位 1启用0停用 - Ctime *int64 `gorm:"-" json:"ctime"` // 添加时间 + Id int64 `gorm:"primary_key;" json:"id"` // ID + Name *string `gorm:"default:''" json:"name"` // 餐厅名字 + Sort *int64 `gorm:"default:0" json:"sort"` // 排序 + Status *int64 `gorm:"default:0" json:"status"` // 状态位 1启用0停用 + Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间 } + type FsCanteenTypeModel struct{ db *gorm.DB } func NewFsCanteenTypeModel(db *gorm.DB) *FsCanteenTypeModel { return &FsCanteenTypeModel{db} } diff --git a/model/gmodel/fs_font_gen.go b/model/gmodel/fs_font_gen.go index 57c24971..86abd41b 100644 --- a/model/gmodel/fs_font_gen.go +++ b/model/gmodel/fs_font_gen.go @@ -5,12 +5,13 @@ import ( ) type FsFont struct { - Id int64 `gorm:"primary_key" json:"id"` // id - Title *string `gorm:"-" json:"title"` // 字体名字 - LinuxFontname *string `gorm:"-" json:"linux_fontname"` // linux对应字体名 - FilePath *string `gorm:"-" json:"file_path"` // 字体文件路径 - Sort *int64 `gorm:"-" json:"sort"` // 排序 + Id int64 `gorm:"primary_key;" json:"id"` // id + Title *string `gorm:"default:''" json:"title"` // 字体名字 + LinuxFontname *string `gorm:"default:''" json:"linux_fontname"` // linux对应字体名 + FilePath *string `gorm:"default:''" json:"file_path"` // 字体文件路径 + Sort *int64 `gorm:"default:0" json:"sort"` // 排序 } + type FsFontModel struct{ db *gorm.DB } func NewFsFontModel(db *gorm.DB) *FsFontModel { return &FsFontModel{db} } diff --git a/model/gmodel/fs_user_gen.go b/model/gmodel/fs_user_gen.go index a7edf585..9e5948eb 100644 --- a/model/gmodel/fs_user_gen.go +++ b/model/gmodel/fs_user_gen.go @@ -1,37 +1,36 @@ package gmodel -import ( - "gorm.io/gorm" -) +import "gorm.io/gorm" type FsUser struct { - Id int64 `gorm:"primary_key" json:"id"` // ID - FaceId *int64 `gorm:"-" json:"face_id"` // facebook的userid - Sub *int64 `gorm:"-" json:"sub"` // google的sub - FirstName *string `gorm:"-" json:"first_name"` // FirstName - LastName *string `gorm:"-" json:"last_name"` // LastName - Username *string `gorm:"-" json:"username"` // 用户名 - Company *string `gorm:"-" json:"company"` // 公司名称 - Mobile *string `gorm:"-" json:"mobile"` // 手机号码 - AuthKey *string `gorm:"-" json:"auth_key"` // - PasswordHash *string `gorm:"-" json:"password_hash"` // - VerificationToken *string `gorm:"-" json:"verification_token"` // - PasswordResetToken *string `gorm:"-" json:"password_reset_token"` // - Email *string `gorm:"-" json:"email"` // 邮箱 - Type *int64 `gorm:"-" json:"type"` // 1普通餐厅 2连锁餐厅 - Status *int64 `gorm:"-" json:"status"` // 1正常 0不正常 - IsDel *int64 `gorm:"-" json:"is_del"` // 是否删除 1删除 - CreatedAt *int64 `gorm:"-" json:"created_at"` // 添加时间 - UpdatedAt *int64 `gorm:"-" json:"updated_at"` // 更新时间 - IsOrderStatusEmail *int64 `gorm:"-" json:"is_order_status_email"` // 订单状态改变时是否接收邮件 - IsEmailAdvertisement *int64 `gorm:"-" json:"is_email_advertisement"` // 是否接收邮件广告 - IsOrderStatusPhone *int64 `gorm:"-" json:"is_order_status_phone"` // 订单状态改变是是否接收电话 - IsPhoneAdvertisement *int64 `gorm:"-" json:"is_phone_advertisement"` // 是否接收短信广告 - IsOpenRender *int64 `gorm:"-" json:"is_open_render"` // 是否打开个性化渲染(1:开启,0:关闭) - IsThousandFace *int64 `gorm:"-" json:"is_thousand_face"` // 是否已经存在千人千面(1:存在,0:不存在) - IsLowRendering *int64 `gorm:"-" json:"is_low_rendering"` // 是否开启低渲染模型渲染 - IsRemoveBg *int64 `gorm:"-" json:"is_remove_bg"` // 用户上传logo是否去除背景 + 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} }