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

This commit is contained in:
eson
2023-06-25 18:30:58 +08:00
35 changed files with 641 additions and 58 deletions

View File

@@ -3,9 +3,10 @@ package gmodel
import "context"
func (l *FsProductModel3dLightModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3dLight, err error) {
err = l.db.WithContext(ctx).Model(&FsProductModel3dLight{}).Where("`id` in (?)", ids).Find(&resp).Error
if err != nil {
return nil, err
}
return
err = l.db.WithContext(ctx).Model(&FsProductModel3dLight{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
return resp, err
}
func (l *FsProductModel3dLightModel) GetAll(ctx context.Context) (resp []FsProductModel3dLight, err error) {
err = l.db.WithContext(ctx).Model(&FsProductModel3dLight{}).Where("`status` = ?", 1).Find(&resp).Error
return resp, err
}

View File

@@ -26,3 +26,23 @@ func (d *FsProductModel3dModel) GetAllByIdsTag(ctx context.Context, ids []int64,
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ? and `tag` = ?", ids, 1, tag).Find(&resp).Error
return resp, err
}
type Get3dModelsByParamReq struct {
Tag int64
ProductId int64
}
func (d *FsProductModel3dModel) Get3dModelsByParam(ctx context.Context, req Get3dModelsByParamReq) (resp []FsProductModel3d, err error) {
if req.ProductId == 0 && req.Tag == 0 {
return nil, nil
}
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`status` = ?", 1)
if req.ProductId > 0 {
db = db.Where("`product_id` =? ", req.ProductId)
}
if req.Tag > 0 {
db = db.Where("`tag` =? ", req.Tag)
}
err = db.Find(&resp).Error
return resp, err
}

View File

@@ -40,3 +40,13 @@ func (t *FsProductTemplateV2Model) FindByParam(ctx context.Context, id int64, mo
func (t *FsProductTemplateV2Model) Update(ctx context.Context, id int64, data *FsProductTemplateV2) error {
return t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Updates(&data).Error
}
func (t *FsProductTemplateV2Model) FindAllByModelIds(ctx context.Context, modelIds []int64) (resp []FsProductTemplateV2, err error) {
if len(modelIds) == 0 {
return
}
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `is_del` = ? and `status` = ?", modelIds, 0, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}