This commit is contained in:
laodaming
2023-08-14 17:31:57 +08:00
parent 94a36bd98e
commit 24a5bf11a3
5 changed files with 61 additions and 142 deletions

View File

@@ -32,3 +32,14 @@ func (pt *FsProductTemplateTagsModel) GetList(ctx context.Context, page, limit i
err = db.Offset(offset).Limit(limit).Find(&resp).Error
return resp, err
}
func (pt *FsProductTemplateTagsModel) GetListByTitles(ctx context.Context, titles []string, limit int, orderBy string) (resp []FsProductTemplateTags, err error) {
if len(titles) == 0 {
return nil, nil
}
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", titles, 1)
if orderBy != "" {
db = db.Order(orderBy)
}
err = db.Limit(limit).Find(&resp).Error
return resp, err
}

View File

@@ -61,12 +61,9 @@ func (m *FsUserMaterialModel) FindLatestOne(ctx context.Context, userId int64, g
if userId == 0 && guestId == 0 {
return FsUserMaterial{}, nil
}
db := m.db.WithContext(ctx).Model(&FsUserMaterial{}).Order("id DESC")
if userId != 0 {
db = db.Where("`user_id` = ?", userId)
} else {
db = db.Where("`guest_id` = ?", guestId)
}
db := m.db.WithContext(ctx).Model(&FsUserMaterial{}).
Where("`user_id` = ? and `guest_id` = ?", userId, guestId).
Order("id DESC")
err = db.Take(&resp).Error
return resp, err
}
@@ -75,3 +72,8 @@ func (m *FsUserMaterialModel) FindOneById(ctx context.Context, id int64) (resp *
err = m.db.WithContext(ctx).Model(&FsUserMaterial{}).Where("id = ?", id).Take(&resp).Error
return resp, err
}
func (m *FsUserMaterialModel) GetListByUser(ctx context.Context, userId, guestId int64, limit int) (resp *FsUserMaterial, err error) {
err = m.db.WithContext(ctx).Model(&FsUserMaterial{}).
Where("`user_id` = ? and `guest_id` = ?", userId, guestId).Order("id DESC").Limit(limit).Find(&resp).Error
return resp, err
}