正在显示
13 个修改的文件
包含
154 行增加
和
55 行删除
@@ -31,3 +31,10 @@ type Relevant struct { | @@ -31,3 +31,10 @@ type Relevant struct { | ||
31 | // 公司 | 31 | // 公司 |
32 | Company *Company `json:"company"` | 32 | Company *Company `json:"company"` |
33 | } | 33 | } |
34 | + | ||
35 | +func (relevant *Relevant) Identify() interface{} { | ||
36 | + if relevant.RelevantId == 0 { | ||
37 | + return nil | ||
38 | + } | ||
39 | + return relevant.RelevantId | ||
40 | +} |
@@ -37,3 +37,10 @@ type Undertaker struct { | @@ -37,3 +37,10 @@ type Undertaker struct { | ||
37 | // 合同附件 | 37 | // 合同附件 |
38 | ContractAttachment []*Attachment `json:"contractAttachment"` | 38 | ContractAttachment []*Attachment `json:"contractAttachment"` |
39 | } | 39 | } |
40 | + | ||
41 | +func (undertaker *Undertaker) Identify() interface{} { | ||
42 | + if undertaker.UndertakerId == 0 { | ||
43 | + return nil | ||
44 | + } | ||
45 | + return undertaker.UndertakerId | ||
46 | +} |
@@ -15,14 +15,11 @@ import ( | @@ -15,14 +15,11 @@ import ( | ||
15 | 15 | ||
16 | type ContractUndertakerFeedbackRepository struct { | 16 | type ContractUndertakerFeedbackRepository struct { |
17 | transactionContext *pgTransaction.TransactionContext | 17 | transactionContext *pgTransaction.TransactionContext |
18 | + IdWorker *snowflake.IdWorker | ||
18 | } | 19 | } |
19 | 20 | ||
20 | func (repository *ContractUndertakerFeedbackRepository) nextIdentify() (int64, error) { | 21 | func (repository *ContractUndertakerFeedbackRepository) nextIdentify() (int64, error) { |
21 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
22 | - if err != nil { | ||
23 | - return 0, err | ||
24 | - } | ||
25 | - id, err := IdWorker.NextId() | 22 | + id, err := repository.IdWorker.NextId() |
26 | return id, err | 23 | return id, err |
27 | } | 24 | } |
28 | 25 | ||
@@ -202,8 +199,13 @@ func NewContractUndertakerFeedbackRepository(transactionContext *pgTransaction.T | @@ -202,8 +199,13 @@ func NewContractUndertakerFeedbackRepository(transactionContext *pgTransaction.T | ||
202 | if transactionContext == nil { | 199 | if transactionContext == nil { |
203 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 200 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
204 | } else { | 201 | } else { |
202 | + idWorker, err := snowflake.NewIdWorker(1) | ||
203 | + if err != nil { | ||
204 | + return nil, err | ||
205 | + } | ||
205 | return &ContractUndertakerFeedbackRepository{ | 206 | return &ContractUndertakerFeedbackRepository{ |
206 | transactionContext: transactionContext, | 207 | transactionContext: transactionContext, |
208 | + IdWorker: idWorker, | ||
207 | }, nil | 209 | }, nil |
208 | } | 210 | } |
209 | } | 211 | } |
@@ -17,14 +17,11 @@ import ( | @@ -17,14 +17,11 @@ import ( | ||
17 | 17 | ||
18 | type CooperationApplicationRepository struct { | 18 | type CooperationApplicationRepository struct { |
19 | transactionContext *pgTransaction.TransactionContext | 19 | transactionContext *pgTransaction.TransactionContext |
20 | + IdWorker *snowflake.IdWorker | ||
20 | } | 21 | } |
21 | 22 | ||
22 | func (repository *CooperationApplicationRepository) nextIdentify() (int64, error) { | 23 | func (repository *CooperationApplicationRepository) nextIdentify() (int64, error) { |
23 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
24 | - if err != nil { | ||
25 | - return 0, err | ||
26 | - } | ||
27 | - id, err := IdWorker.NextId() | 24 | + id, err := repository.IdWorker.NextId() |
28 | return id, err | 25 | return id, err |
29 | } | 26 | } |
30 | 27 | ||
@@ -322,8 +319,13 @@ func NewCooperationApplicationRepository(transactionContext *pgTransaction.Trans | @@ -322,8 +319,13 @@ func NewCooperationApplicationRepository(transactionContext *pgTransaction.Trans | ||
322 | if transactionContext == nil { | 319 | if transactionContext == nil { |
323 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 320 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
324 | } else { | 321 | } else { |
322 | + idWorker, err := snowflake.NewIdWorker(1) | ||
323 | + if err != nil { | ||
324 | + return nil, err | ||
325 | + } | ||
325 | return &CooperationApplicationRepository{ | 326 | return &CooperationApplicationRepository{ |
326 | transactionContext: transactionContext, | 327 | transactionContext: transactionContext, |
328 | + IdWorker: idWorker, | ||
327 | }, nil | 329 | }, nil |
328 | } | 330 | } |
329 | } | 331 | } |
@@ -15,14 +15,11 @@ import ( | @@ -15,14 +15,11 @@ import ( | ||
15 | 15 | ||
16 | type CooperationContractChangeLogRepository struct { | 16 | type CooperationContractChangeLogRepository struct { |
17 | transactionContext *pgTransaction.TransactionContext | 17 | transactionContext *pgTransaction.TransactionContext |
18 | + IdWorker *snowflake.IdWorker | ||
18 | } | 19 | } |
19 | 20 | ||
20 | func (repository *CooperationContractChangeLogRepository) nextIdentify() (int64, error) { | 21 | func (repository *CooperationContractChangeLogRepository) nextIdentify() (int64, error) { |
21 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
22 | - if err != nil { | ||
23 | - return 0, err | ||
24 | - } | ||
25 | - id, err := IdWorker.NextId() | 22 | + id, err := repository.IdWorker.NextId() |
26 | return id, err | 23 | return id, err |
27 | } | 24 | } |
28 | 25 | ||
@@ -198,8 +195,13 @@ func NewCooperationContractChangeLogRepository(transactionContext *pgTransaction | @@ -198,8 +195,13 @@ func NewCooperationContractChangeLogRepository(transactionContext *pgTransaction | ||
198 | if transactionContext == nil { | 195 | if transactionContext == nil { |
199 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 196 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
200 | } else { | 197 | } else { |
198 | + idWorker, err := snowflake.NewIdWorker(1) | ||
199 | + if err != nil { | ||
200 | + return nil, err | ||
201 | + } | ||
201 | return &CooperationContractChangeLogRepository{ | 202 | return &CooperationContractChangeLogRepository{ |
202 | transactionContext: transactionContext, | 203 | transactionContext: transactionContext, |
204 | + IdWorker: idWorker, | ||
203 | }, nil | 205 | }, nil |
204 | } | 206 | } |
205 | } | 207 | } |
@@ -15,14 +15,11 @@ import ( | @@ -15,14 +15,11 @@ import ( | ||
15 | 15 | ||
16 | type CooperationContractRelevantRepository struct { | 16 | type CooperationContractRelevantRepository struct { |
17 | transactionContext *pgTransaction.TransactionContext | 17 | transactionContext *pgTransaction.TransactionContext |
18 | + IdWorker *snowflake.IdWorker | ||
18 | } | 19 | } |
19 | 20 | ||
20 | func (repository *CooperationContractRelevantRepository) nextIdentify() (int64, error) { | 21 | func (repository *CooperationContractRelevantRepository) nextIdentify() (int64, error) { |
21 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
22 | - if err != nil { | ||
23 | - return 0, err | ||
24 | - } | ||
25 | - id, err := IdWorker.NextId() | 22 | + id, err := repository.IdWorker.NextId() |
26 | return id, err | 23 | return id, err |
27 | } | 24 | } |
28 | 25 | ||
@@ -210,8 +207,13 @@ func NewCooperationContractRelevantRepository(transactionContext *pgTransaction. | @@ -210,8 +207,13 @@ func NewCooperationContractRelevantRepository(transactionContext *pgTransaction. | ||
210 | if transactionContext == nil { | 207 | if transactionContext == nil { |
211 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 208 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
212 | } else { | 209 | } else { |
210 | + idWorker, err := snowflake.NewIdWorker(1) | ||
211 | + if err != nil { | ||
212 | + return nil, err | ||
213 | + } | ||
213 | return &CooperationContractRelevantRepository{ | 214 | return &CooperationContractRelevantRepository{ |
214 | transactionContext: transactionContext, | 215 | transactionContext: transactionContext, |
216 | + IdWorker: idWorker, | ||
215 | }, nil | 217 | }, nil |
216 | } | 218 | } |
217 | } | 219 | } |
@@ -16,14 +16,11 @@ import ( | @@ -16,14 +16,11 @@ import ( | ||
16 | 16 | ||
17 | type CooperationContractRepository struct { | 17 | type CooperationContractRepository struct { |
18 | transactionContext *pgTransaction.TransactionContext | 18 | transactionContext *pgTransaction.TransactionContext |
19 | + IdWorker *snowflake.IdWorker | ||
19 | } | 20 | } |
20 | 21 | ||
21 | func (repository *CooperationContractRepository) nextIdentify() (int64, error) { | 22 | func (repository *CooperationContractRepository) nextIdentify() (int64, error) { |
22 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
23 | - if err != nil { | ||
24 | - return 0, err | ||
25 | - } | ||
26 | - id, err := IdWorker.NextId() | 23 | + id, err := repository.IdWorker.NextId() |
27 | return id, err | 24 | return id, err |
28 | } | 25 | } |
29 | 26 | ||
@@ -108,7 +105,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -108,7 +105,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
108 | // 新增相关人 | 105 | // 新增相关人 |
109 | var relevantPeopleModel []*models.CooperationContractRelevant | 106 | var relevantPeopleModel []*models.CooperationContractRelevant |
110 | for _, relevant := range cooperationContract.RelevantPeople { | 107 | for _, relevant := range cooperationContract.RelevantPeople { |
108 | + if relevant.Identify() == nil { | ||
109 | + orderGoodId, err := repository.nextIdentify() | ||
110 | + if err != nil { | ||
111 | + return nil, err | ||
112 | + } else { | ||
113 | + relevant.RelevantId = orderGoodId | ||
114 | + } | ||
115 | + } | ||
111 | relevantPeopleModel = append(relevantPeopleModel, &models.CooperationContractRelevant{ | 116 | relevantPeopleModel = append(relevantPeopleModel, &models.CooperationContractRelevant{ |
117 | + CooperationContractRelevantId: relevant.RelevantId, | ||
112 | CooperationContractNumber: cooperationContract.CooperationContractNumber, | 118 | CooperationContractNumber: cooperationContract.CooperationContractNumber, |
113 | UserId: relevant.UserId, | 119 | UserId: relevant.UserId, |
114 | UserBaseId: relevant.UserBaseId, | 120 | UserBaseId: relevant.UserBaseId, |
@@ -169,7 +175,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -169,7 +175,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
169 | // 新增分红激励规则 | 175 | // 新增分红激励规则 |
170 | var dividendsIncentivesRulesModel []*models.DividendsIncentivesRule | 176 | var dividendsIncentivesRulesModel []*models.DividendsIncentivesRule |
171 | for _, rule := range cooperationContract.DividendsIncentivesRules { | 177 | for _, rule := range cooperationContract.DividendsIncentivesRules { |
178 | + if rule.Identify() == nil { | ||
179 | + ruleId, err := repository.nextIdentify() | ||
180 | + if err != nil { | ||
181 | + return nil, err | ||
182 | + } else { | ||
183 | + rule.DividendsIncentivesRuleId = ruleId | ||
184 | + } | ||
185 | + } | ||
172 | dividendsIncentivesRulesModel = append(dividendsIncentivesRulesModel, &models.DividendsIncentivesRule{ | 186 | dividendsIncentivesRulesModel = append(dividendsIncentivesRulesModel, &models.DividendsIncentivesRule{ |
187 | + DividendsIncentivesRuleId: rule.DividendsIncentivesRuleId, | ||
173 | CooperationContractNumber: cooperationContract.CooperationContractNumber, | 188 | CooperationContractNumber: cooperationContract.CooperationContractNumber, |
174 | ReferrerPercentage: rule.ReferrerPercentage, | 189 | ReferrerPercentage: rule.ReferrerPercentage, |
175 | SalesmanPercentage: rule.SalesmanPercentage, | 190 | SalesmanPercentage: rule.SalesmanPercentage, |
@@ -197,7 +212,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -197,7 +212,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
197 | // 新增金额激励规则 | 212 | // 新增金额激励规则 |
198 | var moneyIncentivesRulesModel []*models.MoneyIncentivesRule | 213 | var moneyIncentivesRulesModel []*models.MoneyIncentivesRule |
199 | for _, rule := range cooperationContract.MoneyIncentivesRules { | 214 | for _, rule := range cooperationContract.MoneyIncentivesRules { |
215 | + if rule.Identify() == nil { | ||
216 | + ruleId, err := repository.nextIdentify() | ||
217 | + if err != nil { | ||
218 | + return nil, err | ||
219 | + } else { | ||
220 | + rule.MoneyIncentivesRuleId = ruleId | ||
221 | + } | ||
222 | + } | ||
200 | moneyIncentivesRulesModel = append(moneyIncentivesRulesModel, &models.MoneyIncentivesRule{ | 223 | moneyIncentivesRulesModel = append(moneyIncentivesRulesModel, &models.MoneyIncentivesRule{ |
224 | + MoneyIncentivesRuleId: rule.MoneyIncentivesRuleId, | ||
201 | CooperationContractNumber: cooperationContract.CooperationContractNumber, | 225 | CooperationContractNumber: cooperationContract.CooperationContractNumber, |
202 | MoneyIncentivesAmount: rule.MoneyIncentivesAmount, | 226 | MoneyIncentivesAmount: rule.MoneyIncentivesAmount, |
203 | MoneyIncentivesStage: rule.MoneyIncentivesStage, | 227 | MoneyIncentivesStage: rule.MoneyIncentivesStage, |
@@ -302,7 +326,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -302,7 +326,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
302 | // 将待添加的相关人领域模型转换为数据模型 | 326 | // 将待添加的相关人领域模型转换为数据模型 |
303 | var cooperationContractRelevantPeopleToAddModels []*models.CooperationContractRelevant | 327 | var cooperationContractRelevantPeopleToAddModels []*models.CooperationContractRelevant |
304 | for _, relevantDomain := range cooperationContractRelevantPeopleToAdd { | 328 | for _, relevantDomain := range cooperationContractRelevantPeopleToAdd { |
329 | + if relevantDomain.Identify() == nil { | ||
330 | + relevantId, err := repository.nextIdentify() | ||
331 | + if err != nil { | ||
332 | + return nil, err | ||
333 | + } else { | ||
334 | + relevantDomain.RelevantId = relevantId | ||
335 | + } | ||
336 | + } | ||
305 | cooperationContractRelevantPeopleToAddModels = append(cooperationContractRelevantPeopleToAddModels, &models.CooperationContractRelevant{ | 337 | cooperationContractRelevantPeopleToAddModels = append(cooperationContractRelevantPeopleToAddModels, &models.CooperationContractRelevant{ |
338 | + CooperationContractRelevantId: relevantDomain.RelevantId, | ||
306 | CooperationContractNumber: relevantDomain.CooperationContractNumber, | 339 | CooperationContractNumber: relevantDomain.CooperationContractNumber, |
307 | UserId: relevantDomain.UserId, | 340 | UserId: relevantDomain.UserId, |
308 | UserBaseId: relevantDomain.UserBaseId, | 341 | UserBaseId: relevantDomain.UserBaseId, |
@@ -401,7 +434,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -401,7 +434,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
401 | // 将待添加的相关人领域模型转换为数据模型 | 434 | // 将待添加的相关人领域模型转换为数据模型 |
402 | var cooperationContractUndertakersToAddModels []*models.CooperationContractUndertaker | 435 | var cooperationContractUndertakersToAddModels []*models.CooperationContractUndertaker |
403 | for _, undertakerDomain := range cooperationContractUndertakersToAdd { | 436 | for _, undertakerDomain := range cooperationContractUndertakersToAdd { |
437 | + if undertakerDomain.Identify() == nil { | ||
438 | + undertakerId, err := repository.nextIdentify() | ||
439 | + if err != nil { | ||
440 | + return nil, err | ||
441 | + } else { | ||
442 | + undertakerDomain.UndertakerId = undertakerId | ||
443 | + } | ||
444 | + } | ||
404 | cooperationContractUndertakersToAddModels = append(cooperationContractUndertakersToAddModels, &models.CooperationContractUndertaker{ | 445 | cooperationContractUndertakersToAddModels = append(cooperationContractUndertakersToAddModels, &models.CooperationContractUndertaker{ |
446 | + CooperationContractUndertakerId: undertakerDomain.UndertakerId, | ||
405 | CooperationContractNumber: undertakerDomain.CooperationContractNumber, | 447 | CooperationContractNumber: undertakerDomain.CooperationContractNumber, |
406 | UserId: undertakerDomain.UserId, | 448 | UserId: undertakerDomain.UserId, |
407 | UserBaseId: undertakerDomain.UserBaseId, | 449 | UserBaseId: undertakerDomain.UserBaseId, |
@@ -534,7 +576,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -534,7 +576,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
534 | // 将待添加的分红激励规则领域模型转换为数据模型 | 576 | // 将待添加的分红激励规则领域模型转换为数据模型 |
535 | var dividendsIncentivesRulesToAddModels []*models.DividendsIncentivesRule | 577 | var dividendsIncentivesRulesToAddModels []*models.DividendsIncentivesRule |
536 | for _, dividendsIncentivesRuleDomain := range dividendsIncentivesRulesToAdd { | 578 | for _, dividendsIncentivesRuleDomain := range dividendsIncentivesRulesToAdd { |
579 | + if dividendsIncentivesRuleDomain.Identify() == nil { | ||
580 | + ruleId, err := repository.nextIdentify() | ||
581 | + if err != nil { | ||
582 | + return nil, err | ||
583 | + } else { | ||
584 | + dividendsIncentivesRuleDomain.DividendsIncentivesRuleId = ruleId | ||
585 | + } | ||
586 | + } | ||
537 | dividendsIncentivesRulesToAddModels = append(dividendsIncentivesRulesToAddModels, &models.DividendsIncentivesRule{ | 587 | dividendsIncentivesRulesToAddModels = append(dividendsIncentivesRulesToAddModels, &models.DividendsIncentivesRule{ |
588 | + DividendsIncentivesRuleId: dividendsIncentivesRuleDomain.DividendsIncentivesRuleId, | ||
538 | CooperationContractNumber: dividendsIncentivesRuleDomain.CooperationContractNumber, | 589 | CooperationContractNumber: dividendsIncentivesRuleDomain.CooperationContractNumber, |
539 | ReferrerPercentage: dividendsIncentivesRuleDomain.ReferrerPercentage, | 590 | ReferrerPercentage: dividendsIncentivesRuleDomain.ReferrerPercentage, |
540 | SalesmanPercentage: dividendsIncentivesRuleDomain.SalesmanPercentage, | 591 | SalesmanPercentage: dividendsIncentivesRuleDomain.SalesmanPercentage, |
@@ -657,7 +708,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -657,7 +708,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
657 | // 将待添加的金额激励规则领域模型转换为数据模型 | 708 | // 将待添加的金额激励规则领域模型转换为数据模型 |
658 | var moneyIncentivesRulesToAddModels []*models.MoneyIncentivesRule | 709 | var moneyIncentivesRulesToAddModels []*models.MoneyIncentivesRule |
659 | for _, moneyIncentivesRuleDomain := range moneyIncentivesRulesToAdd { | 710 | for _, moneyIncentivesRuleDomain := range moneyIncentivesRulesToAdd { |
711 | + if moneyIncentivesRuleDomain.Identify() == nil { | ||
712 | + ruleId, err := repository.nextIdentify() | ||
713 | + if err != nil { | ||
714 | + return nil, err | ||
715 | + } else { | ||
716 | + moneyIncentivesRuleDomain.MoneyIncentivesRuleId = ruleId | ||
717 | + } | ||
718 | + } | ||
660 | moneyIncentivesRulesToAddModels = append(moneyIncentivesRulesToAddModels, &models.MoneyIncentivesRule{ | 719 | moneyIncentivesRulesToAddModels = append(moneyIncentivesRulesToAddModels, &models.MoneyIncentivesRule{ |
720 | + MoneyIncentivesRuleId: moneyIncentivesRuleDomain.MoneyIncentivesRuleId, | ||
661 | CooperationContractNumber: moneyIncentivesRuleDomain.CooperationContractNumber, | 721 | CooperationContractNumber: moneyIncentivesRuleDomain.CooperationContractNumber, |
662 | MoneyIncentivesAmount: moneyIncentivesRuleDomain.MoneyIncentivesAmount, | 722 | MoneyIncentivesAmount: moneyIncentivesRuleDomain.MoneyIncentivesAmount, |
663 | MoneyIncentivesStage: moneyIncentivesRuleDomain.MoneyIncentivesStage, | 723 | MoneyIncentivesStage: moneyIncentivesRuleDomain.MoneyIncentivesStage, |
@@ -1175,8 +1235,13 @@ func NewCooperationContractRepository(transactionContext *pgTransaction.Transact | @@ -1175,8 +1235,13 @@ func NewCooperationContractRepository(transactionContext *pgTransaction.Transact | ||
1175 | if transactionContext == nil { | 1235 | if transactionContext == nil { |
1176 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 1236 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
1177 | } else { | 1237 | } else { |
1238 | + idWorker, err := snowflake.NewIdWorker(1) | ||
1239 | + if err != nil { | ||
1240 | + return nil, err | ||
1241 | + } | ||
1178 | return &CooperationContractRepository{ | 1242 | return &CooperationContractRepository{ |
1179 | transactionContext: transactionContext, | 1243 | transactionContext: transactionContext, |
1244 | + IdWorker: idWorker, | ||
1180 | }, nil | 1245 | }, nil |
1181 | } | 1246 | } |
1182 | } | 1247 | } |
@@ -15,14 +15,11 @@ import ( | @@ -15,14 +15,11 @@ import ( | ||
15 | 15 | ||
16 | type CooperationContractUndertakerRepository struct { | 16 | type CooperationContractUndertakerRepository struct { |
17 | transactionContext *pgTransaction.TransactionContext | 17 | transactionContext *pgTransaction.TransactionContext |
18 | + IdWorker *snowflake.IdWorker | ||
18 | } | 19 | } |
19 | 20 | ||
20 | func (repository *CooperationContractUndertakerRepository) nextIdentify() (int64, error) { | 21 | func (repository *CooperationContractUndertakerRepository) nextIdentify() (int64, error) { |
21 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
22 | - if err != nil { | ||
23 | - return 0, err | ||
24 | - } | ||
25 | - id, err := IdWorker.NextId() | 22 | + id, err := repository.IdWorker.NextId() |
26 | return id, err | 23 | return id, err |
27 | } | 24 | } |
28 | 25 | ||
@@ -225,8 +222,13 @@ func NewCooperationContractUndertakerRepository(transactionContext *pgTransactio | @@ -225,8 +222,13 @@ func NewCooperationContractUndertakerRepository(transactionContext *pgTransactio | ||
225 | if transactionContext == nil { | 222 | if transactionContext == nil { |
226 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 223 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
227 | } else { | 224 | } else { |
225 | + idWorker, err := snowflake.NewIdWorker(1) | ||
226 | + if err != nil { | ||
227 | + return nil, err | ||
228 | + } | ||
228 | return &CooperationContractUndertakerRepository{ | 229 | return &CooperationContractUndertakerRepository{ |
229 | transactionContext: transactionContext, | 230 | transactionContext: transactionContext, |
231 | + IdWorker: idWorker, | ||
230 | }, nil | 232 | }, nil |
231 | } | 233 | } |
232 | } | 234 | } |
@@ -14,14 +14,11 @@ import ( | @@ -14,14 +14,11 @@ import ( | ||
14 | 14 | ||
15 | type CooperationModeRepository struct { | 15 | type CooperationModeRepository struct { |
16 | transactionContext *pgTransaction.TransactionContext | 16 | transactionContext *pgTransaction.TransactionContext |
17 | + IdWorker *snowflake.IdWorker | ||
17 | } | 18 | } |
18 | 19 | ||
19 | func (repository *CooperationModeRepository) nextIdentify() (int64, error) { | 20 | func (repository *CooperationModeRepository) nextIdentify() (int64, error) { |
20 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
21 | - if err != nil { | ||
22 | - return 0, err | ||
23 | - } | ||
24 | - id, err := IdWorker.NextId() | 21 | + id, err := repository.IdWorker.NextId() |
25 | return id, err | 22 | return id, err |
26 | } | 23 | } |
27 | 24 | ||
@@ -221,8 +218,13 @@ func NewCooperationModeRepository(transactionContext *pgTransaction.TransactionC | @@ -221,8 +218,13 @@ func NewCooperationModeRepository(transactionContext *pgTransaction.TransactionC | ||
221 | if transactionContext == nil { | 218 | if transactionContext == nil { |
222 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 219 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
223 | } else { | 220 | } else { |
221 | + idWorker, err := snowflake.NewIdWorker(1) | ||
222 | + if err != nil { | ||
223 | + return nil, err | ||
224 | + } | ||
224 | return &CooperationModeRepository{ | 225 | return &CooperationModeRepository{ |
225 | transactionContext: transactionContext, | 226 | transactionContext: transactionContext, |
227 | + IdWorker: idWorker, | ||
226 | }, nil | 228 | }, nil |
227 | } | 229 | } |
228 | } | 230 | } |
@@ -17,14 +17,11 @@ import ( | @@ -17,14 +17,11 @@ import ( | ||
17 | 17 | ||
18 | type CooperationProjectRepository struct { | 18 | type CooperationProjectRepository struct { |
19 | transactionContext *pgTransaction.TransactionContext | 19 | transactionContext *pgTransaction.TransactionContext |
20 | + IdWorker *snowflake.IdWorker | ||
20 | } | 21 | } |
21 | 22 | ||
22 | func (repository *CooperationProjectRepository) nextIdentify() (int64, error) { | 23 | func (repository *CooperationProjectRepository) nextIdentify() (int64, error) { |
23 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
24 | - if err != nil { | ||
25 | - return 0, err | ||
26 | - } | ||
27 | - id, err := IdWorker.NextId() | 24 | + id, err := repository.IdWorker.NextId() |
28 | return id, err | 25 | return id, err |
29 | } | 26 | } |
30 | 27 | ||
@@ -317,8 +314,13 @@ func NewCooperationProjectRepository(transactionContext *pgTransaction.Transacti | @@ -317,8 +314,13 @@ func NewCooperationProjectRepository(transactionContext *pgTransaction.Transacti | ||
317 | if transactionContext == nil { | 314 | if transactionContext == nil { |
318 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 315 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
319 | } else { | 316 | } else { |
317 | + idWorker, err := snowflake.NewIdWorker(1) | ||
318 | + if err != nil { | ||
319 | + return nil, err | ||
320 | + } | ||
320 | return &CooperationProjectRepository{ | 321 | return &CooperationProjectRepository{ |
321 | transactionContext: transactionContext, | 322 | transactionContext: transactionContext, |
323 | + IdWorker: idWorker, | ||
322 | }, nil | 324 | }, nil |
323 | } | 325 | } |
324 | } | 326 | } |
@@ -15,14 +15,11 @@ import ( | @@ -15,14 +15,11 @@ import ( | ||
15 | 15 | ||
16 | type CreditAccountRepository struct { | 16 | type CreditAccountRepository struct { |
17 | transactionContext *pgTransaction.TransactionContext | 17 | transactionContext *pgTransaction.TransactionContext |
18 | + IdWorker *snowflake.IdWorker | ||
18 | } | 19 | } |
19 | 20 | ||
20 | func (repository *CreditAccountRepository) nextIdentify() (int64, error) { | 21 | func (repository *CreditAccountRepository) nextIdentify() (int64, error) { |
21 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
22 | - if err != nil { | ||
23 | - return 0, err | ||
24 | - } | ||
25 | - id, err := IdWorker.NextId() | 22 | + id, err := repository.IdWorker.NextId() |
26 | return id, err | 23 | return id, err |
27 | } | 24 | } |
28 | 25 | ||
@@ -249,8 +246,13 @@ func NewCreditAccountRepository(transactionContext *pgTransaction.TransactionCon | @@ -249,8 +246,13 @@ func NewCreditAccountRepository(transactionContext *pgTransaction.TransactionCon | ||
249 | if transactionContext == nil { | 246 | if transactionContext == nil { |
250 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 247 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
251 | } else { | 248 | } else { |
249 | + idWorker, err := snowflake.NewIdWorker(1) | ||
250 | + if err != nil { | ||
251 | + return nil, err | ||
252 | + } | ||
252 | return &CreditAccountRepository{ | 253 | return &CreditAccountRepository{ |
253 | transactionContext: transactionContext, | 254 | transactionContext: transactionContext, |
255 | + IdWorker: idWorker, | ||
254 | }, nil | 256 | }, nil |
255 | } | 257 | } |
256 | } | 258 | } |
@@ -16,14 +16,11 @@ import ( | @@ -16,14 +16,11 @@ import ( | ||
16 | 16 | ||
17 | type DividendsEstimateRepository struct { | 17 | type DividendsEstimateRepository struct { |
18 | transactionContext *pgTransaction.TransactionContext | 18 | transactionContext *pgTransaction.TransactionContext |
19 | + IdWorker *snowflake.IdWorker | ||
19 | } | 20 | } |
20 | 21 | ||
21 | func (repository *DividendsEstimateRepository) nextIdentify() (int64, error) { | 22 | func (repository *DividendsEstimateRepository) nextIdentify() (int64, error) { |
22 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
23 | - if err != nil { | ||
24 | - return 0, err | ||
25 | - } | ||
26 | - id, err := IdWorker.NextId() | 23 | + id, err := repository.IdWorker.NextId() |
27 | return id, err | 24 | return id, err |
28 | } | 25 | } |
29 | 26 | ||
@@ -332,8 +329,13 @@ func NewDividendsEstimateRepository(transactionContext *pgTransaction.Transactio | @@ -332,8 +329,13 @@ func NewDividendsEstimateRepository(transactionContext *pgTransaction.Transactio | ||
332 | if transactionContext == nil { | 329 | if transactionContext == nil { |
333 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 330 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
334 | } else { | 331 | } else { |
332 | + idWorker, err := snowflake.NewIdWorker(1) | ||
333 | + if err != nil { | ||
334 | + return nil, err | ||
335 | + } | ||
335 | return &DividendsEstimateRepository{ | 336 | return &DividendsEstimateRepository{ |
336 | transactionContext: transactionContext, | 337 | transactionContext: transactionContext, |
338 | + IdWorker: idWorker, | ||
337 | }, nil | 339 | }, nil |
338 | } | 340 | } |
339 | } | 341 | } |
@@ -15,14 +15,11 @@ import ( | @@ -15,14 +15,11 @@ import ( | ||
15 | 15 | ||
16 | type DividendsIncentivesRuleRepository struct { | 16 | type DividendsIncentivesRuleRepository struct { |
17 | transactionContext *pgTransaction.TransactionContext | 17 | transactionContext *pgTransaction.TransactionContext |
18 | + IdWorker *snowflake.IdWorker | ||
18 | } | 19 | } |
19 | 20 | ||
20 | func (repository *DividendsIncentivesRuleRepository) nextIdentify() (int64, error) { | 21 | func (repository *DividendsIncentivesRuleRepository) nextIdentify() (int64, error) { |
21 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
22 | - if err != nil { | ||
23 | - return 0, err | ||
24 | - } | ||
25 | - id, err := IdWorker.NextId() | 22 | + id, err := repository.IdWorker.NextId() |
26 | return id, err | 23 | return id, err |
27 | } | 24 | } |
28 | 25 | ||
@@ -202,8 +199,13 @@ func NewDividendsIncentivesRuleRepository(transactionContext *pgTransaction.Tran | @@ -202,8 +199,13 @@ func NewDividendsIncentivesRuleRepository(transactionContext *pgTransaction.Tran | ||
202 | if transactionContext == nil { | 199 | if transactionContext == nil { |
203 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 200 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
204 | } else { | 201 | } else { |
202 | + idWorker, err := snowflake.NewIdWorker(1) | ||
203 | + if err != nil { | ||
204 | + return nil, err | ||
205 | + } | ||
205 | return &DividendsIncentivesRuleRepository{ | 206 | return &DividendsIncentivesRuleRepository{ |
206 | transactionContext: transactionContext, | 207 | transactionContext: transactionContext, |
208 | + IdWorker: idWorker, | ||
207 | }, nil | 209 | }, nil |
208 | } | 210 | } |
209 | } | 211 | } |
-
请 注册 或 登录 后发表评论