浏览代码

fix:沙盘推演切换数据库

Roc 1 年之前
父节点
当前提交
12272c68f3
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      models/tables/sandbox/query.go

+ 5 - 5
models/tables/sandbox/query.go

@@ -6,20 +6,20 @@ import (
 
 // GetBySandboxId 根据沙盘ID查询详情
 func GetBySandboxId(id uint32) (item *Sandbox, err error) {
-	err = global.DEFAULT_MYSQL.Where("sandbox_id = ? and is_delete=0 ", id).Order("sandbox_id desc").First(&item).Error
+	err = global.MYSQL["data"].Where("sandbox_id = ? and is_delete=0 ", id).Order("sandbox_id desc").First(&item).Error
 	return
 }
 
 // GetPageListByWhere 分页获取活动列表
 func GetPageListByWhere(condition string, pars []interface{}, startSize, pageSize int) (total int64, list []*Sandbox, err error) {
 	// 获取查询总数量
-	err = global.DEFAULT_MYSQL.Model(Sandbox{}).Where(condition, pars...).Count(&total).Error
+	err = global.MYSQL["data"].Model(Sandbox{}).Where(condition, pars...).Count(&total).Error
 	if err != nil {
 		return
 	}
 
 	// 获取列表数据
-	err = global.DEFAULT_MYSQL.Model(Sandbox{}).Where(condition, pars...).Order("modify_time desc,sandbox_id desc").Offset(startSize).Limit(pageSize).Find(&list).Error
+	err = global.MYSQL["data"].Model(Sandbox{}).Where(condition, pars...).Order("modify_time desc,sandbox_id desc").Offset(startSize).Limit(pageSize).Find(&list).Error
 	return
 }
 
@@ -33,9 +33,9 @@ type PermissionSandboxCount struct {
 // GetPermissionCountListByWhere 获取各品种的沙盘数
 func GetPermissionCountListByWhere(condition string, pars []interface{}) (list []*PermissionSandboxCount, err error) {
 
-	//err = global.DEFAULT_MYSQL.Model(ResearchReport{}).Where("research_report_id IN (?)", ids).Scan(&list).Error
+	//err = global.MYSQL["data"].Model(ResearchReport{}).Where("research_report_id IN (?)", ids).Scan(&list).Error
 
 	// 获取列表数据
-	err = global.DEFAULT_MYSQL.Model(Sandbox{}).Select("chart_permission_id,chart_permission_name,count(1) total").Where(condition, pars...).Order("modify_time desc,sandbox_id desc").Group("chart_permission_id").Scan(&list).Error
+	err = global.MYSQL["data"].Model(Sandbox{}).Select("chart_permission_id,chart_permission_name,count(1) total").Where(condition, pars...).Order("modify_time desc,sandbox_id desc").Group("chart_permission_id").Scan(&list).Error
 	return
 }