فهرست منبع

单修复引号与双引号导致的SQL错误

在多个文件中,将字符串的双引号替换为单引号,以避免SQL语法错误。这涉及修改条件语句、查询语句和更新语句中的字符串表示方式。
Roc 7 ماه پیش
والد
کامیت
32958e1b14

+ 1 - 1
controllers/report_chapter_type.go

@@ -268,7 +268,7 @@ func (this *ReportChapterTypeController) Edit() {
 		br.ErrMsg = "获取重名报告章节失败, Err:" + e.Error()
 		return
 	}
-	if exists != nil && exists.ReportChapterTypeId != req.ReportChapterTypeId {
+	if exists != nil && exists.ReportChapterTypeId > 0 && exists.ReportChapterTypeId != req.ReportChapterTypeId {
 		br.Msg = "章节名称已存在"
 		return
 	}

+ 1 - 1
controllers/semantic_analysis/sa_compare.go

@@ -694,7 +694,7 @@ func (this *SaCompareController) Search() {
 
 	var list []*saModel.SaCompare
 	saCompare := new(saModel.SaCompare)
-	existCond := fmt.Sprintf(` AND result_img != ""`)
+	existCond := fmt.Sprintf(` AND result_img != ''`)
 	existPars := make([]interface{}, 0)
 	if keyword != "" {
 		existCond += ` AND  ( title LIKE ? )`

+ 1 - 1
models/data_manage/multiple_graph_config.go

@@ -152,7 +152,7 @@ func ReplaceEdbInfoInLineEquationMultipleGraphConfig(oldEdbInfo, newEdbInfo *Edb
 		//	return
 		//}
 
-		csql := `SELECT * FROM multiple_graph_config WHERE edb_info_id_a=0 AND edb_info_id_b=0 AND curve !=""`
+		csql := `SELECT * FROM multiple_graph_config WHERE edb_info_id_a=0 AND edb_info_id_b=0 AND curve !=''`
 		err = to.Raw(csql).Find(&multipleGraphConfigList).Error
 		if err != nil {
 			errmsg = "获取指标关联图表配置信息失败:Err:" + err.Error()

+ 2 - 2
models/data_manage/trade_position_analysis.go

@@ -226,13 +226,13 @@ func MultiInsertTradeBaseDataToTop(exchange string, startDate, endDate string) (
 
 	now := time.Now().Format(utils.FormatDateTime)
 	sql1 := `INSERT INTO trade_position_` + exchange + `_top(classify_name,classify_type,deal_short_name,deal_value,deal_change,data_time,deal_type,source_type,rank,create_time,modify_time)
-		SELECT classify_name,classify_type,buy_short_name,buy_value,buy_change,data_time,1,0,rank,?,? FROM base_from_trade_` + exchange + `_index where rank <50 and buy_short_name !="" and data_time between ? and ?`
+		SELECT classify_name,classify_type,buy_short_name,buy_value,buy_change,data_time,1,0,rank,?,? FROM base_from_trade_` + exchange + `_index where rank <50 and buy_short_name !='' and data_time between ? and ?`
 	err = global.DmSQL["data"].Exec(sql1, now, now, startDate, endDate).Error
 	if err != nil {
 		return
 	}
 	sql2 := `INSERT INTO trade_position_` + exchange + `_top(classify_name,classify_type,deal_short_name,deal_value,deal_change,data_time,deal_type,source_type,rank,create_time,modify_time)
-	SELECT classify_name,classify_type,sold_short_name,sold_value,sold_change,data_time,2,0,rank,?,? FROM base_from_trade_` + exchange + `_index where rank <50 and sold_short_name !="" and data_time between ? and ?`
+	SELECT classify_name,classify_type,sold_short_name,sold_value,sold_change,data_time,2,0,rank,?,? FROM base_from_trade_` + exchange + `_index where rank <50 and sold_short_name !='' and data_time between ? and ?`
 	err = global.DmSQL["data"].Raw(sql2, now, now, startDate, endDate).Error
 	return
 }

+ 3 - 4
models/report.go

@@ -317,7 +317,6 @@ func DeleteReport(reportIds int) (err error) {
 }
 
 type ReportDetail struct {
-	gorm.Model
 	Id                 int    `gorm:"column:id;primary_key;autoIncrement" description:"报告Id"`
 	AddType            int    `gorm:"column:add_type" description:"新增方式:1:新增报告,2:继承报告"`
 	ClassifyIdFirst    int    `gorm:"column:classify_id_first" description:"一级分类id"`
@@ -662,7 +661,7 @@ func ModifyReportVideo(reportId int, videoUrl, videoName, videoSize string, play
 // @return err error
 func ModifyReportVideoByNoVideo(reportId int, videoUrl, videoName, videoSize string, playSeconds float64) (err error) {
 	//o := orm.NewOrmUsingDB("rddp")
-	sql := `UPDATE report SET video_url=?,video_name=?,video_play_seconds=?,video_size=? WHERE id=? AND video_url=""`
+	sql := `UPDATE report SET video_url=?,video_name=?,video_play_seconds=?,video_size=? WHERE id=? AND video_url=''`
 	//_, err = o.Raw(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Exec()
 	err = global.DmSQL["rddp"].Exec(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Error
 	return
@@ -1051,7 +1050,7 @@ func UpdateReportPublishTime(reportId int, videoNameDate string) (err error) {
 		return
 	}
 	//修改音频标题
-	sql2 := ` UPDATE report SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE id = ? and (video_name !="" and video_name is not null)`
+	sql2 := ` UPDATE report SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE id = ? and (video_name !='' and video_name is not null)`
 	//_, err = o.Raw(sql2, reportId).Exec()
 	err = global.DmSQL["rddp"].Exec(sql2, reportId).Error
 	return
@@ -1066,7 +1065,7 @@ func UpdateReportChapterPublishTime(reportId int, videoNameDate string) (err err
 		return
 	}
 	//修改音频标题
-	sql2 := ` UPDATE report_chapter SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE report_id = ? and (video_name !="" and video_name is not null)`
+	sql2 := ` UPDATE report_chapter SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE report_id = ? and (video_name !='' and video_name is not null)`
 	//_, err = o.Raw(sql2, reportId).Exec()
 	err = global.DmSQL["rddp"].Exec(sql2, reportId).Error
 	return

+ 1 - 0
models/semantic_analysis/sa_compare.go

@@ -152,6 +152,7 @@ func (m *SaCompare) GetPageItemsByCondition(startSize, pageSize int, condition s
 	}
 	sql += ` LIMIT ?,?`
 	//_, err = o.Raw(sql, pars...).QueryRows(&items)
+	pars = append(pars, startSize, pageSize)
 	err = global.DEFAULT_DmSQL.Raw(sql, pars...).Find(&items).Error
 	return
 }

+ 1 - 1
services/english_report.go

@@ -813,7 +813,7 @@ func MultiEnglishPolicyReportSync() (err error, errMsg string) {
 	var pars []interface{}
 	//startDate := time.Now().Format(utils.FormatDate)
 	startDate := time.Now().AddDate(0, -1, 0).Format(utils.FormatDate)
-	condition += ` AND publish_time >= ? AND state = 1 AND (content !="" AND content is not null)`
+	condition += ` AND publish_time >= ? AND state = 1 AND (content !='' AND content is not null)`
 	pars = append(pars, startDate)
 	policyReports, err := models.GetEnglishPolicyReportByCondition(condition, pars)
 	if err != nil {