chore: replace all cn comments to en version by volc api (#313)
This commit is contained in:
@@ -25,7 +25,7 @@ import (
|
||||
|
||||
type Database = database.Database
|
||||
|
||||
// DatabaseFilter 数据库过滤条件
|
||||
// DatabaseFilter Database filter criteria
|
||||
type DatabaseFilter struct {
|
||||
CreatorID *int64
|
||||
SpaceID *int64
|
||||
@@ -64,19 +64,19 @@ type TableReaderSheetData struct {
|
||||
|
||||
type ExcelExtraInfo struct {
|
||||
Sheets []*common.DocTableSheet
|
||||
ExtensionName string // 扩展名
|
||||
FileSize int64 // 文件大小
|
||||
ExtensionName string // extension
|
||||
FileSize int64 // file size
|
||||
SourceFileID int64
|
||||
TosURI string
|
||||
}
|
||||
|
||||
type LocalTableMeta struct {
|
||||
ExcelFile *excelize.File // xlsx格式文件
|
||||
RawLines [][]string // csv|xls 的全部内容
|
||||
ExcelFile *excelize.File // XLSX format file
|
||||
RawLines [][]string // All content of csv | xls
|
||||
SheetsNameList []string
|
||||
SheetsRowCount []int
|
||||
ExtensionName string // 扩展名
|
||||
FileSize int64 // 文件大小
|
||||
ExtensionName string // extension
|
||||
FileSize int64 // file size
|
||||
}
|
||||
|
||||
type ColumnInfo struct {
|
||||
|
||||
@@ -43,7 +43,7 @@ func SwitchToDataType(itemType table.FieldItemType) entity.DataType {
|
||||
case table.FieldItemType_Boolean:
|
||||
return entity.TypeBoolean
|
||||
default:
|
||||
// 默认使用 VARCHAR
|
||||
// VARCHAR is used by default
|
||||
return entity.TypeVarchar
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func ConvertSystemFieldToString(fieldName string, value interface{}) string {
|
||||
case time.Time:
|
||||
return v.Format(TimeFormat)
|
||||
case []uint8:
|
||||
// 尝试解析字符串表示的时间
|
||||
// Attempt to parse the time represented by a string
|
||||
return string(v)
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func ConvertLogicOperator(logic database.Logic) entity.LogicalOperator {
|
||||
case database.Logic_Or:
|
||||
return entity.OR
|
||||
default:
|
||||
return entity.AND // 默认使用AND
|
||||
return entity.AND // Default use AND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ func (d *DraftImpl) CreateWithTX(ctx context.Context, tx *query.QueryTx, databas
|
||||
AppID: database.AppID,
|
||||
SpaceID: database.SpaceID,
|
||||
RelatedOnlineID: onlineID,
|
||||
IsVisible: 1, // 默认可见
|
||||
IsVisible: 1, // visible by default
|
||||
PromptDisabled: func() int32 {
|
||||
if database.PromptDisabled {
|
||||
return 1
|
||||
@@ -98,7 +98,7 @@ func (d *DraftImpl) CreateWithTX(ctx context.Context, tx *query.QueryTx, databas
|
||||
return database, nil
|
||||
}
|
||||
|
||||
// Get 获取草稿数据库信息
|
||||
// Get draft database information
|
||||
func (d *DraftImpl) Get(ctx context.Context, id int64) (*entity.Database, error) {
|
||||
res := d.query.DraftDatabaseInfo
|
||||
|
||||
@@ -110,7 +110,7 @@ func (d *DraftImpl) Get(ctx context.Context, id int64) (*entity.Database, error)
|
||||
return nil, fmt.Errorf("query draft database failed: %v", err)
|
||||
}
|
||||
|
||||
// 构建返回的数据库对象
|
||||
// Build the returned database object
|
||||
db := &entity.Database{
|
||||
ID: info.ID,
|
||||
SpaceID: info.SpaceID,
|
||||
@@ -178,7 +178,7 @@ func (d *DraftImpl) MGet(ctx context.Context, ids []int64) ([]*entity.Database,
|
||||
return databases, nil
|
||||
}
|
||||
|
||||
// UpdateWithTX 使用事务更新草稿数据库信息
|
||||
// UpdateWithTX updates draft database information using transactions
|
||||
func (d *DraftImpl) UpdateWithTX(ctx context.Context, tx *query.QueryTx, database *entity.Database) (*entity.Database, error) {
|
||||
fieldJson, err := json.Marshal(database.FieldList)
|
||||
if err != nil {
|
||||
@@ -204,7 +204,7 @@ func (d *DraftImpl) UpdateWithTX(ctx context.Context, tx *query.QueryTx, databas
|
||||
"updated_at": now,
|
||||
}
|
||||
|
||||
// 执行更新
|
||||
// execute update
|
||||
res := tx.DraftDatabaseInfo
|
||||
_, err = res.WithContext(ctx).Where(res.ID.Eq(database.ID)).Updates(updates)
|
||||
if err != nil {
|
||||
@@ -228,13 +228,13 @@ func (d *DraftImpl) DeleteWithTX(ctx context.Context, tx *query.QueryTx, id int6
|
||||
return nil
|
||||
}
|
||||
|
||||
// List 列出符合条件的数据库信息
|
||||
// List eligible database information
|
||||
func (d *DraftImpl) List(ctx context.Context, filter *entity.DatabaseFilter, page *entity.Pagination, orderBy []*database.OrderBy) ([]*entity.Database, int64, error) {
|
||||
res := d.query.DraftDatabaseInfo
|
||||
|
||||
q := res.WithContext(ctx)
|
||||
|
||||
// 添加过滤条件
|
||||
// Add filter criteria
|
||||
if filter != nil {
|
||||
if filter.CreatorID != nil {
|
||||
q = q.Where(res.CreatorID.Eq(*filter.CreatorID))
|
||||
|
||||
@@ -65,7 +65,7 @@ func (o *OlineImpl) CreateWithTX(ctx context.Context, tx *query.QueryTx, databas
|
||||
AppID: database.AppID,
|
||||
SpaceID: database.SpaceID,
|
||||
RelatedDraftID: draftID,
|
||||
IsVisible: 1, // 默认可见
|
||||
IsVisible: 1, // visible by default
|
||||
PromptDisabled: func() int32 {
|
||||
if database.PromptDisabled {
|
||||
return 1
|
||||
@@ -97,7 +97,7 @@ func (o *OlineImpl) CreateWithTX(ctx context.Context, tx *query.QueryTx, databas
|
||||
return database, nil
|
||||
}
|
||||
|
||||
// Get 获取线上数据库信息
|
||||
// Get online database information
|
||||
func (o *OlineImpl) Get(ctx context.Context, id int64) (*entity.Database, error) {
|
||||
res := o.query.OnlineDatabaseInfo
|
||||
|
||||
@@ -131,7 +131,7 @@ func (o *OlineImpl) Get(ctx context.Context, id int64) (*entity.Database, error)
|
||||
return db, nil
|
||||
}
|
||||
|
||||
// UpdateWithTX 使用事务更新线上数据库信息
|
||||
// UpdateWithTX updates online database information using transactions
|
||||
func (o *OlineImpl) UpdateWithTX(ctx context.Context, tx *query.QueryTx, database *entity.Database) (*entity.Database, error) {
|
||||
fieldJson, err := json.Marshal(database.FieldList)
|
||||
if err != nil {
|
||||
@@ -141,7 +141,7 @@ func (o *OlineImpl) UpdateWithTX(ctx context.Context, tx *query.QueryTx, databas
|
||||
fieldJsonStr := string(fieldJson)
|
||||
now := time.Now().UnixMilli()
|
||||
|
||||
// 构建更新内容
|
||||
// Build update content
|
||||
updates := map[string]interface{}{
|
||||
"app_id": database.AppID,
|
||||
"table_name": database.TableName,
|
||||
@@ -158,7 +158,7 @@ func (o *OlineImpl) UpdateWithTX(ctx context.Context, tx *query.QueryTx, databas
|
||||
"updated_at": now,
|
||||
}
|
||||
|
||||
// 执行更新
|
||||
// execute update
|
||||
res := tx.OnlineDatabaseInfo
|
||||
_, err = res.WithContext(ctx).Where(res.ID.Eq(database.ID)).Updates(updates)
|
||||
if err != nil {
|
||||
@@ -184,7 +184,7 @@ func (o *OlineImpl) DeleteWithTX(ctx context.Context, tx *query.QueryTx, id int6
|
||||
return nil
|
||||
}
|
||||
|
||||
// MGet 批量获取在线数据库信息
|
||||
// MGet batch acquisition of online database information
|
||||
func (o *OlineImpl) MGet(ctx context.Context, ids []int64) ([]*entity.Database, error) {
|
||||
if len(ids) == 0 {
|
||||
return []*entity.Database{}, nil
|
||||
@@ -192,7 +192,7 @@ func (o *OlineImpl) MGet(ctx context.Context, ids []int64) ([]*entity.Database,
|
||||
|
||||
res := o.query.OnlineDatabaseInfo
|
||||
|
||||
// 查询未删除的、ID在给定列表中的记录
|
||||
// Query undeleted records with IDs in the given list
|
||||
records, err := res.WithContext(ctx).
|
||||
Where(res.ID.In(ids...)).
|
||||
Find()
|
||||
@@ -200,7 +200,7 @@ func (o *OlineImpl) MGet(ctx context.Context, ids []int64) ([]*entity.Database,
|
||||
return nil, fmt.Errorf("batch query online database failed: %v", err)
|
||||
}
|
||||
|
||||
// 构建返回结果
|
||||
// Build returns results
|
||||
databases := make([]*entity.Database, 0, len(records))
|
||||
for _, info := range records {
|
||||
db := &entity.Database{
|
||||
@@ -231,14 +231,14 @@ func (o *OlineImpl) MGet(ctx context.Context, ids []int64) ([]*entity.Database,
|
||||
return databases, nil
|
||||
}
|
||||
|
||||
// List 列出符合条件的数据库信息
|
||||
// List eligible database information
|
||||
func (o *OlineImpl) List(ctx context.Context, filter *entity.DatabaseFilter, page *entity.Pagination, orderBy []*database.OrderBy) ([]*entity.Database, int64, error) {
|
||||
res := o.query.OnlineDatabaseInfo
|
||||
|
||||
// 构建基础查询
|
||||
// Build basic query
|
||||
q := res.WithContext(ctx)
|
||||
|
||||
// 添加过滤条件
|
||||
// Add filter criteria
|
||||
if filter != nil {
|
||||
if filter.CreatorID != nil {
|
||||
q = q.Where(res.CreatorID.Eq(*filter.CreatorID))
|
||||
@@ -274,7 +274,7 @@ func (o *OlineImpl) List(ctx context.Context, filter *entity.DatabaseFilter, pag
|
||||
offset = page.Offset
|
||||
}
|
||||
|
||||
// 处理排序
|
||||
// processing sort
|
||||
if len(orderBy) > 0 {
|
||||
for _, order := range orderBy {
|
||||
switch order.Field {
|
||||
|
||||
@@ -180,18 +180,18 @@ func UpdateFieldInfo(newFieldItems []*database.FieldItem, existingFieldItems []*
|
||||
return updatedFieldItems, updatedColumns, droppedColumns, nil
|
||||
}
|
||||
|
||||
// UpdatePhysicalTableWithDrops 更新物理表结构,包括显式指定要删除的列
|
||||
// UpdatePhysicalTableWithDrops update the physical table structure, including explicitly specifying columns to drop
|
||||
func UpdatePhysicalTableWithDrops(ctx context.Context, db rdb.RDB, existingTable *entity3.Table, newColumns []*entity3.Column, droppedColumns []string, tableName string) error {
|
||||
// 创建列名到列的映射
|
||||
// Create a column name-to-column mapping
|
||||
existingColumnMap := make(map[string]*entity3.Column)
|
||||
for _, col := range existingTable.Columns {
|
||||
existingColumnMap[col.Name] = col
|
||||
}
|
||||
|
||||
// 收集要添加和修改的列
|
||||
// Collect columns to add and modify
|
||||
var columnsToAdd, columnsToModify []*entity3.Column
|
||||
|
||||
// 查找要添加和修改的列
|
||||
// Find columns to add and modify
|
||||
for _, newCol := range newColumns {
|
||||
if _, exists := existingColumnMap[newCol.Name]; exists {
|
||||
columnsToModify = append(columnsToModify, newCol)
|
||||
@@ -200,7 +200,7 @@ func UpdatePhysicalTableWithDrops(ctx context.Context, db rdb.RDB, existingTable
|
||||
}
|
||||
}
|
||||
|
||||
// 应用变更到物理表
|
||||
// Apply changes to physical tables
|
||||
if len(columnsToAdd) > 0 || len(columnsToModify) > 0 || len(droppedColumns) > 0 {
|
||||
// build AlterTableRequest
|
||||
alterReq := &rdb.AlterTableRequest{
|
||||
@@ -208,7 +208,7 @@ func UpdatePhysicalTableWithDrops(ctx context.Context, db rdb.RDB, existingTable
|
||||
Operations: getOperation(columnsToAdd, columnsToModify, droppedColumns),
|
||||
}
|
||||
|
||||
// 执行表结构变更
|
||||
// Perform table structure changes
|
||||
_, err := db.AlterTable(ctx, alterReq)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -218,11 +218,11 @@ func UpdatePhysicalTableWithDrops(ctx context.Context, db rdb.RDB, existingTable
|
||||
return nil
|
||||
}
|
||||
|
||||
// getOperation 将列的添加、修改和删除操作转换为 AlterTableOperation 数组
|
||||
// getOperation converts column add, modify, and delete operations into an AlterTableOperation array
|
||||
func getOperation(columnsToAdd, columnsToModify []*entity3.Column, droppedColumns []string) []*rdb.AlterTableOperation {
|
||||
operations := make([]*rdb.AlterTableOperation, 0)
|
||||
|
||||
// 处理添加列操作
|
||||
// Handle add column operations
|
||||
for _, column := range columnsToAdd {
|
||||
operations = append(operations, &rdb.AlterTableOperation{
|
||||
Action: entity3.AddColumn,
|
||||
@@ -230,7 +230,7 @@ func getOperation(columnsToAdd, columnsToModify []*entity3.Column, droppedColumn
|
||||
})
|
||||
}
|
||||
|
||||
// 处理修改列操作
|
||||
// Handle modify column operations
|
||||
for _, column := range columnsToModify {
|
||||
operations = append(operations, &rdb.AlterTableOperation{
|
||||
Action: entity3.ModifyColumn,
|
||||
@@ -238,7 +238,7 @@ func getOperation(columnsToAdd, columnsToModify []*entity3.Column, droppedColumn
|
||||
})
|
||||
}
|
||||
|
||||
// 处理删除列操作
|
||||
// Handle delete column operations
|
||||
for _, columnName := range droppedColumns {
|
||||
operations = append(operations, &rdb.AlterTableOperation{
|
||||
Action: entity3.DropColumn,
|
||||
|
||||
@@ -118,7 +118,7 @@ func (t *TosTableParser) getLocalSheetMeta(ctx context.Context, maxLine int64) (
|
||||
}
|
||||
|
||||
reader := bytes.NewReader(object)
|
||||
if documentExtension == "csv" { // 处理 csv 文件
|
||||
if documentExtension == "csv" { // Processing csv files
|
||||
records, err := csv.NewReader(reader).ReadAll()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -457,7 +457,7 @@ func getXlsLocalSheetMetaWithTmpFileCallback(ctx context.Context, tmpFile string
|
||||
func (t *TosTableParser) PredictColumnType(columns []*common.DocTableColumn, sampleData [][]string, sheetIdx, startLineIdx int64) ([]*common.DocTableColumn, error) {
|
||||
if len(sampleData) == 0 {
|
||||
for _, column := range columns {
|
||||
column.ColumnType = common.ColumnTypePtr(common.ColumnType_Text) // 兜底展示
|
||||
column.ColumnType = common.ColumnTypePtr(common.ColumnType_Text) // bottom line display
|
||||
column.ContainsEmptyValue = ptr.Of(true)
|
||||
}
|
||||
return columns, nil
|
||||
|
||||
@@ -804,7 +804,7 @@ func (d databaseService) ListDatabaseRecord(ctx context.Context, req *ListDataba
|
||||
|
||||
selectResp, err := d.rdb.SelectData(ctx, &rdb.SelectDataRequest{
|
||||
TableName: physicalTableName,
|
||||
Fields: []string{}, // 空表示查询所有字段
|
||||
Fields: []string{}, // Null means query all fields
|
||||
Where: complexCondition,
|
||||
OrderBy: orderBy,
|
||||
Limit: &limit,
|
||||
|
||||
Reference in New Issue
Block a user