Explorar el Código

refactor(models): 优化 ChartEdbMapping 查询语句

- 在 SQL 查询中使用别名 a,提高查询语句的可读性
- 将 Scan 方法替换为 Find 方法,更符合 GORM 的使用习惯
Roc hace 1 mes
padre
commit
fd548699f8
Se han modificado 1 ficheros con 5 adiciones y 4 borrados
  1. 5 4
      models/chart_edb_mapping.go

+ 5 - 4
models/chart_edb_mapping.go

@@ -27,10 +27,11 @@ type ChartEdbMapping struct {
 
 // GetChartEdbMappingListByEdbInfoId 根据指标id获取关联图表列表
 func GetChartEdbMappingListByEdbInfoId(edbInfoId int) (list []*ChartEdbMapping, err error) {
-	sql := ` SELECT *
+	sql := ` SELECT a.*
              FROM chart_edb_mapping AS a
-			 WHERE edb_info_id=? 
-             ORDER BY chart_edb_mapping_id ASC `
-	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).Scan(&list).Error
+			 WHERE a.edb_info_id=? 
+             ORDER BY a.chart_edb_mapping_id ASC `
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).Find(&list).Error
+
 	return
 }