package cast

import (
	"context"
	"dubbo.apache.org/dubbo-go/v3/common/constant"
	"fmt"
	"fonchain-fiee/cmd/config"
	"fonchain-fiee/pkg/model/login"
	"github.com/gin-gonic/gin"
)

func NewCtxWithUserInfo(ctx *gin.Context) (newCtx context.Context) {
	var userInfo = login.Info{}
	if config.AppConfig.System.AppMode != "dev" {
		userInfo = login.GetUserInfoFromC(ctx)
	} else {
		userInfo = login.Info{
			ID:     61,
			Name:   "小波",
			TelNum: "18288888888",
		}
	}
	var mm = make(map[string]interface{}, 3)
	mm["userid"] = fmt.Sprintf("%d", userInfo.ID)
	mm["name"] = userInfo.Name
	mm["phone"] = userInfo.TelNum
	newCtx = context.WithValue(context.Background(), constant.DubboCtxKey("attachment"), mm)
	return
}
