Advertisement
Ruslan_Rayanov

Map GetItems

Oct 18th, 2020
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.46 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[crud_testMap_getItems]
  2.     @filters CRUDFilterParameter READONLY,
  3.     @sort sql_variant,
  4.     @direction nvarchar(8),
  5.     @page int,
  6.     @pageSize int,
  7.     @username nvarchar(32)
  8. AS
  9. BEGIN
  10.     declare   @result TABLE (id int, lat nvarchar(32), lng nvarchar(32), description nvarchar(max), tooltip nvarchar(128), radius int, canDrag bit)
  11.  
  12.     declare @langID int
  13.     select @langID = try_cast(Value as int) from @filters where [Key] = 'langID'
  14.  
  15.  
  16.     declare @filterCity int
  17.     select @filterCity = Value from @filters where [Key] = 'tooltip'
  18.    
  19.     insert into @result
  20.     select id,
  21.            lat,
  22.            lng,
  23.            iif(@langID=1, 'There may be a form with detailed data for a point', 'Здесь может быть  форма с детальными данными по точке') description,
  24.            address as tooltip,
  25.            500 radius,
  26.            1 canDrag
  27.     from tst_addresses
  28.     where isnull(@filterCity,0)=0 or address like '%'+(select name from as_geo_regions where id = @filterCity)+'%'
  29. /*          
  30.     insert into @result
  31.     select 1 id,
  32.         '43.5868685' lat,
  33.         '39.7299474' lng,
  34.         '<div class="as-form" data-code="captureContact"></div>' description,
  35.         'Подсказка для элемента' tooltip,
  36.         500 radius,
  37.         0 canDrag
  38.    
  39.     insert into @result
  40.     select 2 id,
  41.         '42.5868685' lat,
  42.         '39.1299474' lng,
  43.         'Вторая точка' description,
  44.         'Подсказка для второй точки' tooltip,
  45.         500 radius,
  46.         0 canDrag
  47.        
  48.     insert into @result
  49.     select 3 id,
  50.         '55.753960' lat,
  51.         '37.620393' lng,
  52.         'Еще одна точка' description,
  53.         'Подсказка для этой точки' tooltip,
  54.         500 radius,
  55.         0 canDrag
  56.  */  
  57.    
  58.     -- 1 SELECT - сами данные    
  59.     select * from @result
  60.     order by  radius
  61.        
  62.     OFFSET @PageSize * (@Page - 1) ROWS
  63.     FETCH NEXT @PageSize ROWS ONLY;
  64.    
  65.     -- 2 SELECT - кол-во в таблице
  66.     select count(*) from @result   
  67.  
  68.     declare @isAdmin int = 0
  69.     select @isAdmin = 1 from sec_getUserRoles(@username) where role = 'admin'
  70.  
  71.  
  72.     -- 3 SELECT Дополнительные настройки таблицы
  73.     Select 'map' ViewType,
  74.         1 MapShowUserLocation,
  75.         '/Controls/Resource/GetFile?code=userPhoto&user='+@username+'&thumb=1' MapUserImageUrl,
  76.         1 MapShowAllRegions,
  77.         1 MapShowLocationInRange,
  78.         '{
  79.             "fitBound": 1,
  80.             "zoom":9,
  81.            "mapCenter": {"lat":55.760533, "lng": 37.487028}
  82.        }' MapOptions,
  83.         iif(@langID=1, 'Map with points', 'Вывод точек на карте') title,
  84.         iif(@langID=1, 'An example of a map display with some points found, each point has the ability to place a shape or some kind of description', 'Пример вывода карты с некоторыми найденными точками, у каждой точки есть возможность разместить форму или некое описание') titleTooltip,
  85.        
  86.         case when isnull(@isAdmin,0)=0 then '' else '<a href="/tst-addAddress" class="btn btn-primary mb-1"><i class="fas fa-plus"></i> '+iif(@langID=1, 'Add point', 'Добавить точку')+'</a>' end as ToolbarAdditional,
  87.         1 InstantFilter
  88.     -- 4 SELECT Данные для подвала страницы или данные для Ганта/Канбана (если установлен ViewType в 3 SELECT)
  89. END
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement