Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[crud_tst-cardproducts_getItems]
- @filters CRUDFilterParameter READONLY,
- @sort sql_variant,
- @direction nvarchar(8),
- @page int,
- @pageSize int,
- @username nvarchar(32)
- AS
- BEGIN
- declare @result TABLE (id int, imgTop nvarchar(128), Title nvarchar(512), headerColor nvarchar(16), [text] nvarchar(max), cardClass nvarchar(128))
- declare @langID int
- select @langID = try_cast(Value as int) from @filters where [Key] = 'langID'
- declare @filterName nvarchar(128)
- select @filterName = Value from @filters where [Key] = 'name'
- declare @filterPrice nvarchar(128)
- select @filterPrice = Value from @filters where [Key] = 'price'
- declare @sumFrom int, @sumTo int
- select @sumFrom = min(try_cast(value as money)) from split(@filterPrice, ',')
- select @sumTo = max(try_cast(value as money)) from split(@filterPrice, ',')
- insert into @result
- select id as id,
- dbo.rs_resourceLink('tst-product',try_cast(id as nvarchar),0) as imgTop,
- '<div class="small font-weight-bold mb-3">' + isnull(name, 'Без названия') + '</div>
- <div class="row" style="font-size: small;">
- <div class="col-12 col-md-6"><i class="fas fa-clipboard-list mr-1 text-success"></i>' + isnull(art, 'Нет артикула') + '</div>
- <div class="col-12 col-md-6 font-weight-bold" style="text-align: end;">' + isnull(cast(price as nvarchar), 'Цена не указана') + '<i class="fas fa-ruble-sign ml-1 text-primary"></i></div>
- </div>' as Title,
- 'info' as headerColor,
- '<div class="small">'+[desc]+'</div>' as [text],
- '' as cardClass
- from tst_products
- where (isnull(@filterName,'')='' or name like '%'+@filterName+'%' or art like '%'+@filterName+'%' or [desc] like '%'+@filterName+'%')
- and (isnull(@filterPrice,'')='' or price between @sumFrom and @sumTo)
- -- 1 SELECT - сами данные
- select * from @result
- order by Title
- OFFSET @PageSize * (@Page - 1) ROWS
- FETCH NEXT @PageSize ROWS ONLY;
- -- 2 SELECT - кол-во в таблице
- select count(*) from @result
- -- 3 SELECT Дополнительные настройки таблицы
- select 'card' ViewType, 'columns' CardGroupType, 1 InstantFilter, iif(@langID=1, 'Product cards', 'Карточки товаров') title
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement