|
@@ -1,8 +1,8 @@
|
|
|
package future_good
|
|
|
|
|
|
import (
|
|
|
+ "eta_gn/eta_api/global"
|
|
|
"fmt"
|
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -22,38 +22,38 @@ type FutureGoodChartClassify struct {
|
|
|
}
|
|
|
|
|
|
// AddFutureGoodChartClassify 添加future_good_chart分类
|
|
|
-func AddFutureGoodChartClassify(item *FutureGoodChartClassify) (lastId int64, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- lastId, err = o.Insert(item)
|
|
|
+func AddFutureGoodChartClassify(item *FutureGoodChartClassify) (err error) {
|
|
|
+ err = global.DmSQL["data"].Create(item).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetFutureGoodChartClassifyCount 获取同级分类下存在同名分类的数量
|
|
|
func GetFutureGoodChartClassifyCount(FutureGoodChartClassifyName string, parentId int) (count int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT COUNT(1) AS count FROM future_good_chart_classify WHERE parent_id=? AND future_good_chart_classify_name=? AND is_delete=0 `
|
|
|
- err = o.Raw(sql, parentId, FutureGoodChartClassifyName).QueryRow(&count)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, parentId, FutureGoodChartClassifyName).Scan(&count).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetFutureGoodChartClassifyById(classifyId int) (item *FutureGoodChartClassify, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT * FROM future_good_chart_classify WHERE future_good_chart_classify_id=? AND is_delete=0 `
|
|
|
- err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, classifyId).First(&item).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetFutureGoodChartClassifyByParentId(parentId int) (items []*FutureGoodChartClassifyItems, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM future_good_chart_classify WHERE parent_id=? AND is_delete=0 order by sort asc,future_good_chart_classify_id asc`
|
|
|
- _, err = o.Raw(sql, parentId).QueryRows(&items)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, parentId).Scan(&items).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetFutureGoodChartClassifyAll() (items []*FutureGoodChartClassifyItems, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM future_good_chart_classify WHERE parent_id<>0 AND is_delete=0 order by sort asc,future_good_chart_classify_id asc`
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ err = global.DmSQL["data"].Raw(sql).Scan(&items).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -72,58 +72,58 @@ type FutureGoodChartClassifyItems struct {
|
|
|
}
|
|
|
|
|
|
func GetFutureGoodChartClassifyByCondition(condition string, pars []interface{}) (item *FutureGoodChartClassify, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM future_good_chart_classify WHERE 1=1 AND is_delete=0 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- err = o.Raw(sql, pars).QueryRow(&item)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, pars).Scan(&item).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetNextFutureGoodChartClassifyByCondition 获取下一个分类
|
|
|
func GetNextFutureGoodChartClassifyByCondition(condition string, pars []interface{}) (item *FutureGoodChartClassify, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM future_good_chart_classify WHERE 1=1 AND is_delete=0 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += " ORDER BY sort asc , create_time ASC LIMIT 1 "
|
|
|
- err = o.Raw(sql, pars).QueryRow(&item)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, pars).First(&item).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetFirstFutureGoodChartClassifyByParentId 获取当前父级图表分类下的排序第一条的数据
|
|
|
func GetFirstFutureGoodChartClassifyByParentId(parentId int) (item *FutureGoodChartClassify, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM future_good_chart_classify WHERE parent_id=? AND is_delete=0 order by sort asc,future_good_chart_classify_id asc limit 1`
|
|
|
- err = o.Raw(sql, parentId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, parentId).First(&item).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateFutureGoodChartClassifySortByParentId 根据图表父类id更新排序
|
|
|
func UpdateFutureGoodChartClassifySortByParentId(parentId, classifyId, nowSort int, updateSort string) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` update future_good_chart_classify set sort = ` + updateSort + ` WHERE parent_id=? and sort > ? AND is_delete=0 `
|
|
|
if classifyId > 0 {
|
|
|
sql += ` or ( future_good_chart_classify_id > ` + fmt.Sprint(classifyId) + ` and sort= ` + fmt.Sprint(nowSort) + `)`
|
|
|
}
|
|
|
- _, err = o.Raw(sql, parentId, nowSort).Exec()
|
|
|
+ err = global.DmSQL["data"].Exec(sql, parentId, nowSort).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// Update 更新图表分类基础信息
|
|
|
func (FutureGoodChartClassify *FutureGoodChartClassify) Update(cols []string) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- _, err = o.Update(FutureGoodChartClassify, cols...)
|
|
|
+ err = global.DmSQL["data"].Select(cols).Updates(FutureGoodChartClassify).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetFutureGoodChartClassifyMaxSort 获取图表分类下最大的排序数
|
|
|
func GetFutureGoodChartClassifyMaxSort(parentId int) (sort int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT Max(sort) AS sort FROM future_good_chart_classify WHERE parent_id=? AND is_delete=0 `
|
|
|
- err = o.Raw(sql, parentId).QueryRow(&sort)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, parentId).Scan(&sort).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -134,36 +134,36 @@ type FutureGoodChartClassifyView struct {
|
|
|
}
|
|
|
|
|
|
func GetFutureGoodChartClassifyViewById(classifyId int) (item *FutureGoodChartClassifyView, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT * FROM future_good_chart_classify WHERE future_good_chart_classify_id=? AND is_delete=0 `
|
|
|
- err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, classifyId).Scan(&item).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//用于分类展示
|
|
|
+// 用于分类展示
|
|
|
func GetChartInfoAll() (items []*FutureGoodChartClassifyItems, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT chart_info_id,chart_classify_id,chart_name AS chart_classify_name,
|
|
|
unique_code,sys_user_id,sys_user_real_name,date_type,start_date,end_date,chart_type,calendar,season_start_date,season_end_date
|
|
|
FROM chart_info ORDER BY sort asc,create_time ASC `
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ err = global.DmSQL["data"].Raw(sql).Scan(&items).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetNoContentFutureGoodInfoAll 获取不含content的表格列表 用于分类展示
|
|
|
func GetNoContentFutureGoodInfoAll() (items []FutureGoodChartClassifyItems, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
|
|
|
unique_code,sys_user_id,sys_user_real_name
|
|
|
FROM excel_info where is_delete=0 ORDER BY sort asc,create_time desc `
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ err = global.DmSQL["data"].Raw(sql).Scan(&items).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetFutureGoodChartInfoCountByClassifyId 根据分类id获取名下表格数量
|
|
|
func GetFutureGoodChartInfoCountByClassifyId(classifyId int) (total int64, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT count(1) total FROM excel_info WHERE excel_classify_id = ? AND is_delete=0 `
|
|
|
- err = o.Raw(sql, classifyId).QueryRow(&total)
|
|
|
+ err = global.DmSQL["data"].Raw(sql, classifyId).Scan(&total).Error
|
|
|
+
|
|
|
return
|
|
|
}
|