package excel import ( "eta_gn/eta_chart_lib/global" "time" ) type ExcelSheet struct { ExcelSheetId int `gorm:"column:excel_sheet_id;primaryKey" orm:"column(excel_sheet_id);pk"` ExcelInfoId int `gorm:"column:excel_info_id" description:"excel的id"` SheetName string `gorm:"column:sheet_name" description:"sheet名称"` PageNum int `gorm:"column:page_num" description:"总页码数"` Index string `gorm:"column:index" description:"excel数据中的index"` Sort int `gorm:"column:sort" description:"排序"` Config string `gorm:"column:config" description:"配置信息"` CalcChain string `gorm:"column:calc_chain" description:"计算公式"` ModifyTime time.Time `gorm:"column:modify_time" description:"最近修改日期"` CreateTime time.Time `gorm:"column:create_time" description:"创建日期"` } func (excelSheet *ExcelSheet) Update(cols []string) (err error) { o := global.DmSQL["data"] err = o.Model(excelSheet).Select(cols).Updates(excelSheet).Error return } func AddExcelSheet(excelInfo *ExcelSheet) (err error) { o := global.DmSQL["data"] err = o.Create(excelInfo).Error return } func GetAllSheetList(excelInfoId int) (item []*ExcelSheet, err error) { o := global.DmSQL["data"] sql := ` SELECT * FROM excel_sheet WHERE 1=1 AND excel_info_id = ? ` sql += " ORDER BY sort asc " err = o.Raw(sql, excelInfoId).Scan(&item).Error return } type SheetItem struct { ExcelSheetId int `gorm:"column:excel_sheet_id;primaryKey" json:"-" orm:"column(excel_sheet_id);pk"` ExcelInfoId int `gorm:"column:excel_info_id" description:"excel的id" json:"-"` SheetName string `gorm:"column:sheet_name" description:"sheet名称" ` PageNum int `gorm:"column:page_num" description:"数据总页码数" ` Index string `gorm:"column:index" description:"excel数据中的index" ` Sort int `gorm:"column:sort" description:"排序" ` Config string `gorm:"column:config" description:"sheet配置" ` CalcChain string `gorm:"column:calc_chain" description:"计算公式"` ModifyTime time.Time `gorm:"column:modify_time" description:"最近修改日期" json:"-"` CreateTime time.Time `gorm:"column:create_time" description:"创建日期"` Data *ExcelSheetData `description:"excel的数据"` } func GetAllSheetItemList(excelInfoId int) (item []*SheetItem, err error) { o := global.DmSQL["data"] sql := ` SELECT * FROM excel_sheet WHERE 1=1 AND excel_info_id = ? ` sql += " ORDER BY sort asc " err = o.Raw(sql, excelInfoId).Scan(&item).Error return } func GetAllNoConfigSheetItemList(excelInfoId int) (item []*SheetItem, err error) { o := global.DmSQL["data"] sql := ` SELECT excel_sheet_id,excel_info_id,sheet_name,sort,page_num,create_time FROM excel_sheet WHERE 1=1 AND excel_info_id = ? ` sql += " ORDER BY sort asc " err = o.Raw(sql, excelInfoId).Scan(&item).Error return } type AddExcelSheetParams struct { ExcelSheetId int `gorm:"column:excel_sheet_id;primaryKey" orm:"column(excel_sheet_id);pk"` ExcelInfoId int `gorm:"column:excel_info_id" description:"excel的id" ` SheetName string `gorm:"column:sheet_name" description:"sheet名称" ` Index string `gorm:"column:index" description:"excel数据中的index" ` Sort int `gorm:"column:sort" description:"排序" ` Config string `gorm:"column:config" description:"配置信息" ` CalcChain string `gorm:"column:calc_chain" description:"计算公式" ` DataList []*ExcelSheetData `gorm:"column:data_list" description:"excel的数据" ` }