|
@@ -1,15 +1,16 @@
|
|
package models
|
|
package models
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "eta/eta_chart_lib/global"
|
|
"eta/eta_chart_lib/utils"
|
|
"eta/eta_chart_lib/utils"
|
|
"fmt"
|
|
"fmt"
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
// ExcelInfo excel表格详情表
|
|
// ExcelInfo excel表格详情表
|
|
type ExcelInfo struct {
|
|
type ExcelInfo struct {
|
|
- ExcelInfoId int `orm:"column(excel_info_id);pk"`
|
|
|
|
|
|
+ //ExcelInfoId int `orm:"column(excel_info_id);pk"`
|
|
|
|
+ ExcelInfoId int `gorm:"column:excel_info_id;primaryKey"`
|
|
Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
|
|
Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
|
|
ExcelType int `description:"表格类型,1:指标列,2:日期列,默认:1"`
|
|
ExcelType int `description:"表格类型,1:指标列,2:日期列,默认:1"`
|
|
ExcelName string `description:"表格名称"`
|
|
ExcelName string `description:"表格名称"`
|
|
@@ -28,13 +29,15 @@ type ExcelInfo struct {
|
|
|
|
|
|
// Update 更新 excel表格基础信息
|
|
// Update 更新 excel表格基础信息
|
|
func (excelInfo *ExcelInfo) Update(cols []string) (err error) {
|
|
func (excelInfo *ExcelInfo) Update(cols []string) (err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- _, err = o.Update(excelInfo, cols...)
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //_, err = o.Update(excelInfo, cols...)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Model(&excelInfo).Select(cols).Updates(&excelInfo).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
type MyExcelInfoList struct {
|
|
type MyExcelInfoList struct {
|
|
- ExcelInfoId int `orm:"column(excel_info_id);pk"`
|
|
|
|
|
|
+ //ExcelInfoId int `orm:"column(excel_info_id);pk"`
|
|
|
|
+ ExcelInfoId int `gorm:"column:excel_info_id;primaryKey"`
|
|
ExcelName string `description:"表格名称"`
|
|
ExcelName string `description:"表格名称"`
|
|
UniqueCode string `description:"表格唯一编码"`
|
|
UniqueCode string `description:"表格唯一编码"`
|
|
ExcelClassifyId int `description:"表格分类id"`
|
|
ExcelClassifyId int `description:"表格分类id"`
|
|
@@ -49,77 +52,85 @@ type MyExcelInfoList struct {
|
|
|
|
|
|
// AddExcelInfo 新增表格
|
|
// AddExcelInfo 新增表格
|
|
func AddExcelInfo(excelInfo *ExcelInfo) (err error) {
|
|
func AddExcelInfo(excelInfo *ExcelInfo) (err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
// 表格信息入库
|
|
// 表格信息入库
|
|
- lastId, err := o.Insert(excelInfo)
|
|
|
|
- if err != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- excelInfo.ExcelInfoId = int(lastId)
|
|
|
|
|
|
+ //lastId, err := o.Insert(excelInfo)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Model(&excelInfo).Create(&excelInfo).Error
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+ //excelInfo.ExcelInfoId = int(lastId)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// EditExcelInfo 编辑表格
|
|
// EditExcelInfo 编辑表格
|
|
func EditExcelInfo(excelInfo *ExcelInfo, updateExcelInfoParams []string) (err error) {
|
|
func EditExcelInfo(excelInfo *ExcelInfo, updateExcelInfoParams []string) (err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
// ETA表格信息变更
|
|
// ETA表格信息变更
|
|
- _, err = o.Update(excelInfo, updateExcelInfoParams...)
|
|
|
|
|
|
+ //_, err = o.Update(excelInfo, updateExcelInfoParams...)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Model(&excelInfo).Select(updateExcelInfoParams).Updates(&excelInfo).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetExcelInfoById 根据id 获取eta表格详情
|
|
// GetExcelInfoById 根据id 获取eta表格详情
|
|
func GetExcelInfoById(excelInfoId int) (item *ExcelInfo, err error) {
|
|
func GetExcelInfoById(excelInfoId int) (item *ExcelInfo, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
- err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func GetExcelInfoViewById(excelInfoId int) (item *ExcelInfoView, err error) {
|
|
func GetExcelInfoViewById(excelInfoId int) (item *ExcelInfoView, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
- err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func GetExcelInfoCountByCondition(condition string, pars []interface{}) (count int, err error) {
|
|
func GetExcelInfoCountByCondition(condition string, pars []interface{}) (count int, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
if condition != "" {
|
|
if condition != "" {
|
|
sql += condition
|
|
sql += condition
|
|
}
|
|
}
|
|
- err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
|
|
|
+ //err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Scan(&count).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func GetExcelInfoByCondition(condition string, pars []interface{}) (item *ExcelInfo, err error) {
|
|
func GetExcelInfoByCondition(condition string, pars []interface{}) (item *ExcelInfo, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
if condition != "" {
|
|
if condition != "" {
|
|
sql += condition
|
|
sql += condition
|
|
}
|
|
}
|
|
- err = o.Raw(sql, pars).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, pars).QueryRow(&item)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetNextExcelInfo 根据分类id获取下一个excel表格
|
|
// GetNextExcelInfo 根据分类id获取下一个excel表格
|
|
func GetNextExcelInfo(classifyId int) (item *ExcelInfo, err error) {
|
|
func GetNextExcelInfo(classifyId int) (item *ExcelInfo, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT b.* FROM excel_classify AS a
|
|
sql := ` SELECT b.* FROM excel_classify AS a
|
|
INNER JOIN excel_info AS b ON a.excel_classify_id=b.excel_classify_id
|
|
INNER JOIN excel_info AS b ON a.excel_classify_id=b.excel_classify_id
|
|
WHERE a.excel_classify_id>? AND is_delete=0
|
|
WHERE a.excel_classify_id>? AND is_delete=0
|
|
ORDER BY a.excel_classify_id ASC
|
|
ORDER BY a.excel_classify_id ASC
|
|
LIMIT 1 `
|
|
LIMIT 1 `
|
|
- err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, classifyId).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// EditExcelInfoImage 修改excel表格的图片
|
|
// EditExcelInfoImage 修改excel表格的图片
|
|
func EditExcelInfoImage(excelInfoId int, imageUrl string) (err error) {
|
|
func EditExcelInfoImage(excelInfoId int, imageUrl string) (err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
sql := ` UPDATE excel_info SET excel_image=?, modify_time = NOW() WHERE excel_info_id = ? AND is_delete=0 `
|
|
sql := ` UPDATE excel_info SET excel_image=?, modify_time = NOW() WHERE excel_info_id = ? AND is_delete=0 `
|
|
- _, err = o.Raw(sql, imageUrl, excelInfoId).Exec()
|
|
|
|
|
|
+ //_, err = o.Raw(sql, imageUrl, excelInfoId).Exec()
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Exec(sql, imageUrl, excelInfoId).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("EditExcelInfoImage Err:", err.Error())
|
|
fmt.Println("EditExcelInfoImage Err:", err.Error())
|
|
return err
|
|
return err
|
|
@@ -130,33 +141,37 @@ func EditExcelInfoImage(excelInfoId int, imageUrl string) (err error) {
|
|
|
|
|
|
// GetExcelInfoByUniqueCode 根据unique_code来获取excel表格详情
|
|
// GetExcelInfoByUniqueCode 根据unique_code来获取excel表格详情
|
|
func GetExcelInfoByUniqueCode(uniqueCode string) (item *ExcelInfoView, err error) {
|
|
func GetExcelInfoByUniqueCode(uniqueCode string) (item *ExcelInfoView, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT * FROM excel_info WHERE unique_code=? AND is_delete=0 `
|
|
sql := ` SELECT * FROM excel_info WHERE unique_code=? AND is_delete=0 `
|
|
- err = o.Raw(sql, uniqueCode).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, uniqueCode).QueryRow(&item)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, uniqueCode).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetFirstExcelInfoByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
|
|
// GetFirstExcelInfoByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
|
|
func GetFirstExcelInfoByClassifyId(classifyId int) (item *ExcelInfo, err error) {
|
|
func GetFirstExcelInfoByClassifyId(classifyId int) (item *ExcelInfo, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT * FROM excel_info WHERE excel_classify_id=? AND is_delete=0 order by sort asc,excel_info_id asc limit 1`
|
|
sql := ` SELECT * FROM excel_info WHERE excel_classify_id=? AND is_delete=0 order by sort asc,excel_info_id asc limit 1`
|
|
- err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, classifyId).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// UpdateExcelInfoSortByClassifyId 根据表格id更新排序
|
|
// UpdateExcelInfoSortByClassifyId 根据表格id更新排序
|
|
func UpdateExcelInfoSortByClassifyId(classifyId, nowSort, prevExcelInfoId int, updateSort string) (err error) {
|
|
func UpdateExcelInfoSortByClassifyId(classifyId, nowSort, prevExcelInfoId int, updateSort string) (err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` update excel_info set sort = ` + updateSort + ` WHERE excel_classify_id=? and sort > ? AND is_delete=0 `
|
|
sql := ` update excel_info set sort = ` + updateSort + ` WHERE excel_classify_id=? and sort > ? AND is_delete=0 `
|
|
if prevExcelInfoId > 0 {
|
|
if prevExcelInfoId > 0 {
|
|
sql += ` or (excel_info_id > ` + fmt.Sprint(prevExcelInfoId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
|
|
sql += ` or (excel_info_id > ` + fmt.Sprint(prevExcelInfoId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
|
|
}
|
|
}
|
|
- _, err = o.Raw(sql, classifyId, nowSort).Exec()
|
|
|
|
|
|
+ //_, err = o.Raw(sql, classifyId, nowSort).Exec()
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Exec(sql, classifyId, nowSort).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
type ExcelInfoView struct {
|
|
type ExcelInfoView struct {
|
|
- ExcelInfoId int `orm:"column(excel_info_id);pk"`
|
|
|
|
|
|
+ //ExcelInfoId int `orm:"column(excel_info_id);pk"`
|
|
|
|
+ ExcelInfoId int `gorm:"column:excel_info_id;primaryKey"`
|
|
Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
|
|
Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
|
|
ExcelType int `description:"表格类型,1:指标列,2:日期列,默认:1"`
|
|
ExcelType int `description:"表格类型,1:指标列,2:日期列,默认:1"`
|
|
ExcelName string `description:"表格名称"`
|
|
ExcelName string `description:"表格名称"`
|
|
@@ -176,9 +191,10 @@ type ExcelInfoView struct {
|
|
|
|
|
|
// GetExcelInfoByClassifyIdAndName 根据分类id和表格名获取表格信息
|
|
// GetExcelInfoByClassifyIdAndName 根据分类id和表格名获取表格信息
|
|
func GetExcelInfoByClassifyIdAndName(classifyId int, excelName string) (item *ExcelInfo, err error) {
|
|
func GetExcelInfoByClassifyIdAndName(classifyId int, excelName string) (item *ExcelInfo, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT * FROM excel_info WHERE excel_classify_id = ? and excel_name=? AND is_delete=0 `
|
|
sql := ` SELECT * FROM excel_info WHERE excel_classify_id = ? and excel_name=? AND is_delete=0 `
|
|
- err = o.Raw(sql, classifyId, excelName).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, classifyId, excelName).QueryRow(&item)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, classifyId, excelName).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -188,28 +204,36 @@ func GetExcelInfoListByUniqueCodeSlice(uniqueCodeSlice []string) (total int64, i
|
|
if num <= 0 {
|
|
if num <= 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- sql := ` SELECT * FROM excel_info WHERE unique_code in ("` + utils.GetOrmInReplace(num) + `") AND is_delete=0 `
|
|
|
|
- total, err = o.Raw(sql, uniqueCodeSlice).QueryRows(&items)
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //sql := ` SELECT * FROM excel_info WHERE unique_code in ("` + utils.GetOrmInReplace(num) + `") AND is_delete=0 `
|
|
|
|
+ //total, err = o.Raw(sql, uniqueCodeSlice).QueryRows(&items)
|
|
|
|
+ sql := ` SELECT * FROM excel_info WHERE unique_code in ? AND is_delete=0 `
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, uniqueCodeSlice).Find(&items).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ total = int64(len(items))
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetExcelListByCondition 获取excel表格列表数据
|
|
// GetExcelListByCondition 获取excel表格列表数据
|
|
func GetExcelListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyExcelInfoList, err error) {
|
|
func GetExcelListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyExcelInfoList, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
if condition != "" {
|
|
if condition != "" {
|
|
sql += condition
|
|
sql += condition
|
|
}
|
|
}
|
|
//sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
|
|
//sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
|
|
sql += " ORDER BY create_time DESC LIMIT ?,? "
|
|
sql += " ORDER BY create_time DESC LIMIT ?,? "
|
|
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
|
|
|
|
+ pars = append(pars, startSize, pageSize)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Find(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetNoContentExcelListByCondition 获取没有content的excel表格列表数据
|
|
// GetNoContentExcelListByCondition 获取没有content的excel表格列表数据
|
|
func GetNoContentExcelListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyExcelInfoList, err error) {
|
|
func GetNoContentExcelListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyExcelInfoList, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT excel_info_id,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time
|
|
sql := ` SELECT excel_info_id,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time
|
|
FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
if condition != "" {
|
|
if condition != "" {
|
|
@@ -217,43 +241,49 @@ FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
}
|
|
}
|
|
//sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
|
|
//sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
|
|
sql += " ORDER BY create_time DESC LIMIT ?,? "
|
|
sql += " ORDER BY create_time DESC LIMIT ?,? "
|
|
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
|
|
|
|
+ pars = append(pars, startSize, pageSize)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func GetExcelListCountByCondition(condition string, pars []interface{}) (count int, err error) {
|
|
func GetExcelListCountByCondition(condition string, pars []interface{}) (count int, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
if condition != "" {
|
|
if condition != "" {
|
|
sql += condition
|
|
sql += condition
|
|
}
|
|
}
|
|
- err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
|
|
|
+ //err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Scan(&count).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetExcelViewInfoByExcelInfoId 根据excelInfoId 获取ETA表格详情
|
|
// GetExcelViewInfoByExcelInfoId 根据excelInfoId 获取ETA表格详情
|
|
func GetExcelViewInfoByExcelInfoId(excelInfoId int) (item *MyExcelInfoList, err error) {
|
|
func GetExcelViewInfoByExcelInfoId(excelInfoId int) (item *MyExcelInfoList, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT * FROM excel_info WHERE excel_info_id = ? AND is_delete=0 `
|
|
sql := ` SELECT * FROM excel_info WHERE excel_info_id = ? AND is_delete=0 `
|
|
- err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetExcelInfoCountByClassifyId 根据分类id获取名下表格数量
|
|
// GetExcelInfoCountByClassifyId 根据分类id获取名下表格数量
|
|
func GetExcelInfoCountByClassifyId(classifyId int) (total int64, err error) {
|
|
func GetExcelInfoCountByClassifyId(classifyId int) (total int64, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT count(1) total FROM excel_info WHERE excel_classify_id = ? AND is_delete=0 `
|
|
sql := ` SELECT count(1) total FROM excel_info WHERE excel_classify_id = ? AND is_delete=0 `
|
|
- err = o.Raw(sql, classifyId).QueryRow(&total)
|
|
|
|
|
|
+ //err = o.Raw(sql, classifyId).QueryRow(&total)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, classifyId).Count(&total).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func GetExcelInfoListByCondition(condition string, pars []interface{}) (items []*ExcelInfo, err error) {
|
|
func GetExcelInfoListByCondition(condition string, pars []interface{}) (items []*ExcelInfo, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
if condition != "" {
|
|
if condition != "" {
|
|
sql += condition
|
|
sql += condition
|
|
}
|
|
}
|
|
sql += ` ORDER BY sort asc, excel_info_id asc`
|
|
sql += ` ORDER BY sort asc, excel_info_id asc`
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Find(&items).Error
|
|
return
|
|
return
|
|
}
|
|
}
|