|
@@ -1,9 +1,12 @@
|
|
package entity
|
|
package entity
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ ac "applocation/apploc"
|
|
"db"
|
|
"db"
|
|
"fmt"
|
|
"fmt"
|
|
"log"
|
|
"log"
|
|
|
|
+ "net/http"
|
|
|
|
+ "qfw/util"
|
|
"qfw/util/redis"
|
|
"qfw/util/redis"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
@@ -12,10 +15,11 @@ type AppLocStruct struct {
|
|
UserId string //用户id
|
|
UserId string //用户id
|
|
Longitude string // 经度
|
|
Longitude string // 经度
|
|
Latitude string //纬度
|
|
Latitude string //纬度
|
|
|
|
+ R *http.Request
|
|
}
|
|
}
|
|
|
|
|
|
-func NewAppLoc(userId, longitude, latitude string) *AppLocStruct {
|
|
|
|
- return &AppLocStruct{userId, longitude, latitude}
|
|
|
|
|
|
+func NewAppLoc(userId, longitude, latitude string, r http.Request) *AppLocStruct {
|
|
|
|
+ return &AppLocStruct{userId, longitude, latitude, &r}
|
|
}
|
|
}
|
|
|
|
|
|
var AppLocLog = "apploc_log"
|
|
var AppLocLog = "apploc_log"
|
|
@@ -25,14 +29,22 @@ var RedisUserKey = "apploc_%s"
|
|
func (this *AppLocStruct) SaveAppLocInfo() bool {
|
|
func (this *AppLocStruct) SaveAppLocInfo() bool {
|
|
log.Println(this.Longitude, "---", this.Latitude)
|
|
log.Println(this.Longitude, "---", this.Latitude)
|
|
timeNow := time.Now()
|
|
timeNow := time.Now()
|
|
|
|
+ ref := this.R.Referer()
|
|
appLocInfo := map[string]interface{}{
|
|
appLocInfo := map[string]interface{}{
|
|
"date": timeNow.Unix(),
|
|
"date": timeNow.Unix(),
|
|
"userId": this.UserId,
|
|
"userId": this.UserId,
|
|
"longitude": this.Longitude,
|
|
"longitude": this.Longitude,
|
|
"latitude": this.Latitude,
|
|
"latitude": this.Latitude,
|
|
|
|
+ "ip": util.GetIp(this.R),
|
|
|
|
+ "refer": ref,
|
|
|
|
+ "year": timeNow.Year(),
|
|
|
|
+ "month": timeNow.Month(),
|
|
|
|
+ "day": timeNow.Day(),
|
|
|
|
+ "hour": timeNow.Hour(),
|
|
|
|
+ "minutes": timeNow.Minute(),
|
|
}
|
|
}
|
|
if db.Mgo_Log.Save(AppLocLog, appLocInfo) != "" {
|
|
if db.Mgo_Log.Save(AppLocLog, appLocInfo) != "" {
|
|
- redis.Put("other", fmt.Sprintf(RedisUserKey, this.UserId), timeNow.Day(), 12*60*60)
|
|
|
|
|
|
+ redis.Put("other", fmt.Sprintf(RedisUserKey, this.UserId), timeNow.Day(), ac.Apploctime)
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
return false
|