2023-06-15 08:08:43 +00:00
|
|
|
package gmodel
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TODO: 使用model的属性做你想做的
|
|
|
|
|
2023-06-15 09:51:06 +00:00
|
|
|
type UserBasicInfoForSave struct {
|
|
|
|
ID uint `gorm:"primary_key" json:"id"`
|
2023-06-16 11:26:48 +00:00
|
|
|
FirstName string `gorm:"-" json:"first_name"`
|
|
|
|
LastName string `gorm:"-" json:"last_name"`
|
|
|
|
Mobile string `gorm:"-" json:"mobile"`
|
|
|
|
Company string `gorm:"-" json:"company"`
|
|
|
|
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"`
|
|
|
|
Type int64 `gorm:"-" json:"type"`
|
|
|
|
IsOpenRender int64 `gorm:"-" json:"is_open_render"`
|
|
|
|
IsLowRendering int64 `gorm:"-" json:"is_low_rendering"`
|
|
|
|
IsRemoveBg int64 `gorm:"-" json:"is_remove_bg"`
|
2023-06-15 08:08:43 +00:00
|
|
|
}
|
|
|
|
|
2023-06-15 09:51:06 +00:00
|
|
|
func (u *FsUserModel) FindUserByEmail(ctx context.Context, emailname string) (resp FsUser, err error) {
|
2023-06-16 11:26:48 +00:00
|
|
|
err = u.db.WithContext(ctx).Model(&FsUser{}).Where("`email` = ?", emailname).First(&resp).Error
|
2023-06-15 08:08:43 +00:00
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2023-06-15 09:51:06 +00:00
|
|
|
func (u *FsUserModel) FindUserById(ctx context.Context, Id int64) (resp FsUser, err error) {
|
2023-06-16 11:26:48 +00:00
|
|
|
err = u.db.WithContext(ctx).Model(&FsUser{}).Where("`id` = ? and is_del = ?", Id, 0).First(&resp).Error
|
2023-06-15 08:08:43 +00:00
|
|
|
return resp, err
|
|
|
|
}
|
2023-06-15 09:51:06 +00:00
|
|
|
|
|
|
|
func (u *FsUserModel) UpdateUserBasicInfoById(ctx context.Context, Id int64, user *UserBasicInfoForSave) (err error) {
|
|
|
|
|
|
|
|
err = u.db.WithContext(ctx).Model(&FsUser{}).
|
|
|
|
Where("`id` = ? and is_del = ? and status = ?", Id, 0, 1).
|
|
|
|
Updates(map[string]interface{}{
|
|
|
|
"first_name": user.FirstName,
|
|
|
|
"last_name": user.LastName,
|
|
|
|
"mobile": user.Mobile,
|
|
|
|
"company": user.Company,
|
|
|
|
"is_order_status_email": user.IsOrderStatusEmail,
|
|
|
|
"is_email_advertisement": user.IsEmailAdvertisement,
|
|
|
|
"is_order_status_phone": user.IsOrderStatusPhone,
|
|
|
|
"is_phone_advertisement": user.IsPhoneAdvertisement,
|
|
|
|
"type": user.Type,
|
|
|
|
"is_open_render": user.IsOpenRender,
|
|
|
|
"is_low_rendering": user.IsLowRendering,
|
|
|
|
"is_remove_bg": user.IsRemoveBg,
|
|
|
|
}).Error
|
|
|
|
return err
|
|
|
|
}
|