作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !10
FROM 192.168.0.243:5000/mmm/allied-creation-gateway:libfontconfig
ENV APP_DIR $GOPATH/src/project-20211221
ENV APP_DIR $GOPATH/src/project-20211222
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR/
COPY ./pkg pkg
... ...
... ... @@ -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.BlockChainSourceCooperationContract,
})
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
}
... ...
... ... @@ -46,7 +46,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen
if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
domain.BlockChainSourceCooperationDividendsEstimate,
strconv.Itoa(int(v.DividendsEstimateId)),
"",
strconv.Itoa(int(v.DividendsEstimateId)),
v,
)); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
... ... @@ -84,7 +84,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentive
if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
domain.BlockChainSourceCooperationDividendsEstimate,
strconv.Itoa(int(v.DividendsEstimateId)),
"",
strconv.Itoa(int(v.DividendsEstimateId)),
v,
)); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
... ...
... ... @@ -39,6 +39,8 @@ var SUPLUS_SALE_APP = "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
// TODO:特殊短信验证码,不验证,正式环境注入空
var SMSCODE_ALL_POWER = "999512"
var EnableBlockChain = true
func init() {
if os.Getenv("LOG_LEVEL") != "" {
LOG_LEVEL = os.Getenv("LOG_LEVEL")
... ...
... ... @@ -10,7 +10,7 @@ var (
// 是否启用日志收集 (本地不启用)
ENABLE_KAFKA_LOG = false
// kafka topic up_block_chain
TOPIC_UP_BLOCK_CHAIN = "up_block_chain"
TOPIC_UP_BLOCK_CHAIN = "allied_creation_message"
)
func init() {
... ...
... ... @@ -76,6 +76,7 @@ const (
)
const (
BlockChainSourceCooperationContract = "allied-creation.cooperation.contract"
BlockChainSourceCooperationProject = "allied-creation.cooperation.project"
BlockChainSourceCooperationDividendsEstimate = "allied-creation.cooperation.dividends-estimate"
)
... ...
... ... @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/linmadan/egglib-go/utils/json"
"github.com/tal-tech/go-queue/kq"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"strings"
)
... ... @@ -23,8 +24,9 @@ func RegisterDefaultPusherClient(host, topic string) {
// 异步推送到队列
func Push(topic string, o interface{}) error {
// TODO:功能未开启
if !constant.EnableBlockChain {
return nil
}
var pusher *kq.Pusher
var ok bool
if pusher, ok = defaultClientMap[topic]; !ok {
... ... @@ -35,10 +37,14 @@ func Push(topic string, o interface{}) error {
// 新建一个推送对象
func NewPushObject(source, primaryId, issueId string, obj interface{}) interface{} {
return map[string]interface{}{
data := map[string]interface{}{
"source": source,
"primaryId": primaryId,
"issueId": issueId,
"data": json.MarshalToString(obj),
}
return map[string]interface{}{
"topic": "up_block_chain",
"data": data,
}
}
... ...
... ... @@ -3,13 +3,15 @@ package allied_creation_user
import (
"encoding/json"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
func (gateway HttplibAlliedCreationUser) ListBlockChains(param ReqListBlockChain) (DataListBlockChain, error) {
// TODO:功能未开启
if !constant.EnableBlockChain || param.Disable {
return []DataListBlockChainItem{}, nil
}
url := gateway.baseUrL + "/block-chains/"
method := "post"
req := gateway.CreateRequest(url, method)
... ...
... ... @@ -6,6 +6,8 @@ type (
EnableDistinctPrimaryID bool `json:"enableDistinctPrimaryId"`
PrimaryIDList []string `json:"primaryIdList"`
Source string `json:"source"`
// 禁用标识
Disable bool `json:"-"`
}
DataListBlockChain []DataListBlockChainItem
DataListBlockChainItem struct {
... ...