package dao import ( "errors" "yintai-api/app/common/model" "gorm.io/gorm" ) type ConfigTranslations struct { db *gorm.DB } func NewConfigTranslations(db ...*gorm.DB) *ConfigTranslations { return &ConfigTranslations{db: getDB(db...)} } func (r *ConfigTranslations) TableName() string { return "yt_config_translations" } func (r *ConfigTranslations) Create(m *model.ConfigTranslations) error { return r.db.Table(r.TableName()).Create(m).Error } func (r *ConfigTranslations) Update(m *model.ConfigTranslations) error { return r.db.Table(r.TableName()).Save(m).Error } func (r *ConfigTranslations) Delete(id int64) error { return r.db.Table(r.TableName()).Where("id = ?", id).Delete(&ConfigTranslations{}).Error } func (r *ConfigTranslations) Get(id int64) (*model.ConfigTranslations, error) { var res model.ConfigTranslations if err := r.db.Table(r.TableName()).Where("id = ?", id).First(&res).Error; err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { return nil, nil } return nil, err } return &res, nil } func (r *ConfigTranslations) Exists(id int64) (bool, error) { var count int64 if err := r.db.Table(r.TableName()).Where("id = ?", id).Count(&count).Error; err != nil { return false, err } return count > 0, nil } func (r *ConfigTranslations) List(...any) ([]*model.ConfigTranslations, int64, error) { panic("implement me") }