瀏覽代碼

改成gorm

xyxie 2 月之前
父節點
當前提交
ff5208bcc0
共有 94 個文件被更改,包括 515 次插入550 次删除
  1. 40 46
      models/ai_predict_model/ai_predict_model_classify.go
  2. 39 45
      models/ai_predict_model/ai_predict_model_dashboard.go
  3. 25 28
      models/ai_predict_model/ai_predict_model_dashboard_detail.go
  4. 25 28
      models/ai_predict_model/ai_predict_model_data.go
  5. 39 55
      models/ai_predict_model/ai_predict_model_framework.go
  6. 21 24
      models/ai_predict_model/ai_predict_model_framework_node.go
  7. 42 52
      models/ai_predict_model/ai_predict_model_index.go
  8. 27 23
      models/ai_summary/ai_pormpt.go
  9. 33 27
      models/ai_summary/ai_summary.go
  10. 45 40
      models/ai_summary/ai_summary_classify.go
  11. 2 2
      models/aimod/ai.go
  12. 1 1
      models/aimod/file_upload_record.go
  13. 9 9
      models/bi_dashboard/bi_dashboard.go
  14. 6 6
      models/bi_dashboard/bi_dashboard_classify.go
  15. 11 12
      models/bi_dashboard/bi_dashboard_detail.go
  16. 5 5
      models/bi_dashboard/bi_dashboard_grant.go
  17. 1 1
      models/bi_dashboard/bi_dashboard_home_page.go
  18. 1 1
      models/binlog/business_sys_interaction_log.go
  19. 1 1
      models/company/company.go
  20. 5 5
      models/data_source/base_from_sci99.go
  21. 23 23
      models/data_source/data_source.go
  22. 5 5
      models/data_source/guagnzhouqihuo.go
  23. 4 4
      models/data_source/icpi.go
  24. 2 2
      models/data_source/longzhong.go
  25. 1 1
      models/data_stat/edb_info_delete_log.go
  26. 1 1
      models/data_stat/edb_info_stat_column.go
  27. 2 2
      models/data_stat/edb_info_update_log.go
  28. 2 2
      models/data_stat/edb_info_update_stat.go
  29. 2 2
      models/data_stat/edb_source_stat.go
  30. 2 2
      models/document_manage_model/outside_report.go
  31. 1 1
      models/document_manage_model/outside_report_attachment.go
  32. 1 1
      models/edb_monitor/edb_monitor.go
  33. 1 1
      models/edb_monitor/edb_monitor_classify.go
  34. 1 1
      models/edb_monitor/edb_monitor_message.go
  35. 1 1
      models/edb_monitor/response/edb_monitor.go
  36. 1 1
      models/eta_trial/questionnaire_fill_record.go
  37. 1 1
      models/eta_trial/request.go
  38. 1 1
      models/fe_calendar/fe_calendar_matter.go
  39. 1 1
      models/material/material.go
  40. 2 2
      models/material/material_classify.go
  41. 5 5
      models/ppt_english/ppt_english.go
  42. 1 1
      models/ppt_english/ppt_english_grant.go
  43. 1 1
      models/ppt_english/ppt_english_group.go
  44. 1 1
      models/ppt_english/ppt_english_group_mapping.go
  45. 1 1
      models/ppt_english/report_ppt_english_img.go
  46. 1 1
      models/report_approve/report_approve.go
  47. 1 1
      models/report_approve/report_approve_flow.go
  48. 1 1
      models/report_approve/report_approve_message.go
  49. 1 1
      models/report_approve/report_approve_node.go
  50. 1 1
      models/report_approve/report_approve_record.go
  51. 2 2
      models/residual_analysis_model/calculate_residual_analysis_config.go
  52. 1 1
      models/residual_analysis_model/calculate_residual_analysis_config_mapping.go
  53. 1 1
      models/residual_analysis_model/edb_data_residual_analysis.go
  54. 2 2
      models/sandbox/sandbox.go
  55. 2 2
      models/sandbox/sandbox_classify.go
  56. 1 1
      models/sandbox/sandbox_draft.go
  57. 3 3
      models/sandbox/sandbox_version.go
  58. 1 1
      models/semantic_analysis/sa_compare.go
  59. 1 1
      models/semantic_analysis/sa_compare_classify.go
  60. 1 1
      models/semantic_analysis/sa_compare_doc.go
  61. 1 1
      models/semantic_analysis/sa_compare_label.go
  62. 1 1
      models/semantic_analysis/sa_compare_search_keyword.go
  63. 1 1
      models/semantic_analysis/sa_doc.go
  64. 1 1
      models/semantic_analysis/sa_doc_classify.go
  65. 1 1
      models/semantic_analysis/sa_doc_section.go
  66. 1 1
      models/semantic_analysis/sa_label.go
  67. 2 3
      models/smart_report/smart_report.go
  68. 1 1
      models/smart_report/smart_report_save_log.go
  69. 2 2
      models/smart_report/smart_resource.go
  70. 1 1
      models/speech_recognition/speech_recognition.go
  71. 1 1
      models/speech_recognition/speech_recognition_api_log.go
  72. 1 1
      models/speech_recognition/speech_recognition_content.go
  73. 1 1
      models/speech_recognition/speech_recognition_menu.go
  74. 1 1
      models/speech_recognition/speech_recognition_tag.go
  75. 1 1
      models/speech_recognition/speech_recognition_tag_mapping.go
  76. 1 1
      models/speech_recognition/speech_recognition_tag_menu.go
  77. 1 1
      models/system/admin_config.go
  78. 1 1
      models/system/admin_operate_record.go
  79. 1 1
      models/system/admin_verify_code_record.go
  80. 3 3
      models/system/research_group.go
  81. 2 2
      models/system/sys_department.go
  82. 3 3
      models/system/sys_group.go
  83. 8 9
      models/system/sys_menu.go
  84. 2 2
      models/system/sys_menu_button.go
  85. 3 3
      models/system/sys_role.go
  86. 1 1
      models/system/sys_role_admin.go
  87. 1 1
      models/system/sys_session.go
  88. 2 2
      models/system/sys_team.go
  89. 1 1
      models/system/sys_user.go
  90. 1 1
      models/system/sys_user_login_record.go
  91. 2 2
      models/yb/price_driven.go
  92. 1 1
      models/yb/price_driven_tag.go
  93. 1 1
      models/yb/yb_community_question_process.go
  94. 1 1
      models/yb/yb_poster_resource.go

+ 40 - 46
models/ai_predict_model/ai_predict_model_classify.go

@@ -1,16 +1,16 @@
 package data_manage
 
 import (
+	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
 
 // AiPredictModelClassify 同花顺高频数据-分类
 type AiPredictModelClassify struct {
-	AiPredictModelClassifyId int       `orm:"column(ai_predict_model_classify_id);pk"`
+	AiPredictModelClassifyId int       `gorm:"primaryKey;column:ai_predict_model_classify_id;"`
 	UniqueCode               string    `description:"唯一编码"`
 	ClassifyName             string    `description:"分类名称"`
 	ClassifyNameEn           string    `description:"英文分类名称"`
@@ -64,12 +64,7 @@ func (m *AiPredictModelClassify) Cols() AiPredictModelClassifyCols {
 }
 
 func (m *AiPredictModelClassify) Create() (err error) {
-	o := orm.NewOrmUsingDB("data")
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.AiPredictModelClassifyId = int(id)
+	err = global.DbMap[utils.DbNameIndex].Create(m).Error
 	return
 }
 
@@ -77,21 +72,19 @@ func (m *AiPredictModelClassify) CreateMulti(items []*AiPredictModelClassify) (e
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.InsertMulti(len(items), items)
+	err = global.DbMap[utils.DbNameIndex].CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *AiPredictModelClassify) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Update(m, cols...)
+	err = global.DbMap[utils.DbNameIndex].Select(cols).Updates(m).Error
 	return
 }
 
 func (m *AiPredictModelClassify) Remove() (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	_, err = o.Raw(sql, m.AiPredictModelClassifyId).Exec()
+	err = o.Exec(sql, m.AiPredictModelClassifyId).Error
 	return
 }
 
@@ -99,9 +92,9 @@ func (m *AiPredictModelClassify) MultiRemove(ids []int) (err error) {
 	if len(ids) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
-	_, err = o.Raw(sql, ids).Exec()
+	err = o.Exec(sql, ids).Error
 	return
 }
 
@@ -109,39 +102,39 @@ func (m *AiPredictModelClassify) RemoveByCondition(condition string, pars []inte
 	if condition == "" {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s`, m.TableName(), condition)
-	_, err = o.Raw(sql, pars).Exec()
+	err = o.Exec(sql, pars...).Error
 	return
 }
 
 func (m *AiPredictModelClassify) GetItemById(id int) (item *AiPredictModelClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	err = o.Raw(sql, id).QueryRow(&item)
+	err = o.Raw(sql, id).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelClassify) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *AiPredictModelClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	order := ``
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	err = o.Raw(sql, pars...).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelClassify) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars...).Scan(&count).Error
 	return
 }
 
 func (m *AiPredictModelClassify) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*AiPredictModelClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -151,12 +144,12 @@ func (m *AiPredictModelClassify) GetItemsByCondition(condition string, pars []in
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 
 func (m *AiPredictModelClassify) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*AiPredictModelClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -166,7 +159,8 @@ func (m *AiPredictModelClassify) GetPageItemsByCondition(condition string, pars
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	pars = append(pars, startSize, pageSize)
+	err = o.Exec(sql, pars...).Find(&items).Error
 	return
 }
 
@@ -209,9 +203,9 @@ type AiPredictModelClassifyEditReq struct {
 }
 
 func (m *AiPredictModelClassify) GetSortMax(parentId int) (sort int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT MAX(%s) FROM %s WHERE %s = ?`, m.Cols().Sort, m.TableName(), m.Cols().ParentId)
-	err = o.Raw(sql, parentId).QueryRow(&sort)
+	err = o.Raw(sql, parentId).Scan(&sort).Error
 	return
 }
 
@@ -250,51 +244,51 @@ type AiPredictModelClassifyMoveReq struct {
 }
 
 func GetAiPredictModelClassifyById(classifyId int) (item *AiPredictModelClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := `SELECT * FROM ai_predict_model_classify WHERE ai_predict_model_classify_id = ?`
-	err = o.Raw(sql, classifyId).QueryRow(&item)
+	err = o.Raw(sql, classifyId).First(&item).Error
 	return
 }
 
 func GetAiPredictModelClassifyByRootIdLevel(rootId int, orderStr string) (items []*AiPredictModelClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := ` SELECT * FROM ai_predict_model_classify WHERE root_id = ? `
 	if orderStr != "" {
 		sql += orderStr
 	} else {
 		sql += ` order by level desc, sort asc, ai_predict_model_classify_id asc`
 	}
-	_, err = o.Raw(sql, rootId).QueryRows(&items)
+	err = o.Raw(sql, rootId).Find(&items).Error
 	return
 }
 
 // UpdateAiPredictModelClassifySortByParentId 根据父类id更新排序
 func UpdateAiPredictModelClassifySortByParentId(parentId, classifyId, nowSort int, updateSort string) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := ` update ai_predict_model_classify set sort = ` + updateSort + ` WHERE parent_id = ? AND sort > ? `
 	if classifyId > 0 {
 		sql += ` or ( ai_predict_model_classify_id > ` + fmt.Sprint(classifyId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
 	}
-	_, err = o.Raw(sql, parentId, nowSort).Exec()
+	err = o.Exec(sql, parentId, nowSort).Error
 	return
 }
 
 // GetFirstAiPredictModelClassifyByParentId 获取当前父级分类下,且排序数相同 的排序第一条的数据
 func GetFirstAiPredictModelClassifyByParentId(parentId int) (item *AiPredictModelClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := ` SELECT * FROM ai_predict_model_classify WHERE parent_id = ? order by sort asc,ai_predict_model_classify_id asc limit 1`
-	err = o.Raw(sql, parentId).QueryRow(&item)
+	err = o.Raw(sql, parentId).First(&item).Error
 	return
 }
 
 func UpdateAiPredictModelClassifyChildByParentClassifyId(classifyIds []int, rootId int, levelStep int) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	var pars []interface{}
 	pars = append(pars, rootId, levelStep)
 	pars = append(pars, classifyIds)
 	// 更新相关联的二级分类的parentId,和classify_name_second
 	sql := `UPDATE ai_predict_model_classify SET root_id = ?, level = level+? where ai_predict_model_classify_id IN (` + utils.GetOrmInReplace(len(classifyIds)) + `)`
-	_, err = o.Raw(sql, pars).Exec()
+	err = o.Exec(sql, pars...).Error
 	if err != nil {
 		return
 	}
@@ -303,7 +297,7 @@ func UpdateAiPredictModelClassifyChildByParentClassifyId(classifyIds []int, root
 
 // GetAiPredictModelIndexCountByClassifyId 获取目录下(包含子目录)的指标数量
 func GetAiPredictModelIndexCountByClassifyId(classifyId int) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := `SELECT COUNT(1) AS count FROM ai_predict_model_index AS a
 				WHERE a.classify_id IN(
 				SELECT t.ai_predict_model_classify_id FROM 
@@ -316,13 +310,13 @@ func GetAiPredictModelIndexCountByClassifyId(classifyId int) (count int, err err
 				UNION SELECT * FROM ai_predict_model_classify WHERE ai_predict_model_classify_id = @pid
 				)AS t
 			)`
-	err = o.Raw(sql, classifyId).QueryRow(&count)
+	err = o.Raw(sql, classifyId).Scan(&count).Error
 	return
 }
 
 // GetAiPredictModelClassifyCountByClassifyId 获取目录下子目录数量
 func GetAiPredictModelClassifyCountByClassifyId(chartClassifyId int) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := `SELECT COUNT(1) AS count FROM (
 			SELECT rd.*
 			FROM (SELECT * FROM ai_predict_model_classify WHERE parent_id IS NOT NULL) rd,
@@ -332,13 +326,13 @@ func GetAiPredictModelClassifyCountByClassifyId(chartClassifyId int) (count int,
 			UNION SELECT * FROM ai_predict_model_classify WHERE ai_predict_model_classify_id = @pid
 			)AS t
 			WHERE t.ai_predict_model_classify_id <> ?`
-	err = o.Raw(sql, chartClassifyId, chartClassifyId).QueryRow(&count)
+	err = o.Raw(sql, chartClassifyId, chartClassifyId).Scan(&count).Error
 	return
 }
 
 // RemoveAiPredictModelClassify 删除分类及子分类
 func RemoveAiPredictModelClassify(classifyId int) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := `DELETE FROM ai_predict_model_classify
 				WHERE ai_predict_model_classify_id IN(
 				SELECT t.ai_predict_model_classify_id FROM
@@ -351,6 +345,6 @@ func RemoveAiPredictModelClassify(classifyId int) (err error) {
 				UNION SELECT * FROM ai_predict_model_classify WHERE ai_predict_model_classify_id = @pid
 				)AS t
 			)`
-	_, err = o.Raw(sql, classifyId).Exec()
+	err = o.Exec(sql, classifyId).Error
 	return
 }

+ 39 - 45
models/ai_predict_model/ai_predict_model_dashboard.go

@@ -1,16 +1,16 @@
 package data_manage
 
 import (
+	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
 
 // AiPredictModelDashboard AI预测模型-BI看板
 type AiPredictModelDashboard struct {
-	AiPredictModelDashboardId int       `orm:"column(ai_predict_model_dashboard_id);pk"`
+	AiPredictModelDashboardId int       `orm:"column(ai_predict_model_dashboard_id);pk" gorm:"primaryKey"`
 	AiPredictModelIndexId     int       `description:"标的ID"`
 	DashboardName             string    `description:"看板名称"`
 	Sort                      int       `description:"排序"`
@@ -49,12 +49,8 @@ func (m *AiPredictModelDashboard) Cols() AiPredictModelDashboardCols {
 }
 
 func (m *AiPredictModelDashboard) Create() (err error) {
-	o := orm.NewOrmUsingDB("data")
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.AiPredictModelDashboardId = int(id)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Create(m).Error
 	return
 }
 
@@ -62,21 +58,21 @@ func (m *AiPredictModelDashboard) CreateMulti(items []*AiPredictModelDashboard)
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.InsertMulti(len(items), items)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *AiPredictModelDashboard) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Update(m, cols...)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Select(cols).Updates(m).Error
 	return
 }
 
 func (m *AiPredictModelDashboard) Remove() (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	_, err = o.Raw(sql, m.AiPredictModelDashboardId).Exec()
+	err = o.Exec(sql, m.AiPredictModelDashboardId).Error
 	return
 }
 
@@ -84,9 +80,9 @@ func (m *AiPredictModelDashboard) MultiRemove(ids []int) (err error) {
 	if len(ids) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
-	_, err = o.Raw(sql, ids).Exec()
+	err = o.Exec(sql, ids).Error
 	return
 }
 
@@ -94,39 +90,39 @@ func (m *AiPredictModelDashboard) RemoveByCondition(condition string, pars []int
 	if condition == "" {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s`, m.TableName(), condition)
-	_, err = o.Raw(sql, pars).Exec()
+	err = o.Exec(sql, pars...).Error
 	return
 }
 
 func (m *AiPredictModelDashboard) GetItemById(id int) (item *AiPredictModelDashboard, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	err = o.Raw(sql, id).QueryRow(&item)
+	err = o.Raw(sql, id).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelDashboard) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *AiPredictModelDashboard, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	order := ``
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	err = o.Raw(sql, pars...).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelDashboard) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars...).Scan(&count).Error
 	return
 }
 
 func (m *AiPredictModelDashboard) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*AiPredictModelDashboard, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -136,12 +132,12 @@ func (m *AiPredictModelDashboard) GetItemsByCondition(condition string, pars []i
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 
 func (m *AiPredictModelDashboard) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*AiPredictModelDashboard, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -151,7 +147,8 @@ func (m *AiPredictModelDashboard) GetPageItemsByCondition(condition string, pars
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	pars = append(pars, startSize, pageSize)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 
@@ -202,18 +199,14 @@ type AiPredictModelDashboardDetailReq struct {
 }
 
 // SaveIndexDashboard 保存标的看板
-func (m *AiPredictModelDashboard) SaveIndexDashboard(dashboardItem *AiPredictModelDashboard, dashboardDetails []*AiPredictModelDashboardDetail, isUpdate bool, updateCols []string) (err error) {
+func (m *AiPredictModelDashboard) SaveIndexDashboard(dashboardItem *AiPredictModelDashboard, dashboardDetails []*AiPredictModelDashboardDetail, isUpdate bool, updateCols []string) (e error) {
 	if dashboardItem == nil {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	tx, e := o.Begin()
-	if e != nil {
-		err = fmt.Errorf("trans begin err: %v", e)
-		return
-	}
+	o := global.DbMap[utils.DbNameIndex]
+	tx := o.Begin()
 	defer func() {
-		if err != nil {
+		if e != nil {
 			_ = tx.Rollback()
 			return
 		}
@@ -223,16 +216,17 @@ func (m *AiPredictModelDashboard) SaveIndexDashboard(dashboardItem *AiPredictMod
 	// 新增/更新看板
 	var dashboardId int
 	if !isUpdate {
-		newId, e := tx.Insert(dashboardItem)
+		e = tx.Create(dashboardItem).Error
 		if e != nil {
-			err = fmt.Errorf("insert dashboard err: %v", e)
+			e = fmt.Errorf("insert dashboard err: %v", e)
 			return
 		}
-		dashboardId = int(newId)
+		dashboardId = dashboardItem.AiPredictModelDashboardId
 	} else {
-		_, e = tx.Update(dashboardItem, updateCols...)
+		// TODO 改造
+		e = tx.Select(updateCols).Updates(dashboardItem).Error
 		if e != nil {
-			err = fmt.Errorf("update dashboard err: %v", e)
+			e = fmt.Errorf("update dashboard err: %v", e)
 			return
 		}
 		dashboardId = dashboardItem.AiPredictModelDashboardId
@@ -241,9 +235,9 @@ func (m *AiPredictModelDashboard) SaveIndexDashboard(dashboardItem *AiPredictMod
 	// 清空详情并新增
 	if isUpdate {
 		sql := `DELETE FROM ai_predict_model_dashboard_detail WHERE ai_predict_model_dashboard_id = ?`
-		_, e = tx.Raw(sql, dashboardItem.AiPredictModelDashboardId).Exec()
+		e = tx.Exec(sql, dashboardItem.AiPredictModelDashboardId).Error
 		if e != nil {
-			err = fmt.Errorf("clear dashboard detail err: %v", e)
+			e = fmt.Errorf("clear dashboard detail err: %v", e)
 			return
 		}
 	}
@@ -251,9 +245,9 @@ func (m *AiPredictModelDashboard) SaveIndexDashboard(dashboardItem *AiPredictMod
 		for _, v := range dashboardDetails {
 			v.AiPredictModelDashboardId = dashboardId
 		}
-		_, e = tx.InsertMulti(utils.MultiAddNum, dashboardDetails)
+		e = tx.CreateInBatches(dashboardDetails, utils.MultiAddNum).Error
 		if e != nil {
-			err = fmt.Errorf("insert dashboard detail err: %v", e)
+			e = fmt.Errorf("insert dashboard detail err: %v", e)
 			return
 		}
 	}

+ 25 - 28
models/ai_predict_model/ai_predict_model_dashboard_detail.go

@@ -1,16 +1,16 @@
 package data_manage
 
 import (
+	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
 
 // AiPredictModelDashboardDetail AI预测模型-BI看板
 type AiPredictModelDashboardDetail struct {
-	AiPredictModelDashboardDetailId int       `orm:"column(ai_predict_model_dashboard_detail_id);pk"`
+	AiPredictModelDashboardDetailId int       `orm:"column(ai_predict_model_dashboard_detail_id);pk" gorm:"primaryKey"`
 	AiPredictModelDashboardId       int       `description:"看板ID"`
 	Type                            int       `description:"类型:1-图表;2-表格"`
 	UniqueCode                      string    `description:"图表/表格唯一编码"`
@@ -46,12 +46,8 @@ func (m *AiPredictModelDashboardDetail) Cols() AiPredictModelDashboardDetailCols
 }
 
 func (m *AiPredictModelDashboardDetail) Create() (err error) {
-	o := orm.NewOrmUsingDB("data")
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.AiPredictModelDashboardDetailId = int(id)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Create(m).Error
 	return
 }
 
@@ -59,21 +55,21 @@ func (m *AiPredictModelDashboardDetail) CreateMulti(items []*AiPredictModelDashb
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.InsertMulti(len(items), items)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *AiPredictModelDashboardDetail) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Update(m, cols...)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Select(cols).Updates(m).Error
 	return
 }
 
 func (m *AiPredictModelDashboardDetail) Remove() (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	_, err = o.Raw(sql, m.AiPredictModelDashboardDetailId).Exec()
+	err = o.Exec(sql, m.AiPredictModelDashboardDetailId).Error
 	return
 }
 
@@ -81,9 +77,9 @@ func (m *AiPredictModelDashboardDetail) MultiRemove(ids []int) (err error) {
 	if len(ids) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
-	_, err = o.Raw(sql, ids).Exec()
+	err = o.Exec(sql, ids).Error
 	return
 }
 
@@ -91,39 +87,39 @@ func (m *AiPredictModelDashboardDetail) RemoveByCondition(condition string, pars
 	if condition == "" {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s`, m.TableName(), condition)
-	_, err = o.Raw(sql, pars).Exec()
+	err = o.Exec(sql, pars...).Error
 	return
 }
 
 func (m *AiPredictModelDashboardDetail) GetItemById(id int) (item *AiPredictModelDashboardDetail, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	err = o.Raw(sql, id).QueryRow(&item)
+	err = o.Raw(sql, id).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelDashboardDetail) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *AiPredictModelDashboardDetail, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	order := ``
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	err = o.Raw(sql, pars...).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelDashboardDetail) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars...).Scan(&count).Error
 	return
 }
 
 func (m *AiPredictModelDashboardDetail) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*AiPredictModelDashboardDetail, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -133,12 +129,12 @@ func (m *AiPredictModelDashboardDetail) GetItemsByCondition(condition string, pa
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 
 func (m *AiPredictModelDashboardDetail) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*AiPredictModelDashboardDetail, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -148,7 +144,8 @@ func (m *AiPredictModelDashboardDetail) GetPageItemsByCondition(condition string
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	pars = append(pars, startSize, pageSize)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 

+ 25 - 28
models/ai_predict_model/ai_predict_model_data.go

@@ -2,9 +2,9 @@ package data_manage
 
 import (
 	"database/sql"
+	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
@@ -16,7 +16,7 @@ const (
 
 // AiPredictModelData AI预测模型标的数据
 type AiPredictModelData struct {
-	AiPredictModelDataId  int             `orm:"column(ai_predict_model_data_id);pk"`
+	AiPredictModelDataId  int             `orm:"column(ai_predict_model_data_id);pk" gorm:"primaryKey"`
 	AiPredictModelIndexId int             `description:"标的ID"`
 	IndexCode             string          `description:"标的编码"`
 	DataTime              time.Time       `description:"数据日期"`
@@ -67,12 +67,8 @@ func (m *AiPredictModelData) Cols() AiPredictModelDataCols {
 }
 
 func (m *AiPredictModelData) Create() (err error) {
-	o := orm.NewOrmUsingDB("data")
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.AiPredictModelDataId = int(id)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Create(m).Error
 	return
 }
 
@@ -80,21 +76,21 @@ func (m *AiPredictModelData) CreateMulti(items []*AiPredictModelData) (err error
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.InsertMulti(len(items), items)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *AiPredictModelData) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Update(m, cols...)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Select(cols).Updates(m).Error
 	return
 }
 
 func (m *AiPredictModelData) Remove() (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sqlRun := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	_, err = o.Raw(sqlRun, m.AiPredictModelDataId).Exec()
+	err = o.Exec(sqlRun, m.AiPredictModelDataId).Error
 	return
 }
 
@@ -102,9 +98,9 @@ func (m *AiPredictModelData) MultiRemove(ids []int) (err error) {
 	if len(ids) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sqlRun := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
-	_, err = o.Raw(sqlRun, ids).Exec()
+	err = o.Exec(sqlRun, ids).Error
 	return
 }
 
@@ -112,39 +108,39 @@ func (m *AiPredictModelData) RemoveByCondition(condition string, pars []interfac
 	if condition == "" {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sqlRun := fmt.Sprintf(`DELETE FROM %s WHERE %s`, m.TableName(), condition)
-	_, err = o.Raw(sqlRun, pars).Exec()
+	err = o.Exec(sqlRun, pars...).Error
 	return
 }
 
 func (m *AiPredictModelData) GetItemById(id int) (item *AiPredictModelData, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sqlRun := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	err = o.Raw(sqlRun, id).QueryRow(&item)
+	err = o.Raw(sqlRun, id).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelData) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *AiPredictModelData, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	order := ``
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
 	sqlRun := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
-	err = o.Raw(sqlRun, pars).QueryRow(&item)
+	err = o.Raw(sqlRun, pars...).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelData) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sqlRun := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sqlRun, pars).QueryRow(&count)
+	err = o.Raw(sqlRun, pars...).Scan(&count).Error
 	return
 }
 
 func (m *AiPredictModelData) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*AiPredictModelData, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -154,12 +150,12 @@ func (m *AiPredictModelData) GetItemsByCondition(condition string, pars []interf
 		order = ` ORDER BY ` + orderRule
 	}
 	sqlRun := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sqlRun, pars).QueryRows(&items)
+	err = o.Raw(sqlRun, pars...).Find(&items).Error
 	return
 }
 
 func (m *AiPredictModelData) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*AiPredictModelData, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -169,7 +165,8 @@ func (m *AiPredictModelData) GetPageItemsByCondition(condition string, pars []in
 		order = ` ORDER BY ` + orderRule
 	}
 	sqlRun := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sqlRun, pars, startSize, pageSize).QueryRows(&items)
+	pars = append(pars, startSize, pageSize)
+	err = o.Raw(sqlRun, pars...).Find(&items).Error
 	return
 }
 

+ 39 - 55
models/ai_predict_model/ai_predict_model_framework.go

@@ -1,16 +1,16 @@
 package data_manage
 
 import (
+	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
 
 // AiPredictModelFramework 图库框架表
 type AiPredictModelFramework struct {
-	AiPredictModelFrameworkId int       `orm:"column(ai_predict_model_framework_id);pk"`
+	AiPredictModelFrameworkId int       `orm:"column(ai_predict_model_framework_id);pk" gorm:"primaryKey"`
 	FrameworkCode             string    `description:"框架唯一编码"`
 	FrameworkName             string    `description:"框架名称"`
 	FrameworkImg              string    `description:"框架图片"`
@@ -61,12 +61,8 @@ var AiPredictModelFrameworkColumns = struct {
 }
 
 func (m *AiPredictModelFramework) Create() (err error) {
-	o := orm.NewOrmUsingDB("data")
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.AiPredictModelFrameworkId = int(id)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Create(m).Error
 	return
 }
 
@@ -74,47 +70,47 @@ func (m *AiPredictModelFramework) CreateMulti(items []*AiPredictModelFramework)
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.InsertMulti(len(items), items)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *AiPredictModelFramework) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Update(m, cols...)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Select(cols).Updates(m).Error
 	return
 }
 
 func (m *AiPredictModelFramework) Del() (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
-	_, err = o.Raw(sql, m.AiPredictModelFrameworkId).Exec()
+	err = o.Exec(sql, m.AiPredictModelFrameworkId).Error
 	return
 }
 
 func (m *AiPredictModelFramework) GetItemById(id int) (item *AiPredictModelFramework, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
-	err = o.Raw(sql, id).QueryRow(&item)
+	err = o.Raw(sql, id).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelFramework) GetItemByCondition(condition string, pars []interface{}) (item *AiPredictModelFramework, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s LIMIT 1`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	err = o.Raw(sql, pars...).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelFramework) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars...).Scan(&count).Error
 	return
 }
 
 func (m *AiPredictModelFramework) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*AiPredictModelFramework, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -124,12 +120,12 @@ func (m *AiPredictModelFramework) GetItemsByCondition(condition string, pars []i
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 
 func (m *AiPredictModelFramework) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*AiPredictModelFramework, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -139,17 +135,14 @@ func (m *AiPredictModelFramework) GetPageItemsByCondition(condition string, pars
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	pars = append(pars, startSize, pageSize)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 
 func (m *AiPredictModelFramework) CreateFrameworkAndNodes(item *AiPredictModelFramework, nodes []*AiPredictModelFrameworkNode) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	tx, e := o.Begin()
-	if e != nil {
-		err = fmt.Errorf("orm begin err: %s", e.Error())
-		return
-	}
+	o := global.DbMap[utils.DbNameIndex]
+	tx := o.Begin()
 	defer func() {
 		if err != nil {
 			_ = tx.Rollback()
@@ -158,19 +151,18 @@ func (m *AiPredictModelFramework) CreateFrameworkAndNodes(item *AiPredictModelFr
 		_ = tx.Commit()
 	}()
 
-	id, e := tx.Insert(item)
+	e := tx.Create(item).Error
 	if e != nil {
 		err = fmt.Errorf("insert framework err: %s", e.Error())
 		return
 	}
-	newId := int(id)
-	item.AiPredictModelFrameworkId = newId
+	newId := item.AiPredictModelFrameworkId
 
 	if len(nodes) > 0 {
 		for _, n := range nodes {
 			n.AiPredictModelFrameworkId = newId
 		}
-		_, e = tx.InsertMulti(len(nodes), nodes)
+		e = tx.CreateInBatches(nodes, utils.MultiAddNum).Error
 		if e != nil {
 			err = fmt.Errorf("insert multi nodes err: %s", e.Error())
 			return
@@ -180,12 +172,8 @@ func (m *AiPredictModelFramework) CreateFrameworkAndNodes(item *AiPredictModelFr
 }
 
 func (m *AiPredictModelFramework) EditFrameworkAndNodes(item *AiPredictModelFramework, updateCols []string, nodes []*AiPredictModelFrameworkNode) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	tx, e := o.Begin()
-	if e != nil {
-		err = fmt.Errorf("orm begin err: %s", e.Error())
-		return
-	}
+	o := global.DbMap[utils.DbNameIndex]
+	tx := o.Begin()
 	defer func() {
 		if err != nil {
 			_ = tx.Rollback()
@@ -194,20 +182,20 @@ func (m *AiPredictModelFramework) EditFrameworkAndNodes(item *AiPredictModelFram
 		_ = tx.Commit()
 	}()
 
-	_, e = tx.Update(item, updateCols...)
+	e := tx.Select(updateCols).Updates(item).Error
 	if e != nil {
 		err = fmt.Errorf("framework update err: %s", e.Error())
 		return
 	}
 
 	sql := `DELETE FROM ai_predict_model_framework_node WHERE ai_predict_model_framework_id = ?`
-	_, e = tx.Raw(sql, item.AiPredictModelFrameworkId).Exec()
+	e = tx.Exec(sql, item.AiPredictModelFrameworkId).Error
 	if e != nil {
 		err = fmt.Errorf("clear nodes err: %s", e.Error())
 		return
 	}
 	if len(nodes) > 0 {
-		_, e = tx.InsertMulti(len(nodes), nodes)
+		e = tx.CreateInBatches(nodes, utils.MultiAddNum).Error
 		if e != nil {
 			err = fmt.Errorf("insert multi nodes err: %s", e.Error())
 			return
@@ -217,12 +205,8 @@ func (m *AiPredictModelFramework) EditFrameworkAndNodes(item *AiPredictModelFram
 }
 
 func (m *AiPredictModelFramework) RemoveFrameworkAndNodes(frameworkId int) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	tx, e := o.Begin()
-	if e != nil {
-		err = fmt.Errorf("orm begin err: %s", e.Error())
-		return
-	}
+	o := global.DbMap[utils.DbNameIndex]
+	tx := o.Begin()
 	defer func() {
 		if err != nil {
 			_ = tx.Rollback()
@@ -232,14 +216,14 @@ func (m *AiPredictModelFramework) RemoveFrameworkAndNodes(frameworkId int) (err
 	}()
 
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
-	_, e = tx.Raw(sql, frameworkId).Exec()
+	e := tx.Exec(sql, frameworkId).Error
 	if e != nil {
 		err = fmt.Errorf("delete framework err: %s", e.Error())
 		return
 	}
 
 	sql = `DELETE FROM ai_predict_model_framework_node WHERE ai_predict_model_framework_id = ?`
-	_, e = tx.Raw(sql, frameworkId).Exec()
+	e = tx.Exec(sql, frameworkId).Error
 	if e != nil {
 		err = fmt.Errorf("clear nodes err: %s", e.Error())
 		return
@@ -294,20 +278,20 @@ type AiPredictModelFrameworkMoveReq struct {
 
 // UpdateAiPredictModelFrameworkSort 更新我的图库框架排序
 func UpdateAiPredictModelFrameworkSort(adminId, frameworkId, current int, updates string) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`UPDATE ai_predict_model_framework SET sort = %s WHERE  sort > ?`, updates)
 	if frameworkId > 0 {
 		sql += ` OR (ai_predict_model_framework_id > ` + fmt.Sprint(frameworkId) + ` AND sort = ` + fmt.Sprint(current) + `)`
 	}
-	_, err = o.Raw(sql, current).Exec()
+	err = o.Exec(sql, current).Error
 	return
 }
 
 // GetFirstAiPredictModelFramework 获取我的图库框架排首位的数据
 func GetFirstAiPredictModelFramework() (item *AiPredictModelFramework, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := `SELECT * FROM ai_predict_model_framework ORDER BY sort ASC,ai_predict_model_framework_id ASC LIMIT 1`
-	err = o.Raw(sql).QueryRow(&item)
+	err = o.Raw(sql).First(&item).Error
 	return
 }
 

+ 21 - 24
models/ai_predict_model/ai_predict_model_framework_node.go

@@ -1,16 +1,16 @@
 package data_manage
 
 import (
+	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
 
 // AiPredictModelFrameworkNode 图库框架节点表
 type AiPredictModelFrameworkNode struct {
-	AiPredictModelFrameworkNodeId int       `orm:"column(ai_predict_model_framework_node_id);pk"`
+	AiPredictModelFrameworkNodeId int       `orm:"column(ai_predict_model_framework_node_id);pk" gorm:"primaryKey"`
 	AiPredictModelFrameworkId     int       `description:"框架ID"`
 	FrameworkName                 string    `description:"框架名称"`
 	NodeId                        string    `description:"节点ID"`
@@ -28,12 +28,8 @@ func (m *AiPredictModelFrameworkNode) PrimaryId() string {
 }
 
 func (m *AiPredictModelFrameworkNode) Create() (err error) {
-	o := orm.NewOrmUsingDB("data")
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.AiPredictModelFrameworkNodeId = int(id)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Create(m).Error
 	return
 }
 
@@ -41,47 +37,47 @@ func (m *AiPredictModelFrameworkNode) CreateMulti(items []*AiPredictModelFramewo
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.InsertMulti(len(items), items)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *AiPredictModelFrameworkNode) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Update(m, cols...)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Select(cols).Updates(m).Error
 	return
 }
 
 func (m *AiPredictModelFrameworkNode) Del() (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
-	_, err = o.Raw(sql, m.AiPredictModelFrameworkNodeId).Exec()
+	err = o.Exec(sql, m.AiPredictModelFrameworkNodeId).Error
 	return
 }
 
 func (m *AiPredictModelFrameworkNode) GetItemById(id int) (item *AiPredictModelFrameworkNode, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
-	err = o.Raw(sql, id).QueryRow(&item)
+	err = o.Raw(sql, id).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelFrameworkNode) GetItemByCondition(condition string, pars []interface{}) (item *AiPredictModelFrameworkNode, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s LIMIT 1`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	err = o.Raw(sql, pars...).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelFrameworkNode) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars...).Scan(&count).Error
 	return
 }
 
 func (m *AiPredictModelFrameworkNode) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*AiPredictModelFrameworkNode, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -91,12 +87,12 @@ func (m *AiPredictModelFrameworkNode) GetItemsByCondition(condition string, pars
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 
 func (m *AiPredictModelFrameworkNode) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*AiPredictModelFrameworkNode, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -106,7 +102,8 @@ func (m *AiPredictModelFrameworkNode) GetPageItemsByCondition(condition string,
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	pars = append(pars, startSize, pageSize)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 

+ 42 - 52
models/ai_predict_model/ai_predict_model_index.go

@@ -1,10 +1,10 @@
 package data_manage
 
 import (
+	"eta/eta_api/global"
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"strings"
 	"time"
@@ -12,7 +12,7 @@ import (
 
 // AiPredictModelIndex AI预测模型标的
 type AiPredictModelIndex struct {
-	AiPredictModelIndexId int       `orm:"column(ai_predict_model_index_id);pk"`
+	AiPredictModelIndexId int       `orm:"column(ai_predict_model_index_id);pk" gorm:"primaryKey"`
 	IndexName             string    `description:"标的名称"`
 	IndexCode             string    `description:"自生成的指标编码"`
 	ClassifyId            int       `description:"分类ID"`
@@ -79,12 +79,8 @@ func (m *AiPredictModelIndex) Cols() AiPredictModelIndexCols {
 }
 
 func (m *AiPredictModelIndex) Create() (err error) {
-	o := orm.NewOrmUsingDB("data")
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.AiPredictModelIndexId = int(id)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Create(m).Error
 	return
 }
 
@@ -92,21 +88,21 @@ func (m *AiPredictModelIndex) CreateMulti(items []*AiPredictModelIndex) (err err
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.InsertMulti(len(items), items)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *AiPredictModelIndex) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Update(m, cols...)
+	o := global.DbMap[utils.DbNameIndex]
+	err = o.Select(cols).Updates(m).Error
 	return
 }
 
 func (m *AiPredictModelIndex) Remove() (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	_, err = o.Raw(sql, m.AiPredictModelIndexId).Exec()
+	err = o.Exec(sql, m.AiPredictModelIndexId).Error
 	return
 }
 
@@ -114,9 +110,9 @@ func (m *AiPredictModelIndex) MultiRemove(ids []int) (err error) {
 	if len(ids) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
-	_, err = o.Raw(sql, ids).Exec()
+	err = o.Exec(sql, ids).Error
 	return
 }
 
@@ -124,39 +120,39 @@ func (m *AiPredictModelIndex) RemoveByCondition(condition string, pars []interfa
 	if condition == "" {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s`, m.TableName(), condition)
-	_, err = o.Raw(sql, pars).Exec()
+	err = o.Exec(sql, pars...).Error
 	return
 }
 
 func (m *AiPredictModelIndex) GetItemById(id int) (item *AiPredictModelIndex, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	err = o.Raw(sql, id).QueryRow(&item)
+	err = o.Raw(sql, id).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelIndex) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *AiPredictModelIndex, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	order := ``
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	err = o.Raw(sql, pars...).First(&item).Error
 	return
 }
 
 func (m *AiPredictModelIndex) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars...).Scan(&count).Error
 	return
 }
 
 func (m *AiPredictModelIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*AiPredictModelIndex, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -166,12 +162,12 @@ func (m *AiPredictModelIndex) GetItemsByCondition(condition string, pars []inter
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 
 func (m *AiPredictModelIndex) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*AiPredictModelIndex, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -181,7 +177,8 @@ func (m *AiPredictModelIndex) GetPageItemsByCondition(condition string, pars []i
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	pars = append(pars, startSize, pageSize)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }
 
@@ -233,12 +230,8 @@ type AiPredictModelIndexPageListResp struct {
 
 // RemoveIndexAndData 删除标的及数据
 func (m *AiPredictModelIndex) RemoveIndexAndData(indexId int) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	tx, e := o.Begin()
-	if e != nil {
-		err = fmt.Errorf("trans begin err: %v", e)
-		return
-	}
+	o := global.DbMap[utils.DbNameIndex]
+	tx := o.Begin()
 	defer func() {
 		if err != nil {
 			_ = tx.Rollback()
@@ -248,13 +241,13 @@ func (m *AiPredictModelIndex) RemoveIndexAndData(indexId int) (err error) {
 	}()
 
 	sql := `DELETE FROM ai_predict_model_index WHERE ai_predict_model_index_id = ? LIMIT 1`
-	_, e = tx.Raw(sql, indexId).Exec()
+	e := tx.Exec(sql, indexId).Error
 	if e != nil {
 		err = fmt.Errorf("remove index err: %v", e)
 		return
 	}
 	sql = ` DELETE FROM ai_predict_model_data WHERE ai_predict_model_index_id = ?`
-	_, e = tx.Raw(sql, indexId).Exec()
+	e = tx.Exec(sql, indexId).Error
 	if e != nil {
 		err = fmt.Errorf("remove index data err: %v", e)
 		return
@@ -264,22 +257,22 @@ func (m *AiPredictModelIndex) RemoveIndexAndData(indexId int) (err error) {
 
 // UpdateAiPredictModelIndexSortByClassifyId 根据分类id更新排序
 func UpdateAiPredictModelIndexSortByClassifyId(classifyId, nowSort int, prevEdbInfoId int, updateSort string) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := ` UPDATE ai_predict_model_index SET sort = ` + updateSort + ` WHERE classify_id = ?`
 	if prevEdbInfoId > 0 {
 		sql += ` AND ( sort > ? or ( ai_predict_model_index_id > ` + fmt.Sprint(prevEdbInfoId) + ` and sort=` + fmt.Sprint(nowSort) + ` )) `
 	} else {
 		sql += ` AND ( sort > ? )`
 	}
-	_, err = o.Raw(sql, classifyId, nowSort).Exec()
+	err = o.Exec(sql, classifyId, nowSort).Error
 	return
 }
 
 // GetFirstAiPredictModelIndexByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
 func GetFirstAiPredictModelIndexByClassifyId(classifyId int) (item *AiPredictModelIndex, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DbMap[utils.DbNameIndex]
 	sql := ` SELECT * FROM ai_predict_model_index WHERE classify_id = ? order by sort asc,ai_predict_model_index_id asc limit 1`
-	err = o.Raw(sql, classifyId).QueryRow(&item)
+	err = o.Raw(sql, classifyId).First(&item).Error
 	return
 }
 
@@ -293,12 +286,8 @@ func (m *AiPredictModelIndex) ImportIndexAndData(createIndexes, updateIndexes []
 	if len(createIndexes) == 0 && len(updateIndexes) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	tx, e := o.Begin()
-	if e != nil {
-		err = fmt.Errorf("trans begin err: %v", e)
-		return
-	}
+	o := global.DbMap[utils.DbNameIndex]
+	tx := o.Begin()
 	defer func() {
 		if err != nil {
 			_ = tx.Rollback()
@@ -310,7 +299,7 @@ func (m *AiPredictModelIndex) ImportIndexAndData(createIndexes, updateIndexes []
 	if len(updateIndexes) > 0 {
 		for _, v := range updateIndexes {
 			// 更新指标
-			_, e = tx.Update(v.Index, updateCols...)
+			e := tx.Select(updateCols).Updates(v.Index).Error
 			if e != nil {
 				err = fmt.Errorf("update index err: %v", e)
 				return
@@ -323,12 +312,12 @@ func (m *AiPredictModelIndex) ImportIndexAndData(createIndexes, updateIndexes []
 
 			// 清空指标并新增
 			sql := `DELETE FROM ai_predict_model_data WHERE ai_predict_model_index_id = ?`
-			_, e = tx.Raw(sql, v.Index.AiPredictModelIndexId).Exec()
+			e = tx.Exec(sql, v.Index.AiPredictModelIndexId).Error
 			if e != nil {
 				err = fmt.Errorf("clear index data err: %v", e)
 				return
 			}
-			_, e = tx.InsertMulti(utils.MultiAddNum, v.Data)
+			e = tx.CreateInBatches(v.Data, utils.MultiAddNum).Error
 			if e != nil {
 				err = fmt.Errorf("insert index data err: %v", e)
 				return
@@ -338,18 +327,19 @@ func (m *AiPredictModelIndex) ImportIndexAndData(createIndexes, updateIndexes []
 
 	if len(createIndexes) > 0 {
 		for _, v := range createIndexes {
-			indexId, e := tx.Insert(v.Index)
+			e := tx.Create(v.Index).Error
 			if e != nil {
 				err = fmt.Errorf("insert index err: %v", e)
 				return
 			}
-			v.Index.AiPredictModelIndexId = int(indexId)
+
+			indexId := v.Index.AiPredictModelIndexId
 			for _, d := range v.Data {
 				d.AiPredictModelIndexId = int(indexId)
 				d.IndexCode = v.Index.IndexCode
 				d.DataTimestamp = d.DataTime.UnixNano() / 1e6
 			}
-			_, e = tx.InsertMulti(utils.MultiAddNum, v.Data)
+			e = tx.CreateInBatches(v.Data, utils.MultiAddNum).Error
 			if e != nil {
 				err = fmt.Errorf("insert index data err: %v", e)
 				return

+ 27 - 23
models/ai_summary/ai_pormpt.go

@@ -1,12 +1,13 @@
 package ai_summary
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta/eta_api/global"
+	"eta/eta_api/utils"
 	"time"
 )
 
 type AiPrompt struct {
-	AiPromptId    int       `orm:"column(ai_prompt_id);pk"` // ai纪要提示词id
+	AiPromptId    int       `orm:"column(ai_prompt_id);pk" gorm:"primaryKey"` // ai纪要提示词id
 	PromptContent string    // 原始内容
 	SysAdminId    int       // 创建人ID
 	SysAdminName  string    // 创建人姓名
@@ -18,7 +19,7 @@ type AiPrompt struct {
 }
 
 type AiPromptItem struct {
-	AiPromptId    int    `orm:"column(ai_prompt_id);pk"` // ai纪要提示词id
+	AiPromptId    int    `orm:"column(ai_prompt_id);pk" gorm:"primaryKey"` // ai纪要提示词id
 	PromptContent string // 原始内容
 	SysAdminId    int    // 创建人ID
 	SysAdminName  string // 创建人姓名
@@ -36,8 +37,8 @@ func GetAiPromptList(sysUserId, isShare int) (items []*AiPromptItem, err error)
 	} else {
 		sql = ` SELECT * FROM ai_prompt WHERE sys_admin_id=? ORDER BY sort  `
 	}
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, sysUserId).QueryRows(&items)
+	o := global.DbMap[utils.DbNameMaster]
+	err = o.Raw(sql, sysUserId).Find(&items).Error
 	return
 }
 
@@ -45,8 +46,8 @@ func GetAiPromptShareList() (items []*AiPromptItem, err error) {
 	sql := ``
 	sql = ` SELECT * FROM ai_prompt WHERE is_share=1 ORDER BY create_time DESC `
 
-	o := orm.NewOrm()
-	_, err = o.Raw(sql).QueryRows(&items)
+	o := global.DbMap[utils.DbNameMaster]
+	err = o.Raw(sql).Find(&items).Error
 	return
 }
 
@@ -64,8 +65,12 @@ type AiPromptAddReq struct {
 }
 
 func AddPropmt(item *AiPrompt) (lastId int64, err error) {
-	o := orm.NewOrm()
-	lastId, err = o.Insert(item)
+	o := global.DbMap[utils.DbNameMaster]
+	err = o.Create(item).Error
+	if err != nil {
+		return
+	}
+	lastId = int64(item.AiPromptId)
 	return
 }
 
@@ -77,23 +82,23 @@ type AiPromptEditReq struct {
 
 // Update
 func (aiPrompt *AiPrompt) Update(cols []string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Update(aiPrompt, cols...)
+	o := global.DbMap[utils.DbNameMaster]
+	err = o.Select(cols).Updates(aiPrompt).Error
 	return
 }
 
 // DelAiSummaryById 根据纪要id删除纪要
 func DelAiPromptyId(aiPromptId int) (err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `delete from ai_prompt where ai_prompt_id = ? `
-	_, err = o.Raw(sql, aiPromptId).Exec()
+	err = o.Exec(sql, aiPromptId).Error
 	return
 }
 
 func GetAiPromptById(promptId int) (item *AiPrompt, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT * FROM ai_prompt WHERE 1=1 AND ai_prompt_id=? `
-	err = o.Raw(sql, promptId).QueryRow(&item)
+	err = o.Raw(sql, promptId).First(&item).Error
 	return
 }
 
@@ -109,25 +114,24 @@ type ReqMovePrompt struct {
 
 // GetAiPromptMaxSort 获取ai提示词下最大的排序数
 func GetAiPromptMaxSort(adminId int) (sort int, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT Max(sort) AS sort FROM ai_prompt WHERE sys_admin_id=? `
-	err = o.Raw(sql, adminId).QueryRow(&sort)
+	err = o.Raw(sql, adminId).Scan(&sort).Error
 	return
 }
 
-
 // MoveDownPromptBySort 往下移动提示词
 func MoveDownPromptBySort(sysAdminId, prevSort, currentSort int) (err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `update ai_prompt set sort = sort - 1 where sys_admin_id = ? and sort <= ? and sort> ? `
-	_, err = o.Raw(sql, sysAdminId, prevSort, currentSort).Exec()
+	err = o.Exec(sql, sysAdminId, prevSort, currentSort).Error
 	return
 }
 
 // MoveUpPromptBySort 往上移动提示词
 func MoveUpPromptBySort(sysAdminId, nextSort, currentSort int) (err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `update ai_prompt set sort = sort + 1 where sys_admin_id = ? and sort >= ? and sort< ?`
-	_, err = o.Raw(sql, sysAdminId, nextSort, currentSort).Exec()
+	err = o.Exec(sql, sysAdminId, nextSort, currentSort).Error
 	return
-}
+}

+ 33 - 27
models/ai_summary/ai_summary.go

@@ -1,13 +1,14 @@
 package ai_summary
 
 import (
+	"eta/eta_api/global"
+	"eta/eta_api/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
 type AiSummary struct {
-	AiSummaryId     int       `orm:"column(ai_summary_id);pk"` // ai纪要id
+	AiSummaryId     int       `orm:"column(ai_summary_id);pk" gorm:"primaryKey"` // ai纪要id
 	SaDocId         int       // 文档ID
 	OriginContent   string    // 原始内容
 	SummaryContent  string    // 纪要内容
@@ -24,7 +25,7 @@ type AiSummary struct {
 }
 
 type AiSummaryItems struct {
-	AiSummaryId     int    `orm:"column(ai_summary_id);pk"` // ai纪要id
+	AiSummaryId     int    `orm:"column(ai_summary_id);pk" gorm:"primaryKey"` // ai纪要id
 	SaDocId         int    // 文档ID
 	OriginContent   string // 原始内容
 	OriginTitle     string // 原文标题
@@ -43,95 +44,100 @@ type AiSummaryItems struct {
 
 func GetAiChatTopicList(sysUserId int) (item []*AiSummary, err error) {
 	sql := ` SELECT * FROM ai_summary WHERE classify_id=? ORDER BY create_time DESC `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, sysUserId).QueryRows(&item)
+	o := global.DbMap[utils.DbNameMaster]
+	err = o.Raw(sql, sysUserId).Find(&item).Error
 	return
 }
 
 // GetAiSummaryById 根据纪要id获取详情
 func GetAiSummaryById(aiSummaryId int) (sandboxInfo *AiSummary, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `select * from ai_summary where ai_summary_id = ? `
-	err = o.Raw(sql, aiSummaryId).QueryRow(&sandboxInfo)
+	err = o.Raw(sql, aiSummaryId).First(&sandboxInfo).Error
 	return
 }
 
 // GetAiSummaryById 根据纪要id获取详情
 func GetAiSummaryItemById(aiSummaryId int) (sandboxInfo *AiSummaryItems, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `select * from ai_summary where ai_summary_id = ? `
-	err = o.Raw(sql, aiSummaryId).QueryRow(&sandboxInfo)
+	err = o.Raw(sql, aiSummaryId).First(&sandboxInfo).Error
 	return
 }
 
 // DelAiSummaryById 根据纪要id删除纪要
 func DelAiSummaryById(aiSummaryId int) (err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `delete from ai_summary where ai_summary_id = ? `
-	_, err = o.Raw(sql, aiSummaryId).Exec()
+	err = o.Exec(sql, aiSummaryId).Error
 	return
 }
 
 func MoveAiSummary(aiSummaryId, classifyId int) (err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` UPDATE  ai_summary
 			SET
 			  classify_id = ?
 			WHERE ai_summary_id = ?`
-	_, err = o.Raw(sql, classifyId, aiSummaryId).Exec()
+	err = o.Exec(sql, classifyId, aiSummaryId).Error
 	return
 }
 
 // GetFirstAiSummaryByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
 func GetFirstAiSummaryByClassifyId(classifyId int) (item *AiSummary, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT * FROM ai_summary WHERE classify_id=? order by sort asc,ai_summary_id asc limit 1`
-	err = o.Raw(sql, classifyId).QueryRow(&item)
+	err = o.Raw(sql, classifyId).First(&item).Error
 	return
 }
 
 // Update
 func (aiSummary *AiSummary) Update(cols []string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Update(aiSummary, cols...)
+	o := global.DbMap[utils.DbNameMaster]
+	err = o.Select(cols).Updates(aiSummary).Error
 	return
 }
 
 // UpdateSandboxSortByClassifyId 根据纪要id更新排序
 func UpdateAiSummarySortByClassifyId(classifyId, nowSort, prevAiSummaryId int, updateSort string) (err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` update ai_summary set sort = ` + updateSort + ` WHERE classify_id=?  AND `
 	if prevAiSummaryId > 0 {
 		sql += ` (sort > ? or (ai_summary_id > ` + fmt.Sprint(prevAiSummaryId) + ` and sort = ` + fmt.Sprint(nowSort) + `))`
 	}
-	_, err = o.Raw(sql, classifyId, nowSort).Exec()
+	err = o.Exec(sql, classifyId, nowSort).Error
 	return
 }
 
 func GetAiSummaryListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*AiSummaryItems, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT * FROM ai_summary WHERE 1=1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += " ORDER BY create_time DESC LIMIT ?,? "
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
+	pars = append(pars, startSize, pageSize)
+	err = o.Raw(sql, pars...).Find(&item).Error
 	return
 }
 
 func GetAiSummaryListCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT COUNT(1) AS count FROM ai_summary WHERE 1=1 `
 	if condition != "" {
 		sql += condition
 	}
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars...).Scan(&count).Error
 	return
 }
 
 func AddAiSummary(item *AiSummary) (lastId int64, err error) {
-	o := orm.NewOrm()
-	lastId, err = o.Insert(item)
+	o := global.DbMap[utils.DbNameMaster]
+	err = o.Create(item).Error
+	if err != nil {
+		return
+	}
+	lastId = int64(item.AiSummaryId)
 	return
 }
 
@@ -157,9 +163,9 @@ type GenerateAiSummaryReq struct {
 
 // GetAiSummaryMaxSort 获取ai纪要下最大的排序数
 func GetAiSummaryMaxSort(classifyId int) (sort int, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT Max(sort) AS sort FROM ai_summary WHERE parent_id=? `
-	err = o.Raw(sql, classifyId).QueryRow(&sort)
+	err = o.Raw(sql, classifyId).Scan(&sort).Error
 	return
 }
 

+ 45 - 40
models/ai_summary/ai_summary_classify.go

@@ -1,15 +1,16 @@
 package ai_summary
 
 import (
+	"eta/eta_api/global"
+	"eta/eta_api/utils"
 	"fmt"
 	"time"
 
-	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 type AiSummaryClassify struct {
-	AiSummaryClassifyId int       `orm:"column(ai_summary_classify_id);pk"` // ai纪要分类id
+	AiSummaryClassifyId int       `orm:"column(ai_summary_classify_id);pk" gorm:"primaryKey"` // ai纪要分类id
 	ClassifyName        string    // 分类名称
 	ParentId            int       // 父级id
 	CreateTime          time.Time // 创建时间
@@ -23,8 +24,12 @@ type AiSummaryClassify struct {
 }
 
 func AddAiSummaryClassify(item *AiSummaryClassify) (lastId int64, err error) {
-	o := orm.NewOrm()
-	lastId, err = o.Insert(item)
+	o := global.DbMap[utils.DbNameMaster]
+	err = o.Create(item).Error
+	if err != nil {
+		return
+	}
+	lastId = int64(item.AiSummaryClassifyId)
 	return
 }
 
@@ -51,15 +56,15 @@ type AiSummaryClassifyListResp struct {
 
 // GetAiSummaryClassifyByParentId
 func GetAiSummaryClassifyByParentId(parentId int) (items []*AiSummaryClassifyItems, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT * FROM ai_summary_classify WHERE parent_id=? order by sort asc,ai_summary_classify_id asc`
-	_, err = o.Raw(sql, parentId).QueryRows(&items)
+	err = o.Raw(sql, parentId).Find(&items).Error
 	return
 }
 
 // GetAiSummaryInfoByAdminId 获取所有我创建的纪要,用于分类展示
 func GetAiSummaryInfoByAdminId(adminId int) (items []*AiSummaryClassifyItems, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT
 	a.*,
 	b.ai_summary_classify_id,
@@ -72,13 +77,13 @@ WHERE
 ORDER BY
 	a.sort ASC,
 	a.create_time ASC `
-	_, err = o.Raw(sql, adminId).QueryRows(&items)
+	err = o.Raw(sql, adminId).Find(&items).Error
 	return
 }
 
 // GetAiSummaryClassifyAndInfoByParentId
 func GetAiSummaryClassifyAndInfoByParentId(parentId int) (items []*AiSummaryClassifyItems, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT
 	0 AS ai_summary_id,
 	ai_summary_classify_id,
@@ -112,7 +117,7 @@ WHERE
 ORDER BY
 	sort ASC,
 	ai_summary_classify_id ASC`
-	_, err = o.Raw(sql, parentId, parentId).QueryRows(&items)
+	err = o.Raw(sql, parentId, parentId).Find(&items).Error
 	return
 }
 
@@ -123,17 +128,17 @@ type AddAiSummaryClassifyReq struct {
 }
 
 func GetAiSummaryClassifyCount(classifyName string, parentId int) (count int, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT COUNT(1) AS count FROM ai_summary_classify WHERE parent_id=? AND classify_name=? `
-	err = o.Raw(sql, parentId, classifyName).QueryRow(&count)
+	err = o.Raw(sql, parentId, classifyName).Scan(&count).Error
 	return
 }
 
 // GetAiSummaryClassifyMaxSort 获取ai纪要下最大的排序数
 func GetAiSummaryClassifyMaxSort(parentId int) (sort int, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT Max(sort) AS sort FROM ai_summary_classify WHERE parent_id=? `
-	err = o.Raw(sql, parentId).QueryRow(&sort)
+	err = o.Raw(sql, parentId).Scan(&sort).Error
 	return
 }
 
@@ -143,9 +148,9 @@ type EditAiSummaryClassifyReq struct {
 }
 
 func EditSandboxClassify(classifyId int, classifyName string) (err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `UPDATE ai_summary_classify SET classify_name=?, modify_time=NOW() WHERE ai_summary_classify_id=? `
-	_, err = o.Raw(sql, classifyName, classifyId).Exec()
+	err = o.Exec(sql, classifyName, classifyId).Error
 	return
 }
 
@@ -154,7 +159,7 @@ type AiSummaryClassifyDeleteCheckReq struct {
 }
 
 func GetAiSummaryInfoCountByClassifyId(classifyId int) (count int, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT COUNT(1) AS count FROM ai_summary AS a
 				WHERE a.classify_id IN(
 				SELECT t.ai_summary_classify_id FROM 
@@ -167,7 +172,7 @@ func GetAiSummaryInfoCountByClassifyId(classifyId int) (count int, err error) {
 				UNION SELECT * FROM ai_summary_classify WHERE ai_summary_classify_id = @pid 
 				)AS t
 				) `
-	err = o.Raw(sql, classifyId).QueryRow(&count)
+	err = o.Raw(sql, classifyId).Scan(&count).Error
 	return
 }
 
@@ -177,7 +182,7 @@ type DeleteAiSummaryClassifyReq struct {
 }
 
 func DeleteAiSummaryClassify(classifyId int) (err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` DELETE FROM ai_summary_classify
 				WHERE ai_summary_classify_id IN(
 				SELECT t.ai_summary_classify_id FROM
@@ -190,7 +195,7 @@ func DeleteAiSummaryClassify(classifyId int) (err error) {
 				UNION SELECT * FROM ai_summary_classify WHERE ai_summary_classify_id = @pid
 				)AS t
 				) `
-	_, err = o.Raw(sql, classifyId).Exec()
+	err = o.Exec(sql, classifyId).Error
 	return
 }
 
@@ -206,48 +211,48 @@ type MoveAiSummaryClassifyReq struct {
 }
 
 func GetAiSummaryClassifyById(classifyId int) (item *AiSummaryClassify, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT * FROM ai_summary_classify WHERE ai_summary_classify_id=? `
-	err = o.Raw(sql, classifyId).QueryRow(&item)
+	err = o.Raw(sql, classifyId).First(&item).Error
 	return
 }
 
 func GetAiSummaryClassifyCountById(classifyId int) (count int, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT count(1) AS count FROM ai_summary_classify WHERE ai_summary_classify_id=? `
-	err = o.Raw(sql, classifyId).QueryRow(&count)
+	err = o.Raw(sql, classifyId).Scan(&count).Error
 	return
 }
 
 // Update 更新沙盘分类基础信息
 func (aiSummaryClassify *AiSummaryClassify) Update(cols []string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Update(aiSummaryClassify, cols...)
+	o := global.DbMap[utils.DbNameMaster]
+	err = o.Select(cols).Updates(aiSummaryClassify).Error
 	return
 }
 
 // GetFirstAiSummaryClassifyByParentId 获取当前父级沙盘分类下的排序第一条的数据
 func GetFirstAiSummaryClassifyByParentId(parentId int) (item *AiSummaryClassify, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT * FROM ai_summary_classify WHERE parent_id=? order by sort asc,ai_summary_classify_id asc limit 1`
-	err = o.Raw(sql, parentId).QueryRow(&item)
+	err = o.Raw(sql, parentId).First(&item).Error
 	return
 }
 
 // UpdateSandboxClassifySortByParentId 根据沙盘父类id更新排序
 func UpdateAiSummaryClassifySortByParentId(parentId, classifyId, nowSort int, updateSort string) (err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` update ai_summary_classify set sort = ` + updateSort + ` WHERE parent_id=? and sort > ? `
 	if classifyId > 0 {
 		sql += ` or ( ai_summary_classify_id > ` + fmt.Sprint(classifyId) + ` and sort= ` + fmt.Sprint(nowSort) + `)`
 	}
-	_, err = o.Raw(sql, parentId, nowSort).Exec()
+	err = o.Exec(sql, parentId, nowSort).Error
 	return
 }
 
 // 获取所有子级分类id
 func GetAiSummaryClassifySubcategories(classifyId int) (Ids string, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT GROUP_CONCAT(ai_summary_classify_id) AS ids
 FROM (
 SELECT @pv := ? AS ai_summary_classify_id
@@ -257,12 +262,12 @@ FROM ai_summary_classify sc
 JOIN (SELECT @pv := ?) initial
 WHERE sc.parent_id = @pv
 ) subcategories; `
-	err = o.Raw(sql, classifyId, classifyId).QueryRow(&Ids)
+	err = o.Raw(sql, classifyId, classifyId).Scan(&Ids).Error
 	return
 }
 
 func GetAiSummaryClassify(aiSummaryClassify int) (aiSummaryClassifyIds string, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT GROUP_CONCAT(t.ai_summary_classify_id) AS ai_summary_classify_id FROM (
 			SELECT a.ai_summary_classify_id FROM ai_summary_classify AS a 
 			WHERE a.ai_summary_classify_id=?
@@ -276,12 +281,12 @@ func GetAiSummaryClassify(aiSummaryClassify int) (aiSummaryClassifyIds string, e
 WHERE
 	parent_id IN ( SELECT ai_summary_classify_id FROM ai_summary_classify WHERE parent_id = ? )
 			)AS t`
-	err = o.Raw(sql, aiSummaryClassify, aiSummaryClassify, aiSummaryClassify).QueryRow(&aiSummaryClassifyIds)
+	err = o.Raw(sql, aiSummaryClassify, aiSummaryClassify, aiSummaryClassify).Scan(&aiSummaryClassifyIds).Error
 	return
 }
 
 func GetAiSummaryAllParentByClassifyId(aiSummaryClassifyId int) (ids string, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := `SELECT
 	GROUP_CONCAT(DISTINCT m.ai_summary_classify_id  ORDER BY m.level) AS ids 
 FROM
@@ -313,7 +318,7 @@ FROM
 	INNER JOIN ai_summary_classify m 
 WHERE
 	ai_summary_classify_id = vm._id `
-	err = o.Raw(sql, aiSummaryClassifyId).QueryRow(&ids)
+	err = o.Raw(sql, aiSummaryClassifyId).Scan(&ids).Error
 	return
 }
 
@@ -324,15 +329,15 @@ type AiSummaryListResp struct {
 
 // GetAiSummaryClassifyAll
 func GetAiSummaryClassifyAll() (items []*AiSummaryClassifyItems, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT * FROM ai_summary_classify WHERE parent_id<>0 order by sort asc,ai_summary_classify_id asc`
-	_, err = o.Raw(sql).QueryRows(&items)
+	err = o.Raw(sql).Find(&items).Error
 	return
 }
 
 func GetAiSummaryClassifyAllIncludeParent() (items []*AiSummaryClassifyItems, err error) {
-	o := orm.NewOrm()
+	o := global.DbMap[utils.DbNameMaster]
 	sql := ` SELECT * FROM ai_summary_classify order by sort asc,ai_summary_classify_id asc`
-	_, err = o.Raw(sql).QueryRows(&items)
+	err = o.Raw(sql).Find(&items).Error
 	return
 }

+ 2 - 2
models/aimod/ai.go

@@ -7,7 +7,7 @@ import (
 )
 
 type AiChatTopic struct {
-	AiChatTopicId   int `orm:"column(ai_chat_topic_id);pk"`
+	AiChatTopicId   int `orm:"column(ai_chat_topic_id);pk" gorm:"primaryKey"`
 	TopicName       string
 	SysUserId       int
 	SysUserRealName string
@@ -18,7 +18,7 @@ type AiChatTopic struct {
 }
 
 type AiChat struct {
-	AiChatId        int `orm:"column(ai_chat_id);pk"`
+	AiChatId        int `orm:"column(ai_chat_id);pk" gorm:"primaryKey"`
 	AiChatTopicId   int
 	Ask             string
 	AskUuid         string

+ 1 - 1
models/aimod/file_upload_record.go

@@ -6,7 +6,7 @@ import (
 )
 
 type FileUploadRecord struct {
-	FileUploadRecordId  int       `orm:"column(file_upload_record_id);pk"`
+	FileUploadRecordId  int       `orm:"column(file_upload_record_id);pk" gorm:"primaryKey"`
 	AdminId             int       `description:"用户id"`
 	FileUrl             string    `description:"文件地址"`
 	FileName            string    `description:"文件名称"`

+ 9 - 9
models/bi_dashboard/bi_dashboard.go

@@ -6,15 +6,15 @@ import (
 )
 
 type BiDashboard struct {
-	BiDashboardId         int       `orm:"column(bi_dashboard_id);pk"`         // bi看板id
-	BiDashboardClassifyId int       `gorm:"column:bi_dashboard_classify_id" `  // 看板分类id
-	BiDashboardName       string    `gorm:"column:bi_dashboard_name;size:255"` // 看板名称
-	SysAdminId            int       `gorm:"column:sys_admin_id" `              // 创建人ID
-	SysAdminName          string    `gorm:"column:sys_admin_name;size:128" `   // 创建人姓名
-	Sort                  int       `gorm:"column:sort" `                      // 排序字段
-	CreateTime            time.Time `gorm:"column:create_time" `               // 创建时间
-	ModifyTime            time.Time `gorm:"column:modify_time"`                // 更新时间
-	State                 int       `gorm:"column:state"`                      // 状态 1:未公开; 4-待审批;5-已驳回;6-已通过
+	BiDashboardId         int       `orm:"column(bi_dashboard_id);pk" gorm:"primaryKey"` // bi看板id
+	BiDashboardClassifyId int       `gorm:"column:bi_dashboard_classify_id" `            // 看板分类id
+	BiDashboardName       string    `gorm:"column:bi_dashboard_name;size:255"`           // 看板名称
+	SysAdminId            int       `gorm:"column:sys_admin_id" `                        // 创建人ID
+	SysAdminName          string    `gorm:"column:sys_admin_name;size:128" `             // 创建人姓名
+	Sort                  int       `gorm:"column:sort" `                                // 排序字段
+	CreateTime            time.Time `gorm:"column:create_time" `                         // 创建时间
+	ModifyTime            time.Time `gorm:"column:modify_time"`                          // 更新时间
+	State                 int       `gorm:"column:state"`                                // 状态 1:未公开; 4-待审批;5-已驳回;6-已通过
 }
 
 // tableName

+ 6 - 6
models/bi_dashboard/bi_dashboard_classify.go

@@ -6,11 +6,11 @@ import (
 )
 
 type BiDashboardClassify struct {
-	BiDashboardClassifyId   int       `orm:"column(bi_dashboard_classify_id);pk"` // bi看板分类id
-	BiDashboardClassifyName string    `gorm:"column:bi_dashboard_classify_name;size:255;not null" `     // 看板分类名称
-	Sort                    int       `gorm:"column:sort" `                                             // 排序字段
-	CreateTime              time.Time `gorm:"column:create_time" `                                      // 创建时间
-	ModifyTime              time.Time `gorm:"column:modify_time"`                                       // 更新时间
+	BiDashboardClassifyId   int       `orm:"column(bi_dashboard_classify_id);pk" gorm:"primaryKey"` // bi看板分类id
+	BiDashboardClassifyName string    `gorm:"column:bi_dashboard_classify_name;size:255;not null" ` // 看板分类名称
+	Sort                    int       `gorm:"column:sort" `                                         // 排序字段
+	CreateTime              time.Time `gorm:"column:create_time" `                                  // 创建时间
+	ModifyTime              time.Time `gorm:"column:modify_time"`                                   // 更新时间
 }
 type BiDashboardClassifyItem struct {
 	BiDashboardClassifyId   int    // bi看板分类id
@@ -108,7 +108,7 @@ type DelDashboardClassifyReq struct {
 // GetBiDashboardClassifyMaxSort 获取看板分类下最大的排序数
 func GetBiDashboardClassifyMaxSort() (sort int, err error) {
 	sql := `SELECT COALESCE(Max(sort), 0) AS sort FROM bi_dashboard_classify `
-	//err = global.DEFAULT_DmSQL.Raw(sql).First(&sort).Error
+	//err = global.DEFAULT_DmSQL.Raw(sql).Scan(&sort).Error
 	o := orm.NewOrm()
 	err = o.Raw(sql).QueryRow(&sort)
 	return

+ 11 - 12
models/bi_dashboard/bi_dashboard_detail.go

@@ -6,13 +6,13 @@ import (
 )
 
 type BiDashboardDetail struct {
-	BiDashboardDetailId int       `orm:"column(bi_dashboard_detail_id);pk" ` // bi看板id
-	BiDashboardId       int       `gorm:"column:bi_dashboard_id" `                                 // 看板id
-	Type                int       `gorm:"column:type" `                                            // 1图表 2表格
-	UniqueCode          string    `gorm:"column:unique_code;size:32;not null" `                    // 报告唯一编码
-	Sort                int       `gorm:"column:sort" `                                            // 排序字段
-	CreateTime          time.Time `gorm:"column:create_time" `                                     // 创建时间
-	ModifyTime          time.Time `gorm:"column:modify_time" `                                     // 更新时间
+	BiDashboardDetailId int       `orm:"column(bi_dashboard_detail_id);pk" gorm:"primaryKey" ` // bi看板id
+	BiDashboardId       int       `gorm:"column:bi_dashboard_id" `                             // 看板id
+	Type                int       `gorm:"column:type" `                                        // 1图表 2表格
+	UniqueCode          string    `gorm:"column:unique_code;size:32;not null" `                // 报告唯一编码
+	Sort                int       `gorm:"column:sort" `                                        // 排序字段
+	CreateTime          time.Time `gorm:"column:create_time" `                                 // 创建时间
+	ModifyTime          time.Time `gorm:"column:modify_time" `                                 // 更新时间
 }
 
 // tableName
@@ -22,8 +22,8 @@ func (m *BiDashboardDetail) TableName() string {
 
 // add
 //func AddBiDashboardDetail(item *BiDashboardDetail) (err error) {
-	//err = global.DEFAULT_DmSQL.Create(item).Error
-	//return
+//err = global.DEFAULT_DmSQL.Create(item).Error
+//return
 //}
 
 func GetBiDashboardDetailById(id int) (list []*BiDashboardDetail, err error) {
@@ -56,7 +56,7 @@ type MoveDashboardDetailReq struct {
 }
 
 // update
-func EditBiDashboardDetail(item *BiDashboardDetail) (err error){
+func EditBiDashboardDetail(item *BiDashboardDetail) (err error) {
 	//return global.DEFAULT_DmSQL.Model(item).Where("bi_dashboard_detail_id = ?", item.BiDashboardDetailId).Updates(item).Error
 	o := orm.NewOrm()
 	_, err = o.Raw("UPDATE bi_dashboard_detail SET bi_dashboard_id=?,type=?,unique_code=?,sort=?,modify_time=? WHERE bi_dashboard_detail_id=?", item.BiDashboardId, item.Type, item.UniqueCode, item.Sort, item.ModifyTime, item.BiDashboardDetailId).Exec()
@@ -67,11 +67,10 @@ type DelDashboardDetailReq struct {
 	BiDashboardDetailId int `description:"看板详情id"`
 }
 
-
 // del
 func DeleteBiDashboardDetailByDetailId(id int) (err error) {
 	//return global.DEFAULT_DmSQL.Where("bi_dashboard_detail_id = ?", id).Delete(&BiDashboardDetail{}).Error
 	o := orm.NewOrm()
 	_, err = o.Raw("DELETE from bi_dashboard_detail where bi_dashboard_detail_id=?", id).Exec()
 	return
-}
+}

+ 5 - 5
models/bi_dashboard/bi_dashboard_grant.go

@@ -6,10 +6,10 @@ import (
 )
 
 type BiDashboardGrant struct {
-	GrantId       int       `orm:"column(grant_id);pk"` // 授权id
-	BiDashboardId int       `gorm:"column:bi_dashboard_id" `                  // 看板id
-	GrantAdminId  int       `gorm:"column:grant_admin_id"`                    // 授权的用户id
-	CreateTime    time.Time `gorm:"column:create_time"`                       // 授权时间
+	GrantId       int       `orm:"column(grant_id);pk" gorm:"primaryKey"` // 授权id
+	BiDashboardId int       `gorm:"column:bi_dashboard_id" `              // 看板id
+	GrantAdminId  int       `gorm:"column:grant_admin_id"`                // 授权的用户id
+	CreateTime    time.Time `gorm:"column:create_time"`                   // 授权时间
 }
 
 // tableName
@@ -72,4 +72,4 @@ func GetDashboardGrantInfo(biDashboardId int) (list []*BiDashboardGrant, err err
 	o := orm.NewOrm()
 	_, err = o.Raw("SELECT * FROM bi_dashboard_grant where bi_dashboard_id=?", biDashboardId).QueryRows(&list)
 	return
-}
+}

+ 1 - 1
models/bi_dashboard/bi_dashboard_home_page.go

@@ -6,7 +6,7 @@ import (
 )
 
 type BiDashboardHomePage struct {
-	BiDashboardHomePageId int       `orm:"column(bi_dashboard_home_page_id);pk"`
+	BiDashboardHomePageId int       `orm:"column(bi_dashboard_home_page_id);pk" gorm:"primaryKey"`
 	BiDashboardId         int       `gorm:"type:int(10);default:null;comment:'看板id'"`
 	AdminId               int       `gorm:"type:int(10);default:null;"`
 	CreateTime            time.Time `gorm:"type:datetime;comment:'创建时间'"`

+ 1 - 1
models/binlog/business_sys_interaction_log.go

@@ -8,7 +8,7 @@ import (
 
 // BusinessSysInteractionLog 商家系统交互记录表
 type BusinessSysInteractionLog struct {
-	ID             uint32    `orm:"column(id);pk"`
+	ID             uint32    `orm:"column(id);pk" gorm:"primaryKey"`
 	InteractionKey string    // 记录Key
 	InteractionVal string    // 记录值
 	Remark         string    // 备注

+ 1 - 1
models/company/company.go

@@ -6,7 +6,7 @@ import (
 )
 
 type Company struct {
-	CompanyId       int       `orm:"column(company_id);pk"`
+	CompanyId       int       `orm:"column(company_id);pk" gorm:"primaryKey"`
 	CompanyName     string    `description:"客户名称"`
 	CompanyType     int       `orm:"column(type)"`
 	CreditCode      string    `description:"社会统一信用码"`

+ 5 - 5
models/data_source/base_from_sci99.go

@@ -8,7 +8,7 @@ import (
 
 // BaseFromSci99Index 代表卓创资讯-原始指标表的结构
 type BaseFromSci99Index struct {
-	BaseFromSciIndexId int       `orm:"column(base_from_sci_index_id);pk"` // 主键,自动递增
+	BaseFromSciIndexId int       `orm:"column(base_from_sci_index_id);pk" gorm:"primaryKey"` // 主键,自动递增
 	IndexCode          string    // 指标编码
 	IndexName          string    // 指标名称
 	ClassifyId         int       // 分类Id
@@ -24,7 +24,7 @@ type BaseFromSci99Index struct {
 
 // BaseFromSci99Data 代表卓创资讯-原始指标数据表的结构
 type BaseFromSci99Data struct {
-	BaseFromSciDataId  int       `orm:"column(base_from_sci_data_id);pk"` // 主键,自动递增
+	BaseFromSciDataId  int       `orm:"column(base_from_sci_data_id);pk" gorm:"primaryKey"` // 主键,自动递增
 	BaseFromSciIndexId int       // 指标id
 	IndexCode          string    // 指标编码
 	DataTime           string    // 数据日期
@@ -35,7 +35,7 @@ type BaseFromSci99Data struct {
 
 // BaseFromSci99Classify 代表卓创资讯-原始指标分类表的结构
 type BaseFromSci99Classify struct {
-	BaseFromSciClassifyId int       `orm:"column(base_from_sci_classify_id);pk"` // 主键,自动递增
+	BaseFromSciClassifyId int       `orm:"column(base_from_sci_classify_id);pk" gorm:"primaryKey"` // 主键,自动递增
 	ClassifyName          string    // 分类名称
 	Sort                  int       // 排序
 	CreateTime            time.Time // 创建时间
@@ -43,7 +43,7 @@ type BaseFromSci99Classify struct {
 }
 
 type BaseFromSci99DataItem struct {
-	BaseFromSciDataId  int     `orm:"column(base_from_sci_data_id);pk"` // 主键,自动递增
+	BaseFromSciDataId  int     `orm:"column(base_from_sci_data_id);pk" gorm:"primaryKey"` // 主键,自动递增
 	BaseFromSciIndexId int     // 指标id
 	IndexCode          string  // 指标编码
 	DataTime           string  // 数据日期
@@ -53,7 +53,7 @@ type BaseFromSci99DataItem struct {
 }
 
 type BaseFromSci99IndexList struct {
-	BaseFromSciIndexId int    `orm:"column(base_from_sci_index_id);pk"` // 主键,自动递增
+	BaseFromSciIndexId int    `orm:"column(base_from_sci_index_id);pk" gorm:"primaryKey"` // 主键,自动递增
 	IndexCode          string // 指标编码
 	IndexName          string // 指标名称
 	ClassifyId         int    // 分类Id

+ 23 - 23
models/data_source/data_source.go

@@ -150,7 +150,7 @@ func GetEsBaseFromIndexByTableName(tableName string) EsBaseFromIndex {
 
 // BaseFromRzdIndex 睿咨得
 type BaseFromRzdIndex struct {
-	BaseFromRzdIndexId    int       `orm:"column(base_from_rzd_index_id);pk"`
+	BaseFromRzdIndexId    int       `orm:"column(base_from_rzd_index_id);pk" gorm:"primaryKey"`
 	BaseFromRzdClassifyId int       `description:"分类ID"`
 	IndexCode             string    `description:"指标编码"`
 	IndexName             string    `description:"指标名称"`
@@ -223,7 +223,7 @@ func (m *BaseFromRzdIndex) GetItemsByCondition(condition string, pars []interfac
 
 // BaseFromHisugarIndex 泛糖科技
 type BaseFromHisugarIndex struct {
-	BaseFromHisugarIndexId int       `orm:"column(base_from_hisugar_index_id);pk"`
+	BaseFromHisugarIndexId int       `orm:"column(base_from_hisugar_index_id);pk" gorm:"primaryKey"`
 	ClassifyId             int       `description:"分类ID"`
 	IndexCode              string    `description:"指标编码"`
 	IndexName              string    `description:"指标名称"`
@@ -299,7 +299,7 @@ func (m *BaseFromHisugarIndex) GetItemsByCondition(condition string, pars []inte
 
 // BaseFromLyIndex 粮油商务网
 type BaseFromLyIndex struct {
-	BaseFromLyIndexId    int       `orm:"column(base_from_ly_index_id);pk"`
+	BaseFromLyIndexId    int       `orm:"column(base_from_ly_index_id);pk" gorm:"primaryKey"`
 	BaseFromLyClassifyId int       `description:"分类ID"`
 	IndexCode            string    `description:"指标编码"`
 	IndexName            string    `description:"指标名称"`
@@ -373,7 +373,7 @@ func (m *BaseFromLyIndex) GetItemsByCondition(condition string, pars []interface
 
 // BaseFromSciHqIndex 卓创红期
 type BaseFromSciHqIndex struct {
-	BaseFromSciHqIndexId int       `orm:"column(base_from_sci_hq_index_id);pk"`
+	BaseFromSciHqIndexId int       `orm:"column(base_from_sci_hq_index_id);pk" gorm:"primaryKey"`
 	ClassifyId           int       `description:"分类ID"`
 	IndexCode            string    `description:"指标编码"`
 	IndexName            string    `description:"指标名称"`
@@ -450,7 +450,7 @@ func (m *BaseFromSciHqIndex) GetItemsByCondition(condition string, pars []interf
 
 // BaseFromOilchemIndex 隆众资讯
 type BaseFromOilchemIndex struct {
-	BaseFromOilchemIndexId int       `orm:"column(base_from_oilchem_index_id);pk"`
+	BaseFromOilchemIndexId int       `orm:"column(base_from_oilchem_index_id);pk" gorm:"primaryKey"`
 	ClassifyId             int       `description:"分类ID"`
 	IndexCode              string    `description:"指标编码"`
 	IndexName              string    `description:"指标名称"`
@@ -523,7 +523,7 @@ func (m *BaseFromOilchemIndex) GetItemsByCondition(condition string, pars []inte
 
 // BaseFromThsHfIndex 同花顺高频数据
 type BaseFromThsHfIndex struct {
-	BaseFromThsHfIndexId    int       `orm:"column(base_from_ths_hf_index_id);pk"`
+	BaseFromThsHfIndexId    int       `orm:"column(base_from_ths_hf_index_id);pk" gorm:"primaryKey"`
 	BaseFromThsHfClassifyId int       `description:"分类ID"`
 	IndexCode               string    `description:"指标编码"`
 	IndexName               string    `description:"指标名称"`
@@ -606,7 +606,7 @@ func (m *BaseFromThsHfIndex) GetItemsByCondition(condition string, pars []interf
 
 // BaseFromCcfIndex CCF化纤信息
 type BaseFromCcfIndex struct {
-	BaseFromCcfIndexId int       `orm:"column(base_from_ccf_index_id);pk"`
+	BaseFromCcfIndexId int       `orm:"column(base_from_ccf_index_id);pk" gorm:"primaryKey"`
 	ClassifyId         int       `description:"分类ID"`
 	IndexCode          string    `description:"指标编码"`
 	IndexName          string    `description:"指标名称"`
@@ -679,7 +679,7 @@ func (m *BaseFromCcfIndex) GetItemsByCondition(condition string, pars []interfac
 
 // BaseFromUsdaFasIndex 美国农业部
 type BaseFromUsdaFasIndex struct {
-	BaseFromUsdaFasIndexId int       `orm:"column(base_from_usda_fas_index_id);pk"`
+	BaseFromUsdaFasIndexId int       `orm:"column(base_from_usda_fas_index_id);pk" gorm:"primaryKey"`
 	ClassifyId             int       `description:"分类ID"`
 	IndexCode              string    `description:"指标编码"`
 	IndexName              string    `description:"指标名称"`
@@ -752,7 +752,7 @@ func (m *BaseFromUsdaFasIndex) GetItemsByCondition(condition string, pars []inte
 
 // BaseFromMysteelChemicalIndex 上海钢联
 type BaseFromMysteelChemicalIndex struct {
-	BaseFromMysteelChemicalIndexId    int       `orm:"column(base_from_mysteel_chemical_index_id);pk"`
+	BaseFromMysteelChemicalIndexId    int       `orm:"column(base_from_mysteel_chemical_index_id);pk" gorm:"primaryKey"`
 	BaseFromMysteelChemicalClassifyId int       `description:"分类ID"`
 	IndexCode                         string    `description:"指标编码"`
 	IndexName                         string    `description:"指标名称"`
@@ -825,7 +825,7 @@ func (m *BaseFromMysteelChemicalIndex) GetItemsByCondition(condition string, par
 
 // BaseFromSmmIndex 有色原始数据库
 type BaseFromSmmIndex struct {
-	BaseFromSmmIndexId int       `orm:"column(base_from_smm_index_id);pk"`
+	BaseFromSmmIndexId int       `orm:"column(base_from_smm_index_id);pk" gorm:"primaryKey"`
 	ClassifyId         int       `description:"分类ID"`
 	IndexCode          string    `description:"指标编码"`
 	IndexName          string    `description:"指标名称"`
@@ -898,7 +898,7 @@ func (m *BaseFromSmmIndex) GetItemsByCondition(condition string, pars []interfac
 
 // BaseFromBaiinfoIndex 百川盈孚
 type BaseFromBaiinfoIndex struct {
-	BaseFromBaiinfoIndexId int       `orm:"column(base_from_baiinfo_index_id);pk"`
+	BaseFromBaiinfoIndexId int       `orm:"column(base_from_baiinfo_index_id);pk" gorm:"primaryKey"`
 	ClassifyId             int       `description:"分类ID"`
 	IndexCode              string    `description:"指标编码"`
 	IndexName              string    `description:"指标名称"`
@@ -971,7 +971,7 @@ func (m *BaseFromBaiinfoIndex) GetItemsByCondition(condition string, pars []inte
 
 // BaseFromSciIndex 卓创数据(红桃3)
 type BaseFromSciIndex struct {
-	BaseFromSciIndexId int       `orm:"column(base_from_sci_index_id);pk"`
+	BaseFromSciIndexId int       `orm:"column(base_from_sci_index_id);pk" gorm:"primaryKey"`
 	ClassifyId         int       `description:"分类ID"`
 	IndexCode          string    `description:"指标编码"`
 	IndexName          string    `description:"指标名称"`
@@ -1044,7 +1044,7 @@ func (m *BaseFromSciIndex) GetItemsByCondition(condition string, pars []interfac
 
 // BaseFromCoalmineMapping 中国煤炭市场网
 type BaseFromCoalmineMapping struct {
-	BaseFromCoalmineMappingId int       `orm:"column(base_from_coalmine_mapping_id);pk"`
+	BaseFromCoalmineMappingId int       `orm:"column(base_from_coalmine_mapping_id);pk" gorm:"primaryKey"`
 	ClassifyId                int       `description:"分类ID"`
 	IndexCode                 string    `description:"指标编码"`
 	IndexName                 string    `description:"指标名称"`
@@ -1117,7 +1117,7 @@ func (m *BaseFromCoalmineMapping) GetItemsByCondition(condition string, pars []i
 
 // BaseFromEiaSteoIndex EIA STEO报告
 type BaseFromEiaSteoIndex struct {
-	BaseFromEiaSteoIndexId    int       `orm:"column(base_from_eia_steo_index_id);pk"`
+	BaseFromEiaSteoIndexId    int       `orm:"column(base_from_eia_steo_index_id);pk" gorm:"primaryKey"`
 	BaseFromEiaSteoClassifyId int       `description:"分类ID"`
 	IndexCode                 string    `description:"指标编码"`
 	IndexName                 string    `description:"指标名称"`
@@ -1190,7 +1190,7 @@ func (m *BaseFromEiaSteoIndex) GetItemsByCondition(condition string, pars []inte
 
 // BaseFromIcpiIndex ICPI消费价格指数
 //type BaseFromIcpiIndex struct {
-//	BaseFromIcpiIndexId    int       `orm:"column(base_from_icpi_index_id);pk"`
+//	BaseFromIcpiIndexId    int       `orm:"column(base_from_icpi_index_id);pk" gorm:"primaryKey"`
 //	BaseFromIcpiClassifyId int       `description:"分类ID"`
 //	IndexCode              string    `description:"指标编码"`
 //	IndexName              string    `description:"指标名称"`
@@ -1263,7 +1263,7 @@ func (m *BaseFromIcpiIndex) GetItemsByCondition(condition string, pars []interfa
 
 // BaseFromYongyiIndex 涌益咨询
 type BaseFromYongyiIndex struct {
-	YongyiIndexId int       `orm:"column(yongyi_index_id);pk"`
+	YongyiIndexId int       `orm:"column(yongyi_index_id);pk" gorm:"primaryKey"`
 	ClassifyId    int       `description:"分类ID"`
 	IndexCode     string    `description:"指标编码"`
 	IndexName     string    `description:"指标名称"`
@@ -1336,7 +1336,7 @@ func (m *BaseFromYongyiIndex) GetItemsByCondition(condition string, pars []inter
 
 // BaseFromFenweiIndex 汾渭数据
 type BaseFromFenweiIndex struct {
-	FenweiIndexId int       `orm:"column(fenwei_index_id);pk"`
+	FenweiIndexId int       `orm:"column(fenwei_index_id);pk" gorm:"primaryKey"`
 	ClassifyId    int       `description:"分类ID"`
 	IndexCode     string    `description:"指标编码"`
 	IndexName     string    `description:"指标名称"`
@@ -1409,7 +1409,7 @@ func (m *BaseFromFenweiIndex) GetItemsByCondition(condition string, pars []inter
 
 // BaseFromSci99Index 卓创资讯
 //type BaseFromSci99Index struct {
-//	BaseFromSciIndexId int       `orm:"column(base_from_sci_index_id);pk"`
+//	BaseFromSciIndexId int       `orm:"column(base_from_sci_index_id);pk" gorm:"primaryKey"`
 //	ClassifyId         int       `description:"分类ID"`
 //	IndexCode          string    `description:"指标编码"`
 //	IndexName          string    `description:"指标名称"`
@@ -1482,7 +1482,7 @@ func (m *BaseFromSci99Index) GetItemsByCondition(condition string, pars []interf
 
 // BaseFromGlIndex 钢联原始指标库
 type BaseFromGlIndex struct {
-	PrimaryId   int       `orm:"column(ID);pk"`
+	PrimaryId   int       `orm:"column(ID);pk" gorm:"primaryKey"`
 	IndexCode   string    `orm:"column(INDEX_CODE)" description:"指标编码"`
 	IndexName   string    `orm:"column(INDEX_NAME)" description:"指标名称"`
 	Unit        string    `orm:"column(UNIT_NAME)" description:"单位"`
@@ -1627,7 +1627,7 @@ func (m *BaseFromManualEdb) GetItemsByCondition(condition string, pars []interfa
 
 // BaseFromBusinessIndex 自有数据
 type BaseFromBusinessIndex struct {
-	BaseFromBusinessIndexId int `orm:"column(base_from_business_index_id);pk"`
+	BaseFromBusinessIndexId int `orm:"column(base_from_business_index_id);pk" gorm:"primaryKey"`
 	//ClassifyId              int       `description:"分类ID"`
 	IndexCode   string    `description:"指标编码"`
 	IndexName   string    `description:"指标名称"`
@@ -1700,7 +1700,7 @@ func (m *BaseFromBusinessIndex) GetItemsByCondition(condition string, pars []int
 
 // BaseFromBloombergIndex Bloomberg
 type BaseFromBloombergIndex struct {
-	BaseFromBloombergIndexId int `orm:"column(base_from_bloomberg_index_id);pk"`
+	BaseFromBloombergIndexId int `orm:"column(base_from_bloomberg_index_id);pk" gorm:"primaryKey"`
 	//ClassifyId              int       `description:"分类ID"`
 	IndexCode   string    `description:"指标编码"`
 	IndexName   string    `description:"指标名称"`
@@ -1773,7 +1773,7 @@ func (m *BaseFromBloombergIndex) GetItemsByCondition(condition string, pars []in
 
 // BaseFromMtjhMapping 煤炭江湖
 type BaseFromMtjhMapping struct {
-	BaseFromMtjhMappingId int `orm:"column(base_from_mtjh_mapping_id);pk"`
+	BaseFromMtjhMappingId int `orm:"column(base_from_mtjh_mapping_id);pk" gorm:"primaryKey"`
 	//ClassifyId            int       `description:"分类ID"`
 	IndexCode   string    `description:"指标编码"`
 	IndexName   string    `description:"指标名称"`
@@ -2012,7 +2012,7 @@ func GetBaseIndexDataMinMax(source, subSource int, indexCode string) (item *Base
 
 // BaseFromMtjhIndex 煤炭江湖数据表
 type BaseFromMtjhIndex struct {
-	BaseFromMtjhIndexId int       `orm:"column(base_from_mtjh_index_id);pk"`
+	BaseFromMtjhIndexId int       `orm:"column(base_from_mtjh_index_id);pk" gorm:"primaryKey"`
 	IndexCode           string    `description:"指标编码"`
 	IndexName           string    `description:"指标名称"`
 	DealValue           float64   `description:"成交量"`

+ 5 - 5
models/data_source/guagnzhouqihuo.go

@@ -6,7 +6,7 @@ import (
 )
 
 type BaseFromTradeGuangzhouClassify struct {
-	BaseFromTradeGuangzhouClassifyId int       `orm:"column(base_from_trade_guangzhou_classify_id);pk"`
+	BaseFromTradeGuangzhouClassifyId int       `orm:"column(base_from_trade_guangzhou_classify_id);pk" gorm:"primaryKey"`
 	ClassifyName                     string    `description:"分类名称"`
 	ClassifyCode                     string    `description:"分类编码"`
 	ParentId                         int       `description:"分类父级id"`
@@ -15,7 +15,7 @@ type BaseFromTradeGuangzhouClassify struct {
 }
 
 type BaseFromTradeGuangzhouIndex struct {
-	BaseFromTradeGuangzhouIndexId    int       `orm:"column(base_from_trade_guangzhou_index_id);pk"`
+	BaseFromTradeGuangzhouIndexId    int       `orm:"column(base_from_trade_guangzhou_index_id);pk" gorm:"primaryKey"`
 	BaseFromTradeGuangzhouClassifyId int       `description:"分类id"`
 	IndexCode                        string    `description:"指标编码"`
 	IndexName                        string    `description:"指标名称"`
@@ -28,7 +28,7 @@ type BaseFromTradeGuangzhouIndex struct {
 }
 
 type BaseFromTradeGuangzhouData struct {
-	BaseFromTradeGuangzhouDataId  int       `orm:"column(base_from_trade_guangzhou_data_id);pk"`
+	BaseFromTradeGuangzhouDataId  int       `orm:"column(base_from_trade_guangzhou_data_id);pk" gorm:"primaryKey"`
 	BaseFromTradeGuangzhouIndexId int       `description:"指标id"`
 	IndexCode                     string    `description:"指标编码"`
 	DataTime                      string    `description:"数据日期"`
@@ -39,7 +39,7 @@ type BaseFromTradeGuangzhouData struct {
 }
 
 type BaseFromTradeGuangzhouClassifyView struct {
-	BaseFromTradeGuangzhouClassifyId int    `orm:"column(base_from_trade_guangzhou_classify_id);pk"`
+	BaseFromTradeGuangzhouClassifyId int    `orm:"column(base_from_trade_guangzhou_classify_id);pk" gorm:"primaryKey"`
 	ClassifyName                     string `description:"分类名称"`
 	ClassifyCode                     string `description:"分类编码"`
 	ParentId                         int    `description:"分类父级id"`
@@ -47,7 +47,7 @@ type BaseFromTradeGuangzhouClassifyView struct {
 }
 
 type BaseFromTradeGuangzhouContract struct {
-	BaseFromTradeGuangzhouContractId int    `orm:"column(base_from_trade_guangzhou_contract_id);pk"`
+	BaseFromTradeGuangzhouContractId int    `orm:"column(base_from_trade_guangzhou_contract_id);pk" gorm:"primaryKey"`
 	BaseFromTradeGuangzhouClassifyId int    `description:"分类id"`
 	ClassifyCode                     string `description:"分类编码"`
 	Contract                         string `description:"合约编码"`

+ 4 - 4
models/data_source/icpi.go

@@ -7,7 +7,7 @@ import (
 )
 
 type BaseFromIcpiIndex struct {
-	BaseFromIcpiIndexId    int       `orm:"column(base_from_icpi_index_id);pk"`
+	BaseFromIcpiIndexId    int       `orm:"column(base_from_icpi_index_id);pk" gorm:"primaryKey"`
 	BaseFromIcpiClassifyId int       `description:"分类id"`
 	IndexCode              string    `description:"指标编码"`
 	IndexName              string    `description:"指标名称"`
@@ -21,7 +21,7 @@ type BaseFromIcpiIndex struct {
 }
 
 type BaseFromIcpiData struct {
-	BaseFromIcpiDataId  int       `orm:"column(base_from_icpi_data_id);pk"`
+	BaseFromIcpiDataId  int       `orm:"column(base_from_icpi_data_id);pk" gorm:"primaryKey"`
 	BaseFromIcpiIndexId int       `description:"指标id"`
 	IndexCode           string    `description:"指标编码"`
 	DataTime            string    `description:"日期"`
@@ -31,7 +31,7 @@ type BaseFromIcpiData struct {
 }
 
 type BaseFromIcpiClassify struct {
-	BaseFromIcpiClassifyId int    `orm:"column(base_from_icpi_classify_id);pk"`
+	BaseFromIcpiClassifyId int    `orm:"column(base_from_icpi_classify_id);pk" gorm:"primaryKey"`
 	ClassifyName           string `description:"分类名称"`
 	ClassifyNameEn         string `description:"英文名称"`
 	ParentId               int    `description:"上级id"`
@@ -47,7 +47,7 @@ func (obj *BaseFromIcpiIndex) GetBaseFromIcpiClassifyAll() (list []*BaseFromIcpi
 }
 
 type BaseFromIcpiDataView struct {
-	BaseFromIcpiDataId  int       `orm:"column(base_from_icpi_data_id);pk"`
+	BaseFromIcpiDataId  int       `orm:"column(base_from_icpi_data_id);pk" gorm:"primaryKey"`
 	BaseFromIcpiIndexId int       `description:"指标id"`
 	IndexCode           string    `description:"指标编码"`
 	DataTime            string    `description:"日期"`

+ 2 - 2
models/data_source/longzhong.go

@@ -36,7 +36,7 @@ func GetLongzhongDataMaxCount(classifyId int) (count int, err error) {
 }
 
 type Longzhongdata struct {
-	LongzhongdataId int `orm:"column(longzhongdata_id);pk"`
+	LongzhongdataId int `orm:"column(longzhongdata_id);pk" gorm:"primaryKey"`
 	LongzhonginfoId int
 	TradeCode       string
 	Dt              string
@@ -123,7 +123,7 @@ func GetExportLzSurveyDataByBreedIds(breedIds []string) (items []*LongzhongSurve
 }
 
 type LongzhongSurveyData struct {
-	SurveyDataId         int `orm:"column(survey_data_id);pk"`
+	SurveyDataId         int `orm:"column(survey_data_id);pk" gorm:"primaryKey"`
 	SurveyProductId      int
 	ProjectQuotaId       int64
 	BreedId              string

+ 1 - 1
models/data_stat/edb_info_delete_log.go

@@ -7,7 +7,7 @@ import (
 
 // EdbInfoDeleteLog 指标删除日志表
 type EdbInfoDeleteLog struct {
-	Id                 uint64  `orm:"column(id);pk"`
+	Id                 uint64  `orm:"column(id);pk" gorm:"primaryKey"`
 	EdbInfoId          int     `description:"指标ID"`
 	EdbInfoType        int     `description:"指标类型,0:普通指标,1:预测指标"`
 	SourceName         string  `description:"来源名称"`

+ 1 - 1
models/data_stat/edb_info_stat_column.go

@@ -4,7 +4,7 @@ import "github.com/beego/beego/v2/client/orm"
 
 // EdbInfoStatColumn 数据源统计表自定义列
 type EdbInfoStatColumn struct {
-	Id           int    `orm:"column(id);pk" description:"自增id"`
+	Id           int    `orm:"column(id);pk" gorm:"primaryKey" description:"自增id"`
 	ColumnName   string `description:"字段名称"`
 	ColumnKey    string `description:"字段"`
 	CreateTime   string `description:" 创建时间"`

+ 2 - 2
models/data_stat/edb_info_update_log.go

@@ -8,7 +8,7 @@ import (
 
 // EdbInfoUpdateLog 指标更新/刷新日志列表
 type EdbInfoUpdateLog struct {
-	Id                     uint64    `orm:"column(id);pk"`
+	Id                     uint64    `orm:"column(id);pk" gorm:"primaryKey"`
 	EdbInfoId              int       `description:"指标ID"`
 	SourceName             string    `description:"来源名称"`
 	Source                 int       `description:"来源id"`
@@ -41,7 +41,7 @@ type EdbInfoUpdateLog struct {
 }
 
 type EdbInfoUpdateLogItem struct {
-	Id                    uint64 `orm:"column(id);pk"`
+	Id                    uint64 `orm:"column(id);pk" gorm:"primaryKey"`
 	EdbInfoId             int    `description:"指标ID"`
 	SourceName            string `description:"来源名称"`
 	Source                int    `description:"来源id"`

+ 2 - 2
models/data_stat/edb_info_update_stat.go

@@ -8,7 +8,7 @@ import (
 
 // EdbInfoUpdateStat 指标更新/刷新 汇总表(数据源明细表)
 type EdbInfoUpdateStat struct {
-	Id                     uint64    `orm:"column(id);pk"`
+	Id                     uint64    `orm:"column(id);pk" gorm:"primaryKey"`
 	EdbInfoId              int       `description:"指标ID"`
 	SourceName             string    `description:"来源名称"`
 	Source                 int       `description:"来源id"`
@@ -42,7 +42,7 @@ type EdbInfoUpdateStat struct {
 }
 
 type EdbInfoUpdateStatItem struct {
-	Id                     uint64  `orm:"column(id);pk"`
+	Id                     uint64  `orm:"column(id);pk" gorm:"primaryKey"`
 	EdbInfoId              int     `description:"指标ID"`
 	SourceName             string  `description:"来源名称"`
 	Source                 int     `description:"来源id"`

+ 2 - 2
models/data_stat/edb_source_stat.go

@@ -8,7 +8,7 @@ import (
 
 // EdbSourceStat 数据源统计表
 type EdbSourceStat struct {
-	Id                uint64    `orm:"column(id);pk"`
+	Id                uint64    `orm:"column(id);pk" gorm:"primaryKey"`
 	SourceName        string    `description:"来源名称"`
 	Source            int       `description:"来源id"`
 	TerminalCode      string    `description:"终端编码,用于配置在机器上"`
@@ -26,7 +26,7 @@ type EdbSourceStat struct {
 }
 
 type EdbInfoSourceStatItem struct {
-	Id                uint64 `orm:"column(id);pk"`
+	Id                uint64 `orm:"column(id);pk" gorm:"primaryKey"`
 	SourceName        string `description:"来源名称"`
 	Source            int    `description:"来源id"`
 	TerminalCode      string `description:"终端编码,用于配置在机器上"`

+ 2 - 2
models/document_manage_model/outside_report.go

@@ -7,7 +7,7 @@ import (
 )
 
 type OutsideReport struct {
-	OutsideReportId  int    `orm:"column(outside_report_id);pk" description:"外部报告ID"`
+	OutsideReportId  int    `orm:"column(outside_report_id);pk" gorm:"primaryKey" description:"外部报告ID"`
 	Source           int    `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"`
 	Title            string `orm:"column(title)" description:"报告标题"`
 	Abstract         string `orm:"column(abstract)" description:"摘要"`
@@ -29,7 +29,7 @@ type OutsideReportPage struct {
 }
 
 type OutsideReportBO struct {
-	OutsideReportId int    `orm:"column(outside_report_id);pk" description:"外部报告ID"`
+	OutsideReportId int    `orm:"column(outside_report_id);pk" gorm:"primaryKey" description:"外部报告ID"`
 	Source          int    `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"`
 	Title           string `orm:"column(title)" description:"报告标题"`
 	Abstract        string `orm:"column(abstract)" description:"摘要"`

+ 1 - 1
models/document_manage_model/outside_report_attachment.go

@@ -6,7 +6,7 @@ import (
 )
 
 type OutsideReportAttachment struct {
-	OutsideReportAttachmentId int    `orm:"column(outside_report_attachment_id);pk" description:"外部报告附件ID"`
+	OutsideReportAttachmentId int    `orm:"column(outside_report_attachment_id);pk" gorm:"primaryKey" description:"外部报告附件ID"`
 	OutsideReportId           int    `orm:"column(outside_report_id)" description:"报告id"`
 	Title                     string `orm:"column(title)" description:"附件名称"`
 	Url                       string `orm:"column(url)" description:"附件地址"`

+ 1 - 1
models/edb_monitor/edb_monitor.go

@@ -7,7 +7,7 @@ import (
 )
 
 type EdbMonitorInfo struct {
-	EdbMonitorId         int       `orm:"column(edb_monitor_id);pk"`
+	EdbMonitorId         int       `orm:"column(edb_monitor_id);pk" gorm:"primaryKey"`
 	EdbMonitorClassifyId int       `description:"预警分类id"`
 	EdbMonitorName       string    `description:"预警名称"`
 	EdbInfoId            int       `description:"指标id"`

+ 1 - 1
models/edb_monitor/edb_monitor_classify.go

@@ -9,7 +9,7 @@ import (
 )
 
 type EdbMonitorClassify struct {
-	ClassifyId   int       `orm:"column(classify_id);pk"`
+	ClassifyId   int       `orm:"column(classify_id);pk" gorm:"primaryKey"`
 	ClassifyName string    `description:"分类名称"`
 	Level        int       `description:"分类层级"`
 	ParentId     int       `description:"父分类ID"`

+ 1 - 1
models/edb_monitor/edb_monitor_message.go

@@ -9,7 +9,7 @@ import (
 )
 
 type EdbMonitorMessage struct {
-	EdbMonitorMessageId int       `orm:"column(edb_monitor_message_id);pk"`
+	EdbMonitorMessageId int       `orm:"column(edb_monitor_message_id);pk" gorm:"primaryKey"`
 	EdbInfoId           int       `description:"指标id"`
 	EdbInfoType         int       `description:"指标类型: 0-普通指标;1-预测指标"`
 	EdbUniqueCode       string    `description:"指标唯一标识"`

+ 1 - 1
models/edb_monitor/response/edb_monitor.go

@@ -5,7 +5,7 @@ import (
 )
 
 type EdbMonitorInfoItem struct {
-	EdbMonitorId           int     `orm:"column(edb_monitor_id);pk"`
+	EdbMonitorId           int     `orm:"column(edb_monitor_id);pk" gorm:"primaryKey"`
 	EdbMonitorClassifyId   int     `description:"预警分类id"`
 	EdbMonitorClassifyName string  `description:"预警分类名称"`
 	EdbMonitorName         string  `description:"预警名称"`

+ 1 - 1
models/eta_trial/questionnaire_fill_record.go

@@ -8,7 +8,7 @@ import (
 
 // QuestionnaireFillRecord 问卷填写记录表
 type QuestionnaireFillRecord struct {
-	RecordId   int    `orm:"column(fill_record_id);pk" description:"记录id"`
+	RecordId   int    `orm:"column(fill_record_id);pk" gorm:"primaryKey" description:"记录id"`
 	Mobile     string `description:"手机"`
 	IsFill     int    `description:"0未点过 1稍后再填 2已填写"`
 	CreateTime time.Time

+ 1 - 1
models/eta_trial/request.go

@@ -15,7 +15,7 @@ type EtaTrialQuestionnaireResp struct {
 
 // EtaTrialQuestionnaireRespItem 问卷调查信息
 type EtaTrialQuestionnaireRespItem struct {
-	QuestionnaireId int      `orm:"column(questionnaire_id);pk" description:"问卷题目id"`
+	QuestionnaireId int      `orm:"column(questionnaire_id);pk" gorm:"primaryKey" description:"问卷题目id"`
 	Question        string   `description:"题目"`
 	Type            int      `description:"1单选 2多选 3简答题"`
 	Sort            int      `description:"排序"`

+ 1 - 1
models/fe_calendar/fe_calendar_matter.go

@@ -16,7 +16,7 @@ const (
 
 // FeCalendarMatter 外汇日历-事项表
 type FeCalendarMatter struct {
-	FeCalendarMatterId  int       `orm:"column(fe_calendar_matter_id);pk" description:"事项ID"`
+	FeCalendarMatterId  int       `orm:"column(fe_calendar_matter_id);pk" gorm:"primaryKey" description:"事项ID"`
 	ChartPermissionId   int       `description:"品种ID"`
 	ChartPermissionName string    `description:"品种名称"`
 	MatterMonth         string    `description:"事项年月:格式2006-01"`

+ 1 - 1
models/material/material.go

@@ -8,7 +8,7 @@ import (
 )
 
 type Material struct {
-	MaterialId      int       `orm:"column(material_id);pk" description:"素材id"`
+	MaterialId      int       `orm:"column(material_id);pk" gorm:"primaryKey" description:"素材id"`
 	MaterialName    string    `description:"素材名称"`
 	MaterialNameEn  string    `description:"英文素材名称"`
 	ImgUrl          string    `description:"素材图片地址"`

+ 2 - 2
models/material/material_classify.go

@@ -8,7 +8,7 @@ import (
 )
 
 type MaterialClassify struct {
-	ClassifyId      int       `orm:"column(classify_id);pk"`
+	ClassifyId      int       `orm:"column(classify_id);pk" gorm:"primaryKey"`
 	ClassifyName    string    `description:"分类名称"`
 	ClassifyNameEn  string    `description:"英文分类名称"`
 	ParentId        int       `description:"父级id"`
@@ -44,7 +44,7 @@ func GetMaterialClassifyAll() (items []*MaterialClassifyItems, err error) {
 }
 
 type MaterialClassifyItems struct {
-	ClassifyId     int       `orm:"column(classify_id);pk"`
+	ClassifyId     int       `orm:"column(classify_id);pk" gorm:"primaryKey"`
 	ClassifyName   string    `description:"分类名称"`
 	ClassifyNameEn string    `description:"英文分类名称"`
 	ParentId       int       `description:"父级id"`

+ 5 - 5
models/ppt_english/ppt_english.go

@@ -10,7 +10,7 @@ import (
 
 // PptEnglish 表
 type PptEnglish struct {
-	PptId         int       `orm:"column(ppt_id);pk;auto" description:"ppt的Id"`
+	PptId         int       `orm:"column(ppt_id);pk" gorm:"primaryKey" description:"ppt的Id"`
 	TemplateType  int       `description:"模版类型"`
 	BackgroundImg string    `description:"背景图片"`
 	Title         string    `description:"标题"`
@@ -32,7 +32,7 @@ type PptEnglish struct {
 }
 
 type PptEnglishItem struct {
-	PptId         int       `orm:"column(ppt_id);pk" description:"ppt的Id"`
+	PptId         int       `orm:"column(ppt_id);pk" gorm:"primaryKey" description:"ppt的Id"`
 	TemplateType  int       `description:"模版类型"`
 	BackgroundImg string    `description:"背景图片"`
 	Title         string    `description:"标题"`
@@ -201,7 +201,7 @@ func GetPptEnglishByTitle(title string) (item *PptEnglish, err error) {
 }
 
 type PptPages struct {
-	PptPagesId int       `orm:"column(ppt_pages_id);pk" description:"报告章节Id"`
+	PptPagesId int       `orm:"column(ppt_pages_id);pk" gorm:"primaryKey" description:"报告章节Id"`
 	PptId      int64     `description:"ppt_id"`
 	Title      string    `description:"标题"`
 	ImgUrl     string    `description:"图片路径"`
@@ -235,7 +235,7 @@ func EditPptEnglishPath(pptId int, pptxPath string) (err error) {
 
 // AddPptEnglishPublishRecord 发布记录表
 type PptEnglishPublishRecord struct {
-	Id         int `orm:"column(id);pk"`
+	Id         int `orm:"column(id);pk" gorm:"primaryKey"`
 	PptId      int
 	PptUrl     string
 	CreateTime time.Time
@@ -250,7 +250,7 @@ func AddPptEnglishPublishRecord(item *PptEnglishPublishRecord) (lastId int64, er
 
 // PptEnglishSaveLog ppt记录表
 type PptEnglishSaveLog struct {
-	Id            int       `orm:"column(id);pk" description:"自增Id"`
+	Id            int       `orm:"column(id);pk" gorm:"primaryKey" description:"自增Id"`
 	PptId         int       `orm:"column(ppt_id)" description:"ppt的Id"`
 	TemplateType  int       `description:"模版类型"`
 	BackgroundImg string    `description:"背景图片"`

+ 1 - 1
models/ppt_english/ppt_english_grant.go

@@ -8,7 +8,7 @@ import (
 
 // PptEnglishGrant Ppt授权表
 type PptEnglishGrant struct {
-	GrantId      int64     `orm:"column(grant_id);pk;auto" description:"自增序号"`
+	GrantId      int64     `orm:"column(grant_id);pk" gorm:"primaryKey" description:"自增序号"`
 	PptId        int64     `description:"ppt ID"`
 	DepartmentId int64     `description:"授权部门id"`
 	GrantAdminId int64     `description:"授权部门id"`

+ 1 - 1
models/ppt_english/ppt_english_group.go

@@ -7,7 +7,7 @@ import (
 )
 
 type PptEnglishGroup struct {
-	GroupId    int64     `orm:"column(group_id);pk;auto" description:"ppt目录ID"`
+	GroupId    int64     `orm:"column(group_id);pk" gorm:"primaryKey" description:"ppt目录ID"`
 	GroupName  string    `description:"目录名称"`
 	AdminId    int       `description:"目录创建者账号ID"`
 	IsShare    int8      `description:"是否共享,0私有,1共享"`

+ 1 - 1
models/ppt_english/ppt_english_group_mapping.go

@@ -8,7 +8,7 @@ import (
 
 // ppt目录和ppt 映射表
 type PptEnglishGroupMapping struct {
-	GroupPptId      int64     `orm:"column(group_ppt_id);pk;auto" description:"自增序号"`
+	GroupPptId      int64     `orm:"column(group_ppt_id);pk" gorm:"primaryKey" description:"自增序号"`
 	GroupId         int64     `description:"ppt目录ID"`
 	PptSort         int64     `description:"Ppt的排序"`
 	PptId           int64     `description:"ppt ID"`

+ 1 - 1
models/ppt_english/report_ppt_english_img.go

@@ -7,7 +7,7 @@ import (
 
 // ReportPptEnglishImg Ppt转报告的图片记录表
 type ReportPptEnglishImg struct {
-	ReportPptImgId  int       `orm:"column(report_ppt_img_id);pk;auto" description:"自增id"`
+	ReportPptImgId  int       `orm:"column(report_ppt_img_id);pk" gorm:"primaryKey" description:"自增id"`
 	PptId           int       `description:"ppt的id"`
 	ReportId        int       `description:"关联的报告ID"`
 	ReportChapterId int       `description:"关联的报告章节ID"`

+ 1 - 1
models/report_approve/report_approve.go

@@ -12,7 +12,7 @@ import (
 
 // ReportApprove 报告审批表
 type ReportApprove struct {
-	ReportApproveId  int       `orm:"column(report_approve_id);pk" description:"审批ID"`
+	ReportApproveId  int       `orm:"column(report_approve_id);pk" gorm:"primaryKey" description:"审批ID"`
 	ReportType       int       `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
 	ReportId         int       `description:"报告ID"`
 	ReportTitle      string    `description:"报告标题"`

+ 1 - 1
models/report_approve/report_approve_flow.go

@@ -11,7 +11,7 @@ import (
 
 // ReportApproveFlow 报告审批流表
 type ReportApproveFlow struct {
-	ReportApproveFlowId int       `orm:"column(report_approve_flow_id);pk" description:"审批流ID"`
+	ReportApproveFlowId int       `orm:"column(report_approve_flow_id);pk" gorm:"primaryKey" description:"审批流ID"`
 	FlowName            string    `description:"审批流名称"`
 	ReportType          int       `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
 	ClassifyFirstId     int       `description:"一级分类ID"`

+ 1 - 1
models/report_approve/report_approve_message.go

@@ -11,7 +11,7 @@ import (
 
 // ReportApproveMessage 报告审批消息表
 type ReportApproveMessage struct {
-	Id              int       `orm:"column(id);pk"`
+	Id              int       `orm:"column(id);pk" gorm:"primaryKey"`
 	SendUserId      int       `description:"发送人ID"`
 	ReceiveUserId   int       `description:"接收者ID"`
 	Content         string    `description:"消息内容"`

+ 1 - 1
models/report_approve/report_approve_node.go

@@ -11,7 +11,7 @@ import (
 
 // ReportApproveNode 报告审批节点表
 type ReportApproveNode struct {
-	ReportApproveNodeId int       `orm:"column(report_approve_node_id);pk" description:"报告审批节点ID"`
+	ReportApproveNodeId int       `orm:"column(report_approve_node_id);pk" gorm:"primaryKey" description:"报告审批节点ID"`
 	ReportApproveFlowId int       `description:"报告审批流ID"`
 	PrevNodeId          int       `description:"上一个节点ID(0为开始节点)"`
 	NextNodeId          int       `description:"下一个节点ID(0为结束节点)"`

+ 1 - 1
models/report_approve/report_approve_record.go

@@ -10,7 +10,7 @@ import (
 
 // ReportApproveRecord 报告审批记录表
 type ReportApproveRecord struct {
-	ReportApproveRecordId int       `orm:"column(report_approve_record_id);pk" description:"审批记录ID"`
+	ReportApproveRecordId int       `orm:"column(report_approve_record_id);pk" gorm:"primaryKey" description:"审批记录ID"`
 	ReportApproveId       int       `description:"审批ID"`
 	State                 int       `description:"审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回"`
 	NodeId                int       `description:"节点ID"`

+ 2 - 2
models/residual_analysis_model/calculate_residual_analysis_config.go

@@ -6,7 +6,7 @@ import (
 )
 
 type CalculateResidualAnalysisConfig struct {
-	CalculateResidualAnalysisConfigId int       `orm:"column(calculate_residual_analysis_config_id);pk;auto" description:"自增id"`
+	CalculateResidualAnalysisConfigId int       `orm:"column(calculate_residual_analysis_config_id);pk" gorm:"primaryKey" description:"自增id"`
 	Config                            string    `orm:"column(config)" description:"计算参数配置"`
 	SysUserId                         int       `orm:"column(sys_user_id)" description:"操作人id"`
 	CreateTime                        time.Time `orm:"column(create_time)" description:"创建时间"`
@@ -164,7 +164,7 @@ type ResidualAnalysisConfigVo struct {
 }
 
 type DetailEdbInfoList struct {
-	EdbInfoId   int    `orm:"column(edb_info_id);pk"`
+	EdbInfoId   int    `orm:"column(edb_info_id);pk" gorm:"primaryKey"`
 	EdbInfoType int    `description:"指标类型,0:普通指标,1:预测指标"`
 	IndexType   int    `orm:"column(index_type)" description:"指标类型:1-映射指标 2-残差指标 3-因变量指标 4-自变量指标"`
 	SourceName  string `description:"来源名称"`

+ 1 - 1
models/residual_analysis_model/calculate_residual_analysis_config_mapping.go

@@ -6,7 +6,7 @@ import (
 )
 
 type CalculateResidualAnalysisConfigMapping struct {
-	CalculateResidualAnalysisConfigMappingId int       `orm:"column(calculate_residual_analysis_config_mapping_id);pk;auto" description:"自增id"`
+	CalculateResidualAnalysisConfigMappingId int       `orm:"column(calculate_residual_analysis_config_mapping_id);pk" gorm:"primaryKey" description:"自增id"`
 	CalculateResidualAnalysisConfigId        int       `orm:"column(calculate_residual_analysis_config_id)" description:"残差分析配置id"`
 	EdbInfoId                                int64     `orm:"column(edb_info_id)" description:"指标id"`
 	ResidualType                             int       `orm:"column(residual_type)" description:"残差类型: 1-映射残差 2-拟合残差"`

+ 1 - 1
models/residual_analysis_model/edb_data_residual_analysis.go

@@ -6,7 +6,7 @@ import (
 )
 
 type edbDataResidualAnalysis struct {
-	EdbDataId     int       `orm:"column(edb_data_id);pk;auto" description:"自增id"`
+	EdbDataId     int       `orm:"column(edb_data_id);pk" gorm:"primaryKey" description:"自增id"`
 	EdbInfoId     int       `orm:"column(edb_info_id)" description:"指标id"`
 	EdbCode       string    `orm:"column(edb_code)" description:"指标编码"`
 	DataTime      string    `orm:"column(data_time)" description:"数据日期"`

+ 2 - 2
models/sandbox/sandbox.go

@@ -11,7 +11,7 @@ import (
 
 // Sandbox 沙盘推演主表
 //type Sandbox struct {
-//	SandboxId           int       `orm:"column(sandbox_id);pk" description:"沙盘id"`
+//	SandboxId           int       `orm:"column(sandbox_id);pk" gorm:"primaryKey" description:"沙盘id"`
 //	Name                string    `description:"沙盘名称"`
 //	ChartPermissionId   int       `description:"品种id"`
 //	ChartPermissionName string    `description:"品种名称"`
@@ -29,7 +29,7 @@ import (
 //}
 
 type Sandbox struct {
-	SandboxId         int       `orm:"column(sandbox_id);pk" description:"沙盘id"`
+	SandboxId         int       `orm:"column(sandbox_id);pk" gorm:"primaryKey" description:"沙盘id"`
 	Name              string    `description:"沙盘名称"`
 	Code              string    `description:"沙盘code"`
 	Content           string    `description:"沙盘数据"`

+ 2 - 2
models/sandbox/sandbox_classify.go

@@ -8,7 +8,7 @@ import (
 )
 
 type SandboxClassify struct {
-	SandboxClassifyId   int       `orm:"column(sandbox_classify_id);pk"`
+	SandboxClassifyId   int       `orm:"column(sandbox_classify_id);pk" gorm:"primaryKey"`
 	SandboxClassifyName string    `description:"分类名称"`
 	ParentId            int       `description:"父级id"`
 	HasData             int       `description:"是否含有指标数据"`
@@ -52,7 +52,7 @@ func GetSandboxClassifyAllIncludeParent() (items []*SandboxClassifyItems, err er
 }
 
 type SandboxClassifyItems struct {
-	SandboxClassifyId   int       `orm:"column(sandbox_classify_id);pk"`
+	SandboxClassifyId   int       `orm:"column(sandbox_classify_id);pk" gorm:"primaryKey"`
 	SandboxClassifyName string    `description:"分类名称"`
 	ParentId            int       `description:"父级id"`
 	HasData             int       `description:"是否含有指标数据"`

+ 1 - 1
models/sandbox/sandbox_draft.go

@@ -7,7 +7,7 @@ import (
 
 // SandboxDraft 沙盘推演草稿表
 type SandboxDraft struct {
-	SandboxDraftId      int       `orm:"column(sandbox_draft_id);pk" description:"沙盘草稿记录id"`
+	SandboxDraftId      int       `orm:"column(sandbox_draft_id);pk" gorm:"primaryKey" description:"沙盘草稿记录id"`
 	SandboxId           int       `description:"沙盘id"`
 	Name                string    `description:"沙盘名称"`
 	ChartPermissionId   int       `description:"品种id"`

+ 3 - 3
models/sandbox/sandbox_version.go

@@ -1,14 +1,14 @@
 package sandbox
 
 import (
-	"github.com/beego/beego/v2/client/orm"
 	"eta/eta_api/utils"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
 // SandboxVersion 沙盘推演版本表
 type SandboxVersion struct {
-	SandboxVersionId    int       `orm:"column(sandbox_version_id);pk" description:"沙盘版本记录id"`
+	SandboxVersionId    int       `orm:"column(sandbox_version_id);pk" gorm:"primaryKey" description:"沙盘版本记录id"`
 	SandboxId           int       `description:"沙盘id"`
 	Name                string    `description:"沙盘名称"`
 	ChartPermissionId   int       `description:"品种id"`
@@ -57,7 +57,7 @@ func GetLastSandboxVersionBySandbox2VersionId(sandboxId, sandboxVersion int) (sa
 
 // SandboxVersionListItem 沙盘推演版本列表数据
 type SandboxVersionListItem struct {
-	SandboxVersionId    int    `orm:"column(sandbox_version_id);pk" description:"沙盘版本记录id"`
+	SandboxVersionId    int    `orm:"column(sandbox_version_id);pk" gorm:"primaryKey" description:"沙盘版本记录id"`
 	SandboxId           int    `description:"沙盘id"`
 	Name                string `description:"沙盘名称"`
 	ChartPermissionId   int    `description:"品种id"`

+ 1 - 1
models/semantic_analysis/sa_compare.go

@@ -9,7 +9,7 @@ import (
 )
 
 type SaCompare struct {
-	SaCompareId  int       `orm:"column(sa_compare_id);pk" description:"比对ID"`
+	SaCompareId  int       `orm:"column(sa_compare_id);pk" gorm:"primaryKey" description:"比对ID"`
 	ClassifyId   int       `description:"比对分类ID"`
 	ClassifyName string    `description:"比对分类名称"`
 	Title        string    `description:"标题"`

+ 1 - 1
models/semantic_analysis/sa_compare_classify.go

@@ -9,7 +9,7 @@ import (
 )
 
 type SaCompareClassify struct {
-	SaCompareClassifyId int       `orm:"column(sa_compare_classify_id);pk" description:"分类ID"`
+	SaCompareClassifyId int       `orm:"column(sa_compare_classify_id);pk" gorm:"primaryKey" description:"分类ID"`
 	ClassifyName        string    `description:"分类名称"`
 	SysAdminId          int       `description:"创建人ID"`
 	SysAdminName        string    `description:"创建人姓名"`

+ 1 - 1
models/semantic_analysis/sa_compare_doc.go

@@ -7,7 +7,7 @@ import (
 )
 
 type SaCompareDoc struct {
-	SaCompareDocId int `orm:"column(sa_compare_doc_id);pk"`
+	SaCompareDocId int `orm:"column(sa_compare_doc_id);pk" gorm:"primaryKey"`
 	CompareId      int `description:"比对ID"`
 	DocId          int `description:"文档ID"`
 }

+ 1 - 1
models/semantic_analysis/sa_compare_label.go

@@ -8,7 +8,7 @@ import (
 )
 
 type SaCompareLabel struct {
-	SaCompareLabelId int       `orm:"column(sa_compare_label_id);pk" description:"段落标签ID"`
+	SaCompareLabelId int       `orm:"column(sa_compare_label_id);pk" gorm:"primaryKey" description:"段落标签ID"`
 	CompareId        int       `description:"比对ID"`
 	DocId            int       `description:"文档ID"`
 	SectionId        int       `description:"段落ID"`

+ 1 - 1
models/semantic_analysis/sa_compare_search_keyword.go

@@ -9,7 +9,7 @@ import (
 
 // SaCompareSearchKeyword 文档比对搜索关键词表
 type SaCompareSearchKeyword struct {
-	SaCompareSearchKeywordId int       `orm:"column(sa_compare_search_keyword_id);pk"`
+	SaCompareSearchKeywordId int       `orm:"column(sa_compare_search_keyword_id);pk" gorm:"primaryKey"`
 	CompareId                int       `description:"文档比对ID"`
 	Keyword                  string    `description:"关键词"`
 	CreateTime               time.Time `description:"创建时间"`

+ 1 - 1
models/semantic_analysis/sa_doc.go

@@ -10,7 +10,7 @@ import (
 )
 
 type SaDoc struct {
-	SaDocId      int       `orm:"column(sa_doc_id);pk" description:"文档ID"`
+	SaDocId      int       `orm:"column(sa_doc_id);pk" gorm:"primaryKey" description:"文档ID"`
 	ClassifyId   int       `description:"文档分类ID"`
 	ClassifyName string    `description:"分类名称"`
 	Title        string    `description:"标题"`

+ 1 - 1
models/semantic_analysis/sa_doc_classify.go

@@ -9,7 +9,7 @@ import (
 )
 
 type SaDocClassify struct {
-	SaDocClassifyId int       `orm:"column(sa_doc_classify_id);pk" description:"分类ID"`
+	SaDocClassifyId int       `orm:"column(sa_doc_classify_id);pk" gorm:"primaryKey" description:"分类ID"`
 	ClassifyName    string    `description:"分类名称"`
 	CoverImg        string    `description:"封面图"`
 	SysAdminId      int       `description:"创建人ID"`

+ 1 - 1
models/semantic_analysis/sa_doc_section.go

@@ -7,7 +7,7 @@ import (
 )
 
 type SaDocSection struct {
-	SaDocSectionId int    `orm:"column(sa_doc_section_id);pk" description:"段落ID"`
+	SaDocSectionId int    `orm:"column(sa_doc_section_id);pk" gorm:"primaryKey" description:"段落ID"`
 	DocId          int    `description:"文档ID"`
 	Content        string `description:"段落内容"`
 	Sort           int    `description:"排序"`

+ 1 - 1
models/semantic_analysis/sa_label.go

@@ -9,7 +9,7 @@ import (
 )
 
 type SaLabel struct {
-	SaLabelId    int       `orm:"column(sa_label_id);pk" description:"标签ID"`
+	SaLabelId    int       `orm:"column(sa_label_id);pk" gorm:"primaryKey" description:"标签ID"`
 	LabelName    string    `description:"标签名称"`
 	SysAdminId   int       `description:"创建人ID"`
 	SysAdminName string    `description:"创建人名称"`

+ 2 - 3
models/smart_report/smart_report.go

@@ -17,7 +17,7 @@ const (
 
 // SmartReport 智能研报
 type SmartReport struct {
-	SmartReportId       int       `orm:"column(smart_report_id);pk" description:"智能研报ID"`
+	SmartReportId       int       `orm:"column(smart_report_id);pk" gorm:"primaryKey" description:"智能研报ID"`
 	ReportCode          string    `description:"报告唯一编码"`
 	ClassifyIdFirst     int       `description:"一级分类ID"`
 	ClassifyNameFirst   string    `description:"一级分类名称"`
@@ -419,11 +419,10 @@ func UpdateSmartReportsStateBySecondIds(oldState, newState int, secondIds []int)
 	return
 }
 
-
 // UpdatePdfUrlSmartReportById 清空pdf相关字段
 func UpdatePdfUrlSmartReportById(reportId int) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	sql := `UPDATE smart_report SET detail_img_url = '',detail_pdf_url='',modify_time=NOW() WHERE smart_report_id = ? `
 	_, err = o.Raw(sql, reportId).Exec()
 	return
-}
+}

+ 1 - 1
models/smart_report/smart_report_save_log.go

@@ -10,7 +10,7 @@ import (
 
 // SmartReportSaveLog 智能研报保存记录
 type SmartReportSaveLog struct {
-	Id            int       `orm:"column(id);pk"`
+	Id            int       `orm:"column(id);pk" gorm:"primaryKey"`
 	SmartReportId int       `description:"智能研报ID"`
 	Content       string    `description:"内容"`
 	ContentSub    string    `description:"内容前两个章节"`

+ 2 - 2
models/smart_report/smart_resource.go

@@ -9,7 +9,7 @@ import (
 )
 
 type SmartReportResource struct {
-	ResourceId int       `orm:"column(resource_id);pk" description:"智能研报资源ID"`
+	ResourceId int       `orm:"column(resource_id);pk" gorm:"primaryKey" description:"智能研报资源ID"`
 	ImgUrl     string    // 图片链接
 	Style      string    // 版图样式
 	ImgName    string    // 图片名称
@@ -49,7 +49,7 @@ func (m *SmartReportResource) Del() (err error) {
 }
 
 type SmartReportResourceItem struct {
-	ResourceId int    `orm:"column(resource_id);pk" description:"智能研报资源ID"`
+	ResourceId int    `orm:"column(resource_id);pk" gorm:"primaryKey" description:"智能研报资源ID"`
 	ImgUrl     string // 图片链接
 	ImgName    string // 图片名称
 	Style      string // 版图样式

+ 1 - 1
models/speech_recognition/speech_recognition.go

@@ -19,7 +19,7 @@ const (
 
 // SpeechRecognition 语音识别主表
 type SpeechRecognition struct {
-	SpeechRecognitionId int       `orm:"column(speech_recognition_id);pk"`
+	SpeechRecognitionId int       `orm:"column(speech_recognition_id);pk" gorm:"primaryKey"`
 	UniqueCode          string    `description:"唯一编码"`
 	FileName            string    `description:"文件名称"`
 	ResourceUrl         string    `description:"文件路径"`

+ 1 - 1
models/speech_recognition/speech_recognition_api_log.go

@@ -26,7 +26,7 @@ var ApiErrMsgMapping = map[int]string{
 
 // SpeechRecognitionApiLog 语音识别-API请求日志
 type SpeechRecognitionApiLog struct {
-	Id                  int       `orm:"column(id);pk"`
+	Id                  int       `orm:"column(id);pk" gorm:"primaryKey"`
 	SpeechRecognitionId int       `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
 	RequestId           string    `description:"API请求的唯一标识TaskId"`
 	RequestCode         int       `description:"API请求结果状态码:-1-待请求;0-成功;其他-失败"`

+ 1 - 1
models/speech_recognition/speech_recognition_content.go

@@ -10,7 +10,7 @@ import (
 
 // SpeechRecognitionContent 语音识别-内容表
 type SpeechRecognitionContent struct {
-	SpeechRecognitionContentId int       `orm:"column(speech_recognition_content_id);pk"`
+	SpeechRecognitionContentId int       `orm:"column(speech_recognition_content_id);pk" gorm:"primaryKey"`
 	SpeechRecognitionId        int       `description:"语音识别ID"`
 	Sort                       int       `description:"段落排序"`
 	Content                    string    `description:"段落内容"`

+ 1 - 1
models/speech_recognition/speech_recognition_menu.go

@@ -15,7 +15,7 @@ const (
 
 // SpeechRecognitionMenu 语音识别-目录表
 type SpeechRecognitionMenu struct {
-	SpeechRecognitionMenuId int       `orm:"column(speech_recognition_menu_id);pk"`
+	SpeechRecognitionMenuId int       `orm:"column(speech_recognition_menu_id);pk" gorm:"primaryKey"`
 	UniqueCode              string    `description:"唯一编码"`
 	MenuName                string    `description:"目录名称"`
 	ParentId                int       `description:"父级ID"`

+ 1 - 1
models/speech_recognition/speech_recognition_tag.go

@@ -10,7 +10,7 @@ import (
 
 // SpeechRecognitionTag 语音识别-标签表
 type SpeechRecognitionTag struct {
-	SpeechRecognitionTagId int       `orm:"column(speech_recognition_tag_id);pk"`
+	SpeechRecognitionTagId int       `orm:"column(speech_recognition_tag_id);pk" gorm:"primaryKey"`
 	UniqueCode             string    `description:"唯一编码"`
 	TagName                string    `description:"标签名称"`
 	MenuId                 int       `description:"目录ID"`

+ 1 - 1
models/speech_recognition/speech_recognition_tag_mapping.go

@@ -9,7 +9,7 @@ import (
 
 // SpeechRecognitionTagMapping 语音识别-标签关联表
 type SpeechRecognitionTagMapping struct {
-	Id                  int `orm:"column(id);pk"`
+	Id                  int `orm:"column(id);pk" gorm:"primaryKey"`
 	SpeechRecognitionId int `description:"语音识别ID"`
 	TagId               int `description:"标签ID"`
 }

+ 1 - 1
models/speech_recognition/speech_recognition_tag_menu.go

@@ -15,7 +15,7 @@ const (
 
 // SpeechRecognitionTagMenu 标签目录表
 type SpeechRecognitionTagMenu struct {
-	SpeechRecognitionTagMenuId int       `orm:"column(speech_recognition_tag_menu_id);pk"`
+	SpeechRecognitionTagMenuId int       `orm:"column(speech_recognition_tag_menu_id);pk" gorm:"primaryKey"`
 	UniqueCode                 string    `description:"唯一编码"`
 	MenuName                   string    `description:"目录名称"`
 	ParentId                   int       `description:"父级ID"`

+ 1 - 1
models/system/admin_config.go

@@ -6,7 +6,7 @@ import (
 )
 
 type AdminConfig struct {
-	ConfigId    int       `orm:"column(config_id);pk" description:"配置id"`
+	ConfigId    int       `orm:"column(config_id);pk" gorm:"primaryKey" description:"配置id"`
 	AdminId     int       `description:"系统客户id"`
 	ConfigCode  string    `description:"配置编码"`
 	ConfigValue string    `description:"配置值"`

+ 1 - 1
models/system/admin_operate_record.go

@@ -6,7 +6,7 @@ import (
 )
 
 type AdminOperateRecord struct {
-	AdminOperateRecordId int       `orm:"column(admin_operate_record_id);pk" description:"id"`
+	AdminOperateRecordId int       `orm:"column(admin_operate_record_id);pk" gorm:"primaryKey" description:"id"`
 	AdminId              int       `description:"系统客户id"`
 	RealName             string    `description:"配置编码"`
 	Uuid                 string    `description:"配置值"`

+ 1 - 1
models/system/admin_verify_code_record.go

@@ -21,7 +21,7 @@ const (
 
 // AdminVerifyCodeRecord 短信邮箱验证码记录表
 type AdminVerifyCodeRecord struct {
-	Id          int       `orm:"column(id);pk"`
+	Id          int       `orm:"column(id);pk" gorm:"primaryKey"`
 	VerifyType  int       `description:"验证方式:1-手机号;2-邮箱"`
 	Source      int       `description:"来源:1-登录;2-异常登录校验;3-忘记密码"`
 	Mobile      string    `description:"手机号"`

+ 3 - 3
models/system/research_group.go

@@ -1,14 +1,14 @@
 package system
 
 import (
-	"github.com/beego/beego/v2/client/orm"
 	"eta/eta_api/utils"
+	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
 // ResearchGroup 研究方向分组表
 type ResearchGroup struct {
-	ResearchGroupId   int       `orm:"column(research_group_id);pk" description:"研究方向分组ID"`
+	ResearchGroupId   int       `orm:"column(research_group_id);pk" gorm:"primaryKey" description:"研究方向分组ID"`
 	ResearchGroupName string    `json:"research_group_name" description:"研究方向分组名称"`
 	ParentId          int       `json:"parent_id" description:"父类ID"`
 	ChartPermissionId int       `json:"chart_permission_id" description:"品种权限ID"`
@@ -36,7 +36,7 @@ func GetResearchGroupById(groupId int) (item *ResearchGroup, err error) {
 
 // ResearchGroupRelation 研究方向关系表
 type ResearchGroupRelation struct {
-	Id              int `orm:"column(id);pk"`
+	Id              int `orm:"column(id);pk" gorm:"primaryKey"`
 	ResearchGroupId int `json:"research_group_id" description:"分组ID"`
 	AdminId         int `json:"admin_id" description:"研究员ID"`
 }

+ 2 - 2
models/system/sys_department.go

@@ -10,7 +10,7 @@ type SysDepartmentAddReq struct {
 }
 
 type SysDepartment struct {
-	DepartmentId   int       `orm:"column(department_id);pk" description:"部门Id"`
+	DepartmentId   int       `orm:"column(department_id);pk" gorm:"primaryKey" description:"部门Id"`
 	DepartmentName string    `description:"部门名称"`
 	Sort           int       `description:"排序"`
 	CreateTime     time.Time `description:"创建时间"`
@@ -83,7 +83,7 @@ func DeleteSysDepartment(departmentId int) (err error) {
 }
 
 type SysDepartmentList struct {
-	DepartmentId   int             `orm:"column(department_id);pk" description:"部门Id"`
+	DepartmentId   int             `orm:"column(department_id);pk" gorm:"primaryKey" description:"部门Id"`
 	DepartmentName string          `description:"部门名称"`
 	CreateTime     time.Time       `description:"创建时间"`
 	Child          []*SysGroupList `description:"分组"`

+ 3 - 3
models/system/sys_group.go

@@ -12,7 +12,7 @@ type SysGroupAddReq struct {
 }
 
 type SysGroup struct {
-	GroupId      int       `orm:"column(group_id);pk" description:"分组ID"`
+	GroupId      int       `orm:"column(group_id);pk" gorm:"primaryKey" description:"分组ID"`
 	DepartmentId int       `description:"部门Id"`
 	ParentId     int       `description:"父级Id"`
 	GroupName    string    `description:"分组名称"`
@@ -85,7 +85,7 @@ func DeleteSysGroup(groupId int) (err error) {
 
 // 因前端显示需要,TopId字段用来当做一级部门id,DepartmentId为当前分组id
 type SysGroupList struct {
-	GroupId      int            `orm:"column(group_id);pk" json:"DepartmentId" description:"分组ID"`
+	GroupId      int            `orm:"column(group_id);pk" gorm:"primaryKey" json:"DepartmentId" description:"分组ID"`
 	ParentId     int            `json:"ParentId" description:"父级ID"`
 	DepartmentId int            `json:"TopId" description:"部门Id"`
 	GroupName    string         `json:"DepartmentName" description:"分组名称"`
@@ -148,7 +148,7 @@ func GetChildSysGroupByGroupId(groupId int) (items []*SysGroup, err error) {
 }
 
 type SysFullGroup struct {
-	GroupId         int       `orm:"column(group_id);pk" description:"分组ID"`
+	GroupId         int       `orm:"column(group_id);pk" gorm:"primaryKey" description:"分组ID"`
 	DepartmentId    int       `description:"部门Id"`
 	ParentId        int       `description:"父级Id"`
 	GroupName       string    `description:"分组名称"`

+ 8 - 9
models/system/sys_menu.go

@@ -16,7 +16,7 @@ const (
 )
 
 type SysMenu struct {
-	MenuId     int       `orm:"column(menu_id);pk"`
+	MenuId     int       `orm:"column(menu_id);pk" gorm:"primaryKey"`
 	ParentId   int       `description:"父级菜单ID"`
 	Name       string    `description:"菜单名称或者按钮名称"`
 	Sort       string    `description:"排序"`
@@ -194,15 +194,14 @@ func GetMenuButtonApisByRoleId(roleId int) (items []*SysMenu, err error) {
 
 // SysMenuSimple ETA商家菜单
 type SysMenuSimple struct {
-	MenuId     int       `orm:"column(menu_id);pk"`
-	ParentId   int       `description:"父级菜单ID"`
-	Name       string    `description:"菜单名称或者按钮名称"`
-	Sort       string    `description:"排序"`
-	Path       string    `description:"路由地址"`
-	NameEn     string    `description:"菜单名称或者按钮名称(英文)"`
+	MenuId   int    `orm:"column(menu_id);pk" gorm:"primaryKey"`
+	ParentId int    `description:"父级菜单ID"`
+	Name     string `description:"菜单名称或者按钮名称"`
+	Sort     string `description:"排序"`
+	Path     string `description:"路由地址"`
+	NameEn   string `description:"菜单名称或者按钮名称(英文)"`
 }
 
-
 // GetMenuByRoleIds 根据管理员多个角色查询菜单ID
 func GetMenuByRoleIds(roleIds string) (items []*SysMenu, err error) {
 	sql := ` SELECT DISTINCT a.* FROM sys_menu AS a
@@ -212,4 +211,4 @@ func GetMenuByRoleIds(roleIds string) (items []*SysMenu, err error) {
             ORDER BY a.sort ASC, create_time DESC, menu_id DESC`
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
 	return
-}
+}

+ 2 - 2
models/system/sys_menu_button.go

@@ -6,7 +6,7 @@ import (
 )
 
 type SysMenuButton struct {
-	MenuButtonId int `orm:"column(menu_button_id);pk" description:"菜单按钮id"`
+	MenuButtonId int `orm:"column(menu_button_id);pk" gorm:"primaryKey" description:"菜单按钮id"`
 	MenuId       int
 	ButtonName   int
 	CreateTime   time.Time
@@ -36,7 +36,7 @@ func AddSysMenuButton(item *SysMenuButton) (lastId int64, err error) {
 }
 
 type SysRoleButton struct {
-	Id           int `orm:"column(id);pk" description:"关联id"`
+	Id           int `orm:"column(id);pk" gorm:"primaryKey" description:"关联id"`
 	RoleId       int
 	MenuButtonId int
 	CreateTime   time.Time

+ 3 - 3
models/system/sys_role.go

@@ -14,7 +14,7 @@ type SysRoleAddReq struct {
 }
 
 type SysRole struct {
-	RoleId       int       `orm:"column(role_id);pk" description:"角色ID"`
+	RoleId       int       `orm:"column(role_id);pk" gorm:"primaryKey" description:"角色ID"`
 	RoleName     string    `description:"角色名称"`
 	RoleType     string    `description:"角色类型"`
 	RoleTypeCode string    `description:"角色类型编码"`
@@ -24,7 +24,7 @@ type SysRole struct {
 }
 
 type SysRoleItem struct {
-	RoleId       int       `orm:"column(role_id);pk" description:"角色ID"`
+	RoleId       int       `orm:"column(role_id);pk" gorm:"primaryKey" description:"角色ID"`
 	RoleName     string    `description:"角色名称"`
 	RoleType     string    `description:"角色类型"`
 	RoleTypeCode string    `description:"角色类型编码"`
@@ -176,7 +176,7 @@ func DeleteRoleMenuByRoleId(roleId int) (err error) {
 }
 
 type SysRoleMenu struct {
-	RoleMenuId int `orm:"column(role_menu_id);pk" description:"关联id"`
+	RoleMenuId int `orm:"column(role_menu_id);pk" gorm:"primaryKey" description:"关联id"`
 	RoleId     int
 	MenuId     int
 	Type       int `description:"类型:0-全选;1-半选(此字段仅用于前端的回显)"`

+ 1 - 1
models/system/sys_role_admin.go

@@ -7,7 +7,7 @@ import (
 )
 
 type SysRoleAdmin struct {
-	Id         int       `orm:"column(id);pk" description:"自增ID"`
+	Id         int       `orm:"column(id);pk" gorm:"primaryKey" description:"自增ID"`
 	AdminId    int       `orm:"column(admin_id);" description:"系统用户id"`
 	RoleId     int       `orm:"column(role_id);" description:"角色ID"`
 	CreateTime time.Time `orm:"column(create_time);" description:"创建时间"`

+ 1 - 1
models/system/sys_session.go

@@ -6,7 +6,7 @@ import (
 )
 
 type SysSession struct {
-	Id              int `orm:"column(id);pk"`
+	Id              int `orm:"column(id);pk" gorm:"primaryKey" gorm:"primaryKey"`
 	SysUserId       int
 	UserName        string
 	AccessToken     string

+ 2 - 2
models/system/sys_team.go

@@ -12,7 +12,7 @@ type SysTeamAddReq struct {
 }
 
 type SysTeam struct {
-	GroupId      int       `orm:"column(group_id);pk" description:"分组ID"`
+	GroupId      int       `orm:"column(group_id);pk" gorm:"primaryKey" description:"分组ID"`
 	ParentId     int       `description:"父级Id"`
 	DepartmentId int       `description:"部门id"`
 	GroupName    string    `description:"分组名称"`
@@ -63,7 +63,7 @@ type SysTeamDeleteReq struct {
 }
 
 type SysTeamList struct {
-	GroupId    int       `orm:"column(group_id);pk" json:"DepartmentId" description:"小组ID"`
+	GroupId    int       `orm:"column(group_id);pk" gorm:"primaryKey" json:"DepartmentId" description:"小组ID"`
 	ParentId   int       `json:"GroupId" description:"小组Id"`
 	GroupName  string    `json:"DepartmentName" description:"分组名称"`
 	CreateTime time.Time `description:"创建时间"`

+ 1 - 1
models/system/sys_user.go

@@ -27,7 +27,7 @@ type LoginResp struct {
 }
 
 type Admin struct {
-	AdminId                   int    `orm:"column(admin_id);pk" description:"系统用户id"`
+	AdminId                   int    `orm:"column(admin_id);pk" gorm:"primaryKey" description:"系统用户id"`
 	AdminName                 string `description:"系统用户名称"`
 	AdminAvatar               string `description:"用户头像"`
 	RealName                  string `description:"系统用户姓名"`

+ 1 - 1
models/system/sys_user_login_record.go

@@ -6,7 +6,7 @@ import (
 )
 
 type SysUserLoginRecord struct {
-	Id         int `orm:"column(id);pk"`
+	Id         int `orm:"column(id);pk" gorm:"primaryKey"`
 	Uid        int
 	UserName   string
 	Ip         string

+ 2 - 2
models/yb/price_driven.go

@@ -7,7 +7,7 @@ import (
 
 // PriceDriven 价格驱动表
 type PriceDriven struct {
-	PriceDrivenId int `orm:"column(price_driven_id);pk" description:"价格驱动ID"`
+	PriceDrivenId int `orm:"column(price_driven_id);pk" gorm:"primaryKey" description:"价格驱动ID"`
 	//ChartPermissionId   int       `json:"chart_permission_id" description:"品种权限ID"`
 	VarietyTagId        int       `json:"variety_tag_id" description:"标签ID"`
 	VarietyTagName      string    `json:"variety_tag_name" description:"标签名称"`
@@ -51,7 +51,7 @@ func (priceDrivenInfo *PriceDriven) Update(cols []string) (err error) {
 
 // PriceDrivenSaveLog 价格驱动保存记录表
 type PriceDrivenSaveLog struct {
-	Id            int `orm:"column(id);pk"`
+	Id            int `orm:"column(id);pk" gorm:"primaryKey"`
 	PriceDrivenId int `json:"price_driven_id" description:"价格驱动ID"`
 	//ChartPermissionId int       `json:"chart_permission_id" description:"品种权限ID"`
 	VarietyTagId      int       `json:"variety_tag_id" description:"标签ID"`

+ 1 - 1
models/yb/price_driven_tag.go

@@ -7,7 +7,7 @@ import (
 
 // PriceDrivenTag 标签库分类表
 type PriceDrivenTag struct {
-	Id             int       `orm:"column(id);pk" `
+	Id             int       `orm:"column(id);pk" gorm:"primaryKey" `
 	VarietyTagId   int       `json:"variety_tag_id" description:"标签ID"`
 	VarietyTagName string    `json:"variety_tag_name" description:"标签名称"`
 	State          int       `json:"state" description:"显示状态 0-禁用 1-启用"`

+ 1 - 1
models/yb/yb_community_question_process.go

@@ -13,7 +13,7 @@ const (
 
 // CommunityQuestionProcess 问答社区流程表
 type CommunityQuestionProcess struct {
-	Id                  int       `orm:"column(id);pk" json:"-"`
+	Id                  int       `orm:"column(id);pk" gorm:"primaryKey" json:"-"`
 	CommunityQuestionId int       `json:"community_question_id"`
 	TransferUserId      int       `json:"transfer_user_id"`
 	TransferAdminId     int       `json:"transfer_admin_id"`

+ 1 - 1
models/yb/yb_poster_resource.go

@@ -10,7 +10,7 @@ import (
 
 // YbPosterResource 研报小程序海报
 type YbPosterResource struct {
-	Id         int       `orm:"column(id);pk" description:"价格驱动ID"`
+	Id         int       `orm:"column(id);pk" gorm:"primaryKey" description:"价格驱动ID"`
 	Path       string    `description:"请求路径"`
 	ImgUrl     string    `description:"图片地址"`
 	Type       string    `description:"类型 poster-海报; qrcode-太阳码"`