|
@@ -32,6 +32,16 @@ type EdbData struct {
|
|
|
DataTimestamp int64 `gorm:"column:data_timestamp"`
|
|
|
}
|
|
|
|
|
|
+// AfterFind 在该模型上设置钩子函数,把日期转成正确的string,所以查询函数只能用Find函数,First或者Scan是不会触发该函数的来获取数据
|
|
|
+func (m *EdbData) AfterFind(db *gorm.DB) (err error) {
|
|
|
+ minDateTmp, err := time.ParseInLocation(utils.FormatDateWallWithLoc, m.DataTime, time.Local)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ m.DataTime = minDateTmp.Format(utils.FormatDate)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func GetAddSql(edbInfoId, edbCode, dataTime, timestampStr string, value string) (addSql string) {
|
|
|
nowStr := time.Now().Format(utils.FormatDateTime)
|
|
|
addSql += "("
|