...
|
...
|
@@ -3,31 +3,31 @@ package bytelib |
|
|
import (
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
|
|
|
"strconv"
|
|
|
)
|
|
|
|
|
|
type RequestCheckoutTablesQuery struct {
|
|
|
OriginalTableId string `json:"originalTableId"`
|
|
|
IsFromOriginalTable bool `json:"isFromOriginalTable"`
|
|
|
TableFileUrl string `json:"tableFileUrl"`
|
|
|
ColumnSchemas []bytecore.ColumnSchema `json:"columnSchemas"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
PageSize int `json:"pageSize"`
|
|
|
QueryParameters map[string]interface{} `json:"queryParameters"`
|
|
|
SortParameters map[string]interface{} `json:"sortParameters"`
|
|
|
OriginalTableId string `json:"originalTableId"`
|
|
|
IsFromOriginalTable bool `json:"isFromOriginalTable"`
|
|
|
TableFileUrl string `json:"tableFileUrl"`
|
|
|
ColumnSchemas []domain.ColumnSchema `json:"columnSchemas"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
PageSize int `json:"pageSize"`
|
|
|
QueryParameters map[string]interface{} `json:"queryParameters"`
|
|
|
SortParameters map[string]interface{} `json:"sortParameters"`
|
|
|
}
|
|
|
|
|
|
type DataCheckoutTables struct {
|
|
|
OriginalTableId string `json:"originalTableId"`
|
|
|
ColumnSchemas []bytecore.ColumnSchema `json:"columnSchemas"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
PageSize int `json:"pageSize"`
|
|
|
DataCount int `json:"dataCount"`
|
|
|
ShowData [][]string `json:"showData"`
|
|
|
AbnormalProccessIndexes [][]interface{} `json:"abnormalProccessIndexes"`
|
|
|
OriginalTableId string `json:"originalTableId"`
|
|
|
ColumnSchemas []domain.ColumnSchema `json:"columnSchemas"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
PageSize int `json:"pageSize"`
|
|
|
DataCount int `json:"dataCount"`
|
|
|
ShowData [][]string `json:"showData"`
|
|
|
AbnormalProccessIndexes [][]interface{} `json:"abnormalProccessIndexes"`
|
|
|
}
|
|
|
|
|
|
func NewRequestCheckoutTablesQuery(param bytecore.ReqLoadDataTable) RequestCheckoutTablesQuery {
|
|
|
func NewRequestCheckoutTablesQuery(param domain.ReqLoadDataTable) RequestCheckoutTablesQuery {
|
|
|
return RequestCheckoutTablesQuery{
|
|
|
OriginalTableId: param.OriginalTableId,
|
|
|
IsFromOriginalTable: param.IsFromOriginalTable,
|
...
|
...
|
@@ -41,18 +41,18 @@ func NewRequestCheckoutTablesQuery(param bytecore.ReqLoadDataTable) RequestCheck |
|
|
}
|
|
|
|
|
|
type RequestCheckoutTablesPreProccess struct {
|
|
|
OriginalTableId string `json:"originalTableId"`
|
|
|
ColumnSchemas []bytecore.ColumnSchema `json:"columnSchemas"`
|
|
|
PreProccessColumnNames []string `json:"preProccessColumnNames"`
|
|
|
PreProccessActionName string `json:"preProccessActionName"`
|
|
|
PreProccessActionParameterValues map[string]string `json:"preProccessActionParameterValues"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
PageSize int `json:"pageSize"`
|
|
|
QueryParameters map[string]interface{} `json:"queryParameters"`
|
|
|
SortParameters map[string]interface{} `json:"sortParameters"`
|
|
|
}
|
|
|
|
|
|
func NewRequestCheckoutTablesPreProccess(param bytecore.ReqEditDataTable) RequestCheckoutTablesPreProccess {
|
|
|
OriginalTableId string `json:"originalTableId"`
|
|
|
ColumnSchemas []domain.ColumnSchema `json:"columnSchemas"`
|
|
|
PreProccessColumnNames []string `json:"preProccessColumnNames"`
|
|
|
PreProccessActionName string `json:"preProccessActionName"`
|
|
|
PreProccessActionParameterValues map[string]string `json:"preProccessActionParameterValues"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
PageSize int `json:"pageSize"`
|
|
|
QueryParameters map[string]interface{} `json:"queryParameters"`
|
|
|
SortParameters map[string]interface{} `json:"sortParameters"`
|
|
|
}
|
|
|
|
|
|
func NewRequestCheckoutTablesPreProccess(param domain.ReqEditDataTable) RequestCheckoutTablesPreProccess {
|
|
|
req := RequestCheckoutTablesPreProccess{
|
|
|
OriginalTableId: fmt.Sprintf("%v", param.FileId),
|
|
|
ColumnSchemas: FieldsToColumnSchemas(param.Fields),
|
...
|
...
|
@@ -79,23 +79,23 @@ type ResponseCheckoutTablesSave struct { |
|
|
CheckoutTableUrl string `json:"checkoutTableUrl"`
|
|
|
}
|
|
|
|
|
|
func FieldsToColumnSchemas(fields []*bytecore.Field) []bytecore.ColumnSchema {
|
|
|
result := make([]bytecore.ColumnSchema, 0)
|
|
|
func FieldsToColumnSchemas(fields []*domain.Field) []domain.ColumnSchema {
|
|
|
result := make([]domain.ColumnSchema, 0)
|
|
|
|
|
|
for _, f := range fields {
|
|
|
result = append(result, bytecore.ColumnSchema{
|
|
|
result = append(result, domain.ColumnSchema{
|
|
|
ColumnName: f.Name,
|
|
|
ColumnType: f.Type,
|
|
|
ColumnType: f.SQLType,
|
|
|
})
|
|
|
}
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
func DomainFieldsToColumnSchemas(fields []*domain.Field) []bytecore.ColumnSchema {
|
|
|
result := make([]bytecore.ColumnSchema, 0)
|
|
|
func DomainFieldsToColumnSchemas(fields []*domain.Field) []domain.ColumnSchema {
|
|
|
result := make([]domain.ColumnSchema, 0)
|
|
|
|
|
|
for _, f := range fields {
|
|
|
result = append(result, bytecore.ColumnSchema{
|
|
|
result = append(result, domain.ColumnSchema{
|
|
|
ColumnName: f.Name,
|
|
|
ColumnType: f.SQLType,
|
|
|
})
|
...
|
...
|
@@ -103,17 +103,18 @@ func DomainFieldsToColumnSchemas(fields []*domain.Field) []bytecore.ColumnSchema |
|
|
return result
|
|
|
}
|
|
|
|
|
|
func ToDataLoadDataTable(data DataCheckoutTables) *bytecore.DataLoadDataTable {
|
|
|
response := &bytecore.DataLoadDataTable{
|
|
|
func ToDataLoadDataTable(data DataCheckoutTables) *domain.DataLoadDataTable {
|
|
|
response := &domain.DataLoadDataTable{
|
|
|
PageNumber: data.PageNumber,
|
|
|
Data: data.ShowData,
|
|
|
Total: data.DataCount,
|
|
|
}
|
|
|
for i, f := range data.ColumnSchemas {
|
|
|
response.Fields = append(response.Fields, &bytecore.Field{
|
|
|
Index: i + 1,
|
|
|
Name: f.ColumnName,
|
|
|
Type: f.ColumnType,
|
|
|
response.Fields = append(response.Fields, &domain.Field{
|
|
|
Index: i + 1,
|
|
|
Name: f.ColumnName,
|
|
|
SQLName: f.ColumnName,
|
|
|
SQLType: f.ColumnType,
|
|
|
})
|
|
|
}
|
|
|
return response
|
...
|
...
|
@@ -121,12 +122,12 @@ func ToDataLoadDataTable(data DataCheckoutTables) *bytecore.DataLoadDataTable { |
|
|
|
|
|
type (
|
|
|
RequestCheckoutTablesGenerateMasterTable struct {
|
|
|
OriginalTableId string `json:"originalTableId"`
|
|
|
CheckoutTableFileUrl string `json:"checkoutTableFileUrl"`
|
|
|
ColumnSchemas []bytecore.ColumnSchema `json:"columnSchemas"`
|
|
|
MasterTableName string `json:"masterTableName"`
|
|
|
FieldSchemas []FieldSchema `json:"fieldSchemas"`
|
|
|
KeyFieldEnNames []string `json:"keyFieldEnNames"`
|
|
|
OriginalTableId string `json:"originalTableId"`
|
|
|
CheckoutTableFileUrl string `json:"checkoutTableFileUrl"`
|
|
|
ColumnSchemas []domain.ColumnSchema `json:"columnSchemas"`
|
|
|
MasterTableName string `json:"masterTableName"`
|
|
|
FieldSchemas []FieldSchema `json:"fieldSchemas"`
|
|
|
KeyFieldEnNames []string `json:"keyFieldEnNames"`
|
|
|
}
|
|
|
DataCheckoutTablesGenerateMasterTable struct {
|
|
|
MasterTableName string `json:"masterTableName"`
|
...
|
...
|
@@ -140,7 +141,7 @@ type ( |
|
|
}
|
|
|
)
|
|
|
|
|
|
func NewRequestCheckoutTablesGenerateMasterTable(param bytecore.ReqGenerateTable) RequestCheckoutTablesGenerateMasterTable {
|
|
|
func NewRequestCheckoutTablesGenerateMasterTable(param domain.ReqGenerateTable) RequestCheckoutTablesGenerateMasterTable {
|
|
|
request := RequestCheckoutTablesGenerateMasterTable{
|
|
|
OriginalTableId: fmt.Sprintf("%v", param.FileId),
|
|
|
CheckoutTableFileUrl: param.FileUrl,
|
...
|
...
|
@@ -160,7 +161,7 @@ func ToFieldSchemas(fields []*domain.Field) []FieldSchema { |
|
|
FieldEnName: f.SQLName,
|
|
|
FieldType: f.SQLType,
|
|
|
FieldDescription: f.Description,
|
|
|
IsAllowNull: false,
|
|
|
IsAllowNull: true,
|
|
|
})
|
|
|
}
|
|
|
return result
|
...
|
...
|
@@ -173,3 +174,116 @@ func ToFieldSchemaEnNames(fields []*domain.Field) []string { |
|
|
}
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
type (
|
|
|
TableAppendRequest struct {
|
|
|
//MasterTableId string `json:"masterTableId"`
|
|
|
OriginalTableId string `json:"originalTableId"`
|
|
|
CheckoutTableFileUrl string `json:"checkoutTableFileUrl"`
|
|
|
DatabaseTableName string `json:"databaseTableName"`
|
|
|
ColumnSchemas []domain.ColumnSchema `json:"columnSchemas"`
|
|
|
FieldSchemas []FieldSchema `json:"fieldSchemas"`
|
|
|
}
|
|
|
|
|
|
MasterTablesAppendRequest struct {
|
|
|
MasterTableId string `json:"masterTableId"`
|
|
|
TableAppendRequest
|
|
|
}
|
|
|
|
|
|
ReplicationTablesAppendRequest struct {
|
|
|
ReplicationTableId string `json:"replicationTableId"`
|
|
|
TableAppendRequest
|
|
|
}
|
|
|
TableAppendResponse struct {
|
|
|
AppendCount int `json:"appendCount"`
|
|
|
}
|
|
|
)
|
|
|
|
|
|
func NewTableAppendRequest(param domain.ReqAppendData) TableAppendRequest {
|
|
|
return TableAppendRequest{
|
|
|
OriginalTableId: intToString(param.FileId),
|
|
|
CheckoutTableFileUrl: param.FileUrl,
|
|
|
DatabaseTableName: param.Table.SQLName,
|
|
|
ColumnSchemas: DomainFieldsToColumnSchemas(param.Table.DataFields),
|
|
|
FieldSchemas: ToFieldSchemas(param.Table.DataFields),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func intToString(i int) string {
|
|
|
return strconv.Itoa(i)
|
|
|
}
|
|
|
|
|
|
type (
|
|
|
CopyTableRequest struct {
|
|
|
DatabaseTableName string `json:"databaseTableName"`
|
|
|
/*
|
|
|
//"master" ->从主表复制 "split" ->从分表复制
|
|
|
//"replication" ->不用传,后面会去掉,现在线上的要先传下
|
|
|
*/
|
|
|
DatabaseTableType string `json:"databaseTableType"`
|
|
|
ReplicationTableName string `json:"replicationTableName"`
|
|
|
FieldSchemas []FieldSchema `json:"fieldSchemas"`
|
|
|
KeyFieldEnNames []string `json:"keyFieldEnNames"`
|
|
|
}
|
|
|
|
|
|
CopyTableResponse struct{}
|
|
|
|
|
|
CopyMasterTableRequest struct {
|
|
|
MasterTableId string `json:"masterTableId"`
|
|
|
CopyTableRequest
|
|
|
}
|
|
|
|
|
|
CopyReplicationTableRequest struct {
|
|
|
ReplicationTableId string `json:"replicationTableId"`
|
|
|
CopyTableRequest
|
|
|
}
|
|
|
)
|
|
|
|
|
|
func NewCopyTableRequest(param domain.ReqCopyTable) CopyTableRequest {
|
|
|
var tableType string
|
|
|
switch param.Table.TableType {
|
|
|
case domain.MainTable.ToString():
|
|
|
tableType = "master"
|
|
|
case domain.SubTable.ToString():
|
|
|
tableType = "split"
|
|
|
case domain.SideTable.ToString():
|
|
|
tableType = "replication"
|
|
|
}
|
|
|
return CopyTableRequest{
|
|
|
DatabaseTableName: param.Table.SQLName,
|
|
|
DatabaseTableType: tableType,
|
|
|
ReplicationTableName: param.CopyToTable.SQLName,
|
|
|
FieldSchemas: ToFieldSchemas(param.CopyToTable.DataFields),
|
|
|
KeyFieldEnNames: []string{param.Table.PK.SQLName},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
type (
|
|
|
SplitTableRequest struct {
|
|
|
DatabaseTableName string `json:"databaseTableName"`
|
|
|
SplitTableName string `json:"splitTableName"`
|
|
|
DatabaseTableFieldSchemas []FieldSchema `json:"databaseTableFieldSchemas"`
|
|
|
SplitTableFieldSchemas []FieldSchema `json:"splitTableFieldSchemas"`
|
|
|
}
|
|
|
|
|
|
SplitTableResponse struct{}
|
|
|
|
|
|
SplitMasterTableRequest struct {
|
|
|
MasterTableId string `json:"masterTableId"`
|
|
|
SplitTableRequest
|
|
|
}
|
|
|
|
|
|
SplitReplicationTableRequest struct {
|
|
|
ReplicationTableId string `json:"replicationTableId"`
|
|
|
SplitTableRequest
|
|
|
}
|
|
|
)
|
|
|
|
|
|
func NewSplitTableRequest(param domain.ReqSplitTable) SplitTableRequest {
|
|
|
return SplitTableRequest{
|
|
|
DatabaseTableName: param.FromTable.SQLName,
|
|
|
SplitTableName: param.ToSubTable.SQLName,
|
|
|
DatabaseTableFieldSchemas: ToFieldSchemas(param.FromTable.DataFields),
|
|
|
SplitTableFieldSchemas: ToFieldSchemas(param.ToSubTable.DataFields),
|
|
|
}
|
|
|
} |
...
|
...
|
|