作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !10
1 FROM 192.168.0.243:5000/mmm/allied-creation-gateway:libfontconfig 1 FROM 192.168.0.243:5000/mmm/allied-creation-gateway:libfontconfig
2 -ENV APP_DIR $GOPATH/src/project-20211221 2 +ENV APP_DIR $GOPATH/src/project-20211222
3 RUN mkdir -p $APP_DIR 3 RUN mkdir -p $APP_DIR
4 WORKDIR $APP_DIR/ 4 WORKDIR $APP_DIR/
5 COPY ./pkg pkg 5 COPY ./pkg pkg
@@ -38,6 +38,14 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP @@ -38,6 +38,14 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP
38 if err != nil { 38 if err != nil {
39 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 39 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
40 } 40 }
  41 + //if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
  42 + // domain.BlockChainSourceCooperationProject,
  43 + // strconv.Itoa(result.CooperationProject.CooperationProjectId),
  44 + // strconv.Itoa(result.CooperationProject.CooperationProjectId),
  45 + // result,
  46 + //)); err != nil {
  47 + // return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
  48 + //}
41 return dto.ToCooperationProjectInfo(&result.CooperationProject), nil 49 return dto.ToCooperationProjectInfo(&result.CooperationProject), nil
42 } 50 }
43 51
@@ -23,6 +23,8 @@ type CooperationContractItem struct { @@ -23,6 +23,8 @@ type CooperationContractItem struct {
23 CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开 23 CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开
24 CooperationContractDescription string `json:"cooperationContractDescription"` //合约描述 24 CooperationContractDescription string `json:"cooperationContractDescription"` //合约描述
25 AuthFlag bool `json:"authFlag"` 25 AuthFlag bool `json:"authFlag"`
  26 + UpChainID int `json:"upChainId"`
  27 + BlockHash string `json:"blockChainId"`
26 } 28 }
27 29
28 func ToCooperationContractItem(param *allied_creation_cooperation.CooperationContract, operatorOrgId int64) *CooperationContractItem { 30 func ToCooperationContractItem(param *allied_creation_cooperation.CooperationContract, operatorOrgId int64) *CooperationContractItem {
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/broker"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
4 "strconv" 8 "strconv"
5 "time" 9 "time"
6 10
@@ -78,6 +82,16 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -78,6 +82,16 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
78 if err != nil { 82 if err != nil {
79 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 83 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
80 } 84 }
  85 +
  86 + if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
  87 + domain.BlockChainSourceCooperationContract,
  88 + strconv.Itoa(result.CooperationContractId),
  89 + strconv.Itoa(result.CooperationContractId),
  90 + dto.ToCooperationContractInfo(&result.CooperationContract, 0),
  91 + )); err != nil {
  92 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
  93 + }
  94 +
81 return dto.ToCooperationContractInfo(&result.CooperationContract, createCooperationContractCommand.Operator.OrgId), err 95 return dto.ToCooperationContractInfo(&result.CooperationContract, createCooperationContractCommand.Operator.OrgId), err
82 96
83 } 97 }
@@ -124,9 +138,31 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon @@ -124,9 +138,31 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
124 if err != nil { 138 if err != nil {
125 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 139 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
126 } 140 }
  141 +
  142 + var primaryIdList = make([]string, 0)
  143 + for i := range result.Grid.List {
  144 + item := result.Grid.List[i].CooperationContractId
  145 + primaryIdList = append(primaryIdList, strconv.Itoa(item))
  146 + }
  147 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  148 + listCooperationContractQuery.Operator)
  149 + resp, err := creationUserGateway.ListBlockChains(allied_creation_user.ReqListBlockChain{
  150 + DisableLimit: true,
  151 + EnableDistinctPrimaryID: true,
  152 + PrimaryIDList: primaryIdList,
  153 + Source: domain.BlockChainSourceCooperationContract,
  154 + })
  155 + if err != nil {
  156 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  157 + }
  158 + mapChainItems := resp.ToMap()
127 data := []dto.CooperationContractItem{} 159 data := []dto.CooperationContractItem{}
128 for i := range result.Grid.List { 160 for i := range result.Grid.List {
129 item := dto.ToCooperationContractItem(&result.Grid.List[i], listCooperationContractQuery.Operator.OrgId) 161 item := dto.ToCooperationContractItem(&result.Grid.List[i], listCooperationContractQuery.Operator.OrgId)
  162 + if v, ok := mapChainItems[strconv.Itoa(item.CooperationContractId)]; ok {
  163 + item.UpChainID = v.UpChainID
  164 + item.BlockHash = v.BlockHash
  165 + }
130 data = append(data, *item) 166 data = append(data, *item)
131 } 167 }
132 168
@@ -201,6 +237,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -201,6 +237,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
201 if err != nil { 237 if err != nil {
202 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 238 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
203 } 239 }
  240 +
  241 + if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
  242 + domain.BlockChainSourceCooperationContract,
  243 + strconv.Itoa(result.CooperationContractId),
  244 + strconv.Itoa(result.CooperationContractId),
  245 + dto.ToCooperationContractInfo(&result.CooperationContract, 0),
  246 + )); err != nil {
  247 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
  248 + }
  249 +
204 return dto.ToCooperationContractInfo(&result.CooperationContract, updateCooperationContractCommand.Operator.OrgId), nil 250 return dto.ToCooperationContractInfo(&result.CooperationContract, updateCooperationContractCommand.Operator.OrgId), nil
205 } 251 }
206 252
1 package service 1 package service
2 2
3 import ( 3 import (
4 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"  
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
6 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/broker"  
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
8 "strconv" 6 "strconv"
9 7
@@ -44,14 +42,14 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -44,14 +42,14 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
44 CooperationProjectId: result.CooperationProjectId, 42 CooperationProjectId: result.CooperationProjectId,
45 CreateCooperationProjectCommand: *createCooperationProjectCommand, 43 CreateCooperationProjectCommand: *createCooperationProjectCommand,
46 } 44 }
47 - if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(  
48 - domain.BlockChainSourceCooperationProject,  
49 - strconv.Itoa(result.CooperationProject.CooperationProjectId),  
50 - strconv.Itoa(result.CooperationProject.CooperationProjectId),  
51 - result,  
52 - )); err != nil {  
53 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())  
54 - } 45 + //if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
  46 + // domain.BlockChainSourceCooperationProject,
  47 + // strconv.Itoa(result.CooperationProject.CooperationProjectId),
  48 + // strconv.Itoa(result.CooperationProject.CooperationProjectId),
  49 + // result,
  50 + //)); err != nil {
  51 + // return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
  52 + //}
55 return data, nil 53 return data, nil
56 } 54 }
57 55
@@ -146,6 +144,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje @@ -146,6 +144,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
146 EnableDistinctPrimaryID: true, 144 EnableDistinctPrimaryID: true,
147 PrimaryIDList: primaryIdList, 145 PrimaryIDList: primaryIdList,
148 Source: domain.BlockChainSourceCooperationProject, 146 Source: domain.BlockChainSourceCooperationProject,
  147 + Disable: true,
149 }) 148 })
150 if err != nil { 149 if err != nil {
151 return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 150 return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -159,7 +158,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje @@ -159,7 +158,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
159 func (cooperationProjectService *CooperationProjectService) UpdateCooperationProject(updateCooperationProjectCommand *command.UpdateCooperationProjectCommand) (interface{}, error) { 158 func (cooperationProjectService *CooperationProjectService) UpdateCooperationProject(updateCooperationProjectCommand *command.UpdateCooperationProjectCommand) (interface{}, error) {
160 159
161 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationProjectCommand.Operator) 160 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationProjectCommand.Operator)
162 - result, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{ 161 + _, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{
163 CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId, 162 CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId,
164 CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName, 163 CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName,
165 CooperationModeNumber: updateCooperationProjectCommand.CooperationModeNumber, 164 CooperationModeNumber: updateCooperationProjectCommand.CooperationModeNumber,
@@ -174,14 +173,14 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -174,14 +173,14 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
174 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 173 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
175 } 174 }
176 175
177 - if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(  
178 - domain.BlockChainSourceCooperationProject,  
179 - strconv.Itoa(result.CooperationProject.CooperationProjectId),  
180 - strconv.Itoa(result.CooperationProject.CooperationProjectId),  
181 - result,  
182 - )); err != nil {  
183 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())  
184 - } 176 + //if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
  177 + // domain.BlockChainSourceCooperationProject,
  178 + // strconv.Itoa(result.CooperationProject.CooperationProjectId),
  179 + // strconv.Itoa(result.CooperationProject.CooperationProjectId),
  180 + // result,
  181 + //)); err != nil {
  182 + // return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
  183 + //}
185 return updateCooperationProjectCommand, nil 184 return updateCooperationProjectCommand, nil
186 } 185 }
187 186
@@ -46,7 +46,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen @@ -46,7 +46,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen
46 if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject( 46 if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
47 domain.BlockChainSourceCooperationDividendsEstimate, 47 domain.BlockChainSourceCooperationDividendsEstimate,
48 strconv.Itoa(int(v.DividendsEstimateId)), 48 strconv.Itoa(int(v.DividendsEstimateId)),
49 - "", 49 + strconv.Itoa(int(v.DividendsEstimateId)),
50 v, 50 v,
51 )); err != nil { 51 )); err != nil {
52 return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error()) 52 return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error())
@@ -84,7 +84,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentive @@ -84,7 +84,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentive
84 if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject( 84 if err = broker.Push(constant.TOPIC_UP_BLOCK_CHAIN, broker.NewPushObject(
85 domain.BlockChainSourceCooperationDividendsEstimate, 85 domain.BlockChainSourceCooperationDividendsEstimate,
86 strconv.Itoa(int(v.DividendsEstimateId)), 86 strconv.Itoa(int(v.DividendsEstimateId)),
87 - "", 87 + strconv.Itoa(int(v.DividendsEstimateId)),
88 v, 88 v,
89 )); err != nil { 89 )); err != nil {
90 return nil, application.ThrowError(application.TRANSACTION_ERROR, "消息服务异常"+err.Error()) 90 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" @@ -39,6 +39,8 @@ var SUPLUS_SALE_APP = "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
39 // TODO:特殊短信验证码,不验证,正式环境注入空 39 // TODO:特殊短信验证码,不验证,正式环境注入空
40 var SMSCODE_ALL_POWER = "999512" 40 var SMSCODE_ALL_POWER = "999512"
41 41
  42 +var EnableBlockChain = true
  43 +
42 func init() { 44 func init() {
43 if os.Getenv("LOG_LEVEL") != "" { 45 if os.Getenv("LOG_LEVEL") != "" {
44 LOG_LEVEL = os.Getenv("LOG_LEVEL") 46 LOG_LEVEL = os.Getenv("LOG_LEVEL")
@@ -10,7 +10,7 @@ var ( @@ -10,7 +10,7 @@ var (
10 // 是否启用日志收集 (本地不启用) 10 // 是否启用日志收集 (本地不启用)
11 ENABLE_KAFKA_LOG = false 11 ENABLE_KAFKA_LOG = false
12 // kafka topic up_block_chain 12 // kafka topic up_block_chain
13 - TOPIC_UP_BLOCK_CHAIN = "up_block_chain" 13 + TOPIC_UP_BLOCK_CHAIN = "allied_creation_message"
14 ) 14 )
15 15
16 func init() { 16 func init() {
@@ -76,6 +76,7 @@ const ( @@ -76,6 +76,7 @@ const (
76 ) 76 )
77 77
78 const ( 78 const (
  79 + BlockChainSourceCooperationContract = "allied-creation.cooperation.contract"
79 BlockChainSourceCooperationProject = "allied-creation.cooperation.project" 80 BlockChainSourceCooperationProject = "allied-creation.cooperation.project"
80 BlockChainSourceCooperationDividendsEstimate = "allied-creation.cooperation.dividends-estimate" 81 BlockChainSourceCooperationDividendsEstimate = "allied-creation.cooperation.dividends-estimate"
81 ) 82 )
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "fmt" 4 "fmt"
5 "github.com/linmadan/egglib-go/utils/json" 5 "github.com/linmadan/egglib-go/utils/json"
6 "github.com/tal-tech/go-queue/kq" 6 "github.com/tal-tech/go-queue/kq"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
7 "strings" 8 "strings"
8 ) 9 )
9 10
@@ -23,8 +24,9 @@ func RegisterDefaultPusherClient(host, topic string) { @@ -23,8 +24,9 @@ func RegisterDefaultPusherClient(host, topic string) {
23 24
24 // 异步推送到队列 25 // 异步推送到队列
25 func Push(topic string, o interface{}) error { 26 func Push(topic string, o interface{}) error {
26 - // TODO:功能未开启  
27 - return nil 27 + if !constant.EnableBlockChain {
  28 + return nil
  29 + }
28 var pusher *kq.Pusher 30 var pusher *kq.Pusher
29 var ok bool 31 var ok bool
30 if pusher, ok = defaultClientMap[topic]; !ok { 32 if pusher, ok = defaultClientMap[topic]; !ok {
@@ -35,10 +37,14 @@ func Push(topic string, o interface{}) error { @@ -35,10 +37,14 @@ func Push(topic string, o interface{}) error {
35 37
36 // 新建一个推送对象 38 // 新建一个推送对象
37 func NewPushObject(source, primaryId, issueId string, obj interface{}) interface{} { 39 func NewPushObject(source, primaryId, issueId string, obj interface{}) interface{} {
38 - return map[string]interface{}{ 40 + data := map[string]interface{}{
39 "source": source, 41 "source": source,
40 "primaryId": primaryId, 42 "primaryId": primaryId,
41 "issueId": issueId, 43 "issueId": issueId,
42 "data": json.MarshalToString(obj), 44 "data": json.MarshalToString(obj),
43 } 45 }
  46 + return map[string]interface{}{
  47 + "topic": "up_block_chain",
  48 + "data": data,
  49 + }
44 } 50 }
@@ -3,13 +3,15 @@ package allied_creation_user @@ -3,13 +3,15 @@ package allied_creation_user
3 import ( 3 import (
4 "encoding/json" 4 "encoding/json"
5 "fmt" 5 "fmt"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
8 ) 9 )
9 10
10 func (gateway HttplibAlliedCreationUser) ListBlockChains(param ReqListBlockChain) (DataListBlockChain, error) { 11 func (gateway HttplibAlliedCreationUser) ListBlockChains(param ReqListBlockChain) (DataListBlockChain, error) {
11 - // TODO:功能未开启  
12 - return []DataListBlockChainItem{}, nil 12 + if !constant.EnableBlockChain || param.Disable {
  13 + return []DataListBlockChainItem{}, nil
  14 + }
13 url := gateway.baseUrL + "/block-chains/" 15 url := gateway.baseUrL + "/block-chains/"
14 method := "post" 16 method := "post"
15 req := gateway.CreateRequest(url, method) 17 req := gateway.CreateRequest(url, method)
@@ -6,6 +6,8 @@ type ( @@ -6,6 +6,8 @@ type (
6 EnableDistinctPrimaryID bool `json:"enableDistinctPrimaryId"` 6 EnableDistinctPrimaryID bool `json:"enableDistinctPrimaryId"`
7 PrimaryIDList []string `json:"primaryIdList"` 7 PrimaryIDList []string `json:"primaryIdList"`
8 Source string `json:"source"` 8 Source string `json:"source"`
  9 + // 禁用标识
  10 + Disable bool `json:"-"`
9 } 11 }
10 DataListBlockChain []DataListBlockChainItem 12 DataListBlockChain []DataListBlockChainItem
11 DataListBlockChainItem struct { 13 DataListBlockChainItem struct {