Browse Source

Merge branch 'exchange_modifytime_fix'

zwxi 9 months ago
parent
commit
167ae081f9
2 changed files with 15 additions and 0 deletions
  1. 8 0
      controllers/data_source/sci99.go
  2. 7 0
      models/data_source/base_from_sci99.go

+ 8 - 0
controllers/data_source/sci99.go

@@ -121,6 +121,14 @@ func (this *DataSourceController) Sci99Data() {
 		product.Unit = v.Unit
 		product.ModifyTime = v.ModifyTime
 
+		modifyTime, err := data_source.GetSci99IndexLatestDate(v.IndexCode)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取更新时间失败"
+			br.ErrMsg = "获取更新时间失败,Err:" + err.Error()
+			return
+		}
+		product.ModifyTime = modifyTime
+
 		total, err := data_source.GetSci99IndexDataCount(v.IndexCode)
 		page := paging.GetPaging(currentIndex, pageSize, total)
 		dataList, err := data_source.GetSci99IndexData(v.IndexCode, startSize, pageSize)

+ 7 - 0
models/data_source/base_from_sci99.go

@@ -133,3 +133,10 @@ func GetSci99IndexDataByCode(indexCode string) (items []*BaseFromSci99DataItem,
 	_, err = o.Raw(sql, indexCode).QueryRows(&items)
 	return
 }
+
+func GetSci99IndexLatestDate(indexCode string) (ModifyTime string, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT modify_time FROM base_from_sci99_data WHERE index_code=? ORDER BY modify_time DESC limit 1 `
+	err = o.Raw(sql, indexCode).QueryRow(&ModifyTime)
+	return
+}