// Package service 业务逻辑层 package service import ( "server/modules/yx/entity" "server/modules/yx/mapper" "github.com/google/uuid" ) type YxCalculationMajorService struct { mapper *mapper.YxCalculationMajorMapper } func NewYxCalculationMajorService() *YxCalculationMajorService { return &YxCalculationMajorService{mapper: mapper.NewYxCalculationMajorMapper()} } func (s *YxCalculationMajorService) List(page, size int) ([]entity.YxCalculationMajor, int64, error) { return s.mapper.FindAll(page, size) } func (s *YxCalculationMajorService) GetByID(id string) (*entity.YxCalculationMajor, error) { return s.mapper.FindByID(id) } func (s *YxCalculationMajorService) Create(item *entity.YxCalculationMajor) error { item.ID = uuid.New().String() return s.mapper.Create(item) } func (s *YxCalculationMajorService) Update(item *entity.YxCalculationMajor) error { return s.mapper.Update(item) } func (s *YxCalculationMajorService) UpdateFields(id string, fields map[string]interface{}) error { return s.mapper.UpdateFields(id, fields) } func (s *YxCalculationMajorService) Delete(id string) error { return s.mapper.Delete(id) } func (s *YxCalculationMajorService) GetByScoreID(scoreID string) ([]entity.YxCalculationMajor, error) { return s.mapper.FindByScoreID(scoreID) } func (s *YxCalculationMajorService) BatchCreate(items []entity.YxCalculationMajor) error { for i := range items { items[i].ID = uuid.New().String() } return s.mapper.BatchCreate(items, 100) } func (s *YxCalculationMajorService) BatchUpdate(items []entity.YxCalculationMajor) error { return s.mapper.BatchUpdate(items) } func (s *YxCalculationMajorService) BatchUpsert(items []entity.YxCalculationMajor, updateColumns []string) error { for i := range items { if items[i].ID == "" { items[i].ID = uuid.New().String() } } return s.mapper.BatchUpsert(items, updateColumns) } func (s *YxCalculationMajorService) BatchDelete(ids []string) error { return s.mapper.BatchDelete(ids) } func (s *YxCalculationMajorService) DeleteByScoreID(scoreID string) error { return s.mapper.DeleteByScoreID(scoreID) }