作者 yangfu

基础路由修改

@@ -2,6 +2,7 @@ package models @@ -2,6 +2,7 @@ package models
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "opp/internal/utils"
5 "time" 6 "time"
6 7
7 "github.com/astaxie/beego/orm" 8 "github.com/astaxie/beego/orm"
@@ -88,3 +89,29 @@ func DeleteChance(id int64) (err error) { @@ -88,3 +89,29 @@ func DeleteChance(id int64) (err error) {
88 } 89 }
89 return 90 return
90 } 91 }
  92 +
  93 +//我的机会列表
  94 +func GetChanceMyChance(uid, cid int64, reviewStatus int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
  95 + sql := `select a.*,b.images,speechs,videos
  96 +from (
  97 +select id,user_id,create_at,source_content from chance
  98 +where user_id=? and company_id=? and review_status =? and (?=0 or id>?)
  99 +order by create_at desc
  100 +limit ?
  101 +) a left JOIN chance_data b on a.id =b.chance_id`
  102 +
  103 + sqlCount := `select count(0) from (
  104 +select id,user_id,create_at,source_content from chance
  105 +where user_id=? and company_id=? and review_status =?
  106 +order by create_at desc
  107 +) a left JOIN chance_data b on a.id =b.chance_id`
  108 + if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid, reviewStatus); err != nil {
  109 + return
  110 + }
  111 + if v != nil {
  112 + if err = utils.ExecuteQueryAll(v, sql, uid, cid, reviewStatus, lastId, lastId, pageSize); err != nil {
  113 + return
  114 + }
  115 + }
  116 + return
  117 +}
@@ -165,7 +165,6 @@ type ChanceTotalItem struct { @@ -165,7 +165,6 @@ type ChanceTotalItem struct {
165 165
166 /*MyChance 我的机会*/ 166 /*MyChance 我的机会*/
167 type MyChanceRequest struct { 167 type MyChanceRequest struct {
168 - Xxx string `json:"xxx" valid:"Required"`  
169 } 168 }
170 type MyChanceResponse struct { 169 type MyChanceResponse struct {
171 } 170 }
@@ -215,7 +215,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke @@ -215,7 +215,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke
215 userAuth.AccessToken = uid.NewV1().StringNoDash() 215 userAuth.AccessToken = uid.NewV1().StringNoDash()
216 userAuth.RefreshToken = uid.NewV1().StringNoDash() 216 userAuth.RefreshToken = uid.NewV1().StringNoDash()
217 userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) 217 userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second)
218 - userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) 218 + userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire * time.Second * 2)
219 if err = models.UpdateUserAuthById(userAuth); err != nil { 219 if err = models.UpdateUserAuthById(userAuth); err != nil {
220 log.Error(err) 220 log.Error(err)
221 return 221 return
@@ -244,7 +244,11 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT @@ -244,7 +244,11 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT
244 protocol.NewErrWithMessage(4139, err) 244 protocol.NewErrWithMessage(4139, err)
245 return 245 return
246 } 246 }
  247 + //userAuth.AccessToken = uid.NewV1().StringNoDash()
247 userAuth.AccessToken = uid.NewV1().StringNoDash() 248 userAuth.AccessToken = uid.NewV1().StringNoDash()
  249 + userAuth.RefreshToken = uid.NewV1().StringNoDash()
  250 + userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second)
  251 + userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire * time.Second * 2)
248 if err = models.UpdateUserAuthById(userAuth); err != nil { 252 if err = models.UpdateUserAuthById(userAuth); err != nil {
249 return 253 return
250 } 254 }