package company

import (
	"github.com/gin-gonic/gin"
	"hongze/hongze_yb/controller/response"
	"hongze/hongze_yb/services/company"
	userService "hongze/hongze_yb/services/user"
)

// GetHomeFiccPermissions 首页品种权限列表
func GetHomeFiccPermissions(c *gin.Context) {
	userinfo := userService.GetInfoByClaims(c)

	list, err := company.GetHomeFiccPermissions(userinfo)
	if err !=nil {
		response.Fail(err.Error(), c)
		return
	}

	response.OkData("获取成功", list, c)
}

// GetPermissionTree 获取FICC品种权限列表-不校验权限
// @Tags 客户模块
// @Summary  获取FICC品种权限列表
// @Description 获取FICC品种权限列表
// @Security ApiKeyAuth
// @Param Authorization	header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
// @Accept  json
// @Product json
// @Success 200 {object} []company.FiccPermissionList
// @failure 400 {string} string "获取失败"
// @Router /company/permission/tree [get]
func GetPermissionTree(c *gin.Context)  {
	list, err := company.GetFiccPermissionList()
	if err != nil {
		response.FailMsg("获取失败", "GetPermissionList ErrMsg:" + err.Error(), c)
		return
	}
	response.OkData("获取成功", list, c)
}

// GetBindFiccPermissions 展示有权限的品种列表，无权限的隐藏
func GetBindFiccPermissions(c *gin.Context) {
	userinfo := userService.GetInfoByClaims(c)

	list, err := company.GetBindFiccPermissions(userinfo)
	if err !=nil {
		response.Fail(err.Error(), c)
		return
	}

	response.OkData("获取成功", list, c)
}

// GetCommoditiesBindFiccPermissions 大宗商品展示有权限的品种列表，无权限的隐藏
// @Tags 客户模块
// @Summary  获取FICC品种权限列表
// @Description 获取FICC品种权限列表
// @Security ApiKeyAuth
// @Param Authorization	header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
// @Accept  json
// @Product json
// @Success 200 {object} []company.FiccPermissionList
// @failure 400 {string} string "获取失败"
// @Router /company/permission/commodities [get]
func GetCommoditiesBindFiccPermissions(c *gin.Context) {
	userinfo := userService.GetInfoByClaims(c)

	list, err := company.GetCommoditiesBindFiccPermissions(userinfo)
	if err !=nil {
		response.Fail(err.Error(), c)
		return
	}

	response.OkData("获取成功", list, c)
}