api_byte_lib.go
3.7 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package bytelib
import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/bytecore"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
"time"
)
// ApiByteLib 字库底层接口
type ApiByteLib struct {
api.BaseServiceGateway
baseUrL string
}
func NewApiByteLib(host string) *ApiByteLib {
gt := api.NewBaseServiceGateway(host)
gt.ConnectTimeout = 10 * time.Second
gt.ReadWriteTimeout = 10 * time.Second
gt.Interceptor = func(msg string) {
log.Logger.Info(msg)
}
return &ApiByteLib{
BaseServiceGateway: gt,
}
}
// 加载数据
func (gateway ApiByteLib) LoadDataTable(param bytecore.ReqLoadDataTable) (*bytecore.DataLoadDataTable, error) {
return nil, nil
}
// EditTable 编辑表格
func (gateway ApiByteLib) EditTable(param bytecore.ReqEditDataTable) (*bytecore.DataEditDataTable, error) {
url := gateway.Host() + "/table/edit"
method := "post"
var data bytecore.DataEditDataTable
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
}
return &data, nil
}
// SaveTable 保存校验文件 (文件地址)
func (gateway ApiByteLib) SaveTable(param bytecore.ReqSaveTable) (*bytecore.DataSaveTable, error) {
url := gateway.Host() + "/table/save"
method := "post"
var data bytecore.DataSaveTable
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
}
return &data, nil
}
// GenerateTable 生成主表
func (gateway ApiByteLib) GenerateTable(param bytecore.ReqGenerateTable) (*bytecore.DataGenerateTable, error) {
url := gateway.Host() + "/table/generate"
method := "post"
var data bytecore.DataGenerateTable
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
}
return &data, nil
}
// CopyTable 表复制
func (gateway ApiByteLib) CopyTable(param bytecore.ReqCopyTable) (*bytecore.DataCopyTable, error) {
url := gateway.Host() + "/table/copy"
method := "post"
var data bytecore.DataCopyTable
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
}
return &data, nil
}
// AppendData 追加数据
func (gateway ApiByteLib) AppendData(param bytecore.ReqAppendData) (*bytecore.DataAppendData, error) {
url := gateway.Host() + "/table/append"
method := "post"
var data bytecore.DataAppendData
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
}
return &data, nil
}
// DeleteTable 表删除 (主表、副表、分表)
func (gateway ApiByteLib) DeleteTable(param bytecore.ReqDeleteTable) (*bytecore.DataDeleteTable, error) {
url := gateway.Host() + "/table/delete"
method := "post"
var data bytecore.DataDeleteTable
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
}
return &data, nil
}
// CancelFile 表删除 (主表、副表、分表)
func (gateway ApiByteLib) CancelFile(param bytecore.ReqCancelFile) (*bytecore.DataCancelFile, error) {
url := gateway.Host() + "/table/cancel-file"
method := "post"
var data bytecore.DataCancelFile
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
}
return &data, nil
}
// 表拆分
// 更新表结构(分表)
// EditTableData 编辑、添加、删除表数据(副表)
func (gateway ApiByteLib) EditTableData(param bytecore.ReqEditTableData) (*bytecore.DataEditTableData, error) {
url := gateway.Host() + "/table/cancel-file"
method := "post"
var data bytecore.DataEditTableData
err := gateway.FastDoRequest(url, method, param, &data)
if err != nil {
return nil, err
}
return &data, nil
}