// @Author gmy 2024/8/7 9:26:00 package models import ( "eta/eta_index_lib/global" "eta/eta_index_lib/utils" "time" ) type BaseFromLyClassify struct { BaseFromLyClassifyId int `gorm:"column:base_from_ly_classify_id;type:int(11) UNSIGNED;comment:分类ID;primaryKey;not null;"` // 分类ID CreateTime time.Time `gorm:"column:create_time;type:datetime;comment:创建时间;not null;default:CURRENT_TIMESTAMP;"` // 创建时间 ModifyTime time.Time `gorm:"column:modify_time;type:datetime;comment:修改时间;not null;default:CURRENT_TIMESTAMP;"` // 修改时间 ClassifyName string `gorm:"column:classify_name;type:varchar(255);comment:分类名称;not null;"` // 分类名称 ParentId int32 `gorm:"column:parent_id;type:int(11) UNSIGNED;comment:上级id;default:0;"` // 上级id Sort int32 `gorm:"column:sort;type:int(9) UNSIGNED;comment:排序字段,越小越靠前;default:0;"` // 排序字段,越小越靠前 ClassifyNameEn string `gorm:"column:classify_name_en;type:varchar(255);comment:英文分类名称;"` // 英文分类名称 } // GetLyClassifyByName 根据分类名称查询 func GetLyClassifyByName(classifyName string) (item *BaseFromLyClassify, err error) { //o := orm.NewOrm() sql := `SELECT * FROM base_from_ly_classify WHERE classify_name=?` //err = o.Raw(sql, classifyName).QueryRow(&item) err = global.DEFAULT_DB.Raw(sql, classifyName).First(&item).Error if utils.IsErrNoRow(err) { return nil, nil } return }