// Package service 业务逻辑层 package service import ( "server/common" "server/modules/yx/entity" "server/modules/yx/mapper" "github.com/google/uuid" ) type YxSchoolMajorService struct { *common.BaseService[entity.YxSchoolMajor] mapper *mapper.YxSchoolMajorMapper } func NewYxSchoolMajorService() *YxSchoolMajorService { mapper := mapper.NewYxSchoolMajorMapper() return &YxSchoolMajorService{ BaseService: common.NewBaseService[entity.YxSchoolMajor](), mapper: mapper, } } // Create 创建院校专业(使用 UUID 生成 ID) func (s *YxSchoolMajorService) Create(item *entity.YxSchoolMajor) error { item.ID = uuid.New().String() return s.mapper.Create(item) } // BatchUpsert 批量插入或更新(使用 UUID 生成 ID) func (s *YxSchoolMajorService) BatchUpsert(items []entity.YxSchoolMajor, updateColumns []string) error { for i := range items { if items[i].ID == "" { items[i].ID = uuid.New().String() } } return s.mapper.BatchUpsert(items, updateColumns) }