package edb_data

import "hongze/hongze_yb/global"

func ModifyEdbDataThs(edbInfoId int64, dataTime string, value float64) (err error) {
	sql := ` UPDATE edb_data_ths SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
	err = global.MYSQL["data"].Exec(sql, value, edbInfoId, dataTime).Error

	return
}

func ModifyEdbDataWind(edbInfoId int64, dataTime string, value float64) (err error) {
	sql := ` UPDATE edb_data_wind SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
	err = global.MYSQL["data"].Exec(sql, value, edbInfoId, dataTime).Error

	return
}

func ModifyEdbDataPb(edbInfoId int, dataTime string, value float64) (err error) {
	sql := ` UPDATE edb_data_pb SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
	err = global.MYSQL["data"].Exec(sql, value, edbInfoId, dataTime).Error

	return
}

func ModifyBaseFromSmmData(smmDataId int, value string) (err error) {
	sql := `UPDATE base_from_smm_data SET value=?,modify_time=NOW() WHERE smm_data_id=? `
	err = global.MYSQL["data"].Exec(sql, value, smmDataId).Error

	return
}

func ModifyBaseFromSmmMinDateAndMaxDate(baseFromSmmIndexId int, minDate, maxDate string) (err error) {
	sql := ` UPDATE base_from_smm_index SET start_date=?,end_date=?,modify_time=NOW() WHERE base_from_smm_index_id=? `
	err = global.MYSQL["data"].Exec(sql, minDate, maxDate, baseFromSmmIndexId).Error

	return
}

func ModifyEdbDataGl(edbInfoId int64, dataTime, value string) (err error) {
	sql := ` UPDATE edb_data_gl SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
	err = global.MYSQL["data"].Exec(sql, value, edbInfoId, dataTime).Error

	return
}

func ModifyEdbInfoMaxAndMinInfo(edbInfoId int, item *EdbInfoMaxAndMinInfo) (err error) {
	sql := ` UPDATE edb_info SET start_date=?,end_date=?,min_value=?,max_value=?,is_update=2,latest_date=?,latest_value=?,modify_time=NOW() WHERE edb_info_id=? `
	err = global.MYSQL["data"].Exec(sql, item.MinDate, item.MaxDate, item.MinValue, item.MaxValue, item.MaxDate, item.LatestValue, edbInfoId).Error

	return
}