base_controller.go 834 字节
package controllers

import (
	"github.com/beego/beego/v2/server/web/context"
	"github.com/linmadan/egglib-go/web/beego"
	"strconv"
)

type BaseController struct {
	beego.BaseController
}

type RequestHeader struct {
	//	公司id
	CompanyId int64
	//	组织机构id
	OrgId int64
	//	用户id
	UserId int64
	// 	用户基础数据id
	UserBaseId int64
}

// GetRequestHeader 获取请求头信息
func (controller *BaseController) GetRequestHeader(ctx *context.Context) *RequestHeader {
	header := &RequestHeader{}
	header.CompanyId, _ = strconv.ParseInt(ctx.Input.Header("companyid"), 10, 64)
	header.OrgId, _ = strconv.ParseInt(ctx.Input.Header("orgid"), 10, 64)
	header.UserId, _ = strconv.ParseInt(ctx.Input.Header("userid"), 10, 64)
	header.UserBaseId, _ = strconv.ParseInt(ctx.Input.Header("userbaseid"), 10, 64)
	return header
}