作者 陈志颖

feat:添加共创合约暂停或恢复服务

... ... @@ -8,6 +8,8 @@ import (
)
type BatchOperateCooperationContractCommand struct {
// 共创合约id列表
CooperationContractIds []string `cname:"共创合约id" json:"cooperationContractIds" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
... ...
... ... @@ -8,6 +8,8 @@ import (
)
type BatchRemoveCooperationContractCommand struct {
// 共创合约id列表
CooperationContractIds []string `cname:"共创合约id" json:"cooperationContractIds" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
... ...
... ... @@ -8,6 +8,10 @@ import (
)
type OperateCooperationContractCommand struct {
// 共创合约id
CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"`
// 操作
Action int32 `cname:"操作" json:"action" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
... ...
... ... @@ -448,7 +448,7 @@ func (cooperationContractService *CooperationContractService) BatchRemoveCoopera
return nil, nil
}
// OperateRemoveCooperationContract TODO 暂停或恢复共创合约
// OperateCooperationContract 暂停或恢复共创合约
func (cooperationContractService *CooperationContractService) OperateCooperationContract(operateCooperationContractCommand *command.OperateCooperationContractCommand) (interface{}, error) {
if err := operateCooperationContractCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -463,10 +463,34 @@ func (cooperationContractService *CooperationContractService) OperateCooperation
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": operateCooperationContractCommand.CooperationContractId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operateCooperationContractCommand.CooperationContractId)))
}
if err := cooperationContract.Update(map[string]interface{}{
"action": operateCooperationContractCommand,
}); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return cooperationContract, nil
}
return nil, nil
}
// BatchOperateCooperationContract TODO 批量暂停或恢复共创合约
... ...
... ... @@ -81,6 +81,9 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface
if status, ok := data["status"]; ok {
cooperationContract.Status = status.(int32)
}
if action, ok := data["action"]; ok {
cooperationContract.Status = action.(int32)
}
if operateTime, ok := data["operateTime"]; ok {
cooperationContract.OperateTime = operateTime.(time.Time)
}
... ...