digitization_server.go 2.0 KB
package service_gateway

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
	"strconv"
	"time"
)

type HttpLibAlliedCreationStandardServiceGateway struct {
	HttpLibBaseServiceGateway
	baseURL string
}
type Field struct {
	Index   int    `json:"index"`
	Name    string `json:"name"`
	SqlType string `json:"sqlType"`
	SqlName string `json:"sqlName"`
	Flag    int    `json:"flag"`
}

type Conditions struct {
	Field *Field   `json:"field"`
	In    []string `json:"in"`
	Ex    []string `json:"ex"`
}

type Where struct { //输入
	PageNumber int           `json:"pageNumber"`
	PageSize   int           `json:"pageSize"`
	Conditions []*Conditions `json:"conditions"`
}

func NewHttpLibAlliedCreationStandardServiceGateway() *HttpLibAlliedCreationStandardServiceGateway {
	return &HttpLibAlliedCreationStandardServiceGateway{
		HttpLibBaseServiceGateway: HttpLibBaseServiceGateway{
			ConnectTimeout:   100 * time.Second,
			ReadWriteTimeout: 30 * time.Second,
		},
		baseURL: constant.ALLIED_CREATION_STANDARD,
	}
}

//获取下拉列表0
func (serviceGateway *HttpLibAlliedCreationStandardServiceGateway) GetBusiness() (map[string]interface{}, error) {
	AppKey := "gBzrh4BBeVeGQbRngPTUTRZOAcqtSVr9"          //可更改
	AppSecret := "oCUsnka2RUjMKPWjiUbSOcKbqV1pYsaT"       //产品不一样密钥不一样
	timestamp := strconv.FormatInt(time.Now().Unix(), 10) //当前时间戳
	sign := utils.GenMd5(AppKey + AppSecret + timestamp)
	//serviceGateway.baseURL="http://127.1.0.1:8080"
	req, err := serviceGateway.CreateRequest(serviceGateway.baseURL+"/data/business/search", "post").Header("AppKey", AppKey).Header("Timestamp", timestamp).Header("Sign", sign).JSONBody(map[string]interface{}{})
	if err != nil {
		return nil, err
	}
	//var response DataTableSearch
	response := make(map[string]interface{})
	err = req.ToJSON(&response)
	if err != nil {
		return nil, err
	}
	data, err := serviceGateway.responseHandle(response)
	return data, err
}