object_table.go
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package domain
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/gateway/bytelib"
"gorm.io/plugin/soft_delete"
)
type ObjectTable struct {
Id int `json:"id"` // ID
TableId int `json:"tableId" ` //表ID
Name string `json:"name"` //表名
TableType string `json:"tableType" ` //模块
CompanyId int64 `json:"companyId"` //公司id
ParentId int `json:"parentId"` //父id
Flag string `json:"flag"` //分组:Group 集合:Set
Version int `json:"version,omitempty"` //版本
IsLocal bool `json:"isLocal"` //是否有本地存储
RemoteDeleted int `json:"remoteDeleted"` //远端删除
IsDel soft_delete.DeletedAt `json:"isDel,omitempty"` //删除标记
CreatedAt int64 `json:"createdAt,omitempty"` //创建时间
UpdatedAt int64 `json:"updatedAt,omitempty"` //更新时间
DeletedAt int64 `json:"deletedAt,omitempty"` //删除时间
}
type ObjectTableRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ObjectTable) (*ObjectTable, error)
Update(ctx context.Context, conn transaction.Conn, dm *ObjectTable) (*ObjectTable, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ObjectTable) (*ObjectTable, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ObjectTable) (*ObjectTable, error)
FindOne(ctx context.Context, conn transaction.Conn, id int, tableType string) (*ObjectTable, error)
FindOneByTableId(ctx context.Context, conn transaction.Conn, tableId int) (*ObjectTable, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ObjectTable, error)
DeleteGroup(ctx context.Context, conn transaction.Conn, companyId int64, parentId int) error
}
type ObjectTableDataQuery struct {
Page int
Size int
Conditions []*TableDataCondition
Group string
Select string
}
type TableDataCondition struct {
FieldName string `json:"field"` // 条件字段
Like string `json:"like"` // 模糊匹配
In []string `json:"in"` // 匹配多个值
Order string `json:"order"` // 排序 ASC DESC 默认ASC
}
type ObjectTableDataRepository interface {
InsertWithTableData(ctx context.Context, conn transaction.Conn, tableDataPreview bytelib.TableData) error
Find(ctx context.Context, conn transaction.Conn, tableId int, query *ObjectTableDataQuery) (int64, []map[string]interface{}, error)
DropTable(ctx context.Context, conn transaction.Conn, tableId int) error
}
func (m *ObjectTable) Identify() interface{} {
if m.Id == 0 {
return nil
}
return m.Id
}