作者 陈志颖

Merge branch 'dev-chenzhiying' into dev

@@ -4,14 +4,17 @@ import "os" @@ -4,14 +4,17 @@ import "os"
4 4
5 const SERVICE_NAME = "allied-creation-cooperation" 5 const SERVICE_NAME = "allied-creation-cooperation"
6 6
7 -// 日志相关设置 7 +// LOG_LEVEL 日志相关设置
8 var LOG_LEVEL = "debug" 8 var LOG_LEVEL = "debug"
9 var LOG_FILE = "app.log" 9 var LOG_FILE = "app.log"
10 var LOG_PREFIX = "[allied-creation-cooperation]" 10 var LOG_PREFIX = "[allied-creation-cooperation]"
11 11
12 -// 用户信息模块地址 12 +// USER_MODULE_HOST 用户信息模块地址
13 var USER_MODULE_HOST = "http://127.0.0.1:8081" 13 var USER_MODULE_HOST = "http://127.0.0.1:8081"
14 14
  15 +// BASIC_MODULE_HOST 基础服务模块
  16 +var BASIC_MODULE_HOST = "http://127.0.0.1:8080"
  17 +
15 func init() { 18 func init() {
16 if os.Getenv("LOG_LEVEL") != "" { 19 if os.Getenv("LOG_LEVEL") != "" {
17 LOG_LEVEL = os.Getenv("LOG_LEVEL") 20 LOG_LEVEL = os.Getenv("LOG_LEVEL")
  1 +package service_gateway
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
  5 + "strings"
  6 + "time"
  7 +)
  8 +
  9 +type HttplibBasicServiceGateway struct {
  10 + httplibBaseServiceGateway
  11 +}
  12 +
  13 +// AgreeCooperationApplication 同意共创申请
  14 +func (serviceGateway *HttplibBasicServiceGateway) AgreeCooperationApplication() (map[string]interface{}, error) {
  15 + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/agree-join-creation-project"}, "/")
  16 + request := serviceGateway.createRequest(url, "post")
  17 + request.Header("companyId", "")
  18 + request.Header("userId", "")
  19 + request.Header("orgId", "")
  20 + request.Header("userBasic", "")
  21 + options := map[string]interface{}{}
  22 + _, err := request.JSONBody(options)
  23 + if err != nil {
  24 + return nil, err
  25 + }
  26 + response := make(map[string]interface{})
  27 + err2 := request.ToJSON(&response)
  28 + if err2 != nil {
  29 + return nil, err2
  30 + }
  31 + data, err := serviceGateway.responseHandle(response)
  32 + return data, err
  33 +}
  34 +
  35 +// RejectCooperationApplication 拒绝共创申请
  36 +func (serviceGateway *HttplibBasicServiceGateway) RejectCooperationApplication() (map[string]interface{}, error) {
  37 + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/refuse-join-creation-project"}, "/")
  38 + request := serviceGateway.createRequest(url, "post")
  39 + request.Header("companyId", "")
  40 + request.Header("userId", "")
  41 + request.Header("orgId", "")
  42 + request.Header("userBasic", "")
  43 + options := make(map[string]interface{})
  44 + _, err2 := request.JSONBody(options)
  45 + if err2 != nil {
  46 + return nil, err2
  47 + }
  48 + response := make(map[string]interface{})
  49 + err := request.ToJSON(&response)
  50 + if err != nil {
  51 + return nil, err
  52 + }
  53 + data, err := serviceGateway.responseHandle(response)
  54 + return data, err
  55 +}
  56 +
  57 +// InformExpectedDividends 分红预算消息
  58 +func (serviceGateway *HttplibBasicServiceGateway) InformExpectedDividends() (map[string]interface{}, error) {
  59 + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-expected-dividends"}, "/")
  60 + request := serviceGateway.createRequest(url, "post")
  61 + request.Header("companyId", "")
  62 + request.Header("userId", "")
  63 + request.Header("orgId", "")
  64 + request.Header("userBasic", "")
  65 + options := make(map[string]interface{})
  66 + _, err2 := request.JSONBody(options)
  67 + if err2 != nil {
  68 + return nil, err2
  69 + }
  70 + response := make(map[string]interface{})
  71 + err := request.ToJSON(&response)
  72 + if err != nil {
  73 + return nil, err
  74 + }
  75 + data, err := serviceGateway.responseHandle(response)
  76 + return data, err
  77 +}
  78 +
  79 +// InformJoinCreationContract 确认共创
  80 +func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract() (map[string]interface{}, error) {
  81 + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-join-creation-contract"}, "/")
  82 + request := serviceGateway.createRequest(url, "post")
  83 + options := make(map[string]interface{})
  84 + _, err2 := request.JSONBody(options)
  85 + if err2 != nil {
  86 + return nil, err2
  87 + }
  88 + response := make(map[string]interface{})
  89 + err := request.ToJSON(&response)
  90 + if err != nil {
  91 + return nil, err
  92 + }
  93 + data, err := serviceGateway.responseHandle(response)
  94 + return data, err
  95 +}
  96 +
  97 +// PayCreditAccount 账期支付
  98 +func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount() (map[string]interface{}, error) {
  99 + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/notice-personal/credit-account/payment"}, "/")
  100 + request := serviceGateway.createRequest(url, "post")
  101 + request.Header("companyId", "")
  102 + request.Header("userId", "")
  103 + request.Header("orgId", "")
  104 + request.Header("userBasic", "")
  105 + options := make(map[string]interface{})
  106 + _, err2 := request.JSONBody(options)
  107 + if err2 != nil {
  108 + return nil, err2
  109 + }
  110 + response := make(map[string]interface{})
  111 + err := request.ToJSON(&response)
  112 + if err != nil {
  113 + return nil, err
  114 + }
  115 + data, err := serviceGateway.responseHandle(response)
  116 + return data, err
  117 +}
  118 +
  119 +// DividendsEstimate 分红预算
  120 +func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate() (map[string]interface{}, error) {
  121 + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/credit-account/dividends-estimate"}, "/")
  122 + request := serviceGateway.createRequest(url, "post")
  123 + request.Header("companyId", "")
  124 + request.Header("userId", "")
  125 + request.Header("orgId", "")
  126 + request.Header("userBasic", "")
  127 + options := make(map[string]interface{})
  128 + _, err2 := request.JSONBody(options)
  129 + if err2 != nil {
  130 + return nil, err2
  131 + }
  132 + response := make(map[string]interface{})
  133 + err := request.ToJSON(&response)
  134 + if err != nil {
  135 + return nil, err
  136 + }
  137 + data, err := serviceGateway.responseHandle(response)
  138 + return data, err
  139 +}
  140 +
  141 +func NewHttplibMessageServiceGateway() *HttplibBasicServiceGateway {
  142 + return &HttplibBasicServiceGateway{
  143 + httplibBaseServiceGateway: httplibBaseServiceGateway{
  144 + baseURL: constant.BASIC_MODULE_HOST,
  145 + connectTimeout: 100 * time.Second,
  146 + readWriteTimeout: 30 * time.Second,
  147 + },
  148 + }
  149 +}
1 -package service_gateway  
2 -  
3 -import (  
4 - "strings"  
5 - "time"  
6 -)  
7 -  
8 -type HttplibMessageServiceGateway struct {  
9 - httplibBaseServiceGateway  
10 -}  
11 -  
12 -// PushMessage 推送消息  
13 -func (serviceGateway *HttplibMessageServiceGateway) PushMessage(msgType int, projects []string, uids []int64, title string, content string) (map[string]interface{}, error) {  
14 - url := strings.Join([]string{serviceGateway.baseURL, "v1", "push", "pushInfo"}, "/")  
15 - request := serviceGateway.createRequest(url, "post")  
16 - options := map[string]interface{}{}  
17 - _, _ = request.JSONBody(options)  
18 - response := make(map[string]interface{})  
19 - _ = request.ToJSON(&response)  
20 - data, err := serviceGateway.responseHandle(response)  
21 - return data, err  
22 -}  
23 -  
24 -func NewHttplibMessageServiceGateway() *HttplibMessageServiceGateway {  
25 - return &HttplibMessageServiceGateway{  
26 - httplibBaseServiceGateway: httplibBaseServiceGateway{  
27 - baseURL: "",  
28 - connectTimeout: 100 * time.Second,  
29 - readWriteTimeout: 30 * time.Second,  
30 - },  
31 - }  
32 -}  
@@ -13,5 +13,10 @@ type UserServiceGateway interface { @@ -13,5 +13,10 @@ type UserServiceGateway interface {
13 } 13 }
14 14
15 type MessageServiceGateway interface { 15 type MessageServiceGateway interface {
16 - PushMessage(msgType int, projects []string, uids []int64, title string, content string) (map[string]interface{}, error) 16 + AgreeCooperationApplication() (map[string]interface{}, error)
  17 + RejectCooperationApplication() (map[string]interface{}, error)
  18 + InformExpectedDividends() (map[string]interface{}, error)
  19 + InformJoinCreationContract() (map[string]interface{}, error)
  20 + PayCreditAccount() (map[string]interface{}, error)
  21 + DividendsEstimate() (map[string]interface{}, error)
17 } 22 }