作者 yangfu

上报修改

... ... @@ -38,6 +38,14 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
// domain.BlockChainSourceCooperationProject,
// strconv.Itoa(result.CooperationProject.CooperationProjectId),
// strconv.Itoa(result.CooperationProject.CooperationProjectId),
// result,
//)); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
//}
return dto.ToCooperationProjectInfo(&result.CooperationProject), nil
}
... ...
... ... @@ -23,6 +23,8 @@ type CooperationContractItem struct {
CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开
CooperationContractDescription string `json:"cooperationContractDescription"` //合约描述
AuthFlag bool `json:"authFlag"`
UpChainID int `json:"upChainId"`
BlockHash string `json:"blockChainId"`
}
func ToCooperationContractItem(param *allied_creation_cooperation.CooperationContract, operatorOrgId int64) *CooperationContractItem {
... ...
package service
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/broker"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"strconv"
"time"
... ... @@ -78,6 +82,16 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
domain.BlockChainSourceCooperationContract,
strconv.Itoa(result.CooperationContractId),
strconv.Itoa(result.CooperationContractId),
dto.ToCooperationContractInfo(&result.CooperationContract, 0),
)); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
}
return dto.ToCooperationContractInfo(&result.CooperationContract, createCooperationContractCommand.Operator.OrgId), err
}
... ... @@ -124,9 +138,31 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var primaryIdList = make([]string, 0)
for i := range result.Grid.List {
item := result.Grid.List[i].CooperationContractId
primaryIdList = append(primaryIdList, strconv.Itoa(item))
}
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
listCooperationContractQuery.Operator)
resp, err := creationUserGateway.ListBlockChains(allied_creation_user.ReqListBlockChain{
DisableLimit: true,
EnableDistinctPrimaryID: true,
PrimaryIDList: primaryIdList,
Source: domain.BlockChainSourceCooperationProject,
})
if err != nil {
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
mapChainItems := resp.ToMap()
data := []dto.CooperationContractItem{}
for i := range result.Grid.List {
item := dto.ToCooperationContractItem(&result.Grid.List[i], listCooperationContractQuery.Operator.OrgId)
if v, ok := mapChainItems[strconv.Itoa(item.CooperationContractId)]; ok {
item.UpChainID = v.UpChainID
item.BlockHash = v.BlockHash
}
data = append(data, *item)
}
... ... @@ -201,6 +237,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
domain.BlockChainSourceCooperationContract,
strconv.Itoa(result.CooperationContractId),
strconv.Itoa(result.CooperationContractId),
dto.ToCooperationContractInfo(&result.CooperationContract, 0),
)); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
}
return dto.ToCooperationContractInfo(&result.CooperationContract, updateCooperationContractCommand.Operator.OrgId), nil
}
... ...
package service
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/broker"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"strconv"
... ... @@ -44,14 +42,14 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
CooperationProjectId: result.CooperationProjectId,
CreateCooperationProjectCommand: *createCooperationProjectCommand,
}
if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
domain.BlockChainSourceCooperationProject,
strconv.Itoa(result.CooperationProject.CooperationProjectId),
strconv.Itoa(result.CooperationProject.CooperationProjectId),
result,
)); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
}
//if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
// domain.BlockChainSourceCooperationProject,
// strconv.Itoa(result.CooperationProject.CooperationProjectId),
// strconv.Itoa(result.CooperationProject.CooperationProjectId),
// result,
//)); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
//}
return data, nil
}
... ... @@ -146,6 +144,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
EnableDistinctPrimaryID: true,
PrimaryIDList: primaryIdList,
Source: domain.BlockChainSourceCooperationProject,
Disable: true,
})
if err != nil {
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ... @@ -159,7 +158,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
func (cooperationProjectService *CooperationProjectService) UpdateCooperationProject(updateCooperationProjectCommand *command.UpdateCooperationProjectCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationProjectCommand.Operator)
result, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{
_, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{
CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId,
CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName,
CooperationModeNumber: updateCooperationProjectCommand.CooperationModeNumber,
... ... @@ -174,14 +173,14 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
domain.BlockChainSourceCooperationProject,
strconv.Itoa(result.CooperationProject.CooperationProjectId),
strconv.Itoa(result.CooperationProject.CooperationProjectId),
result,
)); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
}
//if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
// domain.BlockChainSourceCooperationProject,
// strconv.Itoa(result.CooperationProject.CooperationProjectId),
// strconv.Itoa(result.CooperationProject.CooperationProjectId),
// result,
//)); err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
//}
return updateCooperationProjectCommand, nil
}
... ...
... ... @@ -76,6 +76,7 @@ const (
)
const (
BlockChainSourceCooperationContract = "allied-creation.cooperation.contract"
BlockChainSourceCooperationProject = "allied-creation.cooperation.project"
BlockChainSourceCooperationDividendsEstimate = "allied-creation.cooperation.dividends-estimate"
)
... ...
... ... @@ -9,7 +9,7 @@ import (
)
func (gateway HttplibAlliedCreationUser) ListBlockChains(param ReqListBlockChain) (DataListBlockChain, error) {
if !constant.EnableBlockChain {
if !constant.EnableBlockChain || param.Disable {
return []DataListBlockChainItem{}, nil
}
url := gateway.baseUrL + "/block-chains/"
... ...
... ... @@ -6,6 +6,8 @@ type (
EnableDistinctPrimaryID bool `json:"enableDistinctPrimaryId"`
PrimaryIDList []string `json:"primaryIdList"`
Source string `json:"source"`
// 禁用标识
Disable bool `json:"-"`
}
DataListBlockChain []DataListBlockChainItem
DataListBlockChainItem struct {
... ...