baseController.go 1.1 KB
package mobile_client

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)

type baseController struct {
	beego.BaseController
}

func (controller *baseController) returnPageListData(count int64, data interface{}, err error, pageNumber int) {
	dataMap := map[string]interface{}{
		"grid": map[string]interface{}{
			"total": count,
			//"pageNumber": pageNumber,
			"list": data,
		},
	}
	controller.Response(dataMap, err)
}

func (controller *baseController) GetUserId() int64 {
	return 1
}

func (controller *baseController) GetCompanyId() int64 {
	return 1
}

func (controller *baseController) GetUserBaseId() int64 {
	return 1
}

func (controller *baseController) GetOrgId() int64 {
	return 1
}

func (controller *baseController) GetOperator() domain.Operator {
	token := controller.Ctx.Input.Header("X-Mmm-Accesstoken")
	loginToken := &domain.LoginToken{}
	loginToken.ParseToken(token)
	return domain.Operator{
		UserId:     loginToken.UserId,
		CompanyId:  loginToken.CompanyId,
		OrgId:      loginToken.OrgId,
		UserBaseId: loginToken.UserBaseId,
		Phone:      loginToken.Account,
	}
}