package cross_variety import ( "eta_gn/eta_api/global" "eta_gn/eta_api/utils" "time" ) // ChartVariety // @Description: chart_variety 图表品种表 type ChartVariety struct { ChartVarietyId int `orm:"column(chart_variety_id);pk" gorm:"primaryKey" ` ChartVarietyName string `description:"品种名称"` ChartVarietyNameEn string `description:"品种名称(英文)"` SysUserId int `description:"创建人id"` SysUserRealName string `description:"创建人姓名"` ModifyTime time.Time `description:"修改时间"` CreateTime time.Time `description:"创建时间"` } // GetVarietyById // @Description: 根据品种id获取品种详情 // @author: Roc // @datetime 2023-11-21 14:55:31 // @param id int // @return item *ChartVariety // @return err error func GetVarietyById(id int) (item *ChartVariety, err error) { sql := `SELECT * FROM chart_variety WHERE chart_variety_id = ?` err = global.DmSQL["data"].Raw(sql, id).First(&item).Error return } // GetVarietyByName // @Description: 根据品种名称获取品种详情 // @author: Roc // @datetime 2023-11-21 14:55:20 // @param name string // @return item *ChartVariety // @return err error func GetVarietyByName(name string) (item *ChartVariety, err error) { sql := `SELECT * FROM chart_variety WHERE chart_variety_name = ?` err = global.DmSQL["data"].Raw(sql, name).First(&item).Error return } // AddVariety // @Description: 添加品种 // @author: Roc // @datetime 2023-11-21 14:52:56 // @param item *ChartVariety // @return err error func AddVariety(item *ChartVariety) (err error) { err = global.DmSQL["data"].Create(item).Error return } // Update // @Description: 更新品种 // @author: Roc // @receiver item // @datetime 2023-11-21 15:15:17 // @param updateColList []string // @return err error func (item *ChartVariety) Update(updateColList []string) (err error) { err = global.DmSQL["data"].Select(updateColList).Updates(item).Error return } // Delete 删除 func (item *ChartVariety) Delete() (err error) { sql := ` DELETE FROM chart_variety WHERE chart_variety_id=? ` err = global.DmSQL["data"].Exec(sql, item.ChartVarietyId).Error return } // GetVarietyList // @Description: 获取所有品种列表 // @author: Roc // @datetime 2023-11-22 10:44:35 // @return items []*ChartVariety // @return err error func GetVarietyList() (items []*ChartVariety, err error) { sql := `SELECT * FROM chart_variety WHERE 1 = 1 ` err = global.DmSQL["data"].Raw(sql).Find(&items).Error return } // GetVarietyListByIdList // @Description: 根据ID列表获取品种列表 // @author: Roc // @datetime 2023-11-23 17:56:39 // @param idList []int // @return items []*ChartVariety // @return err error func GetVarietyListByIdList(idList []int) (items []*ChartVariety, err error) { num := len(idList) if num <= 0 { return } sql := `SELECT * FROM chart_variety WHERE 1 = 1 AND chart_variety_id in (` + utils.GetOrmInReplace(num) + `)` err = global.DmSQL["data"].Raw(sql, idList).Find(&items).Error return }