1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-08-10 22:41:43 +02:00

Main build (Jenkins)

This commit is contained in:
Vitaly the Alpaca (bot)
2024-12-30 20:26:02 +03:00
parent f7eb8af2e1
commit cf12e7d29b
6 changed files with 6352 additions and 6063 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -23,6 +23,7 @@
<module name="OPI_YandexID" file="core/Modules/OPI_YandexID.os"/>
<module name="OPI_YandexMarket" file="core/Modules/OPI_YandexMarket.os"/>
<module name="OPI_YandexMetrika" file="core/Modules/OPI_YandexMetrika.os"/>
<module name="OPI_SQLQueries" file="tools/Modules/OPI_SQLQueries.os"/>
<module name="OPI_Tools" file="tools/Modules/internal/Modules/OPI_Tools.os"/>
<module name="OPI_Cryptography" file="tools/Modules/internal/Modules/OPI_Cryptography.os"/>
<module name="OPI_TestDataRetrieval" file="tools/Modules/OPI_TestDataRetrieval.os"/>

View File

@@ -0,0 +1,286 @@
// OneScript: ./OInt/tools/Modules/OPI_SQLQueries.os
// MIT License
// Copyright (c) 2023 Anton Tsitavets
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// https://github.com/Bayselonarrend/OpenIntegrations
// BSLLS:Typo-off
// BSLLS:LatinAndCyrillicSymbolInWord-off
// BSLLS:IncorrectLineBreak-off
// BSLLS:NumberOfOptionalParams-off
// BSLLS:UsingServiceTag-off
// BSLLS:LineLength-off
//@skip-check module-structure-top-region
//@skip-check module-structure-method-in-regions
//@skip-check wrong-string-literal-content
//@skip-check method-too-many-params
//@skip-check constructor-function-return-section
// Uncomment if OneScript is executed
#Use "./internal"
#Region Internal
Function NewSQLScheme(Val Action) Export
OPI_TypeConversion.GetLine(Action);
Action = Upper(Action);
If Action = "SELECT" Then
Scheme = EmptySchemeSelect();
ElsIf Action = "INSERT" Then
Scheme = EmptySchemeInsert();
ElsIf Action = "UPDATE" Then
Scheme = EmptySchemeUpdate();
ElsIf Action = "DELETE" Then
Scheme = EmptySchemeDelete();
ElsIf Action = "CREATE" Then
Scheme = EmptySchemeCreate();
Else
Scheme = New Structure;
EndIf;
Return Scheme;
EndFunction
Function FormSQLText(Val Scheme) Export
ErrorText = "The value passed is not a valid SQL query schema";
OPI_TypeConversion.GetKeyValueCollection(Scheme, ErrorText);
SchemeType = "";
If Not OPI_Tools.CollectionFieldExist(Scheme, "type", SchemeType) Then
Raise ErrorText;
EndIf;
SchemeType = Upper(SchemeType);
If SchemeType = "SELECT" Then
QueryText = FormTextSelect(Scheme);
ElsIf SchemeType = "INSERT" Then
QueryText = FormTextInsert(Scheme);
ElsIf SchemeType = "UPDATE" Then
QueryText = FormTextUpdate(Scheme);
ElsIf SchemeType = "DELETE" Then
QueryText = FormTextDelete(Scheme);
ElsIf SchemeType = "CREATE" Then
QueryText = FormTextCreate(Scheme);
Else
QueryText = "";
EndIf;
Return QueryText;
EndFunction
Procedure AddColoumn(Scheme, Val Name, Val Type) Export
OPI_TypeConversion.GetLine(Name);
OPI_TypeConversion.GetLine(Type);
If Not Scheme["type"] = "CREATE" Then
Return;
EndIf;
Scheme["columns"].Add(New Structure(Name, Type));
EndProcedure
Procedure SetTableName(Scheme, Val Name) Export
OPI_TypeConversion.GetLine(Name);
Scheme.Insert("table", Name);
EndProcedure
#EndRegion
#Region Private
#Region Scheme
Function EmptySchemeSelect()
Scheme = New Structure("type", "SELECT");
Scheme.Insert("table" , "");
Scheme.Insert("filter" , New Array);
Scheme.Insert("order_by", New Array);
Scheme.Insert("limit" , New Array);
Scheme.Insert("fileds" , New Array);
Return Scheme;
EndFunction
Function EmptySchemeInsert()
Scheme = New Structure("type", "INSERT");
Scheme.Insert("table", "");
Scheme.Insert("set" , New Array);
Return Scheme;
EndFunction
Function EmptySchemeUpdate()
Scheme = New Structure("type", "UPDATE");
Scheme.Insert("table" , "");
Scheme.Insert("set" , New Array);
Scheme.Insert("filter", New Array);
Return Scheme;
EndFunction
Function EmptySchemeDelete()
Scheme = New Structure("type", "DELETE");
Scheme.Insert("table" , "");
Scheme.Insert("filter", New Array);
Return Scheme;
EndFunction
Function EmptySchemeCreate()
Scheme = New Structure("type", "CREATE");
Scheme.Insert("table" , "");
Scheme.Insert("columns", New Array);
Return Scheme;
EndFunction
#EndRegion
#Region Processors
Function FormTextSelect(Val Scheme)
TextSQL = "";
Return TextSQL;
EndFunction
Function FormTextInsert(Val Scheme)
TextSQL = "";
Return TextSQL;
EndFunction
Function FormTextUpdate(Val Scheme)
TextSQL = "";
Return TextSQL;
EndFunction
Function FormTextDelete(Val Scheme)
TextSQL = "";
Return TextSQL;
EndFunction
Function FormTextCreate(Val Scheme)
CheckSchemeRequiredFields(Scheme, "table,columns");
Table = Scheme["table"];
Columns = Scheme["columns"];
SQLTemplate = "CREATE TABLE %1 (
| %2
| )";
ColoumTemplate = "%1 %2";
ColoumnsDescriptionArray = New Array;
For Each Coloumn In Columns Do
ColoumnsDescriptionArray.Add(StrTemplate(ColoumTemplate, Coloumn.Key, Coloumn.Value));
EndDo;
ColoumnsDescription = StrConcat(ColoumnsDescriptionArray, "," + Chars.LF);
TextSQL = StrTemplate(SQLTemplate, Table, ColoumnsDescription);
Return TextSQL;
EndFunction
#EndRegion
Procedure CheckSchemeRequiredFields(Scheme, Val Fields)
RequiredFieldsArray = StrConcat(Fields, ",");
AbsenteesArray = OPI_Tools.FindMissingCollectionFields(Scheme, RequiredFieldsArray);
If ValueIsFilled(AbsenteesArray) Then
Raise "Required schema fields are missing: " + StrConcat(AbsenteesArray, ", ");
EndIf;
EndProcedure
#EndRegion

View File

@@ -1,4 +1,6 @@
// MIT License
// OneScript: ./OInt/tools/Modules/OPI_SQLQueries.os
// MIT License
// Copyright (c) 2023 Anton Tsitavets
@@ -36,7 +38,7 @@
//@skip-check constructor-function-return-section
// Uncomment if OneScript is executed
// #Use "../../tools"
// #Use "./internal"
#Region Internal

View File

@@ -41,9 +41,6 @@
<subsystems>Subsystem.OPI_Integrations</subsystems>
<commonTemplates>CommonTemplate.OPI_TCPClient</commonTemplates>
<commonTemplates>CommonTemplate.OPI_SQLite</commonTemplates>
<commonModules>CommonModule.OPI_Tools</commonModules>
<commonModules>CommonModule.OPI_Cryptography</commonModules>
<commonModules>CommonModule.OPI_TypeConversion</commonModules>
<commonModules>CommonModule.OPI_Airtable</commonModules>
<commonModules>CommonModule.OPI_Bitrix24</commonModules>
<commonModules>CommonModule.OPI_CDEK</commonModules>
@@ -68,7 +65,10 @@
<commonModules>CommonModule.OPI_YandexID</commonModules>
<commonModules>CommonModule.OPI_YandexMarket</commonModules>
<commonModules>CommonModule.OPI_YandexMetrika</commonModules>
<commonModules>CommonModule.OPI_Tools</commonModules>
<commonModules>CommonModule.OPI_SQLQueries</commonModules>
<commonModules>CommonModule.OPI_Cryptography</commonModules>
<commonModules>CommonModule.OPI_TypeConversion</commonModules>
<commonModules>CommonModule.OPI_Tests</commonModules>
<commonModules>CommonModule.OPI_TestsCLI</commonModules>
<commonModules>CommonModule.OPI_TestDataRetrieval</commonModules>

View File

@@ -2106,9 +2106,9 @@
КонецФункции
Функция ПолучитьОбщийМодуль(Знач Имя)
Модуль = Вычислить(Имя);
Возврат Модуль;
КонецФункции