This commit is contained in:
laodaming
2023-09-20 16:46:30 +08:00
parent 5042971472
commit be80525878
5 changed files with 44 additions and 2 deletions

View File

@@ -142,3 +142,16 @@ func (m *FsUserMaterialModel) GetListByUser(ctx context.Context, userId, guestId
Where(cond).Order("id DESC").Limit(limit).Find(&resp).Error
return resp, err
}
func (m *FsUserMaterialModel) FindOneByUserAndLogoUrl(ctx context.Context, userId, guestId int64, logoResourceId string) (resp *FsUserMaterial, err error) {
var cond string
if userId != 0 {
cond = fmt.Sprintf("user_id = %d", userId)
} else if guestId != 0 {
cond = fmt.Sprintf("guest_id = %d", guestId)
} else {
cond = fmt.Sprintf("user_id = %d and guest_id = %d", userId, guestId)
}
err = m.db.WithContext(ctx).Model(&FsUserMaterial{}).Where("`resource_id` = ?", logoResourceId).
Where(cond).Order("id DESC").Take(&resp).Error
return resp, err
}