作者 yangfu

refactor: optimize core

... ... @@ -159,11 +159,11 @@
- [ ] 表格编辑 1
- [ ] 保存校验文件 (文件地址) 1
- [ ] 生成主表 1
- [ ] 表复制 (副表)
- [ ] 表复制 (副表)1
- [ ] 追加数据 (主表、副表)
- [ ] 表删除 (主表、副表)~~、分表~~
- [x] ~~表拆分~~
- [x] ~~更新表结构(分表)~~
- [ ] 表拆分 1
- [ ] 更新表结构(分表)1
- [ ] 编辑、添加、删除表数据(副表) 1
- [ ] 取消校验
... ...
POSTGRESQL_DB_NAME = allied_creation_dev
POSTGRESQL_DB_NAME = allied_creation_test
POSTGRESQL_HOST = 114.55.200.59
POSTGRESQL_PORT = 31543
POSTGRESQL_USER = postgres
... ... @@ -9,7 +9,7 @@ HTTP_PORT = 8081
ENABLE_KAFKA_LOG11 = true
HTTPS_PORT = 8143
ALLIED_CREATION_USER_HOST = http://allied-creation-user-dev.fjmaimaimai.com
BYTE_CORE_HOST = http://220.250.41.79:8303
BYTE_CORE_HOST = http://47.97.5.102:8303
STARROCKS_DB_NAME = character_library
STARROCKS_USER = root
... ...
... ... @@ -4,7 +4,6 @@ import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService"
)
... ... @@ -58,6 +57,6 @@ func CreateTableEditDataService(transactionContext application.TransactionContex
}
// 字库核心
func CreateByteCoreService(transactionContext application.TransactionContext) (bytecore.ByteLibService, error) {
func CreateByteCoreService(transactionContext application.TransactionContext) (domain.ByteLibService, error) {
return domainService.ByteCore, nil
}
... ...
... ... @@ -9,7 +9,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/dto"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/query"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
"path/filepath"
... ... @@ -295,7 +294,7 @@ func (fileService *FileService) CancelVerifyingFile(ctx *domain.Context, cmd *co
}
byteCore, _ := factory.CreateByteCoreService(transactionContext)
_, err = byteCore.CancelFile(bytecore.ReqCancelFile{})
_, err = byteCore.CancelFile(domain.ReqCancelFile{})
if err != nil {
return nil, factory.FastError(err)
}
... ...
... ... @@ -31,8 +31,9 @@ type SearchLogCommand struct {
BeginTime time.Time `cname:"开始时间" json:"beginTime"`
// 结束时间
EndTime time.Time `cname:"结束时间" json:"endTime"`
Context *domain.Context
// 按log_id 排序
SortByLogId string `json:"sortByLogId"`
Context *domain.Context
}
func (cmd *SearchLogCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -19,18 +19,18 @@ type TableDetailDto struct {
Fields []*domain.Field `json:"fields"`
}
func (d *TableDetailDto) Load(m *domain.Table, mainTable *domain.Table) {
d.TableId = m.TableId
d.TableType = m.TableType
d.Name = m.Name
d.ParentId = m.ParentId
if m.TableType == domain.MainTable.ToString() || m.TableType == domain.SideTable.ToString() {
d.MainTableFields = m.Fields(false)
func (d *TableDetailDto) Load(table *domain.Table, mainTable *domain.Table) {
d.TableId = table.TableId
d.TableType = table.TableType
d.Name = table.Name
d.ParentId = table.ParentId
if table.TableType == domain.MainTable.ToString() || table.TableType == domain.SideTable.ToString() {
d.MainTableFields = table.Fields(false)
} else if mainTable != nil {
d.MainTableFields = mainTable.Fields(false)
}
d.Fields = m.Fields(false)
d.ManualFields = m.ManualFields
d.Fields = table.Fields(false)
d.ManualFields = table.ManualFields
if len(d.ManualFields) == 0 {
d.ManualFields = make([]*domain.Field, 0)
}
... ...
... ... @@ -12,7 +12,10 @@ type TablePreviewDto struct {
// 名称
Name string `json:"name"`
// 数据
*domain.DataTable
//*domain.DataTable
Fields []*domain.Field `json:"fields"`
Data interface{} `json:"grid"`
//Total int64 `json:"total"`
}
func (d *TablePreviewDto) Load(m *domain.Table, dataTable *domain.DataTable, objectType string) *TablePreviewDto {
... ... @@ -20,12 +23,8 @@ func (d *TablePreviewDto) Load(m *domain.Table, dataTable *domain.DataTable, obj
d.TableType = m.TableType
d.ObjectType = objectType
d.Name = m.Name
d.DataTable = &domain.DataTable{}
d.Fields = dataTable.MatchFields(m.Fields(true))
d.Data = dataTable.Data
d.Total = dataTable.Total
if len(d.Data) == 0 {
d.Data = make([][]string, 0)
}
d.Data = domain.GripData(domain.ToFieldData(m.Fields(true), dataTable.Data, false), dataTable.Total)
//d.Total = dataTable.Total
return d
}
... ...
package bytecore
import "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
package domain
type ByteLibService interface {
LoadDataTable(param ReqLoadDataTable) (*DataLoadDataTable, error)
EditTable(param ReqEditDataTable) (*DataEditDataTable, error)
SaveTable(param ReqSaveTable) (*DataSaveTable, error)
GenerateTable(ctx *domain.Context, param ReqGenerateTable) (*DataGenerateTable, error)
GenerateTable(ctx *Context, param ReqGenerateTable) (*DataGenerateTable, error)
CopyTable(param ReqCopyTable) (*DataCopyTable, error)
AppendData(param ReqAppendData) (*DataAppendData, error)
SplitTable(param ReqSplitTable) (*DataSplitTable, error)
DeleteTable(param ReqDeleteTable) (*DataDeleteTable, error)
CancelFile(param ReqCancelFile) (*DataCancelFile, error)
EditTableData(param ReqEditTableData) (*DataEditTableData, error)
... ... @@ -20,7 +19,7 @@ type (
FileName string `json:"file_name"`
Url string `json:"url"`
Ext string `json:"ext"`
domain.Where
Where
OriginalTableId string `json:"originalTableId"`
IsFromOriginalTable bool `json:"isFromOriginalTable"`
TableFileUrl string `json:"tableFileUrl"`
... ... @@ -42,26 +41,46 @@ type (
InValidCells []InValidCell `json:"inValidCells"`
}
Field struct {
// 索引序号
Index int `json:"index"`
// 名称
Name string `json:"name"`
// 对应数据库类型
Type string `json:"sqlType"`
}
//Field struct {
// // 索引序号
// Index int `json:"index"`
// // 名称
// Name string `json:"name"`
// // 对应数据库类型
// Type string `json:"sqlType"`
//}
InValidCell struct {
X int `json:"x"`
Y int `json:"y"`
Error string `json:"error"`
Col string `json:"col"`
Index int `json:"index"`
Err string `json:"err"`
}
)
func NewInValidCells(fields Fields, mapData []map[string]string) []InValidCell {
inValidCells := make([]InValidCell, 0)
mapField := fields.ToMap()
for index, m := range mapData {
for k, v := range m {
if field, ok := mapField[k]; ok && len(v) > 0 {
_, err := ValueToType(v, field.SQLType)
if err != nil {
inValidCells = append(inValidCells, InValidCell{
Col: field.Name,
Index: index,
Err: err.Error(),
})
}
}
}
}
return inValidCells
}
// https://github.com/go-gota/gota 类似pandas的数据处理包
// https://github.com/gonum/gonum
func (table DataLoadDataTable) Filter(where domain.Where) *DataLoadDataTable {
func (table DataLoadDataTable) Filter(where Where) *DataLoadDataTable {
begin := (where.PageNumber - 1) * where.PageSize
if begin < 0 {
begin = 0
... ... @@ -115,7 +134,7 @@ type (
ReqGenerateTable struct {
FileId int
FileUrl string
Table *domain.Table
Table *Table
}
DataGenerateTable struct {
... ... @@ -125,6 +144,8 @@ type (
type (
ReqCopyTable struct {
Table *Table
CopyToTable *Table
}
DataCopyTable struct {
... ... @@ -133,9 +154,13 @@ type (
type (
ReqAppendData struct {
FileId int
FileUrl string
Table *Table
}
DataAppendData struct {
AppendCount int `json:"appendCount"`
}
)
... ... @@ -148,6 +173,16 @@ type (
)
type (
ReqSplitTable struct {
FromTable *Table
ToSubTable *Table
}
DataSplitTable struct {
}
)
type (
ReqCancelFile struct {
}
... ... @@ -168,14 +203,35 @@ type ColumnSchema struct {
ColumnType string `json:"columnType"`
}
func ToFields(fields []*domain.Field) []*Field {
func ToFields(fields []*Field) []*Field {
result := make([]*Field, 0)
for _, f := range fields {
result = append(result, &Field{
Index: f.Index,
Name: f.Name,
Type: f.SQLType,
Index: f.Index,
Name: f.Name,
SQLType: f.SQLType,
})
}
return result
}
//func ToFieldData(fields []*Field, data [][]string, byteName bool) []map[string]string {
// var result = make([]map[string]string, 0)
// var key string
// for _, d := range data {
// var item = make(map[string]string)
// for j, f := range fields {
// key = f.Name
// if byteName {
// key = f.Name
// }
// if len(d) >= j {
// item[key] = d[j]
// } else {
// item[key] = ""
// }
// }
// result = append(result, item)
// }
// return result
//}
... ...
... ... @@ -152,16 +152,53 @@ func ValueToType(value string, sqlType string) (interface{}, error) {
toTypeVal = value
case Int.ToString():
toTypeVal, err = numberString.Int()
if err != nil {
err = fmt.Errorf("[%v]不是有效的数值类型", value)
}
case Float.ToString():
toTypeVal, err = numberString.Float64()
err = fmt.Errorf("[%v]不是有效的浮点数类型", value)
case Date.ToString():
toTypeVal, err = xtime.Parse(value)
err = fmt.Errorf("[%v]不是有效的日期类型", value)
return nil, nil
case Datetime.ToString():
toTypeVal, err = xtime.Parse(value)
err = fmt.Errorf("[%v]不是有效的时间类型", value)
return nil, nil
default:
return nil, fmt.Errorf("unknow sql type :%v", sqlType)
}
return toTypeVal, err
}
func ToFieldData(fields []*Field, data [][]string, byName bool) []map[string]string {
var result = make([]map[string]string, 0)
var key string
for _, d := range data {
var item = make(map[string]string)
for j, f := range fields {
key = f.SQLName
if byName {
key = f.Name
}
if len(d) >= j {
item[key] = d[j]
} else {
item[key] = ""
}
}
result = append(result, item)
}
return result
}
func GripData(data []map[string]string, total int64) map[string]interface{} {
if len(data) == 0 {
data = make([]map[string]string, 0)
}
return map[string]interface{}{
"list": data,
"total": total,
}
}
... ...
... ... @@ -51,6 +51,7 @@ func (file *File) UpdateFileUrl(url string) {
if url == file.FileInfo.Url {
return
}
file.FileInfo.Ext = filepath.Ext(url)
file.FileInfo.Url = url
}
... ...
... ... @@ -56,9 +56,13 @@ func (table *Table) Identify() interface{} {
return table.TableId
}
func (table *Table) TableIdString() string {
return fmt.Sprintf("%v", table.TableId)
}
func (table *Table) WithContext(ctx *Context) *Table {
rand.Seed(time.Now().Unix())
table.SQLName = fmt.Sprintf("%v_t%v_c%v", table.SQLName, rand.Intn(10000), ctx.CompanyId)
table.SQLName = fmt.Sprintf("%v_t%v_c%v", table.SQLName, rand.Intn(1000000), ctx.CompanyId)
table.Context = ctx
return table
}
... ...
... ... @@ -27,6 +27,7 @@ type BaseServiceGateway struct {
ReadWriteTimeout time.Duration
host string
Interceptor func(msg string)
ServiceName string
}
type Request struct {
... ... @@ -58,7 +59,7 @@ func (gateway BaseServiceGateway) CreateRequest(url string, method string) *http
func (gateway BaseServiceGateway) GetResponseData(result Response, data interface{}) error {
err := json.Unmarshal(result.Data, data)
if err != nil {
return NewErrCodeMsg(JsonUnMarshError, err.Error())
return NewErrCodeMsg(gateway.ServiceName, JsonUnMarshError, err.Error())
}
return nil
}
... ... @@ -108,7 +109,7 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{
return err
}
if result.Code != 0 && len(result.Msg) > 0 {
return NewErrCodeMsg(result.Code, result.Msg)
return NewErrCodeMsg(gateway.ServiceName, result.Code, result.Msg)
}
return gateway.GetResponseData(result, val)
}
... ...
... ... @@ -3,7 +3,7 @@ package bytelib
import (
"fmt"
"github.com/beego/beego/v2/core/logs"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api"
"time"
)
... ... @@ -11,7 +11,6 @@ import (
// ApiByteLib 字库底层接口
type ApiByteLib struct {
api.BaseServiceGateway
baseUrL string
}
func NewApiByteLib(host string) *ApiByteLib {
... ... @@ -22,6 +21,7 @@ func NewApiByteLib(host string) *ApiByteLib {
//log.Logger.Info(msg)
logs.Debug(msg)
}
gt.ServiceName = "【字库核心】"
return &ApiByteLib{
BaseServiceGateway: gt,
}
... ... @@ -29,7 +29,7 @@ func NewApiByteLib(host string) *ApiByteLib {
// 加载数据
func (gateway ApiByteLib) LoadDataTable(param bytecore.ReqLoadDataTable) (*bytecore.DataLoadDataTable, error) {
func (gateway ApiByteLib) LoadDataTable(param domain.ReqLoadDataTable) (*domain.DataLoadDataTable, error) {
url := gateway.Host() + "/checkout-tables/query"
method := "post"
var data DataCheckoutTables
... ... @@ -44,7 +44,7 @@ func (gateway ApiByteLib) LoadDataTable(param bytecore.ReqLoadDataTable) (*bytec
}
// EditTable 编辑表格
func (gateway ApiByteLib) EditTable(param bytecore.ReqEditDataTable) (*bytecore.DataEditDataTable, error) {
func (gateway ApiByteLib) EditTable(param domain.ReqEditDataTable) (*domain.DataEditDataTable, error) {
url := gateway.Host() + "/checkout-tables/pre-proccess"
method := "post"
var data DataCheckoutTables
... ... @@ -55,13 +55,13 @@ func (gateway ApiByteLib) EditTable(param bytecore.ReqEditDataTable) (*bytecore.
}
response := ToDataLoadDataTable(data)
return &bytecore.DataEditDataTable{
return &domain.DataEditDataTable{
DataLoadDataTable: *response,
}, nil
}
// SaveTable 保存校验文件 (文件地址)
func (gateway ApiByteLib) SaveTable(param bytecore.ReqSaveTable) (*bytecore.DataSaveTable, error) {
func (gateway ApiByteLib) SaveTable(param domain.ReqSaveTable) (*domain.DataSaveTable, error) {
url := gateway.Host() + "/checkout-tables/save"
method := "post"
var data ResponseCheckoutTablesSave
... ... @@ -72,14 +72,14 @@ func (gateway ApiByteLib) SaveTable(param bytecore.ReqSaveTable) (*bytecore.Data
if err != nil {
return nil, err
}
var response = &bytecore.DataSaveTable{
var response = &domain.DataSaveTable{
Url: data.CheckoutTableUrl,
}
return response, nil
}
// GenerateTable 生成主表
func (gateway ApiByteLib) GenerateTable(param bytecore.ReqGenerateTable) (*bytecore.DataGenerateTable, error) {
func (gateway ApiByteLib) GenerateTable(param domain.ReqGenerateTable) (*domain.DataGenerateTable, error) {
url := gateway.Host() + "/checkout-tables/generate-master-table"
method := "post"
var data DataCheckoutTablesGenerateMasterTable
... ... @@ -88,41 +88,83 @@ func (gateway ApiByteLib) GenerateTable(param bytecore.ReqGenerateTable) (*bytec
if err != nil {
return nil, err
}
var response = bytecore.DataGenerateTable{
var response = domain.DataGenerateTable{
TableName: data.MasterTableName,
}
return &response, nil
}
// CopyTable 表复制
func (gateway ApiByteLib) CopyTable(param bytecore.ReqCopyTable) (*bytecore.DataCopyTable, error) {
url := gateway.Host() + "/table/copy"
func (gateway ApiByteLib) CopyTable(param domain.ReqCopyTable) (*domain.DataCopyTable, error) {
var url string
method := "post"
var data bytecore.DataCopyTable
err := gateway.FastDoRequest(url, method, param, &data)
var data TableAppendResponse
var request interface{}
var copyRequest = NewCopyTableRequest(param)
switch param.Table.TableType {
case domain.MainTable.ToString():
request = CopyMasterTableRequest{
MasterTableId: intToString(param.Table.TableId),
CopyTableRequest: copyRequest,
}
url = gateway.Host() + "/master-tables/copy"
case domain.SubTable.ToString():
request = CopyMasterTableRequest{
MasterTableId: intToString(param.Table.TableId),
CopyTableRequest: copyRequest,
}
url = gateway.Host() + "/master-tables/copy"
case domain.SideTable.ToString():
request = CopyReplicationTableRequest{
ReplicationTableId: intToString(param.Table.TableId),
CopyTableRequest: copyRequest,
}
url = gateway.Host() + "/replication-tables/copy"
}
err := gateway.FastDoRequest(url, method, request, &data)
if err != nil {
return nil, err
}
return &data, nil
return &domain.DataCopyTable{}, nil
}
// AppendData 追加数据
func (gateway ApiByteLib) AppendData(param bytecore.ReqAppendData) (*bytecore.DataAppendData, error) {
url := gateway.Host() + "/table/append"
func (gateway ApiByteLib) AppendData(param domain.ReqAppendData) (*domain.DataAppendData, error) {
var url string
method := "post"
var data bytecore.DataAppendData
err := gateway.FastDoRequest(url, method, param, &data)
var data TableAppendResponse
var request interface{}
var appendRequest = NewTableAppendRequest(param)
switch param.Table.TableType {
case domain.MainTable.ToString():
request = MasterTablesAppendRequest{
MasterTableId: intToString(param.Table.TableId),
TableAppendRequest: appendRequest,
}
url = gateway.Host() + "/master-tables/append"
case domain.SideTable.ToString():
request = ReplicationTablesAppendRequest{
ReplicationTableId: intToString(param.Table.TableId),
TableAppendRequest: appendRequest,
}
url = gateway.Host() + "/replication-tables/append"
}
err := gateway.FastDoRequest(url, method, request, &data)
if err != nil {
return nil, err
}
return &data, nil
return &domain.DataAppendData{
AppendCount: data.AppendCount,
}, nil
}
// DeleteTable 表删除 (主表、副表、分表)
func (gateway ApiByteLib) DeleteTable(param bytecore.ReqDeleteTable) (*bytecore.DataDeleteTable, error) {
func (gateway ApiByteLib) DeleteTable(param domain.ReqDeleteTable) (*domain.DataDeleteTable, error) {
url := gateway.Host() + "/table/delete"
method := "post"
var data bytecore.DataDeleteTable
var data domain.DataDeleteTable
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
... ... @@ -131,10 +173,10 @@ func (gateway ApiByteLib) DeleteTable(param bytecore.ReqDeleteTable) (*bytecore.
}
// CancelFile 表删除 (主表、副表、分表)
func (gateway ApiByteLib) CancelFile(param bytecore.ReqCancelFile) (*bytecore.DataCancelFile, error) {
func (gateway ApiByteLib) CancelFile(param domain.ReqCancelFile) (*domain.DataCancelFile, error) {
url := gateway.Host() + "/table/cancel-file"
method := "post"
var data bytecore.DataCancelFile
var data domain.DataCancelFile
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
... ... @@ -143,14 +185,41 @@ func (gateway ApiByteLib) CancelFile(param bytecore.ReqCancelFile) (*bytecore.Da
}
// 表拆分
func (gateway ApiByteLib) SplitTable(param domain.ReqSplitTable) (*domain.DataSplitTable, error) {
var url string
method := "post"
var data TableAppendResponse
var request interface{}
var splitRequest = NewSplitTableRequest(param)
switch param.FromTable.TableType {
case domain.MainTable.ToString():
request = SplitMasterTableRequest{
MasterTableId: intToString(param.FromTable.TableId),
SplitTableRequest: splitRequest,
}
url = gateway.Host() + "/master-tables/split"
case domain.SideTable.ToString():
request = SplitReplicationTableRequest{
ReplicationTableId: intToString(param.FromTable.TableId),
SplitTableRequest: splitRequest,
}
url = gateway.Host() + "/replication-tables/split"
}
err := gateway.FastDoRequest(url, method, request, &data)
if err != nil {
return nil, err
}
return &domain.DataSplitTable{}, nil
}
// 更新表结构(分表)
// EditTableData 编辑、添加、删除表数据(副表)
func (gateway ApiByteLib) EditTableData(param bytecore.ReqEditTableData) (*bytecore.DataEditTableData, error) {
func (gateway ApiByteLib) EditTableData(param domain.ReqEditTableData) (*domain.DataEditTableData, error) {
url := gateway.Host() + "/table/cancel-file"
method := "post"
var data bytecore.DataEditTableData
var data domain.DataEditTableData
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
... ...
package bytelib
import "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
)
type ApiByteLibService interface {
EditTable(param bytecore.ReqEditDataTable) (*bytecore.DataEditDataTable, error)
EditTable(param domain.ReqEditDataTable) (*domain.DataEditDataTable, error)
}
... ...
... ... @@ -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),
}
}
... ...
... ... @@ -7,17 +7,19 @@ var (
)
type ErrCodeMsg struct {
Code int
Msg string
Service string
Code int
Msg string
}
func (e ErrCodeMsg) Error() string {
return fmt.Sprintf("错误码:%v 错误信息:%v", e.Code, e.Msg)
return fmt.Sprintf("%v 错误码:%v;错误信息:%v", e.Service, e.Code, e.Msg)
}
func NewErrCodeMsg(code int, msg string) ErrCodeMsg {
func NewErrCodeMsg(service string, code int, msg string) ErrCodeMsg {
return ErrCodeMsg{
Code: code,
Msg: msg,
Code: code,
Msg: msg,
Service: service,
}
}
... ...
... ... @@ -5,20 +5,19 @@ import (
"github.com/beego/beego/v2/client/httplib"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/bytelib"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/excel"
)
type ByteCoreService struct {
TempDataTable map[int]*bytecore.DataLoadDataTable
TempDataTable map[int]*domain.DataLoadDataTable
}
var ByteCore bytecore.ByteLibService = &WrapByteCoreService{} //&ByteCoreService{}
var ByteCore domain.ByteLibService = &WrapByteCoreService{} //&ByteCoreService{}
var _ bytecore.ByteLibService = (*ByteCoreService)(nil)
var _ domain.ByteLibService = (*ByteCoreService)(nil)
func (ptr *ByteCoreService) LoadDataTable(param bytecore.ReqLoadDataTable) (*bytecore.DataLoadDataTable, error) {
func (ptr *ByteCoreService) LoadDataTable(param domain.ReqLoadDataTable) (*domain.DataLoadDataTable, error) {
if v, ok := ptr.load(param.FileId); ok {
return v.Filter(param.Where), nil
}
... ... @@ -39,89 +38,94 @@ func (ptr *ByteCoreService) LoadDataTable(param bytecore.ReqLoadDataTable) (*byt
}
cols := importer.Reader().Header().Columns
var response = &bytecore.DataLoadDataTable{
var response = &domain.DataLoadDataTable{
FileId: param.FileId,
Fields: columnToField(cols),
Data: data,
Total: len(data),
PageNumber: param.PageNumber,
InValidCells: make([]bytecore.InValidCell, 0),
InValidCells: make([]domain.InValidCell, 0),
}
ptr.save(param.FileId, response)
return response.Filter(param.Where), nil
}
func (ptr *ByteCoreService) EditTable(param bytecore.ReqEditDataTable) (*bytecore.DataEditDataTable, error) {
func (ptr *ByteCoreService) EditTable(param domain.ReqEditDataTable) (*domain.DataEditDataTable, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.EditTable(param)
}
func (ptr *ByteCoreService) save(fileId int, dataTable *bytecore.DataLoadDataTable) {
func (ptr *ByteCoreService) save(fileId int, dataTable *domain.DataLoadDataTable) {
// Once
if ptr.TempDataTable == nil {
ptr.TempDataTable = make(map[int]*bytecore.DataLoadDataTable)
ptr.TempDataTable = make(map[int]*domain.DataLoadDataTable)
}
ptr.TempDataTable[fileId] = dataTable
}
func (ptr *ByteCoreService) load(fileId int) (*bytecore.DataLoadDataTable, bool) {
func (ptr *ByteCoreService) load(fileId int) (*domain.DataLoadDataTable, bool) {
v, ok := ptr.TempDataTable[fileId]
return v, ok
}
func columnToField(cols []string) []*bytecore.Field {
var fields []*bytecore.Field
func columnToField(cols []string) []*domain.Field {
var fields []*domain.Field
for i, col := range cols {
fields = append(fields, &bytecore.Field{
Name: col,
Index: i + 1,
Type: "string",
fields = append(fields, &domain.Field{
Name: col,
Index: i + 1,
SQLType: domain.String.ToString(),
})
}
return fields
}
func (ptr *ByteCoreService) SaveTable(param bytecore.ReqSaveTable) (*bytecore.DataSaveTable, error) {
func (ptr *ByteCoreService) SaveTable(param domain.ReqSaveTable) (*domain.DataSaveTable, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.SaveTable(param)
}
func (ptr *ByteCoreService) GenerateTable(ctx *domain.Context, param bytecore.ReqGenerateTable) (*bytecore.DataGenerateTable, error) {
func (ptr *ByteCoreService) GenerateTable(ctx *domain.Context, param domain.ReqGenerateTable) (*domain.DataGenerateTable, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.GenerateTable(param)
}
func (ptr *ByteCoreService) CopyTable(param bytecore.ReqCopyTable) (*bytecore.DataCopyTable, error) {
func (ptr *ByteCoreService) CopyTable(param domain.ReqCopyTable) (*domain.DataCopyTable, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.CopyTable(param)
}
func (ptr *ByteCoreService) AppendData(param bytecore.ReqAppendData) (*bytecore.DataAppendData, error) {
func (ptr *ByteCoreService) AppendData(param domain.ReqAppendData) (*domain.DataAppendData, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.AppendData(param)
}
func (ptr *ByteCoreService) DeleteTable(param bytecore.ReqDeleteTable) (*bytecore.DataDeleteTable, error) {
func (ptr *ByteCoreService) DeleteTable(param domain.ReqDeleteTable) (*domain.DataDeleteTable, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.DeleteTable(param)
}
func (ptr *ByteCoreService) CancelFile(param bytecore.ReqCancelFile) (*bytecore.DataCancelFile, error) {
func (ptr *ByteCoreService) CancelFile(param domain.ReqCancelFile) (*domain.DataCancelFile, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.CancelFile(param)
}
func (ptr *ByteCoreService) EditTableData(param bytecore.ReqEditTableData) (*bytecore.DataEditTableData, error) {
func (ptr *ByteCoreService) EditTableData(param domain.ReqEditTableData) (*domain.DataEditTableData, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.EditTableData(param)
}
func (ptr *ByteCoreService) SplitTable(param domain.ReqSplitTable) (*domain.DataSplitTable, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.SplitTable(param)
}
//////////////
// 字库核心
//////////////
func CreateByteCoreService() (bytecore.ByteLibService, error) {
func CreateByteCoreService() (domain.ByteLibService, error) {
return ByteCore, nil
}
... ... @@ -129,11 +133,11 @@ type WrapByteCoreService struct {
ByteCoreService
}
func (ptr *WrapByteCoreService) LoadDataTable(param bytecore.ReqLoadDataTable) (*bytecore.DataLoadDataTable, error) {
func (ptr *WrapByteCoreService) LoadDataTable(param domain.ReqLoadDataTable) (*domain.DataLoadDataTable, error) {
apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST)
return apiByteLib.LoadDataTable(param)
}
func (ptr *WrapByteCoreService) GenerateTable(ctx *domain.Context, param bytecore.ReqGenerateTable) (*bytecore.DataGenerateTable, error) {
return nil, nil
}
//func (ptr *WrapByteCoreService) GenerateTable(ctx *domain.Context, param bytecore.ReqGenerateTable) (*bytecore.DataGenerateTable, error) {
// return nil, nil
//}
... ...
... ... @@ -4,7 +4,6 @@ import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository"
)
... ... @@ -34,12 +33,12 @@ func (ptr *EditDataTableService) Edit(ctx *domain.Context, req domain.EditTableR
}
// 通知底层进行文件表编辑
response, err := ByteCore.EditTable(bytecore.ReqEditDataTable{
response, err := ByteCore.EditTable(domain.ReqEditDataTable{
FileId: file.FileId,
PageNumber: req.Where.PageNumber,
PageSize: req.Where.PageSize,
Fields: bytecore.ToFields(req.Fields),
ProcessFields: bytecore.ToFields(req.ProcessFields),
Fields: domain.ToFields(req.Fields),
ProcessFields: domain.ToFields(req.ProcessFields),
Action: req.Action,
Params: req.Params,
})
... ...
... ... @@ -6,7 +6,6 @@ import (
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
... ... @@ -32,7 +31,7 @@ func (ptr *FlushDataTableService) Flush(ctx *domain.Context, fileId int, table *
// New Table
table = NewTable(domain.ExcelTable, file.FileInfo.Name, table.DataFields, table.RowCount).WithContext(ctx)
// 通知底层保存、进行回调
response, _ := ByteCore.SaveTable(bytecore.ReqSaveTable{FileId: fileId})
response, _ := ByteCore.SaveTable(domain.ReqSaveTable{FileId: fileId})
if err != nil {
return nil, err
}
... ...
... ... @@ -4,7 +4,6 @@ import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository"
)
... ... @@ -44,7 +43,7 @@ func (ptr *GenerateMainTableService) GenerateTable(ctx *domain.Context, fileId i
return nil, err
}
if _, err = ByteCore.GenerateTable(ctx, bytecore.ReqGenerateTable{FileId: fileId, FileUrl: file.FileInfo.Url, Table: table}); err != nil {
if _, err = ByteCore.GenerateTable(ctx, domain.ReqGenerateTable{FileId: fileId, FileUrl: file.FileInfo.Url, Table: mainTable}); err != nil {
return nil, err
}
return struct{}{}, nil
... ...
... ... @@ -4,7 +4,6 @@ import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/bytelib"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository"
)
... ... @@ -37,7 +36,7 @@ func (ptr *PreviewDataTableService) Preview(ctx *domain.Context, fileId int, fie
// Load Data From Excel(python api)
byteCore, _ := CreateByteCoreService()
response, err := byteCore.LoadDataTable(bytecore.ReqLoadDataTable{
response, err := byteCore.LoadDataTable(domain.ReqLoadDataTable{
FileId: file.FileId,
FileName: file.FileInfo.Name,
Url: file.FileInfo.Url,
... ... @@ -54,10 +53,31 @@ func (ptr *PreviewDataTableService) Preview(ctx *domain.Context, fileId int, fie
if err != nil {
return nil, err
}
response.ObjectType = domain.ObjectFile
response.FileId = file.FileId
response.TableType = domain.ExcelTable.ToString()
return response, nil
var responseDto = &FilePreviewDto{}
responseDto.Load(file.FileId, response)
return responseDto, nil
}
type FilePreviewDto struct {
ObjectId int `json:"objectId"`
ObjectType string `json:"objectType"`
TableType string `json:"tableType"`
Fields []*domain.Field `json:"fields"`
Data interface{} `json:"grid"`
PageNumber int `json:"pageNumber"`
InValidCells []domain.InValidCell `json:"inValidCells"`
}
func (d *FilePreviewDto) Load(fileId int, m *domain.DataLoadDataTable) {
d.ObjectId = fileId
d.ObjectType = domain.ObjectFile
d.TableType = domain.ExcelTable.ToString()
d.Fields = m.Fields
mapData := domain.ToFieldData(m.Fields, m.Data, true)
d.Data = domain.GripData(mapData, int64(m.Total))
d.PageNumber = m.PageNumber
d.InValidCells = domain.NewInValidCells(m.Fields, mapData)
}
func (ptr *PreviewDataTableService) GetFileId() int {
... ...
... ... @@ -154,6 +154,7 @@ type SubTableEditLog struct {
func (l *SubTableEditLog) Content() string {
var msg string
msg = "分表编辑 "
msg += l.makeMsg("删除字段", l.Delete)
msg += l.makeMsg("保留字段", l.Reserve)
msg += l.makeMsg("添加字段", l.Add)
... ...
... ... @@ -45,7 +45,7 @@ func (ptr *AddTableStructService) AddTableStruct(ctx *domain.Context, parentTabl
table.DataFields = dataFields
table.ManualFields = manualFields
table.ParentId = parentTableId
table.SQLName = mainTable.SQLName // 主表名跟分表名相同
//table.SQLName = mainTable.SQLName // 主表名跟分表名相同
reserves, deletes, adds := domain.FieldsChange(table.Fields(false), fields)
if err = domain.ValidFields(fields); err != nil {
... ... @@ -71,5 +71,8 @@ func (ptr *AddTableStructService) AddTableStruct(ctx *domain.Context, parentTabl
}
// 通知底层
if _, err = ByteCore.SplitTable(domain.ReqSplitTable{FromTable: mainTable, ToSubTable: table}); err != nil {
return nil, err
}
return table, nil
}
... ...
... ... @@ -59,7 +59,9 @@ func (ptr *AppendDataToTableService) AppendData(ctx *domain.Context, fileId int,
}
// 通知底层进行追加数据
if _, err = ByteCore.AppendData(domain.ReqAppendData{Table: table, FileId: fileId, FileUrl: file.FileInfo.Url}); err != nil {
return nil, err
}
return map[string]interface{}{
"result": fmt.Sprintf("源数据%v条,成功追加%v条;", excelTable.RowCount, excelTable.RowCount),
}, nil
... ...
... ... @@ -51,5 +51,8 @@ func (ptr *CopyDataTableService) CopyTable(ctx *domain.Context, tableId int, tab
}
// 通知底层
if _, err = ByteCore.CopyTable(domain.ReqCopyTable{Table: table, CopyToTable: sideTable}); err != nil {
return nil, err
}
return nil, nil
}
... ...
... ... @@ -68,11 +68,14 @@ func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tabl
}
// 通知底层
//if _, err = ByteCore.SplitTable(domain.ReqSplitTable{FromTable: mainTable, ToSubTable: table}); err != nil {
// return nil, err
//}
return struct{}{}, nil
}
func MappingFields(table *domain.Table, fields []*domain.Field) []*domain.Field {
tableFields := table.Fields(false)
func MappingFields(mainTable *domain.Table, fields []*domain.Field) []*domain.Field {
tableFields := mainTable.Fields(false)
tableFieldsMap := (domain.Fields)(tableFields).ToMap()
for i := range fields {
f := fields[i]
... ... @@ -85,8 +88,8 @@ func MappingFields(table *domain.Table, fields []*domain.Field) []*domain.Field
fields[i].Flag = v.Flag
} else {
if f.Flag == domain.ManualField && f.Index == 0 {
table.DataFieldIndex += 1
fields[i] = DataField(f.Name, f.SQLType, domain.ManualField, table.DataFieldIndex)
mainTable.DataFieldIndex += 1
fields[i] = DataField(f.Name, f.SQLType, domain.ManualField, mainTable.DataFieldIndex)
fields[i].Description = f.Description
}
}
... ...
... ... @@ -165,7 +165,11 @@ func (repository *LogRepository) Find(queryOptions map[string]interface{}) (int6
}
query.SetOffsetAndLimit(20)
query.SetOrderDirect("log_id", "ASC")
if v, ok := queryOptions["sortByLogId"]; ok && len(v.(string)) > 0 {
query.SetOrderDirect("log_id", v.(string))
} else {
query.SetOrderDirect("log_id", "ASC")
}
if count, err := query.SelectAndCount(); err != nil {
return 0, logs, err
} else {
... ...
... ... @@ -48,7 +48,7 @@ func init() {
}
web.InsertFilter("/*", web.BeforeRouter, filters.AllowCors())
web.InsertFilter("/*", web.BeforeExec, filters.CreateRequstLogFilter(Logger)) // CreateRequestLogFilter(true)
web.InsertFilter("/*", web.BeforeExec, CreateRequestLogFilter(true)) // filters.CreateRequstLogFilter(Logger)
web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(Logger), web.WithReturnOnOutput(false))
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/log/command"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/log/query"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/log/service"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
)
type LogController struct {
... ... @@ -68,6 +69,17 @@ func (controller *LogController) SearchLog() {
ResponseGrid(controller.BaseController, total, data, err)
}
func (controller *LogController) TableOperateLog() {
logService := service.NewLogService(nil)
cmd := &command.SearchLogCommand{}
controller.Unmarshal(cmd)
cmd.LogType = domain.CommonLog.ToString()
cmd.SortByLogId = "DESC"
cmd.Context = ParseContext(controller.BaseController)
total, data, err := logService.SearchLog(cmd)
ResponseGrid(controller.BaseController, total, data, err)
}
func (controller *LogController) VerifiedStepLog() {
logService := service.NewLogService(nil)
cmd := &command.SearchLogCommand{}
... ...
... ... @@ -12,5 +12,6 @@ func init() {
web.Router("/data/logs/:logId", &controllers.LogController{}, "Delete:RemoveLog")
web.Router("/data/logs/", &controllers.LogController{}, "Get:ListLog")
web.Router("/data/logs/search", &controllers.LogController{}, "Post:SearchLog")
web.Router("/data/logs/table-operate-Log", &controllers.LogController{}, "Post:TableOperateLog")
web.Router("/data/logs/verified-step-Log", &controllers.LogController{}, "Post:VerifiedStepLog")
}
... ...