package yb_config

import "hongze/hongze_yb/global"

// GetConfigByCode 查询配置详情
func GetConfigByCode(configCode string) (item *YbConfig, err error) {
	err = global.DEFAULT_MYSQL.Model(YbConfig{}).
		Where("config_code = ?", configCode).
		First(&item).Error
	return
}

func (m *YbConfig) Create() (err error) {
	err = global.DEFAULT_MYSQL.Create(m).Error
	return
}

func (m *YbConfig) Update(cols string) (err error) {
	err = global.DEFAULT_MYSQL.Model(m).Select(cols).Updates(*m).Error
	return
}

func (m *YbConfig) Delete() (err error) {
	return
}

func (m *YbConfig) Fetch(condition string, pars []interface{}) (item *YbConfig, err error) {
	err = global.DEFAULT_MYSQL.Model(m).Where(condition, pars).First(&item).Error
	return
}
