fast_domain_repository.go
4.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
133
134
135
136
137
138
139
package factory
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
)
// FastPgFile 快速返回文件对象
//
// transactionContext 事务
// id 对象唯一标识
func FastPgFile(transactionContext application.TransactionContext, id int) (domain.FileRepository, *domain.File, error) {
var rep domain.FileRepository
var mod *domain.File
var err error
if value, err := CreateFileRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"fileId": id}); err != nil {
if err == domain.ErrorNotFound {
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该文件不存在")
}
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
//if err = fastPgDataAuth(transactionContext, mod, options...); err != nil {
// return nil, nil, err
//}
return rep, mod, err
}
// FastPgTable 快速返回表格对象
//
// transactionContext 事务
// id 对象唯一标识
func FastPgTable(transactionContext application.TransactionContext, id int) (domain.TableRepository, *domain.Table, error) {
var rep domain.TableRepository
var mod *domain.Table
var err error
if value, err := CreateTableRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"tableId": id}); err != nil {
if err == domain.ErrorNotFound {
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该表格不存在")
}
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}
// FastPgLog 快速返回日志对象
//
// transactionContext 事务
// id 对象唯一标识
func FastPgLog(transactionContext application.TransactionContext, id int) (domain.LogRepository, *domain.Log, error) {
var rep domain.LogRepository
var mod *domain.Log
var err error
if value, err := CreateLogRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"logId": id}); err != nil {
if err == domain.ErrorNotFound {
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该日志不存在")
}
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}
// FastPgMappingRule 快速返回匹配规则对象
//
// transactionContext 事务
// id 对象唯一标识
func FastPgMappingRule(transactionContext application.TransactionContext, id int) (domain.MappingRuleRepository, *domain.MappingRule, error) {
var rep domain.MappingRuleRepository
var mod *domain.MappingRule
var err error
if value, err := CreateMappingRuleRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"mappingRuleId": id}); err != nil {
if err == domain.ErrorNotFound {
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该匹配规则不存在")
}
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}
// FastPgQuerySet 快速返回查询集合
//
// transactionContext 事务
// id 对象唯一标识
func FastPgQuerySet(transactionContext application.TransactionContext, id int) (domain.QuerySetRepository, *domain.QuerySet, error) {
var rep domain.QuerySetRepository
var mod *domain.QuerySet
var err error
if value, err := CreateQuerySetRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if id > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"querySetId": id}); err != nil {
if err == domain.ErrorNotFound {
return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该查询集合不存在")
}
return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}