package talent_service

import (
	"github.com/gogf/gf/frame/g"
	"youngmini_server/app/dao"
	"youngmini_server/app/model"
	"youngmini_server/app/model/talent_model"
)

func GetInfoTables() *TalentHttpResult {
	allInfos := talent_model.InfoTables{}
	err := g.DB().Model(model.InfoTalentAgeBracket{}).Scan(&allInfos.AgeBracket)
	if err != nil {
		return &TalentHttpResult{Code: -1, Msg: "query age bracket failed"}
	}

	err = g.DB().Model(model.InfoTalentSkinType{}).Scan(&allInfos.SkinType)
	if err != nil {
		return &TalentHttpResult{Code: -2, Msg: "query skin type failed"}
	}

	err = g.DB().Model(model.InfoTalentSkilledArea{}).Scan(&allInfos.SkilledArea)
	if err != nil {
		return &TalentHttpResult{Code: -3, Msg: "query skilled area failed"}
	}

	err = g.DB().Model(model.InfoProductClassify{}).Scan(&allInfos.ProductClassify)
	if err != nil {
		return &TalentHttpResult{Code: -4, Msg: "query product classify failed"}
	}

	err = g.DB().Model(dao.InfoThirdPlatform.Table).Fields(
		dao.InfoThirdPlatform.Columns.PlatformId,
		dao.InfoThirdPlatform.Columns.PlatformIcon,
		dao.InfoThirdPlatform.Columns.PlatformName).Scan(&allInfos.ThirdPlatform)

	if err != nil {
		return &TalentHttpResult{Code: -5, Msg: "query third platform info failed"}
	}

	return &TalentHttpResult{Code: 0, Msg: "success", Data: allInfos}
}