作者 yangfu

fix: sync data

... ... @@ -162,9 +162,6 @@ func AutoRemoveTemporaryTable(ctx context.Context) error {
return nil
}
}
//if err = dao.TableDeleteByTime(transactionContext.(*pgTransaction.TransactionContext), domain.TemporaryTable, begin, end); err != nil {
// return err
//}
if err = transactionContext.CommitTransaction(); err != nil {
return err
}
... ...
... ... @@ -6,6 +6,7 @@ import (
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/event/command"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory"
"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/infrastructure/api/digitalLib"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService"
... ... @@ -36,7 +37,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
switch data.Type {
case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent:
tableId = data.Table.TableId
case domain.QuerySetUpdateEvent, domain.QuerySetUpdateStatusEvent:
case domain.QuerySetUpdateEvent, domain.QuerySetUpdateRenameEvent:
tableId = data.QuerySet.QuerySetInfo.BindTableId
if data.QuerySet.Status != domain.StatusOn {
return nil, nil
... ... @@ -44,6 +45,16 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
if !domain.AssertTableType(data.QuerySet.Type, domain.SchemaTable, domain.CalculateItem, domain.CalculateSet) {
return nil, nil
}
case domain.QuerySetUpdateStatusEvent:
tableId = data.QuerySet.QuerySetInfo.BindTableId
if !domain.AssertTableType(data.QuerySet.Type, domain.SchemaTable, domain.CalculateItem, domain.CalculateSet) {
return nil, nil
}
case domain.TableApplyOnEvent:
tableId = data.Table.TableId
dataChanged = false
case domain.QuerySetDeleteEvent:
tableId = data.Table.TableId
}
if tableId == 0 {
return nil, nil
... ... @@ -53,9 +64,13 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
StructChanged: structChanged,
TableId: tableId,
Event: data.Type.ToString(),
Metadata: cmd.EventTable.Metadata,
}
// tableId 相关联的
tableRepository, table, _ := factory.FastPgTable(transactionContext, tableId)
if table == nil && data.Table != nil {
table = data.Table
}
if table != nil {
notifyData.TableType = domain.EnumsDescription(domain.ObjectTypeMap, table.TableType)
switch domain.TableType(table.TableType) {
... ... @@ -100,7 +115,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
}
switch table.TableType {
case domain.MainTable.ToString(), domain.SubTable.ToString(), domain.SideTable.ToString():
if table.TableInfo.ApplyOnModule&domain.ModuleDigitalCenter == 0 {
if table.TableInfo != nil && table.TableInfo.ApplyOnModule&domain.ModuleDigitalCenter == 0 {
continue
}
break
... ... @@ -118,7 +133,16 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
}
notifyData.TableAffectedList = append(notifyData.TableAffectedList, tree[i])
}
lib := digitalLib.NewDigitalLib("")
found := false
for _, id := range notifyData.TableAffectedList {
if id == tableId {
found = true
}
}
if !found {
notifyData.TableAffectedList = append(notifyData.TableAffectedList, tableId)
}
lib := digitalLib.NewDigitalLib(constant.DIGITAL_SERVER_HOST)
if _, err = lib.SyncNotice(digitalLib.RequestSyncNotice{Body: notifyData}); err != nil {
log.Logger.Error(fmt.Sprintf("通知数控失败:%s", err.Error()))
if t, ok := notifyData.Retry(); ok {
... ... @@ -142,6 +166,7 @@ type NotifyData struct {
CompanyId int `json:"companyId"` // 公司
Event string `json:"event"` // 事件名称
TableAffectedList []int `json:"tableAffectedList"` // 级联影响到的表
Metadata map[string]interface{} `json:"metadata"` // 元数据
sendRetry int
}
... ...
... ... @@ -23,9 +23,9 @@ func FastPgFile(transactionContext application.TransactionContext, id int) (doma
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"fileId": id}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该文件不存在")
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该文件不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
//if err = fastPgDataAuth(transactionContext, mod, options...); err != nil {
... ... @@ -52,9 +52,9 @@ func FastPgTable(transactionContext application.TransactionContext, id int) (dom
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"tableId": id}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该表格不存在")
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该表格不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
... ... @@ -78,9 +78,9 @@ func FastPgLog(transactionContext application.TransactionContext, id int) (domai
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"logId": id}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该日志不存在")
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该日志不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
... ... @@ -104,9 +104,9 @@ func FastPgMappingRule(transactionContext application.TransactionContext, id int
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"mappingRuleId": id}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该匹配规则不存在")
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该匹配规则不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
... ... @@ -130,9 +130,9 @@ func FastPgQuerySet(transactionContext application.TransactionContext, id int) (
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"querySetId": id}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该查询集合不存在")
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该查询集合不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
... ...
... ... @@ -91,9 +91,6 @@ type FileUpload struct {
}
func (fileService *FileService) DeleteAppTableFile(ctx *domain.Context, cmd *command.DeleteAppTableFileCommand) (interface{}, error) {
//if err := cmd.ValidateCommand(); err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, err.Error())
//}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -123,9 +120,6 @@ func (fileService *FileService) DeleteAppTableFile(ctx *domain.Context, cmd *com
}
func (fileService *FileService) AppTableFileAppendData(ctx *domain.Context, cmd *command.AppTableFileAppendDataCommand) (interface{}, error) {
//if err := cmd.ValidateCommand(); err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, err.Error())
//}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...
... ... @@ -277,7 +277,7 @@ func (fileService *FileService) AppendDataToTable(ctx *domain.Context, cmd *comm
return result, nil
}
// AppendDataToTable 追加数据
// AppendDataToTablePreflightCheck 追加数据预查
func (fileService *FileService) AppendDataToTablePreflightCheck(ctx *domain.Context, cmd *command.AppendDataToTableCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -352,41 +352,6 @@ func (fileService *FileService) ExportFile(ctx *domain.Context, cmd *command.Exp
if err != nil {
return nil, factory.FastError(err)
}
//filename := fmt.Sprintf("%v_%v.xlsx", file.FileInfo.Name, time.Now().Format("060102150405"))
//path := fmt.Sprintf("public/%v", filename)
//writerTo := excel.NewXLXSWriterTo(importer.Reader().Header().Columns, data)
//writerTo.ToInterfaces = domain.MakeToInterfaces(table.DataFields)
//if err := writerTo.Save(path); err != nil {
// return nil, factory.FastError(err)
//}
//
//var (
// config = utils.RouterConfig{
// OssEndPoint: "oss-cn-hangzhou.aliyuncs-internal.com",
// AccessKeyID: "LTAI4Fz1LUBW2fXp6QWaJHRS",
// AccessKeySecret: "aLZXwK8pgrs10Ws03qcN7NsrSXFVsg",
// BuckName: "byte-bank",
// }
// key = fmt.Sprintf("byte-bank/%v/%v", time.Now().Format("2006-01-02"), filename)
//)
//bucket, bucketErr := utils.NewBucket(config)
//if bucketErr == nil && bucket != nil {
// log.Logger.Info(fmt.Sprintf("end-point:%v key:%v", config.OssEndPoint, key))
// f, _ := os.Open(path)
// if err = utils.CreateObjects(bucket, utils.Object{
// Key: key,
// Value: f,
// }); err != nil {
// log.Logger.Error(err.Error())
// } else {
// response.Url = domain.ConvertInternalFileUrlToPublic(fmt.Sprintf("https://%v.%v/%v", config.BuckName, config.OssEndPoint, key))
// }
//}
//if len(response.Url) == 0 {
// response.Url = domain.DownloadUrl(filename)
//}
//response.FileName = file.FileInfo.Name
//response.Ext = domain.XLSX
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...
... ... @@ -19,11 +19,11 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
)
// 文件服务
// FileService 文件服务
type FileService struct {
}
// 创建文件服务
// CreateFile 创建文件服务
func (fileService *FileService) CreateFile(ctx *domain.Context, createFileCommand *command.CreateFileCommand) (interface{}, error) {
if err := createFileCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -89,7 +89,7 @@ func (fileService *FileService) CreateFile(ctx *domain.Context, createFileComman
return struct{}{}, nil
}
// 返回文件服务
// GetFile 返回文件服务
func (fileService *FileService) GetFile(ctx *domain.Context, getFileQuery *query.GetFileQuery) (interface{}, error) {
if err := getFileQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -140,7 +140,7 @@ func (fileService *FileService) GetFile(ctx *domain.Context, getFileQuery *query
return response, nil
}
// 返回文件服务列表
// ListFile 返回文件服务列表
func (fileService *FileService) ListFile(listFileQuery *query.ListFileQuery) (interface{}, error) {
if err := listFileQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -218,7 +218,7 @@ func (fileService *FileService) SearchFile(listFileQuery *query.SearchFileQuery)
}, nil
}
// 返回文件服务列表
// SearchAppFile 返回文件服务列表
func (fileService *FileService) SearchAppFile(ctx *domain.Context, listFileQuery *query.SearchFileQuery) (interface{}, error) {
if err := listFileQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -338,7 +338,7 @@ func (fileService *FileService) GetAppFile(ctx *domain.Context, appKey string, f
}, nil
}
// 移除文件服务
// RemoveFile 移除文件服务
func (fileService *FileService) RemoveFile(ctx *domain.Context, removeFileCommand *command.RemoveFileCommand) (interface{}, error) {
if err := removeFileCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -379,7 +379,7 @@ func (fileService *FileService) RemoveFile(ctx *domain.Context, removeFileComman
return struct{}{}, nil
}
// 更新文件服务
// UpdateFile 更新文件服务
func (fileService *FileService) UpdateFile(updateFileCommand *command.UpdateFileCommand) (interface{}, error) {
if err := updateFileCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -422,7 +422,7 @@ func (fileService *FileService) UpdateFile(updateFileCommand *command.UpdateFile
}
}
// 取消校验中的文件
// CancelVerifyingFile 取消校验中的文件
func (fileService *FileService) CancelVerifyingFile(ctx *domain.Context, cmd *command.CancelVerifyingFileCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ...
... ... @@ -12,11 +12,9 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
)
// 日志服务
type LogService struct {
}
// 创建日志服务
func (logService *LogService) CreateLog(createLogCommand *command.CreateLogCommand) (interface{}, error) {
if err := createLogCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -56,7 +54,6 @@ func (logService *LogService) CreateLog(createLogCommand *command.CreateLogComma
}
}
// 返回日志服务
func (logService *LogService) GetLog(getLogQuery *query.GetLogQuery) (interface{}, error) {
if err := getLogQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -93,7 +90,6 @@ func (logService *LogService) GetLog(getLogQuery *query.GetLogQuery) (interface{
}
}
// 返回日志服务列表
func (logService *LogService) ListLog(listLogQuery *query.ListLogQuery) (interface{}, error) {
if err := listLogQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -129,7 +125,6 @@ func (logService *LogService) ListLog(listLogQuery *query.ListLogQuery) (interfa
}
}
// 移除日志服务
func (logService *LogService) RemoveLog(removeLogCommand *command.RemoveLogCommand) (interface{}, error) {
if err := removeLogCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -169,7 +164,6 @@ func (logService *LogService) RemoveLog(removeLogCommand *command.RemoveLogComma
}
}
// 搜索日志
func (logService *LogService) SearchLog(searchLogCommand *command.SearchLogCommand) (int64, interface{}, error) {
if err := searchLogCommand.ValidateCommand(); err != nil {
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -204,7 +198,6 @@ func (logService *LogService) SearchLog(searchLogCommand *command.SearchLogComma
return count, result, nil
}
// 搜索日志
func (logService *LogService) VerifiedStepLog(searchLogCommand *command.SearchLogCommand) (int64, interface{}, error) {
if err := searchLogCommand.ValidateCommand(); err != nil {
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -252,7 +245,6 @@ func (logService *LogService) VerifiedStepLog(searchLogCommand *command.SearchLo
}, nil
}
// 更新日志服务
func (logService *LogService) UpdateLog(updateLogCommand *command.UpdateLogCommand) (interface{}, error) {
if err := updateLogCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ...
... ... @@ -13,11 +13,11 @@ import (
"time"
)
// 匹配规则服务
// MappingRuleService 匹配规则服务
type MappingRuleService struct {
}
// 创建匹配规则服务
// CreateMappingRule 创建匹配规则服务
func (mappingRuleService *MappingRuleService) CreateMappingRule(ctx *domain.Context, cmd *command.CreateMappingRuleCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -81,7 +81,7 @@ func (mappingRuleService *MappingRuleService) CreateMappingRule(ctx *domain.Cont
return result, nil
}
// 返回匹配规则服务
// GetMappingRule 返回匹配规则服务
func (mappingRuleService *MappingRuleService) GetMappingRule(getMappingRuleQuery *query.GetMappingRuleQuery) (interface{}, error) {
if err := getMappingRuleQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -109,7 +109,7 @@ func (mappingRuleService *MappingRuleService) GetMappingRule(getMappingRuleQuery
return result, nil
}
// 返回匹配规则服务列表
// ListMappingRule 返回匹配规则服务列表
func (mappingRuleService *MappingRuleService) ListMappingRule(listMappingRuleQuery *query.ListMappingRuleQuery) (interface{}, error) {
if err := listMappingRuleQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -145,7 +145,7 @@ func (mappingRuleService *MappingRuleService) ListMappingRule(listMappingRuleQue
}
}
// 匹配规则预准备(新建规则)
// Prepare 匹配规则预准备(新建规则)
func (mappingRuleService *MappingRuleService) Prepare(prepareCommand *command.PrepareCommand) (interface{}, error) {
if err := prepareCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -182,7 +182,7 @@ func (mappingRuleService *MappingRuleService) Prepare(prepareCommand *command.Pr
return ruleDto, nil
}
// 移除匹配规则服务
// RemoveMappingRule 移除匹配规则服务
func (mappingRuleService *MappingRuleService) RemoveMappingRule(removeMappingRuleCommand *command.RemoveMappingRuleCommand) (interface{}, error) {
if err := removeMappingRuleCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -222,7 +222,7 @@ func (mappingRuleService *MappingRuleService) RemoveMappingRule(removeMappingRul
}{}, nil
}
// 搜索规则
// Search 搜索规则
func (mappingRuleService *MappingRuleService) Search(searchCommand *command.SearchCommand) (interface{}, error) {
if err := searchCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -259,7 +259,7 @@ func (mappingRuleService *MappingRuleService) Search(searchCommand *command.Sear
}, nil
}
// 更新匹配规则服务
// UpdateMappingRule 更新匹配规则服务
func (mappingRuleService *MappingRuleService) UpdateMappingRule(ctx *domain.Context, cmd *command.UpdateMappingRuleCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ...
... ... @@ -11,6 +11,7 @@ import (
"time"
)
// CalculateSetPreview 计算集预览
func (querySetService *QuerySetService) CalculateSetPreview(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) {
if err := updateQuerySetCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -50,6 +51,7 @@ func (querySetService *QuerySetService) CalculateSetPreview(ctx *domain.Context,
return response, nil
}
// CalculateSetExport 计算集导出
func (querySetService *QuerySetService) CalculateSetExport(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) {
if err := updateQuerySetCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -79,10 +81,6 @@ func (querySetService *QuerySetService) CalculateSetExport(ctx *domain.Context,
}
var fields []string
//for i := range dataTable.Fields {
// fields = append(fields, dataTable.Fields[i].Name)
//}
filename := fmt.Sprintf("%v_%v.xlsx", querySet.Name, time.Now().Format("060102150405"))
path := fmt.Sprintf("public/%v", filename)
excelWriter := excel.NewXLXSWriterTo(fields, dataTable.Data)
... ...
... ... @@ -18,11 +18,11 @@ import (
"time"
)
// 查询集合服务
// QuerySetService 查询集合服务
type QuerySetService struct {
}
// 修改状态
// ChangeStatus 修改状态
func (querySetService *QuerySetService) ChangeStatus(ctx *domain.Context, changeStatusCommand *command.ChangeStatusCommand) (interface{}, error) {
if err := changeStatusCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -48,7 +48,7 @@ func (querySetService *QuerySetService) ChangeStatus(ctx *domain.Context, change
return struct{}{}, nil
}
// 移动
// Copy 复制
func (querySetService *QuerySetService) Copy(ctx *domain.Context, copyCommand *command.CopyCommand) (interface{}, error) {
if err := copyCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -77,7 +77,7 @@ func (querySetService *QuerySetService) Copy(ctx *domain.Context, copyCommand *c
return result, nil
}
// 创建查询集合服务
// CreateQuerySet 创建查询集合服务
func (querySetService *QuerySetService) CreateQuerySet(ctx *domain.Context, createQuerySetCommand *command.CreateQuerySetCommand) (interface{}, error) {
if err := createQuerySetCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -113,7 +113,7 @@ func (querySetService *QuerySetService) CreateQuerySet(ctx *domain.Context, crea
return response, nil
}
// 依赖关系图
// DependencyGraph 依赖关系图
func (querySetService *QuerySetService) DependencyGraph(ctx *domain.Context, dependencyGraphQuery *query.DependencyGraphQuery) (interface{}, error) {
if err := dependencyGraphQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -141,7 +141,7 @@ func (querySetService *QuerySetService) DependencyGraph(ctx *domain.Context, dep
return data, nil
}
// 返回查询集合服务
// GetQuerySet 返回查询集合服务
func (querySetService *QuerySetService) GetQuerySet(ctx *domain.Context, getQuerySetQuery *query.GetQuerySetQuery) (interface{}, error) {
if err := getQuerySetQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -173,7 +173,7 @@ func (querySetService *QuerySetService) GetQuerySet(ctx *domain.Context, getQuer
return (&dto.QuerySetDetailDto{}).Load(querySet, tables.ToMap()), nil
}
// 返回查询集合服务列表
// ListQuerySet 返回查询集合服务列表
func (querySetService *QuerySetService) ListQuerySet(ctx *domain.Context, listQuerySetQuery *query.ListQuerySetQuery) (interface{}, error) {
if err := listQuerySetQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -209,7 +209,7 @@ func (querySetService *QuerySetService) ListQuerySet(ctx *domain.Context, listQu
}
}
// 移动
// Move 移动
func (querySetService *QuerySetService) Move(ctx *domain.Context, moveCommand *command.MoveCommand) (interface{}, error) {
if err := moveCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -236,7 +236,7 @@ func (querySetService *QuerySetService) Move(ctx *domain.Context, moveCommand *c
return struct{}{}, nil
}
// 移除查询集合服务
// RemoveQuerySet 移除查询集合服务
func (querySetService *QuerySetService) RemoveQuerySet(ctx *domain.Context, removeQuerySetCommand *command.RemoveQuerySetCommand) (interface{}, error) {
if err := removeQuerySetCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -275,7 +275,7 @@ func (querySetService *QuerySetService) RemoveQuerySet(ctx *domain.Context, remo
return struct{}{}, nil
}
// 重命名
// Rename 重命名
func (querySetService *QuerySetService) Rename(ctx *domain.Context, renameCommand *command.RenameCommand) (interface{}, error) {
if err := renameCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -302,7 +302,7 @@ func (querySetService *QuerySetService) Rename(ctx *domain.Context, renameComman
return struct{}{}, nil
}
// 返回查询集合服务列表
// SearchQuerySet 返回查询集合服务列表
func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, searchQuerySetQuery *query.SearchQuerySetQuery) (interface{}, error) {
if err := searchQuerySetQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -311,12 +311,6 @@ func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, sear
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//if err := transactionContext.StartTransaction(); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
//}
//defer func() {
// transactionContext.RollbackTransaction()
//}()
QuerySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0)
options := utils.ObjectToMap(searchQuerySetQuery)
... ... @@ -361,16 +355,13 @@ func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, sear
var result = dto.NewQuerySetDtoList(querySets)
//if err := transactionContext.CommitTransaction(); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
//}
return map[string]interface{}{
"count": count,
"querySets": result,
}, nil
}
// 更新查询集合服务
// UpdateQuerySet 更新查询集合服务
func (querySetService *QuerySetService) UpdateQuerySet(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) {
if err := updateQuerySetCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -396,7 +387,7 @@ func (querySetService *QuerySetService) UpdateQuerySet(ctx *domain.Context, upda
return struct{}{}, nil
}
// 更新查询集合服务
// RefreshQuerySet 更新查询集合服务
func (querySetService *QuerySetService) RefreshQuerySet(ctx *domain.Context, updateQuerySetCommand *command.RefreshQuerySetCommand) (interface{}, error) {
if err := updateQuerySetCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -426,6 +417,7 @@ func (querySetService *QuerySetService) RefreshQuerySet(ctx *domain.Context, upd
return struct{}{}, nil
}
// PreviewPrepare 预览准备
func (querySetService *QuerySetService) PreviewPrepare(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) {
if err := updateQuerySetCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -455,6 +447,7 @@ func (querySetService *QuerySetService) PreviewPrepare(ctx *domain.Context, upda
}, nil
}
// CalculateItemPreview 计算项预览
func (querySetService *QuerySetService) CalculateItemPreview(ctx *domain.Context, q *query.CalculateItemPreviewQuery) (interface{}, error) {
if err := q.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -481,6 +474,7 @@ func (querySetService *QuerySetService) CalculateItemPreview(ctx *domain.Context
}, nil
}
// CalculateItemExport 计算项导出
func (querySetService *QuerySetService) CalculateItemExport(ctx *domain.Context, q *query.CalculateItemPreviewQuery) (interface{}, error) {
if err := q.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ...
... ... @@ -31,7 +31,6 @@ func (tableService *TableService) ExportDataTable(ctx *domain.Context, cmd *comm
}()
var table *domain.Table
//var mainTable *domain.Table
_, table, err = factory.FastPgTable(transactionContext, cmd.TableId)
if err != nil {
return nil, factory.FastError(err)
... ... @@ -92,7 +91,6 @@ func (tableService *TableService) ExportDataTableV2(ctx *domain.Context, cmd *co
}
defer locker.Release()
var table *domain.Table
//var mainTable *domain.Table
if cmd.ObjectType == domain.ObjectDBTable {
table = domain.DBTables[cmd.TableId]
if table == nil {
... ... @@ -120,7 +118,6 @@ func exportTableTo(ctx *domain.Context, cmd *command.TablePreviewCommand, table
var options = starrocks.QueryOptions{
TableName: table.SQLName,
Select: table.Fields(false),
//Table: table,
}
db := starrocks.DB
... ...
... ... @@ -105,12 +105,6 @@ func (tableService *TableService) RowsDelete(ctx *domain.Context, cmd *command.R
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//if err := transactionContext.StartTransaction(); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
//}
//defer func() {
// transactionContext.RollbackTransaction()
//}()
var table *domain.Table
_, table, err = factory.FastPgTable(transactionContext, cmd.TableId)
... ... @@ -127,9 +121,6 @@ func (tableService *TableService) RowsDelete(ctx *domain.Context, cmd *command.R
}
options.SetCondition(cmd.Where.Conditions)
total, err := starrocks.WrapDeleteFuncWithDB(starrocks.DB)(options)
//if err := transactionContext.CommitTransaction(); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
//}
return map[string]interface{}{
"rowsAffected": total,
}, nil
... ...
... ... @@ -11,6 +11,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/query"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/astexpr"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
... ... @@ -426,6 +427,9 @@ func (tableService *TableService) ApplyOn(ctx *domain.Context, cmd *command.Appl
} else {
table.TableInfo.SetApplyOn(cmd.Module)
}
defer func() {
domainService.AsyncEvent(domain.NewEventTable(ctx, domain.TableApplyOnEvent).WithTable(table).WithMetadata("module", cmd.Module))
}()
if !ctx.Access() {
for i := range cmd.Modules {
// 字库应用于数控目前限制在3万条记录以内,在字库的应用于数控按钮上增加判断,如果超过3万条,
... ...
... ... @@ -54,7 +54,6 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
var (
querySetMapById = make(map[int]*domain.QuerySet)
// BindTableId , parentId
querySetMapByTableId = make(map[int]*domain.QuerySet)
)
if searchQuery.ReturnGroupItem {
... ... @@ -154,9 +153,6 @@ func filterTableByFilterRule(item *dto.TableObjectDto, searchQuery *query.Search
if rule.TableType == "*" && rule.Status > 0 && rule.Status != item.Status {
return true
}
//if rule.TableType == rule.TableType && rule.Status > 0 && rule.Status != item.Status {
// return true
//}
}
return false
}
... ...
... ... @@ -14,12 +14,6 @@ var LOG_LEVEL = "debug"
var LOG_FILE = "app.log"
var PPROF_ON = true
//天联共创基础模块
//var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com"
// 天联共创用户模块
var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com"
var MMM_BYTE_BANK_HOST = "http://220.250.41.79:8301"
var METADATA_BASTION_HOST = "http://127.0.0.1:8080"
... ... @@ -31,26 +25,14 @@ var AUTH_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com"
var OPEN_API_HOST = "http://mmm-open-api-test.fjmaimaimai.com"
// 数控服务域名地址
var DIGITAL_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com"
var DIGITAL_SERVER_HOST = "http://digitization-server-dev.fjmaimaimai.com"
var BLACK_LIST_USER int64
var BLACK_LIST_COMPANY int64
var WHITE_LIST_USERS []int
//var CUSTOMER_ACCOUNT = []int64{3129687560814592, 3129687690100739, 3492238958608384}
//const CUSTOMER_ACCOUNT_DELIMITER = ","
/***** 1.数据传输 *****/
//const HeaderCompanyId = "companyId"
//const HeaderUserId = "userId"
//const HeaderOrgId = "orgId"
//const HeaderOrgIds = "orgIds"
func init() {
LOG_LEVEL = Configurator.DefaultString("LOG_LEVEL", LOG_LEVEL)
//ALLIED_CREATION_BASIC_HOST = Configurator.DefaultString("ALLIED_CREATION_BASIC_HOST", ALLIED_CREATION_BASIC_HOST)
ALLIED_CREATION_USER_HOST = Configurator.DefaultString("ALLIED_CREATION_USER_HOST", ALLIED_CREATION_USER_HOST)
MMM_BYTE_BANK_HOST = Configurator.DefaultString("MMM_BYTE_BANK_HOST", MMM_BYTE_BANK_HOST)
METADATA_BASTION_HOST = Configurator.DefaultString("METADATA_BASTION_HOST", METADATA_BASTION_HOST)
BYTE_CORE_HOST = Configurator.DefaultString("BYTE_CORE_HOST", BYTE_CORE_HOST)
... ...
... ... @@ -3,5 +3,3 @@ package constant
var JWTSecretKey = "digital-platform"
var JWTExpiresIn = 60 * 60 * 24 //单位:秒
var JWTCacheExpiresIn = 60 * 60 * 24 //单位:秒
... ...
... ... @@ -25,12 +25,14 @@ type EventTable struct {
Type EventType
Table *Table
QuerySet *QuerySet
Metadata map[string]interface{}
}
func NewEventTable(ctx *Context, t EventType) *EventTable {
return &EventTable{
Context: ctx,
Type: t,
Metadata: make(map[string]interface{}),
}
}
func (et *EventTable) WithContext(t *Context) *EventTable {
... ... @@ -52,11 +54,17 @@ func (et *EventTable) WithQuerySet(t *QuerySet) *EventTable {
return et
}
func (et *EventTable) WithMetadata(key string, values interface{}) *EventTable {
et.Metadata[key] = values
return et
}
func (et *EventTable) ResolveEvent(e event.Event) {
et.Context = e.Get("Context").(*Context)
et.Type = e.Get("Type").(EventType)
et.Table = e.Get("Table").(*Table)
et.QuerySet = e.Get("QuerySet").(*QuerySet)
et.Metadata = e.Get("Metadata").(map[string]interface{})
}
func (et *EventTable) FireEvent() event.Event {
... ... @@ -65,5 +73,6 @@ func (et *EventTable) FireEvent() event.Event {
e["Type"] = et.Type
e["Table"] = et.Table
e["QuerySet"] = et.QuerySet
e["Metadata"] = et.Metadata
return event.MustFire(et.Type.ToString(), e)
}
... ...
... ... @@ -93,12 +93,10 @@ func (file *File) CopyTo(fileType FileType, ctx *Context) *File {
}
func (file *File) SetHeaderRow(headerRow int) *File {
//file.FileInfo.HeaderRow = headerRow
return file
}
func (file *File) SetContext(context *Context) *File {
//file.FileInfo.HeaderRow = headerRow
file.Context = context
return file
}
... ...
... ... @@ -17,6 +17,6 @@ func AsyncEvent(e *domain.EventTable) {
e.FireEvent()
}()
log.Logger.Info("开始事件..." + e.Type.ToString())
time.Sleep(time.Millisecond * 400)
time.Sleep(time.Millisecond * 10)
log.Logger.Info("结束事件..." + e.Type.ToString())
}
... ...
... ... @@ -960,7 +960,7 @@ func (ptr *QuerySetService) ChangeStatus(ctx *domain.Context, querySetId int, st
}
defer func() {
AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateStatusEvent).WithTable(table).WithQuerySet(qs))
AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateStatusEvent).WithTable(table).WithQuerySet(qs).WithMetadata("status", status))
}()
}
return nil
... ... @@ -1079,6 +1079,7 @@ func (ptr *QuerySetService) Delete(ctx *domain.Context, querySetId int) error {
}
starrocks.DropView(starrocks.DB, t.SQLName)
}
AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetDeleteEvent).WithQuerySet(querySets[i]).WithTable(t))
}
}
// 2.底层清理
... ...
... ... @@ -73,6 +73,7 @@ func (ptr *DeleteDataTableService) DeleteTables(ctx *domain.Context, tables ...*
if _, err := tableRepository.Remove(t); err != nil {
return err
}
AsyncEvent(domain.NewEventTable(ctx, domain.TableDeleteEvent).WithTable(t))
tableIds = append(tableIds, t.TableId)
}
// delete log
... ...
... ... @@ -330,6 +330,9 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT
Edges: make([]TableEdge, 0),
Tree: tree,
}
if len(tree) == 0 || tableMap == nil {
return dependTree
}
for _, node := range tree {
t, ok := tableMap[node]
... ... @@ -348,11 +351,14 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT
return dependTree
}
func NewTableNode(table *domain.Table) TableNode {
if table == nil {
return TableNode{}
}
return TableNode{
TableId: table.TableId,
Type: table.TableType,
Name: table.Name,
DependencyTables: table.TableInfo.DependencyTables,
DependencyTables: table.DependencyTables(),
}
}
func NewTableEdge(table *domain.Table, dependTable *domain.Table) TableEdge {
... ...
... ... @@ -57,11 +57,6 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi
if err = starrocks.BatchDelete(starrocks.DB, table.SQLName, request.RemoveList); err != nil {
return nil, err
}
//for _, l := range request.RemoveList {
// if e := ptr.remove(ctx, table, l, request.Where); e != nil {
// log.Logger.Error(e.Error())
// }
//}
}
for _, l := range request.UpdateList {
if e := ptr.update(ctx, table, l, request.Where); e != nil {
... ...
... ... @@ -80,13 +80,6 @@ func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tabl
if _, err = ByteCore.SplitTable(domain.ReqSplitTable{FromTable: mainTable, ToSubTable: table}); err != nil {
return nil, err
}
//var tablesAffected []TableNode
//if len(adds) > 0 {
// tablesAffected, _ = DependencyTables(ptr.transactionContext, ctx, tableId)
//}
//return map[string]interface{}{
// "tablesAffected": tablesAffected,
//}, nil
return struct{}{}, nil
}
... ... @@ -140,29 +133,6 @@ func DependencyTables(ptr *pgTransaction.TransactionContext, context *domain.Con
return ret, nil
}
//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]
// if v, ok := tableFieldsMap[f.Name]; ok {
// fields[i].Name = v.Name
// fields[i].SQLName = v.SQLName
// fields[i].Index = v.Index
// fields[i].SQLType = v.SQLType
// fields[i].Description = f.Description
// fields[i].Flag = v.Flag
// } else {
// if f.Flag == domain.ManualField && f.Index == 0 {
// mainTable.DataFieldIndex += 1
// fields[i] = DataField(f.Name, f.SQLType, domain.ManualField, mainTable.DataFieldIndex)
// fields[i].Description = f.Description
// }
// }
// }
// return fields
//}
func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain.Field {
tableFields := mainTable.Fields(false)
tableFieldsMap := (domain.Fields)(tableFields).ToMap()
... ... @@ -179,7 +149,6 @@ func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain.
builder.NewDataField(v.Name, v.SQLType, v.Flag)
} else {
if f.Flag == domain.ManualField {
//mainTable.DataFieldIndex += 1
fields[i] = builder.NewDataField(f.Name, f.SQLType, domain.ManualField)
fields[i].Description = f.Description
}
... ...
... ... @@ -16,4 +16,6 @@ func RegisterEvent() {
event.On(domain.QuerySetUpdateEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
event.On(domain.QuerySetUpdateRenameEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
event.On(domain.QuerySetUpdateStatusEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
event.On(domain.TableApplyOnEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
event.On(domain.QuerySetDeleteEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
}
... ...