file_controller.go
5.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
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
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)
ctx := ParseContext(controller.BaseController)
data, err := fileService.CreateFile(ctx, createFileCommand)
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
data, err := fileService.GetFile(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(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))
cmd.FileType = domain.SourceFile
cmd.Context = ParseContext(controller.BaseController)
data, err := fileService.SearchFile(cmd)
controller.Response(data, err)
}
func (controller *FileController) SearchVerifiedFile() {
fileService := service.NewFileService(nil)
cmd := &query.SearchFileQuery{}
Must(controller.Unmarshal(cmd))
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) 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) CancelVerifyingFile() {
fileService := service.NewFileService(nil)
cmd := &command.CancelVerifyingFileCommand{}
controller.Unmarshal(cmd)
data, err := fileService.CancelVerifyingFile(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}