package service

import (
	"sws_xcx/models"

	"github.com/jinzhu/gorm"
)

type CheckItemService struct {
	rdb *gorm.DB
}

func NewCheckItemService() *CheckItemService {
	return &CheckItemService{
		rdb: ReadDB().Model(&models.CheckItem{}),
	}
}

func (s *CheckItemService) GetCheckItems(lang string) ([]*models.CheckItem, error) {
	var items []*models.CheckItem
	err := s.rdb.Where("language = ? and delete_flag = ?", lang, 0).Order("check_item_number").Find(&items).Error
	return items, err
}
