正在显示
1 个修改的文件
包含
47 行增加
和
0 行删除
| @@ -500,6 +500,53 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper | @@ -500,6 +500,53 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper | ||
| 500 | } | 500 | } |
| 501 | } | 501 | } |
| 502 | 502 | ||
| 503 | +// CancelCooperationApplication 取消共创申请 | ||
| 504 | +func (cooperationApplicationService *CooperationApplicationService) CancelCooperationApplication(cancelCooperationApplicationCommand *command.CancelCooperationApplicationCommand) (interface{}, error) { | ||
| 505 | + if err := cancelCooperationApplicationCommand.ValidateCommand(); err != nil { | ||
| 506 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
| 507 | + } | ||
| 508 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 509 | + if err != nil { | ||
| 510 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 511 | + } | ||
| 512 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 513 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 514 | + } | ||
| 515 | + defer func() { | ||
| 516 | + _ = transactionContext.RollbackTransaction() | ||
| 517 | + }() | ||
| 518 | + //TODO 校验用户菜单模块权限 | ||
| 519 | + | ||
| 520 | + var cooperationApplicationRepository domain.CooperationApplicationRepository | ||
| 521 | + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{ | ||
| 522 | + "transactionContext": transactionContext, | ||
| 523 | + }); err != nil { | ||
| 524 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 525 | + } else { | ||
| 526 | + cooperationApplicationRepository = value | ||
| 527 | + } | ||
| 528 | + cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": cancelCooperationApplicationCommand.CooperationApplicationId}) | ||
| 529 | + if err != nil { | ||
| 530 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 531 | + } | ||
| 532 | + if cooperationApplication == nil { | ||
| 533 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cancelCooperationApplicationCommand.CooperationApplicationId, 10))) | ||
| 534 | + } | ||
| 535 | + if err := cooperationApplication.Update(map[string]interface{}{ | ||
| 536 | + "isCanceled": true, | ||
| 537 | + }); err != nil { | ||
| 538 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 539 | + } | ||
| 540 | + if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil { | ||
| 541 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 542 | + } else { | ||
| 543 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 544 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 545 | + } | ||
| 546 | + return cooperationApplication, nil | ||
| 547 | + } | ||
| 548 | +} | ||
| 549 | + | ||
| 503 | func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService { | 550 | func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService { |
| 504 | newCooperationApplicationService := &CooperationApplicationService{} | 551 | newCooperationApplicationService := &CooperationApplicationService{} |
| 505 | return newCooperationApplicationService | 552 | return newCooperationApplicationService |
-
请 注册 或 登录 后发表评论