1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package excel
- import (
- "eta_gn/eta_api/global"
- "eta_gn/eta_api/utils"
- "time"
- )
- // ExcelSheetData excel表格详情表
- type ExcelSheetData struct {
- ExcelDataId int `orm:"column(excel_data_id);pk" gorm:"primaryKey" `
- ExcelInfoId int `description:"数据归属的excel_info的id"`
- ExcelSheetId int `description:"数据归属sheet"`
- Sort int `description:"数据排序"`
- Data string `description:"数据,分页存储"`
- ModifyTime time.Time `description:"最近修改日期"`
- CreateTime time.Time `description:"创建日期"`
- }
- // Update 更新 excel表格的sheet基础信息
- func (ExcelSheetData *ExcelSheetData) Update(cols []string) (err error) {
- //o := orm.NewOrmUsingDB("data")
- //_, err = o.Update(ExcelSheetData, cols...)
- err = global.DmSQL["data"].Select(cols).Updates(ExcelSheetData).Error
- return
- }
- // AddExcelSheetData 新增excel表格的sheet基础信息
- func AddExcelSheetData(excelInfo *ExcelSheetData) (err error) {
- //o := orm.NewOrmUsingDB("data")
- //// 表格信息入库
- //lastId, err := o.Insert(excelInfo)
- //if err != nil {
- // return
- //}
- //excelInfo.ExcelInfoId = int(lastId)
- err = global.DmSQL["data"].Create(excelInfo).Error
- return
- }
- // GetSheetDataListBySheetIdListAndPage 根据sheet_id列表和页码获取所有的sheet数据详情
- func GetSheetDataListBySheetIdListAndPage(excelSheetIdList []int, page int) (items []*ExcelSheetData, err error) {
- num := len(excelSheetIdList)
- if num <= 0 {
- return
- }
- // o := orm.NewOrmUsingDB("data")
- // sql := ` SELECT *
- //FROM excel_sheet_data WHERE 1=1 AND excel_sheet_id in (` + utils.GetOrmInReplace(num) + `) AND sort = ? `
- // _, err = o.Raw(sql, excelSheetIdList, page).QueryRows(&items)
- sql := ` SELECT *
- FROM excel_sheet_data WHERE 1=1 AND excel_sheet_id in (` + utils.GetOrmInReplace(num) + `) AND sort = ? `
- err = global.DmSQL["data"].Raw(sql, excelSheetIdList, page).Find(&items).Error
- return
- }
- // GetAllSheetDataListByExcelInfoId 根据表格id获取所有的sheet的所有数据详情
- func GetAllSheetDataListByExcelInfoId(excelInfoId int) (items []*ExcelSheetData, err error) {
- // o := orm.NewOrmUsingDB("data")
- // sql := ` SELECT *
- //FROM excel_sheet_data WHERE 1=1 AND excel_info_id = ? ORDER BY sort ASC `
- // _, err = o.Raw(sql, excelInfoId).QueryRows(&items)
- sql := ` SELECT *
- FROM excel_sheet_data WHERE 1=1 AND excel_info_id = ? ORDER BY sort ASC `
- err = global.DmSQL["data"].Raw(sql, excelInfoId).Find(&items).Error
- return
- }
|