golang-yitisheng-server/server/modules/yx/service/yx_school_major_service.go

40 lines
1010 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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)
}