package my_chart_classify_mapping

import "hongze/hongze_yb/global"

// GetMyChartSort 获取图表排序
func GetMyChartSort(adminId, myChartClassifyId, sort int) (item *MyChartClassifyMapping, err error) {
	sql := ` SELECT * FROM my_chart_classify_mapping WHERE 1=1 AND admin_id = ? AND my_chart_classify_id = ? `
	if sort == 1 {
		sql += ` ORDER BY sort DESC LIMIT 1 `
	} else {
		sql += ` ORDER BY sort ASC LIMIT 1 `
	}
	err = global.MYSQL["data"].Raw(sql, adminId, myChartClassifyId).First(&item).Error

	return
}

// GetMyChartClassifyMapping 获取图表分类关联信息
func GetMyChartClassifyMapping(adminId, myChartId, myChartClassifyId int) (item *MyChartClassifyMapping, err error) {
	sql := `SELECT * FROM my_chart_classify_mapping WHERE admin_id=? AND my_chart_id=? AND my_chart_classify_id=? `
	err = global.MYSQL["data"].Raw(sql, adminId, myChartId, myChartClassifyId).First(&item).Error

	return
}