This commit is contained in:
laodaming
2023-06-20 19:56:18 +08:00
parent b2062d6448
commit edeb2bb5f1
9 changed files with 160 additions and 231 deletions

View File

@@ -2,10 +2,10 @@ package gmodel
import "context"
func (ml *FsMapLibraryModel) GetAllEnabledList(ctx context.Context, fields string) (resp []FsMapLibrary, err error) {
func (ml *FsMapLibraryModel) GetAllEnabledList(ctx context.Context, fields ...string) (resp []FsMapLibrary, err error) {
db := ml.db.WithContext(ctx).Model(&FsMapLibrary{}).Where("`status` = ?", 1)
if fields != "" {
db = db.Select(fields)
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Find(&resp).Error
if err != nil {

View File

@@ -1 +1,11 @@
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
}

View File

@@ -14,3 +14,12 @@ func (pt *FsProductTemplateTagsModel) GetListByIds(ctx context.Context, ids []in
}
return
}
func (pt *FsProductTemplateTagsModel) FindOne(ctx context.Context, id int64, fields ...string) (resp *FsProductTemplateTags, err error) {
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`id` = ?", id)
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Take(resp).Error
return resp, err
}

View File

@@ -29,3 +29,11 @@ func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Find(&resp).Error
return resp, err
}
func (t *FsProductTemplateV2Model) FindByParam(ctx context.Context, id int64, modelId int64, fields ...string) (resp *FsProductTemplateV2, err error) {
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? and `model_id` = ?", id, modelId)
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Take(&resp).Error
return resp, err
}