作者 yangfu

Merge branch 'test'

... ... @@ -6,6 +6,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/authlib"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/bytelib"
"path/filepath"
"sort"
"strings"
"time"
... ... @@ -311,6 +312,9 @@ func (fileService *FileService) SearchAppFile(ctx *domain.Context, listFileQuery
files = append(files, file)
}
}
sort.SliceStable(files, func(i, j int) bool {
return files[i].Name < files[j].Name
})
apps = append(apps, &dto.AppDto{
AppId: app.AppId,
AppKey: app.AppKey,
... ...
... ... @@ -2,14 +2,15 @@ package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/zeromicro/go-zero/core/collection"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks"
"gorm.io/gorm"
"sort"
)
func (tableService *TableService) FieldOptionalValues(ctx *domain.Context, cmd *command.FieldOptionalValuesCommand) (interface{}, error) {
... ... @@ -84,6 +85,28 @@ func (tableService *TableService) FieldOptionalValues(ctx *domain.Context, cmd *
if !domain.SQLType(field.SQLType).IsString() {
match = ""
}
if table.TableType == domain.CalculateSet.ToString() {
var querySet *domain.QuerySet
querySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0)
querySet, err = querySetRepository.FindOne(map[string]interface{}{"BindTableId": cmd.ObjectId})
if err != nil {
return nil, factory.FastError(err)
}
svr, _ := factory.FastQuerySetServices(transactionContext)
dataTable, err = svr.LoadCalculateSetData(ctx, querySet, querySet.QueryComponents)
if err != nil {
return nil, factory.FastError(err)
}
values := removeDuplicate(dataTable.Values(field))
sort.SliceStable(values, func(i, j int) bool {
return values[i] < values[j]
})
return map[string]interface{}{
"values": values,
"total": len(values),
}, nil
}
options := &starrocks.QueryOptions{
Table: table,
TableName: table.SQLName,
... ... @@ -127,3 +150,15 @@ func (tableService *TableService) FieldOptionalValues(ctx *domain.Context, cmd *
"total": len(values),
}, nil
}
func removeDuplicate(inputs []string) []string {
s := collection.NewSet()
var result = make([]string, 0)
for _, input := range inputs {
if !s.Contains(input) {
s.Add(input)
result = append(result, input)
}
}
return result
}
... ...
... ... @@ -33,7 +33,11 @@ func (ptr *AddTableStructService) AddTableStruct(ctx *domain.Context, parentTabl
}
// 验证表名是否重复
duplicateTable, err := tableRepository.FindOne(map[string]interface{}{"context": ctx, "tableName": name})
duplicateTable, err := tableRepository.FindOne(map[string]interface{}{"context": ctx, "tableName": name, "tableTypes": []string{
domain.MainTable.ToString(),
domain.SubTable.ToString(),
domain.SideTable.ToString(),
}})
if err == nil && duplicateTable != nil {
return nil, fmt.Errorf("表名称重复")
}
... ...