Browse Source

fix: gorm

hsun 2 months ago
parent
commit
998f2c802d

+ 1 - 1
controllers/data_manage/future_good/future_good_chart_info.go

@@ -1118,7 +1118,7 @@ func (this *FutureGoodChartInfoController) ChartInfoMove() {
 			br.ErrMsg = "移动失败,Err:" + tmpErr.Error()
 			return
 		}
-		if tmpChartInfo != nil {
+		if tmpChartInfo != nil && tmpChartInfo.ChartInfoId > 0 {
 			br.Msg = "移动失败,同一个分类下图表名称不允许重复"
 			br.ErrMsg = "移动失败,同一个分类下图表名称不允许重复"
 			return

+ 6 - 0
controllers/speech_recognition/speech_recognition_tag.go

@@ -228,6 +228,12 @@ func (this *SpeechRecognitionTagController) Remove() {
 		br.ErrMsg = "获取标签失败, Err: " + e.Error()
 		return
 	}
+	if tagItem != nil && tagItem.SpeechRecognitionTagId <= 0 {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	// 校验标签是否关联转写文件
 	{

+ 0 - 7
models/data_manage/chart_classify.go

@@ -89,14 +89,7 @@ func GetChartClassifyById(classifyId int) (item *ChartClassify, err error) {
 func GetChartClassifyCountById(classifyId int) (count int, err error) {
 	o := global.DbMap[utils.DbNameIndex]
 	sqlStr := `SELECT count(1) AS count FROM chart_classify WHERE chart_classify_id=? `
-	var totalNull sql.NullInt64
 	err = o.Raw(sqlStr, classifyId).Scan(&count).Error
-	if !totalNull.Valid {
-		count = 0
-	} else {
-		count = int(totalNull.Int64)
-	}
-
 	return
 }
 

+ 1 - 1
models/data_manage/chart_info_correlation.go

@@ -10,7 +10,7 @@ import (
 
 // ChartInfoCorrelation 相关性图表-扩展信息
 type ChartInfoCorrelation struct {
-	CorrelationChartInfoId int       `gorm:"column(correlation_chart_info_id);primaryKey" description:"相关性图表ID(chart_info表source=3的)"`
+	CorrelationChartInfoId int       `gorm:"column(correlation_chart_info_id);primaryKey;autoIncrement:false;" description:"相关性图表ID(chart_info表source=3的)"`
 	LeadValue              int       `gorm:"column(lead_value)" description:"领先值"`
 	LeadUnit               string    `gorm:"column(lead_unit)" description:"领先单位"`
 	CalculateValue         int       `gorm:"column(calculate_value)" description:"计算窗口"`

+ 6 - 3
models/data_manage/mysteel_chemical_index.go

@@ -550,9 +550,12 @@ type BaseRefreshEdbInfo struct {
 	RefreshTime     string `description:"刷新时间"`
 }
 
-func (m *BaseRefreshEdbInfo) AfterFind(db *gorm.DB) (err error) {
-	m.EndDate = utils.GormDateStrToDateStr(m.EndDate)
-
+func (obj *BaseRefreshEdbInfo) AfterFind(tx *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		if obj.EndDate != "" {
+			obj.EndDate = utils.GormDateStrToDateStr(obj.EndDate)
+		}
+	}
 	return
 }
 

+ 2 - 2
models/speech_recognition/speech_recognition_tag.go

@@ -71,7 +71,7 @@ func (m *SpeechRecognitionTag) Update(cols []string) (err error) {
 func (m *SpeechRecognitionTag) Del() (err error) {
 	o := global.DbMap[utils.DbNameMaster]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
-	err = o.Raw(sql, m.SpeechRecognitionTagId).Error
+	err = o.Exec(sql, m.SpeechRecognitionTagId).Error
 	return
 }
 
@@ -81,7 +81,7 @@ func (m *SpeechRecognitionTag) MultiDel(menuIds []int) (err error) {
 	}
 	o := global.DbMap[utils.DbNameMaster]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.PrimaryId(), utils.GetOrmInReplace(len(menuIds)))
-	err = o.Raw(sql, menuIds).Error
+	err = o.Exec(sql, menuIds).Error
 	return
 }