123456789101112131415161718192021222324252627282930313233343536373839404142 |
- // @Author gmy 2024/8/7 9:26:00
- package models
- import (
- "errors"
- "github.com/beego/beego/v2/client/orm"
- )
- type BaseFromRzdClassify struct {
- BaseFromRzdClassifyId int `orm:"column(base_from_rzd_classify_id);pk"`
- CreateTime string `orm:"column(create_time)"`
- ModifyTime string `orm:"column(modify_time)"`
- ClassifyName string `orm:"column(classify_name)"`
- ParentId int `orm:"column(parent_id)"`
- Sort int `orm:"column(sort)"`
- ClassifyNameEn string `orm:"column(classify_name_en)"`
- }
- func init() {
- orm.RegisterModel(new(BaseFromRzdClassify))
- }
- // GetRzdClassifyByName 根据分类名称查询
- func GetRzdClassifyByName(classifyName string) (item *BaseFromRzdClassify, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_rzd_classify WHERE classify_name=?`
- err = o.Raw(sql, classifyName).QueryRow(&item)
- if errors.Is(err, orm.ErrNoRows) {
- return nil, nil
- }
- return
- }
- // AddRzdClassify 新增分类
- func AddRzdClassify(classify *BaseFromRzdClassify) (int64, error) {
- o := orm.NewOrm()
- id, err := o.Insert(classify)
- if err != nil {
- return 0, err
- }
- return id, nil
- }
|