1234567891011121314151617181920212223242526272829303132 |
- // @Author gmy 2024/8/7 9:26:00
- package models
- import (
- "errors"
- "github.com/beego/beego/v2/client/orm"
- )
- type BaseFromLyClassify struct {
- BaseFromLyClassifyId int `orm:"column(base_from_ly_classify_id);pk"` // 分类ID
- CreateTime string `orm:"column(create_time)"` // 创建时间
- ModifyTime string `orm:"column(modify_time)"` // 修改时间
- ClassifyName string `orm:"column(classify_name)"` // 分类名称
- ParentId int `orm:"column(parent_id)"` // 上级id
- Sort int `orm:"column(sort)"` // 排序字段,越小越靠前
- ClassifyNameEn string `orm:"column(classify_name_en)"` // 英文分类名称
- }
- func init() {
- orm.RegisterModel(new(BaseFromLyClassify))
- }
- // 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)
- if errors.Is(err, orm.ErrNoRows) {
- return nil, nil
- }
- return
- }
|