@@ -54,8 +54,8 @@ public string[] GetTableList(string databaseName, string tags = null)
5454 {
5555 var tables = dataBase . TableContext . Tables ;
5656 var query = from item in tables
57- where ( item . TableInfo . DerivedTags & ( TagInfo ) tags ) != TagInfo . Unused
58- select item . Name ;
57+ where ( item . TableInfo . DerivedTags & ( TagInfo ) tags ) != TagInfo . Unused
58+ select item . Name ;
5959 return query . ToArray ( ) ;
6060 }
6161
@@ -81,6 +81,46 @@ public IDictionary<int, object> GetTableData(string databaseName, string tableNa
8181 } ) ;
8282 }
8383
84+ [ HttpGet ]
85+ [ Route ( "tables/*/info" ) ]
86+ public GetTableInfoResponse [ ] GetTablesInfo ( string databaseName , string tags = null , string columnTags = null )
87+ {
88+ var tables = this . GetTables ( databaseName , tags ) ;
89+ return tables . Select ( table =>
90+ {
91+ return table . Dispatcher . Invoke ( ( ) =>
92+ {
93+ var tableInfo = table . TableInfo ;
94+ if ( ! string . IsNullOrWhiteSpace ( columnTags ) )
95+ {
96+ tableInfo = table . TableInfo . Filter ( ( TagInfo ) columnTags ) ;
97+ }
98+
99+ return GetTableInfoResponse . ConvertFrom ( tableInfo ) ;
100+ } ) ;
101+ } ) . ToArray ( ) ;
102+ }
103+
104+ [ HttpPost ]
105+ [ Route ( "tables/*/info" ) ]
106+ public GetTableInfoResponse [ ] GetTablesInfoByTableName ( string databaseName , [ FromBody ] GetTableInfoByTableNameRequest request , string tags = null , string columnTags = null )
107+ {
108+ var tables = this . GetTables ( databaseName , tags ) ;
109+ var intersectTables = tables . Select ( table => table . Dispatcher . Invoke ( ( ) => table . TableName ) )
110+ . Intersect ( request . TableNames , StringComparer . OrdinalIgnoreCase ) ;
111+
112+ return intersectTables . Select ( tableName =>
113+ {
114+ var table = tables . First ( o => o . Dispatcher . Invoke ( ( ) => o . TableName == tableName ) ) ;
115+ var tableInfo = table . Dispatcher . Invoke ( ( ) => table . TableInfo ) ;
116+ if ( ! string . IsNullOrWhiteSpace ( columnTags ) )
117+ {
118+ tableInfo = tableInfo . Filter ( ( TagInfo ) columnTags ) ;
119+ }
120+ return GetTableInfoResponse . ConvertFrom ( tableInfo ) ;
121+ } ) . ToArray ( ) ;
122+ }
123+
84124 [ HttpGet ]
85125 [ Route ( "tables/{tableName}/info" ) ]
86126 public GetTableInfoResponse GetTableInfo ( string databaseName , string tableName , string tags = null )
@@ -106,7 +146,7 @@ public GetTableInfoResponse GetTableInfo(string databaseName, string tableName,
106146 public void CopyTable ( string databaseName , string tableName , [ FromBody ] CopyTableRequest request )
107147 {
108148 var table = this . GetTable ( databaseName , tableName ) ;
109- table . Dispatcher . Invoke ( ( ) => table . Copy ( this . Authentication , request . NewTableName , request . CategoryPath , request . CopyContent ) ) ;
149+ table . Dispatcher . Invoke ( ( ) => table . Copy ( this . Authentication , request . NewTableName , request . CategoryPath , request . CopyContent ) ) ;
110150 }
111151
112152 [ HttpDelete ]
@@ -154,15 +194,15 @@ public ContainsTableResponse ContainsTable(string databaseName, string tableName
154194 }
155195
156196 [ HttpGet ]
157- [ Route ( "table-item " ) ]
197+ [ Route ( "table-items " ) ]
158198 public string [ ] GetTableItemList ( string databaseName )
159199 {
160200 var dataBase = this . GetDataBase ( databaseName ) ;
161201 return dataBase . Dispatcher . Invoke ( ( ) => dataBase . TableContext . Select ( item => item . Path ) . ToArray ( ) ) ;
162202 }
163203
164204 [ HttpPost ]
165- [ Route ( "table-item /log" ) ]
205+ [ Route ( "table-items /log" ) ]
166206 public GetTableItemLogInfoResponse [ ] GetTableItemLogInfo ( string databaseName , [ FromBody ] GetTableItemLogInfoRequest request )
167207 {
168208 var tableItem = this . GetTableItem ( databaseName , request . TableItemPath ) ;
@@ -174,31 +214,31 @@ public GetTableItemLogInfoResponse[] GetTableItemLogInfo(string databaseName, [F
174214 }
175215
176216 [ HttpPut ]
177- [ Route ( "table-item /move" ) ]
217+ [ Route ( "table-items /move" ) ]
178218 public void MoveTableItem ( string databaseName , [ FromBody ] MoveTableItemRequest request )
179219 {
180220 var tableItem = this . GetTableItem ( databaseName , request . TableItemPath ) ;
181221 tableItem . Dispatcher . Invoke ( ( ) => tableItem . Move ( this . Authentication , request . ParentPath ) ) ;
182222 }
183223
184224 [ HttpPut ]
185- [ Route ( "table-item /rename" ) ]
225+ [ Route ( "table-items /rename" ) ]
186226 public void RenameTableItem ( string databaseName , [ FromBody ] RenameTableItemRequest request )
187227 {
188228 var tableItem = this . GetTableItem ( databaseName , request . TableItemPath ) ;
189229 tableItem . Dispatcher . Invoke ( ( ) => tableItem . Rename ( this . Authentication , request . NewName ) ) ;
190230 }
191231
192232 [ HttpPut ]
193- [ Route ( "table-item /delete" ) ]
233+ [ Route ( "table-items /delete" ) ]
194234 public void DeleteTableItem ( string databaseName , [ FromBody ] DeleteTableItemRequest request )
195235 {
196236 var tableItem = this . GetTableItem ( databaseName , request . TableItemPath ) ;
197237 tableItem . Dispatcher . Invoke ( ( ) => tableItem . Delete ( this . Authentication ) ) ;
198238 }
199239
200240 [ HttpPost ]
201- [ Route ( "table-item /contains" ) ]
241+ [ Route ( "table-items /contains" ) ]
202242 public ContainsTableItemResponse ContainsTableItem ( string databaseName , [ FromBody ] ContainsTableItemRequest request )
203243 {
204244 var dataBase = this . GetDataBase ( databaseName ) ;
@@ -221,6 +261,34 @@ private IDataBase GetDataBase(string databaseName)
221261 } ) ;
222262 }
223263
264+ private ITable [ ] GetTables ( string dataBaseName , string tags = null )
265+ {
266+ if ( dataBaseName == null )
267+ throw new ArgumentNullException ( nameof ( dataBaseName ) ) ;
268+
269+ var dataBase = this . cremaHost . Dispatcher . Invoke ( ( ) =>
270+ {
271+ if ( this . cremaHost . DataBases . Contains ( dataBaseName ) == false )
272+ throw new DataBaseNotFoundException ( dataBaseName ) ;
273+ return this . cremaHost . DataBases [ dataBaseName ] ;
274+ } ) ;
275+
276+ return dataBase . Dispatcher . Invoke ( ( ) =>
277+ {
278+ if ( tags == null )
279+ {
280+ var tables = dataBase . TableContext . Tables . ToArray ( ) ;
281+ return tables ;
282+ }
283+ else
284+ {
285+ var tagInfo = ( TagInfo ) tags ;
286+ var tables = dataBase . TableContext . Tables . Where ( table => ( table . TableInfo . DerivedTags & tagInfo ) != TagInfo . Unused ) . ToArray ( ) ;
287+ return tables ;
288+ }
289+ } ) ;
290+ }
291+
224292 private ITable GetTable ( string dataBaseName , string tableName )
225293 {
226294 if ( dataBaseName == null )
0 commit comments