package controllers

import (
	"eta/eta_mini_crm_ht/models"
	"eta/eta_mini_crm_ht/models/response"
)

type RiskConfigController struct {
	BaseAuthController
}

// GetCustomerRiskList
// @Title 获取客户风险等级
// @Description 获取客户风险等级
// @Success 200 {object} models.LoginResp
// @router /customerRiskList [get]
func (this *RiskConfigController) GetCustomerRiskList() {
	br := new(models.BaseResponse).Init()
	defer func() {
		this.Data["json"] = br
		this.ServeJSON()
	}()
	list, err := models.GetCustomerRiskList()
	if err != nil {
		br.Msg = "获取失败"
		br.ErrMsg = "获取失败，Err:" + err.Error()
		return
	}
	var viewList []*models.RiskConfigView
	for _, item := range list {
		viewList = append(viewList, item.ToView())
	}
	resp := new(response.RiskConfigResp)
	resp.List = viewList
	br.Ret = 200
	br.Success = true
	br.Msg = "获取成功"
	br.Data = resp
}

// GetProductRiskList
// @Title 获取产品风险等级
// @Description  获取产品风险等级
// @Success 200 {object} models.LoginResp
// @router /productRiskList [get]
func (this *RiskConfigController) GetProductRiskList() {
	br := new(models.BaseResponse).Init()
	defer func() {
		this.Data["json"] = br
		this.ServeJSON()
	}()
	list, err := models.GetProductRiskList()
	if err != nil {
		br.Msg = "获取失败"
		br.ErrMsg = "获取失败，Err:" + err.Error()
		return
	}
	var viewList []*models.RiskConfigView
	for _, item := range list {
		viewList = append(viewList, item.ToView())
	}
	resp := new(response.RiskConfigResp)
	resp.List = viewList
	br.Ret = 200
	br.Success = true
	br.Msg = "获取成功"
	br.Data = resp
}
