package logic

import (
	"fmt"
	"hongze/hongze_yb/models/tables/rddp/chart_permission"
	"hongze/hongze_yb/utils"
)

type ApplyVariety struct {
	PermissionName string `json:"permission_name" description:"权限名称"`
	Name           string `json:"name" description:"品种名称"`
	PicUrl         string `json:"pic_url" description:"品种图片"`
}

// GetApplyVarietyList 获取所有可以申请的品种权限
func GetApplyVarietyList() (list []ApplyVariety, err error) {
	// 查询所有的二级品种，按照顺序排序，
	permissionImgMap := make(map[string]string, 0)
	permissionImgMap["宏观经济"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/宏观经济.png"
	permissionImgMap["资产配置"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/资产配置.png"
	permissionImgMap["贵金属"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/贵金属.png"
	permissionImgMap["汇率"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/汇率.png"
	permissionImgMap["利率债"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/利率债.png"
	permissionImgMap["原油"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/原油.png"
	permissionImgMap["成品油"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/成品油.png"
	permissionImgMap["LPG"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/LPG.png"
	permissionImgMap["PTA"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/PTA.png"
	permissionImgMap["MEG"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/MEG.png"
	permissionImgMap["纺服"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/纺服.png"
	permissionImgMap["甲醇"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/甲醇.png"
	permissionImgMap["聚烯烃"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/聚烯烃.png"
	permissionImgMap["尿素"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/尿素.png"
	permissionImgMap["沥青"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/沥青.png"
	permissionImgMap["苯乙烯"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/苯乙烯.png"
	permissionImgMap["PVC"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/PVC.png"
	permissionImgMap["聚酯"] = "https://hzstatic.hzinsights.com/static/yb_variety/聚酯.png"
	permissionImgMap["钢材"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/钢材.png"
	permissionImgMap["铁矿"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/铁矿.png"
	permissionImgMap["玻璃纯碱"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/玻璃纯碱.png"
	permissionImgMap["烧碱"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/烧碱.png"
	permissionImgMap["双焦"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/双焦.png"
	permissionImgMap["铜"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/铜.png"
	permissionImgMap["铝"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/铝.png"
	permissionImgMap["镍/不锈钢"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/镍不锈钢.png"
	permissionImgMap["锌"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/锌.png"
	permissionImgMap["钴锂"] = "https://hzstatic.hzinsights.com/static/yb_variety/钴锂.png"
	permissionImgMap["碳酸锂"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/碳酸锂.png"
	permissionImgMap["工业硅"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/工业硅.png"
	permissionImgMap["策略"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/策略.png"
	permissionImgMap["固定收益"] = "https://hzstatic.hzinsights.com/static/yb_variety/v2/固定收益.png"
	allFiccPermissions, e := chart_permission.GetListByProductIdAndPermissionType(1)
	if e != nil {
		err = fmt.Errorf("获取品种权限失败 Err:%s", e.Error())
		return
	}

	for _, v := range allFiccPermissions {
		if v.ParentId > 0 {
			tmp := ApplyVariety{PermissionName: v.PermissionName, Name: v.PermissionName, PicUrl: utils.APPLY_VARIETY_IMG_DEFAULT}
			img, ok := permissionImgMap[v.PermissionName]
			if ok {
				tmp.PicUrl = img
			}
			list = append(list, tmp)
		}
	}
	/*list = append(list, ApplyVariety{PermissionName: "宏观经济", Name: "宏观经济", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/宏观经济.png"})
	list = append(list, ApplyVariety{PermissionName: "利率债", Name: "利率债", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/利率债.png"})
	list = append(list, ApplyVariety{PermissionName: "原油", Name: "原油", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/原油.png"})
	list = append(list, ApplyVariety{PermissionName: "PTA", Name: "PTA", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/PTA.png"})
	list = append(list, ApplyVariety{PermissionName: "MEG", Name: "MEG", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/MEG.png"})
	list = append(list, ApplyVariety{PermissionName: "织造终端", Name: "织造终端", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/织造终端.png"})
	list = append(list, ApplyVariety{PermissionName: "甲醇", Name: "甲醇", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/甲醇.png"})
	list = append(list, ApplyVariety{PermissionName: "聚烯烃", Name: "聚烯烃", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/聚烯烃.png"})
	list = append(list, ApplyVariety{PermissionName: "沥青", Name: "沥青", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/沥青.png"})
	list = append(list, ApplyVariety{PermissionName: "纯苯+苯乙烯", Name: "纯苯+苯乙烯", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/苯乙烯.png"})
	list = append(list, ApplyVariety{PermissionName: "PVC", Name: "PVC", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/PVC.png"})
	list = append(list, ApplyVariety{PermissionName: "聚酯", Name: "聚酯", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/聚酯.png"})
	list = append(list, ApplyVariety{PermissionName: "钢材", Name: "钢材", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/钢材.png"})
	list = append(list, ApplyVariety{PermissionName: "铁矿", Name: "铁矿", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/铁矿.png"})
	list = append(list, ApplyVariety{PermissionName: "玻璃纯碱", Name: "玻璃纯碱", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/玻璃纯碱.png"})
	list = append(list, ApplyVariety{PermissionName: "双焦（焦煤、焦炭）", Name: "双焦(焦煤、焦炭)", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/双焦(焦煤、焦炭).png"})
	list = append(list, ApplyVariety{PermissionName: "有色（铜、铝）", Name: "有色(铜、铝)", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/有色(铜、铝).png"})
	list = append(list, ApplyVariety{PermissionName: "镍+不锈钢", Name: "镍+不锈钢", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/镍2不锈钢.png"})
	list = append(list, ApplyVariety{PermissionName: "有色（锌）", Name: "有色(锌)", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/有色锌.png"})
	list = append(list, ApplyVariety{PermissionName: "钴锂", Name: "钴锂", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/钴锂.png"})*/
	//list = append(list, ApplyVariety{PermissionName: "苯乙烯", Name: "苯乙烯", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/苯乙烯.png"})
	//list = append(list, ApplyVariety{PermissionName: "橡胶", Name: "橡胶", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/橡胶.png"})
	//list = append(list, ApplyVariety{PermissionName: "策略", Name: "市场策略", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/市场策略.png"})
	return
}
