Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
momo
2023-09-26 12:21:30 +08:00
13 changed files with 213 additions and 35 deletions

View File

@@ -87,14 +87,14 @@ func (a *FsAddressModel) SettingUserDefaultAddress(ctx context.Context, userId i
now := time.Now().UTC()
err = tx.Model(&FsAddress{}).Where(" `user_id` = ? and `status` = ? and `address_id = ?` ", userId, 1, addressId).
UpdateColumn("ltime", now.Add(time.Hour*24*365*100)).
err = tx.Model(&FsAddress{}).Where(" `user_id` = ? and `status` = ? and `address_id` = ? ", userId, 1, addressId).
UpdateColumn("ltime", now.AddDate(250, 0, 0)).
UpdateColumn("utime", now).Error
if err != nil {
return err
}
err = tx.Where(" `user_id` = ? and `status` = ? and `address_id != ? and `ltime` > ?` ", userId, 1, addressId, now.Add(time.Hour*24*365)).
err = tx.Where(" `user_id` = ? and `status` = ? and `address_id` != ? and `ltime` > ? ", userId, 1, addressId, now.AddDate(10, 0, 0)).
UpdateColumn("ltime", now).Error
if err != nil {
logx.Error(err)
@@ -107,10 +107,8 @@ func (a *FsAddressModel) SettingUserDefaultAddress(ctx context.Context, userId i
}
func (a *FsAddressModel) DeleteOne(ctx context.Context, addressId int64, userId int64) (err error) {
address := &FsAddress{
AddressId: addressId,
UserId: &userId,
}
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`address_id` = ? and `user_id` = ? and `status` = ? ", addressId, userId, 1).Delete(address).Error
err = a.db.WithContext(ctx).Model(&FsAddress{}).
Where("`address_id` = ? and `user_id` = ? and `status` = ? ", addressId, userId, 1).
UpdateColumn("status", 0).Error
return err
}

View File

@@ -16,7 +16,7 @@ type StepPriceJsonStruct struct {
}
func (d *FsProductModel3dModel) FindOne(ctx context.Context, id int64, fields ...string) (resp *FsProductModel3d, err error) {
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` = ? ", id)
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` = ? and `status` =? ", id, 1)
if len(fields) > 0 {
db = db.Select(fields[0])
}
@@ -41,7 +41,7 @@ func (d *FsProductModel3dModel) GetAllByIdsWithoutStatus(ctx context.Context, id
if len(ids) == 0 {
return
}
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?)", ids)
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ?", ids, 1)
if len(fields) > 0 {
db = db.Select(fields[0])
}
@@ -80,13 +80,13 @@ func (d *FsProductModel3dModel) Get3dModelsByParam(ctx context.Context, req Get3
return resp, err
}
func (d *FsProductModel3dModel) Update(ctx context.Context, id int64, data *FsProductModel3d) error {
return d.db.WithContext(ctx).Where("`id` = ? ", id).Updates(&data).Error
return d.db.WithContext(ctx).Where("`id` = ? and `status` =? ", id, 1).Updates(&data).Error
}
func (d *FsProductModel3dModel) GetAllBySizeIdsTag(ctx context.Context, sizeIds []int64, tag int64, fields ...string) (resp []FsProductModel3d, err error) {
if len(sizeIds) == 0 {
return
}
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`size_id` in (?) and `tag` = ?", sizeIds, tag)
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`size_id` in (?) and `tag` = ? and `status` = ?", sizeIds, tag, 1)
if len(fields) != 0 {
db = db.Select(fields[0])
}
@@ -94,7 +94,7 @@ func (d *FsProductModel3dModel) GetAllBySizeIdsTag(ctx context.Context, sizeIds
return resp, err
}
func (d *FsProductModel3dModel) GetAll(ctx context.Context) (resp []FsProductModel3d, err error) {
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Find(&resp).Error
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`status` = ?", 1).Find(&resp).Error
return resp, err
}
@@ -107,7 +107,7 @@ func (d *FsProductModel3dModel) GetGroupPartListByProductIds(ctx context.Context
if len(productIds) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`product_id` in(?) and `status` =? ", productIds, 1).
Select("product_id,group_concat(part_list) as part_list").
Group("product_id").Find(&resp).Error
return resp, err
@@ -142,3 +142,13 @@ func (d *FsProductModel3dModel) GetAllByProductIdTag(ctx context.Context, produc
err = db.Find(&resp).Error
return resp, err
}
func (d *FsProductModel3dModel) FindOneByProductIdSizeIdTag(ctx context.Context, productId, sizeId, tag int64, fields ...string) (resp *FsProductModel3d, err error) {
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).
Where("`product_id` = ? and `size_id` = ? and `tag` = ? and `status` = ?", productId, sizeId, tag, 1).
Order("sort DESC")
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Take(&resp).Error
return resp, err
}