1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package data_manage
- import (
- "eta/eta_hub/utils"
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "strings"
- "time"
- )
- // Variety variety 装置检修-品种表
- type Variety struct {
- VarietyId int `orm:"column(variety_id);pk"`
- VarietyName string `description:"品种名称"`
- LastUpdateSysUserId int `description:"最后更新人id"`
- LastUpdateSysUserRealName string `description:"最后更新人名称"`
- ProductionDay int `description:"生产天数"`
- SysUserId int `description:"创建人id"`
- SysUserRealName string `description:"创建人姓名"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- }
- func (m *Variety) GetItemsByCondition(cond string, pars []interface{}, fieldArr []string, orderRule string) (items []*Variety, err error) {
- o := orm.NewOrmUsingDB("data")
- 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 variety WHERE 1=1 %s %s`, fields, cond, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // VarietyItem 品种信息
- type VarietyItem struct {
- VarietyId int `description:"品种ID"`
- VarietyName string `description:"品种名称"`
- ProductionDay int `description:"生产天数"`
- CreateTime string `description:"创建时间"`
- UpdateTime string `description:"更新时间"`
- }
- func FormatVariety2Item(origin *Variety) (item *VarietyItem) {
- if origin == nil {
- return
- }
- item = new(VarietyItem)
- item.VarietyId = origin.VarietyId
- item.VarietyName = origin.VarietyName
- item.ProductionDay = origin.ProductionDay
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.UpdateTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
|