作者 yangfu

refresh 过期时间修改

@@ -184,7 +184,7 @@ from audit_flow_process where uid=? and review_status in (%v) and enable_status @@ -184,7 +184,7 @@ from audit_flow_process where uid=? and review_status in (%v) and enable_status
184 func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { 184 func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
185 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( 185 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
186 select a.*,b.user_id chance_user_id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from ( 186 select a.*,b.user_id chance_user_id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from (
187 -select id collect_id,source_id,update_at,collect_time,chance_id from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 187 +select id collect_id,source_id,update_at,collect_time,chance_id from chance_favorite where (0=? or unix_timestamp(collect_time)<?) and user_id =? and enable_status=1
188 and source_type=1 188 and source_type=1
189 and (mark_flag&2)>0 189 and (mark_flag&2)>0
190 )a left outer join chance b on a.source_id = b.id 190 )a left outer join chance b on a.source_id = b.id
@@ -207,7 +207,7 @@ limit ?`) @@ -207,7 +207,7 @@ limit ?`)
207 func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { 207 func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
208 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( 208 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
209 select a.*,b.user_id chance_user_id,b.id chance_id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from ( 209 select a.*,b.user_id chance_user_id,b.id chance_id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from (
210 -select id collect_id,source_id,update_at,zan_time from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 210 +select id collect_id,source_id,update_at,zan_time from chance_favorite where (0=? or unix_timestamp(zan_time)<?) and user_id =? and enable_status=1
211 and source_type=1 211 and source_type=1
212 and (mark_flag&1)>0 212 and (mark_flag&1)>0
213 )a left outer join chance b on a.source_id = b.id 213 )a left outer join chance b on a.source_id = b.id
@@ -16,6 +16,7 @@ const ( @@ -16,6 +16,7 @@ const (
16 ) 16 )
17 17
18 const TokenExpire = 3600 18 const TokenExpire = 3600
  19 +const RefreshTokenExipre = 3600 * 24 * 30 * 3 //刷新token 三个月过期
19 20
20 const SmscodeDayLimitTime = 10 //短信验证码每天最多发10次 21 const SmscodeDayLimitTime = 10 //短信验证码每天最多发10次
21 22
@@ -220,7 +220,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke @@ -220,7 +220,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke
220 userAuth.AccessToken = uid.NewV1().StringNoDash() 220 userAuth.AccessToken = uid.NewV1().StringNoDash()
221 userAuth.RefreshToken = uid.NewV1().StringNoDash() 221 userAuth.RefreshToken = uid.NewV1().StringNoDash()
222 userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) 222 userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second)
223 - userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire * time.Second * 2) 223 + userAuth.RefreshTokenExp = time.Now().Add(protocol.RefreshTokenExipre * time.Second)
224 if err = models.UpdateUserAuthById(userAuth); err != nil { 224 if err = models.UpdateUserAuthById(userAuth); err != nil {
225 log.Error(err) 225 log.Error(err)
226 return 226 return
@@ -253,7 +253,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT @@ -253,7 +253,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT
253 userAuth.AccessToken = uid.NewV1().StringNoDash() 253 userAuth.AccessToken = uid.NewV1().StringNoDash()
254 userAuth.RefreshToken = uid.NewV1().StringNoDash() 254 userAuth.RefreshToken = uid.NewV1().StringNoDash()
255 userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) 255 userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second)
256 - userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire * time.Second * 2) 256 + userAuth.RefreshTokenExp = time.Now().Add(protocol.RefreshTokenExipre * time.Second)
257 if err = models.UpdateUserAuthById(userAuth); err != nil { 257 if err = models.UpdateUserAuthById(userAuth); err != nil {
258 return 258 return
259 } 259 }
@@ -1541,7 +1541,15 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect @@ -1541,7 +1541,15 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect
1541 myChances []protocol.ChanceCollectItemOrm 1541 myChances []protocol.ChanceCollectItemOrm
1542 total int 1542 total int
1543 provider *protocol.BaseUserInfo 1543 provider *protocol.BaseUserInfo
  1544 + favorite *models.ChanceFavorite
1544 ) 1545 )
  1546 + if request.LastId > 0 {
  1547 + if favorite, err = models.GetChanceFavoriteById(request.LastId); err != nil {
  1548 + log.Error("不存在", request.LastId, err)
  1549 + return
  1550 + }
  1551 + request.LastId = favorite.CollectTime.Unix()
  1552 + }
1545 if total, err = models.GetChanceCollect(header.UserId, request.LastId, request.PageSize, &myChances); err != nil { 1553 if total, err = models.GetChanceCollect(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
1546 if err == orm.ErrNoRows { 1554 if err == orm.ErrNoRows {
1547 err = nil 1555 err = nil
@@ -1624,7 +1632,15 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp @@ -1624,7 +1632,15 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp
1624 myChances []protocol.ChanceThumbUpItemOrm 1632 myChances []protocol.ChanceThumbUpItemOrm
1625 total int 1633 total int
1626 provider *protocol.BaseUserInfo 1634 provider *protocol.BaseUserInfo
  1635 + favorite *models.ChanceFavorite
1627 ) 1636 )
  1637 + if request.LastId > 0 {
  1638 + if favorite, err = models.GetChanceFavoriteById(request.LastId); err != nil {
  1639 + log.Error("不存在", request.LastId, err)
  1640 + return
  1641 + }
  1642 + request.LastId = favorite.ZanTime.Unix()
  1643 + }
1628 if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &myChances); err != nil { 1644 if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
1629 if err == orm.ErrNoRows { 1645 if err == orm.ErrNoRows {
1630 err = nil 1646 err = nil