package data_manage import ( "eta/eta_api/global" "eta/eta_api/utils" "time" ) type ChartDescription struct { Id int `gorm:"column:id;primaryKey"` Description string `gorm:"column:description"` ChartInfoId int `gorm:"column:chart_info_id"` // 图表id SysUserId int `gorm:"column:sys_user_id"` // 创建人id SysUserRealName string `gorm:"column:sys_user_real_name"` // 创建人姓名 ModifyTime time.Time `gorm:"column:modify_time"` // 变更时间 CreateTime time.Time `gorm:"column:create_time"` // 关系建立时间 } // AddChartDescription 添加图表简介 func AddChartDescription(item *ChartDescription) (err error) { err = global.DbMap[utils.DbNameIndex].Create(item).Error return } // GetChartDescriptionByChartInfoId 根据图表ID获取图表简介 func GetChartDescriptionByChartInfoId(chartInfoId int) (item []*ChartDescription, err error) { sql := `SELECT * FROM chart_description WHERE chart_info_id = ? order by create_time desc, id desc` err = global.DbMap[utils.DbNameIndex].Raw(sql, chartInfoId).Find(&item).Error return } // GetChartDescriptionById 根据ID获取图表简介 func GetChartDescriptionById(id int) (item *ChartDescription, err error) { sql := `SELECT * FROM chart_description WHERE id = ?` err = global.DbMap[utils.DbNameIndex].Raw(sql, id).First(&item).Error return } // DeleteChartDescription 删除图表简介 func DeleteChartDescription(id int) (err error) { sql := `DELETE FROM chart_description WHERE id = ?` err = global.DbMap[utils.DbNameIndex].Exec(sql, id).Error return } // DeleteChartDescriptionByChartInfoId 根据图表ID删除图表简介 func DeleteChartDescriptionByChartInfoId(chartInfoId int) (err error) { sql := `DELETE FROM chart_description WHERE chart_info_id = ?` err = global.DbMap[utils.DbNameIndex].Exec(sql, chartInfoId).Error return } type ChartDescriptionList struct { Id int `gorm:"column:id;primaryKey"` Description string `gorm:"column:description"` ChartInfoId int `gorm:"column:chart_info_id"` // 图表id SysUserId int `gorm:"column:sys_user_id"` // 创建人id SysUserRealName string `gorm:"column:sys_user_real_name"` // 创建人姓名 CreateTime string `gorm:"column:create_time"` // 创建时间 } type ChartDescriptionListResponse struct { List []*ChartDescriptionList } type ChartDescriptionAddReq struct { ChartInfoId int `description:"图表id"` Description string `description:"简介"` } type ChartDescriptionReq struct { Id int Description string // 图表id ChartInfoId int SysUserId int // 创建人id SysUserRealName string // 创建人姓名 AdminName string // 创建人姓名 ModifyTime time.Time // 变更时间 CreateTime time.Time // 关系建立时间 }