file_controller.go
8.8 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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/command"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/query"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/service"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
)
type FileController struct {
beego.BaseController
}
func (controller *FileController) CreateFile() {
fileService := service.NewFileService(nil)
createFileCommand := &command.CreateFileCommand{}
controller.Unmarshal(createFileCommand)
createFileCommand.FileFrom = domain.FileFromByteBankWebClient
ctx := ParseContext(controller.BaseController)
data, err := fileService.CreateFile(ctx, createFileCommand)
controller.Response(data, err)
}
func (controller *FileController) CreateAppTableFile() {
fileService := service.NewFileService(nil)
createDigitalAppFileCommand := &command.CreateAppTableFileCommand{}
controller.Unmarshal(createDigitalAppFileCommand)
ctx := ParseContext(controller.BaseController)
createFileCommand, err := fileService.CreateAppTableFile(ctx, createDigitalAppFileCommand)
if err != nil {
controller.Response(nil, err)
return
}
createFileCommand.AppKey = ParseAppKey(controller.BaseController)
data, err := fileService.CreateFile(&domain.Context{}, createFileCommand)
controller.Response(data, err)
}
func (controller *FileController) DeleteAppTableFile() {
fileService := service.NewFileService(nil)
cmd := &command.DeleteAppTableFileCommand{}
controller.Unmarshal(cmd)
cmd.AppKey = ParseAppKey(controller.BaseController)
data, err := fileService.DeleteAppTableFile(&domain.Context{}, cmd)
controller.Response(data, err)
}
func (controller *FileController) AppendDataAppTableFile() {
fileService := service.NewFileService(nil)
cmd := &command.AppTableFileAppendDataCommand{}
controller.Unmarshal(cmd)
cmd.AppKey = ParseAppKey(controller.BaseController)
data, err := fileService.AppTableFileAppendData(&domain.Context{}, cmd)
controller.Response(data, err)
}
func (controller *FileController) ListAppTableFile() {
fileService := service.NewFileService(nil)
cmd := &query.ListAppTableFileCommand{}
controller.Unmarshal(cmd)
cmd.AppKey = ParseAppKey(controller.BaseController)
data, err := fileService.AppTableFileList(&domain.Context{}, cmd)
controller.Response(data, err)
}
func (controller *FileController) UpdateFile() {
fileService := service.NewFileService(nil)
updateFileCommand := &command.UpdateFileCommand{}
controller.Unmarshal(updateFileCommand)
fileId, _ := controller.GetInt(":fileId")
updateFileCommand.FileId = fileId
data, err := fileService.UpdateFile(updateFileCommand)
controller.Response(data, err)
}
func (controller *FileController) GetFile() {
fileService := service.NewFileService(nil)
getFileQuery := &query.GetFileQuery{}
fileId, _ := controller.GetInt(":fileId")
getFileQuery.FileId = fileId
getFileQuery.FileName = controller.GetString("name")
getFileQuery.FileType = controller.GetString("type")
data, err := fileService.GetFile(ParseContext(controller.BaseController), getFileQuery)
controller.Response(data, err)
}
func (controller *FileController) RemoveFile() {
fileService := service.NewFileService(nil)
removeFileCommand := &command.RemoveFileCommand{}
controller.Unmarshal(removeFileCommand)
fileId, _ := controller.GetInt(":fileId")
removeFileCommand.FileId = fileId
data, err := fileService.RemoveFile(ParseContext(controller.BaseController), removeFileCommand)
controller.Response(data, err)
}
func (controller *FileController) ListFile() {
fileService := service.NewFileService(nil)
listFileQuery := &query.ListFileQuery{}
offset, _ := controller.GetInt("offset")
listFileQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listFileQuery.Limit = limit
data, err := fileService.ListFile(listFileQuery)
controller.Response(data, err)
}
func (controller *FileController) SearchFile() {
fileService := service.NewFileService(nil)
cmd := &query.SearchFileQuery{}
Must(controller.Unmarshal(cmd))
cmd.Context = ParseContext(controller.BaseController)
data, err := fileService.SearchFile(cmd)
controller.Response(data, err)
}
func (controller *FileController) SearchSourceFile() {
fileService := service.NewFileService(nil)
cmd := &query.SearchFileQuery{}
Must(controller.Unmarshal(cmd))
if cmd.PageSize == 0 {
cmd.PageSize = domain.MaxQueryRow
}
cmd.FileType = domain.SourceFile
cmd.Context = ParseContext(controller.BaseController)
data, err := fileService.SearchFile(cmd)
controller.Response(data, err)
}
func (controller *FileController) SearchAppSourceFile() {
fileService := service.NewFileService(nil)
cmd := &query.SearchFileQuery{}
Must(controller.Unmarshal(cmd))
if cmd.PageSize == 0 {
cmd.PageSize = domain.MaxQueryRow
}
cmd.FileType = domain.SourceFile
data, err := fileService.SearchAppFile(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *FileController) GetAppFile() {
fileService := service.NewFileService(nil)
appKey := controller.GetString("app_key", "")
data, err := fileService.GetAppFile(ParseContext(controller.BaseController), appKey, "")
controller.Response(data, err)
}
func (controller *FileController) SearchVerifiedFile() {
fileService := service.NewFileService(nil)
cmd := &query.SearchFileQuery{}
Must(controller.Unmarshal(cmd))
if cmd.PageSize == 0 {
cmd.PageSize = domain.MaxQueryRow
}
cmd.FileType = domain.VerifiedFile
cmd.Context = ParseContext(controller.BaseController)
data, err := fileService.SearchFile(cmd)
controller.Response(data, err)
}
func (controller *FileController) FilePreview() {
fileService := service.NewFileService(nil)
loadDataTableCommand := &command.LoadDataTableCommand{}
controller.Unmarshal(loadDataTableCommand)
data, err := fileService.FilePreview(ParseContext(controller.BaseController), loadDataTableCommand)
controller.Response(data, err)
}
func (controller *FileController) PrepareTemporaryFile() {
fileService := service.NewFileService(nil)
loadDataTableCommand := &command.PrepareTemporaryFileCommand{}
controller.Unmarshal(loadDataTableCommand)
data, err := fileService.PrepareTemporaryFile(ParseContext(controller.BaseController), loadDataTableCommand)
controller.Response(data, err)
}
func (controller *FileController) EditDataTable() {
fileService := service.NewFileService(nil)
editDataTableCommand := &command.EditDataTableCommand{}
Must(controller.Unmarshal(editDataTableCommand))
data, err := fileService.EditDataTable(ParseContext(controller.BaseController), editDataTableCommand)
controller.Response(data, err)
}
func (controller *FileController) FlushDataTable() {
fileService := service.NewFileService(nil)
flushDataTableCommand := &command.FlushDataTableCommand{}
controller.Unmarshal(flushDataTableCommand)
data, err := fileService.FlushDataTable(ParseContext(controller.BaseController), flushDataTableCommand)
controller.Response(data, err)
}
func (controller *FileController) GenerateMainTable() {
fileService := service.NewFileService(nil)
generateMainTableCommand := &command.GenerateMainTableCommand{}
controller.Unmarshal(generateMainTableCommand)
data, err := fileService.GenerateMainTable(ParseContext(controller.BaseController), generateMainTableCommand)
controller.Response(data, err)
}
func (controller *FileController) AppendDataToTable() {
fileService := service.NewFileService(nil)
cmd := &command.AppendDataToTableCommand{}
controller.Unmarshal(cmd)
data, err := fileService.AppendDataToTable(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *FileController) AppendDataToTablePreflightCheck() {
fileService := service.NewFileService(nil)
cmd := &command.AppendDataToTableCommand{}
controller.Unmarshal(cmd)
data, err := fileService.AppendDataToTablePreflightCheck(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *FileController) CancelVerifyingFile() {
fileService := service.NewFileService(nil)
cmd := &command.CancelVerifyingFileCommand{}
controller.Unmarshal(cmd)
data, err := fileService.CancelVerifyingFile(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *FileController) CheckFileVerifyStatus() {
fileService := service.NewFileService(nil)
cmd := &command.CheckFileVerifyStatusCommand{}
controller.Unmarshal(cmd)
data, err := fileService.CheckFileVerifyStatus(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *FileController) ExportFile() {
fileService := service.NewFileService(nil)
cmd := &command.ExportFileCommand{}
controller.Unmarshal(cmd)
data, err := fileService.ExportFile(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}