package data import ( "context" "git.gz.internal.jumaiyx.cn/job/room-mike-hot-timer/internal/biz" "git.gz.internal.jumaiyx.cn/job/room-mike-hot-timer/internal/data/model" "git.gz.internal.jumaiyx.cn/pkg/log" "github.com/pkg/errors" "gorm.io/gorm" ) type initValue struct { data *Data log log.Logger } func NewInitValue(data *Data, log log.Logger) biz.InitValueRepo { return &initValue{ data: data, log: log, } } func (md *initValue) GetValue(ctx context.Context, ty int32) (int64, error) { value := &model.InitValue{} if err := md.data.db.Model(&model.InitValue{}).Where("type=?", ty).First(&value).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { md.log.Errorf("Get init value err:%v", err) return 0, err } return value.Value, nil }