global.go 748 字节
package domain

import (
	"fmt"
	"sync/atomic"
)

type RequestHeader struct {
	TimeStamp   string
	Version     string
	Uuid        string
	Sign        string
	DeviceType  int
	AppProject  string
	AccessToken string
	Uid         int64 //用户基本信息Id
	CompanyId   int64
	UserId      int64 //UserId 唯一标识,唯一关联所有用户信息(=user_company.id)

	requestId string //请求编号 md5
	reqIndex  int64  //请求链序号
}

func (reqHead *RequestHeader) SetRequestId(addString ...string) {
	if len(addString) == 0 {
		return
	}
	reqHead.requestId = addString[0]
}
func (reqHead *RequestHeader) GetRequestId() string {
	atomic.AddInt64(&reqHead.reqIndex, 1)
	return fmt.Sprintf("%s.%d", reqHead.requestId, reqHead.reqIndex)
}