table_controller.go
10.1 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/query"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/service"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
filecommand "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/command"
fileservice "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/service"
)
type TableController struct {
beego.BaseController
}
func (controller *TableController) CreateTable() {
tableService := service.NewTableService(nil)
createTableCommand := &command.CreateTableCommand{}
controller.Unmarshal(createTableCommand)
data, err := tableService.CreateTable(createTableCommand)
controller.Response(data, err)
}
func (controller *TableController) UpdateTable() {
tableService := service.NewTableService(nil)
updateTableCommand := &command.UpdateTableCommand{}
controller.Unmarshal(updateTableCommand)
tableId, _ := controller.GetInt(":tableId")
updateTableCommand.TableId = tableId
data, err := tableService.UpdateTable(updateTableCommand)
controller.Response(data, err)
}
func (controller *TableController) GetTable() {
tableService := service.NewTableService(nil)
getTableQuery := &query.GetTableQuery{}
tableId, _ := controller.GetInt(":tableId")
getTableQuery.TableId = tableId
data, err := tableService.GetTable(getTableQuery)
controller.Response(data, err)
}
func (controller *TableController) PrepareTable() {
tableService := service.NewTableService(nil)
getTableQuery := &query.GetTableQuery{}
tableId, _ := controller.GetInt("tableId")
getTableQuery.TableId = tableId
data, err := tableService.PrepareSubTable(getTableQuery)
controller.Response(data, err)
}
func (controller *TableController) RemoveTable() {
tableService := service.NewTableService(nil)
removeTableCommand := &command.RemoveTableCommand{}
controller.Unmarshal(removeTableCommand)
tableId, _ := controller.GetInt(":tableId")
removeTableCommand.TableId = tableId
data, err := tableService.RemoveTable(ParseContext(controller.BaseController), removeTableCommand)
controller.Response(data, err)
}
func (controller *TableController) ListTable() {
tableService := service.NewTableService(nil)
listTableQuery := &query.ListTableQuery{}
offset, _ := controller.GetInt("offset")
listTableQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listTableQuery.Limit = limit
data, err := tableService.ListTable(listTableQuery)
controller.Response(data, err)
}
//func (controller *TableController) SplitDataTable() {
// tableService := service.NewTableService(nil)
// splitDataTableCommand := &command.SplitDataTableCommand{}
// controller.Unmarshal(splitDataTableCommand)
// data, err := tableService.SplitDataTable(splitDataTableCommand)
// controller.Response(data, err)
//}
//
//func (controller *TableController) BatchEditSubTable() {
// tableService := service.NewTableService(nil)
// batchEditSubTableCommand := &command.BatchEditSubTableCommand{}
// controller.Unmarshal(batchEditSubTableCommand)
// data, err := tableService.BatchEditSubTable(batchEditSubTableCommand)
// controller.Response(data, err)
//}
func (controller *TableController) CopyDataTable() {
tableService := service.NewTableService(nil)
copyDataTableCommand := &command.CopyDataTableCommand{}
controller.Unmarshal(copyDataTableCommand)
data, err := tableService.CopyDataTable(ParseContext(controller.BaseController), copyDataTableCommand)
controller.Response(data, err)
}
func (controller *TableController) Search() {
tableService := service.NewTableService(nil)
cmd := &query.SearchTableQuery{}
Must(controller.Unmarshal(cmd))
cmd.Context = ParseContext(controller.BaseController)
data, err := tableService.Search(cmd)
controller.Response(data, err)
}
func (controller *TableController) RelationGraph() {
tableService := service.NewTableService(nil)
cmd := &query.SearchTableRelationGraphQuery{}
Must(controller.Unmarshal(cmd))
cmd.TableTypes = []string{domain.MainTable.ToString(), domain.SideTable.ToString(), domain.SubTable.ToString()}
cmd.Context = ParseContext(controller.BaseController)
data, err := tableService.RelationGraph(cmd)
controller.Response(data, err)
}
func (controller *TableController) SearchAppendedList() {
tableService := service.NewTableService(nil)
cmd := &query.SearchTableQuery{}
Must(controller.Unmarshal(cmd))
cmd.TableTypes = []string{domain.MainTable.ToString(), domain.SideTable.ToString()}
cmd.Context = ParseContext(controller.BaseController)
data, err := tableService.Search(cmd)
controller.Response(data, err)
}
func (controller *TableController) SearchSubTableList() {
tableService := service.NewTableService(nil)
cmd := &query.SearchTableQuery{}
Must(controller.Unmarshal(cmd))
cmd.TableTypes = []string{domain.SubTable.ToString()}
cmd.Context = ParseContext(controller.BaseController)
data, err := tableService.Search(cmd)
controller.Response(data, err)
}
func (controller *TableController) SearchQuerySetTables() {
tableService := service.NewTableService(nil)
cmd := &query.SearchTableQuery{}
Must(controller.Unmarshal(cmd))
if len(cmd.TableTypes) == 0 {
cmd.TableTypes = []string{domain.MainTable.ToString(), domain.SideTable.ToString(), domain.SubTable.ToString(), domain.SubProcessTable.ToString()}
}
cmd.Module = domain.ModuleQuerySetCenter
cmd.ReturnDetailStructInfo = true
cmd.Context = ParseContext(controller.BaseController)
data, err := tableService.Search(cmd)
controller.Response(data, err)
}
func (controller *TableController) TableObjectSearch() {
tableService := service.NewTableService(nil)
cmd := &query.SearchTableQuery{}
Must(controller.Unmarshal(cmd))
cmd.Context = ParseContext(controller.BaseController)
data, err := tableService.TableObjectSearch(cmd)
controller.Response(data, err)
}
func (controller *TableController) UpdateTableStruct() {
tableService := service.NewTableService(nil)
cmd := &command.UpdateTableStructCommand{}
controller.Unmarshal(cmd)
tableId, _ := controller.GetInt(":tableId")
cmd.TableId = tableId
data, err := tableService.UpdateTableStruct(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) AddTableStruct() {
tableService := service.NewTableService(nil)
cmd := &command.AddTableStructCommand{}
controller.Unmarshal(cmd)
data, err := tableService.AddTableStruct(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) ApplyOn() {
tableService := service.NewTableService(nil)
cmd := &command.ApplyOnCommand{}
Must(controller.Unmarshal(cmd))
data, err := tableService.ApplyOn(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) ValidExprSql() {
tableService := service.NewTableService(nil)
cmd := &command.ValidExprSqlCommand{}
Must(controller.Unmarshal(cmd))
data, err := tableService.ValidExprSql(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) CheckRowDuplicate() {
tableService := service.NewTableService(nil)
cmd := &command.CheckRowDuplicateCommand{}
Must(controller.Unmarshal(cmd))
data, err := tableService.CheckRowDuplicateV3(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) CheckRowValueDuplicate() {
tableService := service.NewTableService(nil)
cmd := &command.CheckRowDuplicateCommand{}
Must(controller.Unmarshal(cmd))
data, err := tableService.CheckRowDuplicate(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) ExportDataTable() {
tableService := service.NewTableService(nil)
cmd := &command.TablePreviewCommand{}
Must(controller.Unmarshal(cmd))
data, err := tableService.ExportDataTableV2(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) TablePreview() {
tableService := service.NewTableService(nil)
cmd := &command.TablePreviewCommand{}
Must(controller.Unmarshal(cmd))
data, err := tableService.TablePreview(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) DBTablePreview() {
tableService := service.NewTableService(nil)
cmd := &command.DBTablePreviewCommand{}
Must(controller.Unmarshal(cmd))
data, err := tableService.DBTablePreview(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) FieldOptionalValues() {
tableService := service.NewTableService(nil)
cmd := &command.FieldOptionalValuesCommand{}
Must(controller.Unmarshal(cmd))
data, err := tableService.FieldOptionalValues(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *TableController) Preview() {
tableService := service.NewTableService(nil)
fileService := fileservice.NewFileService(nil)
cmd := &struct {
ObjectType string `json:"objectType"`
}{}
Must(controller.Unmarshal(cmd))
var data interface{}
var err error
switch cmd.ObjectType {
case domain.ObjectFile:
cmd := &filecommand.LoadDataTableCommand{}
Must(controller.Unmarshal(cmd))
data, err = fileService.FilePreview(ParseContext(controller.BaseController), cmd)
case domain.ObjectMetaTable:
cmd := &command.TablePreviewCommand{}
Must(controller.Unmarshal(cmd))
data, err = tableService.TablePreview(ParseContext(controller.BaseController), cmd)
case domain.ObjectDBTable:
cmd := &command.DBTablePreviewCommand{}
Must(controller.Unmarshal(cmd))
data, err = tableService.DBTablePreview(ParseContext(controller.BaseController), cmd)
default:
}
controller.Response(data, err)
}
func (controller *TableController) RowEdit() {
tableService := service.NewTableService(nil)
cmd := &command.RowEditCommandV2{}
Must(controller.Unmarshal(cmd))
data, err := tableService.RowEditV2(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}