package mapper

import (
	"server/config"
	"server/modules/yx/entity"
)

type YxHistoryScoreControlLineMapper struct{}

func NewYxHistoryScoreControlLineMapper() *YxHistoryScoreControlLineMapper {
	return &YxHistoryScoreControlLineMapper{}
}

func (m *YxHistoryScoreControlLineMapper) SelectByYearAndCategory(year, professionalCategory, category string) ([]entity.YxHistoryScoreControlLine, error) {
	var items []entity.YxHistoryScoreControlLine
	err := config.DB.Model(&entity.YxHistoryScoreControlLine{}).
		Where("year = ?", year).
		Where("professional_category = ?", professionalCategory).
		Where("category = ?", category).
		Order("batch desc").
		Find(&items).Error
	return items, err
}
