file_table_edit_data_table_service.go
2.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
package domainService
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository"
)
type EditDataTableService struct {
transactionContext *pgTransaction.TransactionContext
}
// Edit 表结构编辑 【data-table】
func (ptr *EditDataTableService) Edit(ctx *domain.Context, req domain.EditTableRequest) (interface{}, error) {
fileRepository, _ := repository.NewFileRepository(ptr.transactionContext)
file, err := fileRepository.FindOne(map[string]interface{}{"fileId": req.FileId})
if err != nil {
return nil, fmt.Errorf("文件不存在")
}
if file.FileType != domain.TemporaryFile.ToString() {
return nil, fmt.Errorf("文件未校验")
}
// TODO:操作名映射
var operateName string = req.Action
// 日志
if err = FastLog(ptr.transactionContext, domain.VerifiedStepLog, file.FileId, &ExcelTableEditLog{
LogEntry: domain.NewLogEntry(file.FileInfo.Name, domain.VerifiedFile.ToString(), domain.FileVerify, ctx),
ProcessFields: req.ProcessFields,
OperateName: operateName,
}); err != nil {
return nil, err
}
// 通知底层进行文件表编辑
response, err := ByteCore.EditTable(domain.ReqEditDataTable{
FileId: file.FileId,
PageNumber: req.Where.PageNumber,
PageSize: req.Where.PageSize,
Fields: domain.ToFields(req.Fields),
ProcessFields: domain.ToFields(req.ProcessFields),
Action: req.Action,
Params: req.Params,
})
if err != nil {
return nil, err
}
return response, nil
}
func NewEditDataTableService(transactionContext *pgTransaction.TransactionContext) (*EditDataTableService, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &EditDataTableService{
transactionContext: transactionContext,
}, nil
}
}