作者 陈志颖

Merge branch 'dev-chenzhiying' into dev

... ... @@ -4,14 +4,17 @@ import "os"
const SERVICE_NAME = "allied-creation-cooperation"
// 日志相关设置
// LOG_LEVEL 日志相关设置
var LOG_LEVEL = "debug"
var LOG_FILE = "app.log"
var LOG_PREFIX = "[allied-creation-cooperation]"
// 用户信息模块地址
// USER_MODULE_HOST 用户信息模块地址
var USER_MODULE_HOST = "http://127.0.0.1:8081"
// BASIC_MODULE_HOST 基础服务模块
var BASIC_MODULE_HOST = "http://127.0.0.1:8080"
func init() {
if os.Getenv("LOG_LEVEL") != "" {
LOG_LEVEL = os.Getenv("LOG_LEVEL")
... ...
package service_gateway
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
"strings"
"time"
)
type HttplibBasicServiceGateway struct {
httplibBaseServiceGateway
}
// AgreeCooperationApplication 同意共创申请
func (serviceGateway *HttplibBasicServiceGateway) AgreeCooperationApplication() (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/agree-join-creation-project"}, "/")
request := serviceGateway.createRequest(url, "post")
request.Header("companyId", "")
request.Header("userId", "")
request.Header("orgId", "")
request.Header("userBasic", "")
options := map[string]interface{}{}
_, err := request.JSONBody(options)
if err != nil {
return nil, err
}
response := make(map[string]interface{})
err2 := request.ToJSON(&response)
if err2 != nil {
return nil, err2
}
data, err := serviceGateway.responseHandle(response)
return data, err
}
// RejectCooperationApplication 拒绝共创申请
func (serviceGateway *HttplibBasicServiceGateway) RejectCooperationApplication() (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/refuse-join-creation-project"}, "/")
request := serviceGateway.createRequest(url, "post")
request.Header("companyId", "")
request.Header("userId", "")
request.Header("orgId", "")
request.Header("userBasic", "")
options := make(map[string]interface{})
_, err2 := request.JSONBody(options)
if err2 != nil {
return nil, err2
}
response := make(map[string]interface{})
err := request.ToJSON(&response)
if err != nil {
return nil, err
}
data, err := serviceGateway.responseHandle(response)
return data, err
}
// InformExpectedDividends 分红预算消息
func (serviceGateway *HttplibBasicServiceGateway) InformExpectedDividends() (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-expected-dividends"}, "/")
request := serviceGateway.createRequest(url, "post")
request.Header("companyId", "")
request.Header("userId", "")
request.Header("orgId", "")
request.Header("userBasic", "")
options := make(map[string]interface{})
_, err2 := request.JSONBody(options)
if err2 != nil {
return nil, err2
}
response := make(map[string]interface{})
err := request.ToJSON(&response)
if err != nil {
return nil, err
}
data, err := serviceGateway.responseHandle(response)
return data, err
}
// InformJoinCreationContract 确认共创
func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract() (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-join-creation-contract"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
_, err2 := request.JSONBody(options)
if err2 != nil {
return nil, err2
}
response := make(map[string]interface{})
err := request.ToJSON(&response)
if err != nil {
return nil, err
}
data, err := serviceGateway.responseHandle(response)
return data, err
}
// PayCreditAccount 账期支付
func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount() (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/notice-personal/credit-account/payment"}, "/")
request := serviceGateway.createRequest(url, "post")
request.Header("companyId", "")
request.Header("userId", "")
request.Header("orgId", "")
request.Header("userBasic", "")
options := make(map[string]interface{})
_, err2 := request.JSONBody(options)
if err2 != nil {
return nil, err2
}
response := make(map[string]interface{})
err := request.ToJSON(&response)
if err != nil {
return nil, err
}
data, err := serviceGateway.responseHandle(response)
return data, err
}
// DividendsEstimate 分红预算
func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate() (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/credit-account/dividends-estimate"}, "/")
request := serviceGateway.createRequest(url, "post")
request.Header("companyId", "")
request.Header("userId", "")
request.Header("orgId", "")
request.Header("userBasic", "")
options := make(map[string]interface{})
_, err2 := request.JSONBody(options)
if err2 != nil {
return nil, err2
}
response := make(map[string]interface{})
err := request.ToJSON(&response)
if err != nil {
return nil, err
}
data, err := serviceGateway.responseHandle(response)
return data, err
}
func NewHttplibMessageServiceGateway() *HttplibBasicServiceGateway {
return &HttplibBasicServiceGateway{
httplibBaseServiceGateway: httplibBaseServiceGateway{
baseURL: constant.BASIC_MODULE_HOST,
connectTimeout: 100 * time.Second,
readWriteTimeout: 30 * time.Second,
},
}
}
... ...
package service_gateway
import (
"strings"
"time"
)
type HttplibMessageServiceGateway struct {
httplibBaseServiceGateway
}
// PushMessage 推送消息
func (serviceGateway *HttplibMessageServiceGateway) PushMessage(msgType int, projects []string, uids []int64, title string, content string) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "v1", "push", "pushInfo"}, "/")
request := serviceGateway.createRequest(url, "post")
options := map[string]interface{}{}
_, _ = request.JSONBody(options)
response := make(map[string]interface{})
_ = request.ToJSON(&response)
data, err := serviceGateway.responseHandle(response)
return data, err
}
func NewHttplibMessageServiceGateway() *HttplibMessageServiceGateway {
return &HttplibMessageServiceGateway{
httplibBaseServiceGateway: httplibBaseServiceGateway{
baseURL: "",
connectTimeout: 100 * time.Second,
readWriteTimeout: 30 * time.Second,
},
}
}
... ... @@ -13,5 +13,10 @@ type UserServiceGateway interface {
}
type MessageServiceGateway interface {
PushMessage(msgType int, projects []string, uids []int64, title string, content string) (map[string]interface{}, error)
AgreeCooperationApplication() (map[string]interface{}, error)
RejectCooperationApplication() (map[string]interface{}, error)
InformExpectedDividends() (map[string]interface{}, error)
InformJoinCreationContract() (map[string]interface{}, error)
PayCreditAccount() (map[string]interface{}, error)
DividendsEstimate() (map[string]interface{}, error)
}
... ...