123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- package eta_training_video
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "strings"
- "time"
- )
- // EtaTrainingVideoClassify 视频分类
- type EtaTrainingVideoClassify struct {
- EtaTrainingVideoClassifyId int `orm:"column(eta_training_video_classify_id);pk"`
- ClassifyName string `description:"视频分类名称"`
- ParentId int `description:"父级ID"`
- Sort int `description:"排序"`
- SysUserId int `description:"创建人ID"`
- SysRealName string `description:"创建人姓名"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *EtaTrainingVideoClassify) TableName() string {
- return "eta_training_video_classify"
- }
- func (m *EtaTrainingVideoClassify) PrimaryId() string {
- return VideoClassifyColumns.EtaTrainingVideoClassifyId
- }
- var VideoClassifyColumns = struct {
- EtaTrainingVideoClassifyId string
- ClassifyName string
- ParentId string
- Sort string
- SysUserId string
- SysRealName string
- CreateTime string
- ModifyTime string
- }{
- EtaTrainingVideoClassifyId: "eta_training_video_classify_id",
- ClassifyName: "classify_name",
- ParentId: "parent_id",
- Sort: "sort",
- SysUserId: "sys_user_id",
- SysRealName: "sys_real_name",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- func (m *EtaTrainingVideoClassify) Create() (err error) {
- o := orm.NewOrm()
- id, err := o.Insert(m)
- if err != nil {
- return
- }
- m.EtaTrainingVideoClassifyId = int(id)
- return
- }
- func (m *EtaTrainingVideoClassify) CreateMulti(items []*EtaTrainingVideoClassify) (err error) {
- if len(items) == 0 {
- return
- }
- o := orm.NewOrm()
- _, err = o.InsertMulti(len(items), items)
- return
- }
- func (m *EtaTrainingVideoClassify) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(m, cols...)
- return
- }
- func (m *EtaTrainingVideoClassify) Del() (err error) {
- o := orm.NewOrm()
- sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
- _, err = o.Raw(sql, m.EtaTrainingVideoClassifyId).Exec()
- return
- }
- func (m *EtaTrainingVideoClassify) GetItemById(id int) (item *EtaTrainingVideoClassify, err error) {
- o := orm.NewOrm()
- sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
- err = o.Raw(sql, id).QueryRow(&item)
- return
- }
- func (m *EtaTrainingVideoClassify) GetItemByCondition(condition string, pars []interface{}) (item *EtaTrainingVideoClassify, err error) {
- o := orm.NewOrm()
- sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s LIMIT 1`, m.TableName(), condition)
- err = o.Raw(sql, pars).QueryRow(&item)
- return
- }
- func (m *EtaTrainingVideoClassify) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
- o := orm.NewOrm()
- sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
- err = o.Raw(sql, pars).QueryRow(&count)
- return
- }
- func (m *EtaTrainingVideoClassify) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*EtaTrainingVideoClassify, err error) {
- o := orm.NewOrm()
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- func (m *EtaTrainingVideoClassify) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*EtaTrainingVideoClassify, err error) {
- o := orm.NewOrm()
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- // EtaTrainingVideoClassifyAddReq 新增视频分类请求体
- type EtaTrainingVideoClassifyAddReq struct {
- ParentId int `description:"父级ID"`
- ClassifyName string `description:"视频分类名称"`
- }
- // EtaTrainingVideoClassifyEditReq 编辑视频分类请求体
- type EtaTrainingVideoClassifyEditReq struct {
- ClassifyId int `description:"视频分类ID"`
- EtaTrainingVideoClassifyAddReq
- }
- // EtaTrainingVideoClassifyRemoveReq 删除视频分类请求体
- type EtaTrainingVideoClassifyRemoveReq struct {
- ClassifyId int `description:"视频分类ID"`
- }
- // EtaTrainingVideoClassifyResp 视频分类响应体
- type EtaTrainingVideoClassifyResp struct {
- List []*EtaTrainingVideoClassifyItem
- }
- // EtaTrainingVideoClassifyItem 视频分类信息
- type EtaTrainingVideoClassifyItem struct {
- ClassifyId int `description:"视频分类ID"`
- ClassifyName string `description:"视频分类名称"`
- ParentId int `description:"父级ID"`
- Sort int `description:"排序"`
- Children []*EtaTrainingVideoClassifyItem
- }
|