From 350c6a5548d633bfdaa69abc3159c5d552bfc475 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 16 Jun 2023 19:05:38 +0800 Subject: [PATCH] fix --- model/gmodel/fs_address_logic.go | 23 ---- model/gmodel/fs_canteen_product_logic.go | 25 ---- model/gmodel/fs_canteen_type_logic.go | 31 ----- model/gmodel/fs_cart_logic.go | 114 ------------------ model/gmodel/fs_font_logic.go | 21 ---- model/gmodel/fs_map_library_logic.go | 11 -- model/gmodel/fs_order_detail_logic.go | 13 -- .../gmodel/fs_order_detail_template_logic.go | 16 --- model/gmodel/fs_order_logic.go | 18 --- model/gmodel/fs_pay_logic.go | 18 --- model/gmodel/fs_product_design_logic.go | 25 ---- model/gmodel/fs_product_logic.go | 47 -------- .../gmodel/fs_product_model3d_light_logic.go | 1 - model/gmodel/fs_product_model3d_logic.go | 26 ---- model/gmodel/fs_product_price_logic.go | 73 ----------- model/gmodel/fs_product_size_logic.go | 43 ------- .../gmodel/fs_product_template_tags_logic.go | 16 --- model/gmodel/fs_product_template_v2_logic.go | 16 --- model/gmodel/fs_qrcode_set_logic.go | 22 ---- model/gmodel/fs_standard_logo_logic.go | 13 -- model/gmodel/fs_tags_logic.go | 32 ----- model/gmodel/fs_user_logic.go | 54 --------- model/gmodel/fsfaqmodel.go | 24 ---- model/gmodel/fsguestmodel.go | 57 --------- model/gmodel/var.go | 5 - 25 files changed, 744 deletions(-) delete mode 100755 model/gmodel/fs_address_logic.go delete mode 100755 model/gmodel/fs_canteen_product_logic.go delete mode 100644 model/gmodel/fs_canteen_type_logic.go delete mode 100755 model/gmodel/fs_cart_logic.go delete mode 100644 model/gmodel/fs_font_logic.go delete mode 100755 model/gmodel/fs_map_library_logic.go delete mode 100755 model/gmodel/fs_order_detail_logic.go delete mode 100755 model/gmodel/fs_order_detail_template_logic.go delete mode 100755 model/gmodel/fs_order_logic.go delete mode 100644 model/gmodel/fs_pay_logic.go delete mode 100755 model/gmodel/fs_product_design_logic.go delete mode 100755 model/gmodel/fs_product_logic.go delete mode 100755 model/gmodel/fs_product_model3d_light_logic.go delete mode 100755 model/gmodel/fs_product_model3d_logic.go delete mode 100755 model/gmodel/fs_product_price_logic.go delete mode 100755 model/gmodel/fs_product_size_logic.go delete mode 100755 model/gmodel/fs_product_template_tags_logic.go delete mode 100755 model/gmodel/fs_product_template_v2_logic.go delete mode 100755 model/gmodel/fs_qrcode_set_logic.go delete mode 100755 model/gmodel/fs_standard_logo_logic.go delete mode 100755 model/gmodel/fs_tags_logic.go delete mode 100644 model/gmodel/fs_user_logic.go delete mode 100755 model/gmodel/fsfaqmodel.go delete mode 100755 model/gmodel/fsguestmodel.go delete mode 100644 model/gmodel/var.go diff --git a/model/gmodel/fs_address_logic.go b/model/gmodel/fs_address_logic.go deleted file mode 100755 index c8bf6600..00000000 --- a/model/gmodel/fs_address_logic.go +++ /dev/null @@ -1,23 +0,0 @@ -package gmodel - -import ( - "context" - "errors" - "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 -} - -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_product_logic.go b/model/gmodel/fs_canteen_product_logic.go deleted file mode 100755 index 6114dd23..00000000 --- a/model/gmodel/fs_canteen_product_logic.go +++ /dev/null @@ -1,25 +0,0 @@ -package gmodel - -import ( - "context" -) - -func (c *FsCanteenProductModel) GetAllByCanteenTypeId(ctx context.Context, typeId int64) (resp []FsCanteenProduct, err error) { - err = c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`canteen_type` = ? and `status` = ?", typeId, 1).Find(&resp).Error - if err != nil { - return nil, err - } - return -} -func (c *FsCanteenProductModel) UpdateById(ctx context.Context, id int64, data *FsCanteenProduct) error { - return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`id` = ? ", id).Updates(&data).Error -} -func (c *FsCanteenProductModel) UpdateByIdArr(ctx context.Context, ids []int64, data *FsCanteenProduct) error { - if len(ids) == 0 { - return nil - } - return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`id` in (?) ", ids).Updates(&data).Error -} -func (c *FsCanteenProductModel) Create(ctx context.Context, data *FsCanteenProduct) error { - return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Create(data).Error -} diff --git a/model/gmodel/fs_canteen_type_logic.go b/model/gmodel/fs_canteen_type_logic.go deleted file mode 100644 index 7ea6b846..00000000 --- a/model/gmodel/fs_canteen_type_logic.go +++ /dev/null @@ -1,31 +0,0 @@ -package gmodel - -import ( - "context" - "errors" - - "gorm.io/gorm" -) - -// FsGetTypeCanteenType GetType返回前端的结构 -type FsGetTypeCanteenType struct { - Id int64 `gorm:"id" json:"key"` // ID - Name string `gorm:"name" json:"name"` // 餐厅名字 -} - -// TODO: 使用model的属性做你想做的 - -func (c *FsCanteenTypeModel) FindAllGetType(ctx context.Context) (resp []*FsGetTypeCanteenType, err error) { - err = c.db.WithContext(ctx).Model(&FsCanteenType{}).Select("id,name").Order("sort desc").Where("`status` = ?", 1).Find(&resp).Error - if err != nil { - return resp, err - } - return resp, nil -} -func (c *FsCanteenTypeModel) FindOne(ctx context.Context, id int64) (resp FsCanteenType, err error) { - err = c.db.WithContext(ctx).Model(&FsCanteenType{}).Where("`id` = ?", id).First(&resp).Error - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return resp, err - } - return resp, nil -} diff --git a/model/gmodel/fs_cart_logic.go b/model/gmodel/fs_cart_logic.go deleted file mode 100755 index e0930629..00000000 --- a/model/gmodel/fs_cart_logic.go +++ /dev/null @@ -1,114 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. - -package gmodel - -import ( - "context" - "errors" - "gorm.io/gorm" -) - -<<<<<<< HEAD:model/gmodel/fscartmodel.go -type FsCart struct { - Id int64 `gorm:"primary_key" json:"id"` // id - UserId *int64 `gorm:"default:0" json:"user_id"` // 用户ID - ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID - TemplateId *int64 `gorm:"default:0" json:"template_id"` // 模板ID - PriceId *int64 `gorm:"default:0" json:"price_id"` // 价格ID - MaterialId *int64 `gorm:"default:0" json:"material_id"` // 材质ID - SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸ID - BuyNum *int64 `gorm:"default:0" json:"buy_num"` // 购买数量 - Cover *string `gorm:"default:''" json:"cover"` // 截图 - DesignId *int64 `gorm:"default:0" json:"design_id"` // 设计ID - Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间 - Status *int64 `gorm:"default:1" json:"status"` // 状态位 - OptionalId *int64 `gorm:"default:0" json:"optional_id"` // 选项ID - IsCheck *int64 `gorm:"default:0" json:"is_check"` // 是否选中状态(0:未选中,1:选中) - TsTime *time.Time `gorm:"" json:"ts_time"` - IsEmail *int64 `gorm:"default:0" json:"is_email"` // 是否发送邮件 -} -type FsCartModel struct { - db *gorm.DB -} - -func NewFsCartModel(db *gorm.DB) *FsCartModel { - return &FsCartModel{db} -} - -======= ->>>>>>> c6292a97dd29b5dc14f96ed71adc82e9ead8ef28:model/gmodel/fs_cart_logic.go -type FindOneCartByParamsReq struct { - UserId *int64 - ProductId *int64 - TemplateId *int64 - PriceId *int64 - DesignId *int64 - MaterialId *int64 - Status *int64 -} - -func (c *FsCartModel) FindOne(ctx context.Context, id int64) (resp FsCart, err error) { - err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).Take(&resp).Error - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return FsCart{}, err - } - return resp, nil -} -func (c *FsCartModel) FindOneCartByParams(ctx context.Context, req FindOneCartByParamsReq) (resp FsCart, err error) { - db := c.db.WithContext(ctx).Model(&FsCart{}) - if req.UserId != nil { - db = db.Where("`user_id` = ?", req.UserId) - } - if req.ProductId != nil { - db = db.Where("`product_id` = ?", req.ProductId) - } - if req.TemplateId != nil { - db = db.Where("`template_id` = ?", req.TemplateId) - } - if req.PriceId != nil { - db = db.Where("`price_id` = ?", req.PriceId) - } - if req.DesignId != nil { - db = db.Where("`design_id` = ?", req.DesignId) - } - if req.MaterialId != nil { - db = db.Where("`material_id` = ?", req.MaterialId) - } - if req.Status != nil { - db = db.Where("`status` = ?", req.Status) - } - if err = db.Take(&resp).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return FsCart{}, err - } - return resp, nil -} -func (c *FsCartModel) Create(ctx context.Context, data FsCart) error { - return c.db.WithContext(ctx).Model(&FsCart{}).Create(&data).Error -} -func (c *FsCartModel) Update(ctx context.Context, id int64, data FsCart) error { - return c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).Updates(data).Error -} -func (c *FsCartModel) UpdateByIdUserId(ctx context.Context, id int64, userId int64, data FsCart) error { - return c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ? and `user_id` = ?", id, userId).Updates(data).Error -} -func (c *FsCartModel) CountUserCart(ctx context.Context, userId int64) (total int64, err error) { - err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`user_id` = ? and `status` = ? limit 1", userId, 1).Count(&total).Error - if err != nil { - return 0, err - } - return -} -func (c *FsCartModel) GetAllByUserId(ctx context.Context, userId int64, sort string) (resp []FsCart, err error) { - db := c.db.WithContext(ctx).Model(&FsCart{}).Where("`user_id` = ? and `status` = ?", userId, 1) - switch sort { - case "ctime-desc": - db = db.Order("`ctime` DESC") - case "ctime-asc": - db = db.Order("`ctime` ASC") - } - err = db.Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_font_logic.go b/model/gmodel/fs_font_logic.go deleted file mode 100644 index ca9e30d6..00000000 --- a/model/gmodel/fs_font_logic.go +++ /dev/null @@ -1,21 +0,0 @@ -package gmodel - -import ( - "context" -) - -// TODO: 使用model的属性做你想做的 - -func (m *FsFontModel) FindAllOrderSortByDesc(ctx context.Context) ([]*FsFont, error) { - - var fonts []*FsFont - err := m.db.Model(&FsFont{}).Order("sort desc").Find(&fonts).Error - switch err { - case nil: - return fonts, nil - case ErrRecordNotFound: - return nil, nil - default: - return nil, err - } -} diff --git a/model/gmodel/fs_map_library_logic.go b/model/gmodel/fs_map_library_logic.go deleted file mode 100755 index df7755bd..00000000 --- a/model/gmodel/fs_map_library_logic.go +++ /dev/null @@ -1,11 +0,0 @@ -package gmodel - -import "context" - -func (ml *FsMapLibraryModel) GetAllEnabledList(ctx context.Context) (resp []FsMapLibrary, err error) { - err = ml.db.WithContext(ctx).Model(&FsMapLibrary{}).Where("`status` = ?", 0).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_order_detail_logic.go b/model/gmodel/fs_order_detail_logic.go deleted file mode 100755 index e16fe337..00000000 --- a/model/gmodel/fs_order_detail_logic.go +++ /dev/null @@ -1,13 +0,0 @@ -package gmodel - -import ( - "context" -) - -func (od *FsOrderDetailModel) GetOrderDetailsByOrderId(ctx context.Context, orderId int64) (resp []FsOrderDetail, err error) { - err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_order_detail_template_logic.go b/model/gmodel/fs_order_detail_template_logic.go deleted file mode 100755 index 571cec9e..00000000 --- a/model/gmodel/fs_order_detail_template_logic.go +++ /dev/null @@ -1,16 +0,0 @@ -package gmodel - -import ( - "context" -) - -func (dt *FsOrderDetailTemplateModel) GetListByIds(ctx context.Context, ids []int64) (resp []FsOrderDetailTemplate, err error) { - if len(ids) == 0 { - return - } - err = dt.db.WithContext(ctx).Model(&FsOrderDetailTemplate{}).Where("`id` in (?)", ids).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_order_logic.go b/model/gmodel/fs_order_logic.go deleted file mode 100755 index 967dc122..00000000 --- a/model/gmodel/fs_order_logic.go +++ /dev/null @@ -1,18 +0,0 @@ -package gmodel - -import ( - "context" - "errors" - "gorm.io/gorm" -) - -func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp FsOrder, err error) { - err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).First(&resp).Error - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return FsOrder{}, err - } - return resp, nil -} -func (o *FsOrderModel) Update(ctx context.Context, id int64, data FsOrder) error { - return o.db.WithContext(ctx).Model(&FsOrder{}).Where("`id` = ?", id).Updates(data).Error -} diff --git a/model/gmodel/fs_pay_logic.go b/model/gmodel/fs_pay_logic.go deleted file mode 100644 index 30cdfa2b..00000000 --- a/model/gmodel/fs_pay_logic.go +++ /dev/null @@ -1,18 +0,0 @@ -package gmodel - -import "context" - -func (p *FsPayModel) GetListByOrderNumber(ctx context.Context, sn string) (resp []FsPay, err error) { - err = p.db.WithContext(ctx).Model(&FsPay{}).Where("`order_number` = ? ", sn).Find(&resp).Error - if err != nil { - return nil, err - } - return resp, nil -} -func (p *FsPayModel) GetOrderPayList(ctx context.Context, sn string, payStatus int64, isRefund int64) (resp []FsPay, err error) { - err = p.db.WithContext(ctx).Model(&FsPay{}).Where("`order_number` = ? and `pay_status` = ? and `is_refund` = ?", sn, payStatus, isRefund).Find(&resp).Error - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/model/gmodel/fs_product_design_logic.go b/model/gmodel/fs_product_design_logic.go deleted file mode 100755 index 819c0074..00000000 --- a/model/gmodel/fs_product_design_logic.go +++ /dev/null @@ -1,25 +0,0 @@ -package gmodel - -import ( - "context" - "errors" - "gorm.io/gorm" -) - -func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string) (resp FsProductDesign, err error) { - err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ? and `status` = ?", sn, 1).First(&resp).Error - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return FsProductDesign{}, err - } - return resp, nil -} -func (d *FsProductDesignModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductDesign, err error) { - if len(ids) == 0 { - return - } - err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_product_logic.go b/model/gmodel/fs_product_logic.go deleted file mode 100755 index 5d5a9ed1..00000000 --- a/model/gmodel/fs_product_logic.go +++ /dev/null @@ -1,47 +0,0 @@ -package gmodel - -import "context" - -func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) { - if len(productIds) == 0 { - return - } - db := p.db.Model(&FsProduct{}). - Where("`id` in (?) and `is_del` =? and `is_shelf` = ? and `status` =?", productIds, 0, 1, 1) - switch sort { - case "sort-asc": - db = db.Order("`sort` ASC") - case "sort-desc": - db = db.Order("`sort` DESC") - } - if err = db.Find(&resp).Error; err != nil { - return nil, err - } - return -} - -func (p *FsProductModel) GetProductListByTypeIds(ctx context.Context, productTypes []int64, sort string) (resp []FsProduct, err error) { - if len(productTypes) == 0 { - return - } - db := p.db.WithContext(ctx).Model(&FsProduct{}).Where("`type` in (?) and `is_del` =? and `is_shelf` = ? and `status` =?", productTypes, 0, 1, 1) - switch sort { - case "sort-asc": - db = db.Order("`sort` ASC") - case "sort-desc": - db = db.Order("`sort` DESC") - } - err = db.Find(&resp).Error - if err != nil { - return nil, err - } - return -} -func (p *FsProductModel) GetRandomProductList(ctx context.Context, limit int) (resp []FsProduct, err error) { - err = p.db.WithContext(ctx).Model(&FsProduct{}). - Where("`is_del` =? and `is_shelf` = ?", 0, 1).Order("RAND()").Limit(limit).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_product_model3d_light_logic.go b/model/gmodel/fs_product_model3d_light_logic.go deleted file mode 100755 index f35dfc56..00000000 --- a/model/gmodel/fs_product_model3d_light_logic.go +++ /dev/null @@ -1 +0,0 @@ -package gmodel diff --git a/model/gmodel/fs_product_model3d_logic.go b/model/gmodel/fs_product_model3d_logic.go deleted file mode 100755 index 9e3e604b..00000000 --- a/model/gmodel/fs_product_model3d_logic.go +++ /dev/null @@ -1,26 +0,0 @@ -package gmodel - -import ( - "context" -) - -func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) { - if len(ids) == 0 { - return - } - err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error - if err != nil { - return nil, err - } - return -} -func (d *FsProductModel3dModel) GetAllByIdsTag(ctx context.Context, ids []int64, tag int64) (resp []FsProductModel3d, err error) { - if len(ids) == 0 { - return - } - err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ? and `tag` = ?", ids, 1, tag).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_product_price_logic.go b/model/gmodel/fs_product_price_logic.go deleted file mode 100755 index 4b7e73e7..00000000 --- a/model/gmodel/fs_product_price_logic.go +++ /dev/null @@ -1,73 +0,0 @@ -package gmodel - -import ( - "context" - "errors" - - "gorm.io/gorm" -) - -type GetPriceListByProductIdsRsp struct { - ProductId int64 `json:"product_id"` - Price string `json:"price"` -} - -func (p *FsProductPriceModel) GetSimplePriceListByProductIds(ctx context.Context, productIds []int64) (resp []GetPriceListByProductIdsRsp, err error) { - if len(productIds) == 0 { - return nil, nil - } - db := p.db.WithContext(ctx).Model(&FsProductPrice{}).Select("product_id,group_concat(step_price) as price"). - Where("`product_id` in (?) and `status` = ? group by product_id", productIds, 1) - if err = db.Find(&resp).Error; err != nil { - return nil, err - } - return -} -func (p *FsProductPriceModel) GetPriceListBySizeIds(ctx context.Context, sizeIds []int64) (resp []FsProductPrice, err error) { - if len(sizeIds) == 0 { - return - } - err = p.db.WithContext(ctx).Model(&FsProductPrice{}).Where("`size_id` in (?) and `status` = ? ", sizeIds, 1).Find(&resp).Error - if err != nil { - return nil, err - } - return -} - -type FindOneProductPriceByParamsReq struct { - ProductId *int64 - MaterialId *int64 - SizeId *int64 - Status *int64 -} - -func (p *FsProductPriceModel) FindOneProductPriceByParams(ctx context.Context, req FindOneProductPriceByParamsReq) (resp FsProductPrice, err error) { - db := p.db.WithContext(ctx).Model(&FsProductPrice{}) - if req.ProductId != nil { - db = db.Where("`product_id` = ?", *req.ProductId) - } - if req.MaterialId != nil { - db = db.Where("`material_id` = ?", *req.MaterialId) - } - if req.SizeId != nil { - db = db.Where("`size_id` = ?", *req.SizeId) - } - if req.Status != nil { - db = db.Where("`status` = ?", *req.Status) - } - if err = db.Take(&resp).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return FsProductPrice{}, err - } - return resp, nil -} -func (p *FsProductPriceModel) GetPriceListByProductIds(ctx context.Context, productIds []int64) (resp []FsProductPrice, err error) { - if len(productIds) == 0 { - return nil, nil - } - db := p.db.WithContext(ctx).Model(&FsProductPrice{}). - Where("`product_id` in (?) and `status` = ?", productIds, 1) - if err = db.Find(&resp).Error; err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_product_size_logic.go b/model/gmodel/fs_product_size_logic.go deleted file mode 100755 index a48d46bf..00000000 --- a/model/gmodel/fs_product_size_logic.go +++ /dev/null @@ -1,43 +0,0 @@ -package gmodel - -import ( - "context" -) - -func (s *FsProductSizeModel) GetAllByIds(ctx context.Context, ids []int64, sort string) (resp []FsProductSize, err error) { - if len(ids) == 0 { - return - } - db := s.db.Model(&FsProductSize{}).Where("`id` in (?) and `status` = ?", ids, 1) - switch sort { - case "sort-asc": - db = db.Order("`sort` ASC") - case "sort-desc": - db = db.Order("`sort` DESC") - } - if err = db.Find(&resp).Error; err != nil { - return nil, err - } - return -} -func (s *FsProductSizeModel) CountByStatus(ctx context.Context, status int) (total int64, err error) { - err = s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`status` = ? limit 1", status).Count(&total).Error - if err != nil { - return 0, err - } - return -} -func (s *FsProductSizeModel) GetAllByProductIds(ctx context.Context, productIds []int64, sort string) (resp []FsProductSize, err error) { - db := s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`product_id` in(?) and `status` = ?", productIds, 1) - switch sort { - case "sort-asc": - db = db.Order("`sort` ASC") - case "sort-desc": - db = db.Order("`sort` DESC") - } - err = db.Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_product_template_tags_logic.go b/model/gmodel/fs_product_template_tags_logic.go deleted file mode 100755 index 68fc2b2e..00000000 --- a/model/gmodel/fs_product_template_tags_logic.go +++ /dev/null @@ -1,16 +0,0 @@ -package gmodel - -import ( - "context" -) - -func (pt *FsProductTemplateTagsModel) GetListByIds(ctx context.Context, ids []int64) (resp []FsProductTemplateTags, err error) { - if len(ids) == 0 { - return - } - err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`id` in (?)", ids).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go deleted file mode 100755 index e31f35fe..00000000 --- a/model/gmodel/fs_product_template_v2_logic.go +++ /dev/null @@ -1,16 +0,0 @@ -package gmodel - -import ( - "context" -) - -func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64) (resp []FsProductTemplateV2, err error) { - if len(productIds) == 0 { - return - } - err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_qrcode_set_logic.go b/model/gmodel/fs_qrcode_set_logic.go deleted file mode 100755 index efad4008..00000000 --- a/model/gmodel/fs_qrcode_set_logic.go +++ /dev/null @@ -1,22 +0,0 @@ -package gmodel - -import ( - "context" - "errors" - "gorm.io/gorm" -) - -func (q *FsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err error) { - err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`status` = ?", 1).Find(&resp).Error - if err != nil { - return nil, err - } - return -} -func (q *FsQrcodeSetModel) FindOne(ctx context.Context, id int64) (resp FsQrcodeSet, err error) { - err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`id` = ?", id).First(&resp).Error - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return FsQrcodeSet{}, err - } - return resp, nil -} diff --git a/model/gmodel/fs_standard_logo_logic.go b/model/gmodel/fs_standard_logo_logic.go deleted file mode 100755 index e7f5ea56..00000000 --- a/model/gmodel/fs_standard_logo_logic.go +++ /dev/null @@ -1,13 +0,0 @@ -package gmodel - -import ( - "context" -) - -func (l *FsStandardLogoModel) GetAll(ctx context.Context) (resp []FsStandardLogo, err error) { - err = l.db.WithContext(ctx).Model(&FsStandardLogo{}).Where("`status` = ? ", 1).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_tags_logic.go b/model/gmodel/fs_tags_logic.go deleted file mode 100755 index 5cdf6c55..00000000 --- a/model/gmodel/fs_tags_logic.go +++ /dev/null @@ -1,32 +0,0 @@ -package gmodel - -import ( - "context" - "errors" - "gorm.io/gorm" -) - -func (t *FsTagsModel) FindOne(ctx context.Context, id int64) (resp FsTags, err error) { - err = t.db.WithContext(ctx).Model(&FsTags{}).Where("`id` = ? and `status` = ?", id, 1).First(&resp).Error - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return FsTags{}, err - } - return resp, nil -} -func (t *FsTagsModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsTags, err error) { - if len(ids) == 0 { - return - } - err = t.db.WithContext(ctx).Model(&FsTags{}).Where("`id` in(?) and `status` = ?", ids, 1).Find(&resp).Error - if err != nil { - return nil, err - } - return -} -func (t *FsTagsModel) GetAllByLevel(ctx context.Context, level int) (resp []FsTags, err error) { - err = t.db.Model(&FsTags{}).Where("`level` = ? and `status` = ?", level, 1).Find(&resp).Error - if err != nil { - return nil, err - } - return -} diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go deleted file mode 100644 index 9b4f6176..00000000 --- a/model/gmodel/fs_user_logic.go +++ /dev/null @@ -1,54 +0,0 @@ -package gmodel - -import ( - "context" -) - -// TODO: 使用model的属性做你想做的 - -type UserBasicInfoForSave struct { - ID uint `gorm:"primary_key" json:"id"` - 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"` -} - -func (u *FsUserModel) FindUserByEmail(ctx context.Context, emailname string) (resp FsUser, err error) { - err = u.db.WithContext(ctx).Model(&FsUser{PasswordHash: new(string)}).Where("`email` = ?", emailname).Take(&resp).Error - return resp, err -} - -func (u *FsUserModel) FindUserById(ctx context.Context, Id int64) (resp FsUser, err error) { - err = u.db.WithContext(ctx).Model(&FsUser{}).Where("`id` = ? and is_del = ?", Id, 0).Take(&resp).Error - return resp, err -} - -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 -} diff --git a/model/gmodel/fsfaqmodel.go b/model/gmodel/fsfaqmodel.go deleted file mode 100755 index b09e16e4..00000000 --- a/model/gmodel/fsfaqmodel.go +++ /dev/null @@ -1,24 +0,0 @@ -package gmodel - -import ( - "database/sql" - "gorm.io/gorm" -) - -type FsFaq struct { - Id int64 `gorm:"primary_key" json:"id"` - TagId *int64 `gorm:"default:0" json:"tag_id"` // 分类ID - TagName *string `gorm:"default:''" json:"tag_name"` // 分类名称 - Title *string `gorm:"default:''" json:"title"` // 标题 - Content *string `gorm:"default:''" json:"content"` // 内容 - Status *int64 `gorm:"default:1" json:"status"` // 状态(0:禁用,1:启用) - Sort *int64 `gorm:"default:0" json:"sort"` // 排序 - Ctime *sql.NullInt64 `gorm:"default:0" json:"ctime"` // 添加时间 -} -type FsFaqModel struct { - db *gorm.DB -} - -func NewFsFaqModel(db *gorm.DB) *FsFaqModel { - return &FsFaqModel{db} -} diff --git a/model/gmodel/fsguestmodel.go b/model/gmodel/fsguestmodel.go deleted file mode 100755 index 714e570e..00000000 --- a/model/gmodel/fsguestmodel.go +++ /dev/null @@ -1,57 +0,0 @@ -package gmodel - -import ( - "context" - "fusenapi/utils/auth" - "time" - - "github.com/zeromicro/go-zero/core/logx" - "gorm.io/gorm" -) - -type FsGuest struct { - GuestId int64 `gorm:"primary_key" json:"guest_id"` // 游客ID - AuthKey *string `gorm:"" json:"auth_key"` // jwt token - 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"` // 更新时间 - 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是否去除背景 -} -type FsGuestModel struct{ db *gorm.DB } - -func NewFsGuestModel(db *gorm.DB) *FsGuestModel { return &FsGuestModel{db} } - -func (m *FsGuestModel) GenerateGuestID(ctx context.Context, AccessSecret *string) (authKey string, err error) { - - err = m.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { - now := time.Now().Unix() - exp := now + 31536000 - - var record = &FsGuest{CreatedAt: &now, UpdatedAt: &exp, AuthKey: &authKey} - tx.Create(record) - - authKey, err = auth.GenerateJwtToken(AccessSecret, now, 31536000, 0, record.GuestId) - if err != nil { - logx.Error(err) - return err - } - record.AuthKey = &authKey - record.CreatedAt = &now - err = tx.Updates(record).Error - if err != nil { - logx.Error(err) - return err - } - return nil - }) - - if err != nil { - return "", err - } - - return authKey, nil -} diff --git a/model/gmodel/var.go b/model/gmodel/var.go deleted file mode 100644 index d2e7bd33..00000000 --- a/model/gmodel/var.go +++ /dev/null @@ -1,5 +0,0 @@ -package gmodel - -import "gorm.io/gorm" - -var ErrRecordNotFound = gorm.ErrRecordNotFound