作者 yangfu

榜单列表查询修改

@@ -6,6 +6,7 @@ require ( @@ -6,6 +6,7 @@ require (
6 github.com/aliyun/alibaba-cloud-sdk-go v1.60.348 6 github.com/aliyun/alibaba-cloud-sdk-go v1.60.348
7 github.com/astaxie/beego v1.10.0 7 github.com/astaxie/beego v1.10.0
8 github.com/disintegration/imaging v1.6.2 8 github.com/disintegration/imaging v1.6.2
  9 + github.com/gin-gonic/gin v1.4.0
9 github.com/go-sql-driver/mysql v1.4.1 10 github.com/go-sql-driver/mysql v1.4.1
10 github.com/gomodule/redigo v1.7.0 11 github.com/gomodule/redigo v1.7.0
11 github.com/gorilla/websocket v1.4.1 12 github.com/gorilla/websocket v1.4.1
1 package utils 1 package utils
2 2
3 import ( 3 import (
  4 + "encoding/json"
4 "fmt" 5 "fmt"
5 "testing" 6 "testing"
6 ) 7 )
@@ -58,3 +59,15 @@ func TestMergeMap(t *testing.T) { @@ -58,3 +59,15 @@ func TestMergeMap(t *testing.T) {
58 MergeMap(to, from) 59 MergeMap(to, from)
59 t.Log("merge 后:", to) 60 t.Log("merge 后:", to)
60 } 61 }
  62 +
  63 +func TestIntUnmarsh(t *testing.T) {
  64 + jsonString := `{"id":8242051651122944}`
  65 + type param struct {
  66 + Id int `json:"id"`
  67 + }
  68 + var p param
  69 + json.Unmarshal([]byte(jsonString), &p)
  70 + t.Log(p)
  71 + jsonByte, _ := json.Marshal(p)
  72 + t.Log(string(jsonByte))
  73 +}
@@ -74,28 +74,27 @@ func GetRankList(header *protocol.RequestHeader, request *protocol.GetRankListRe @@ -74,28 +74,27 @@ func GetRankList(header *protocol.RequestHeader, request *protocol.GetRankListRe
74 log.Error(err) 74 log.Error(err)
75 return 75 return
76 } 76 }
77 - if !hasDepartmentInRank {  
78 - continue  
79 - }  
80 - if departmentId > 0 {  
81 - if err = models.GetRanksByDepartmentSelf(header.CompanyId, request.RankTypeId, request.RankRangeId, request.RankPeriodId, key, departmentId, &selfRank); err != nil {  
82 - log.Error(err)  
83 - return  
84 - }  
85 - } else if hasDepartmentInRank {  
86 - for i := range departments {  
87 - d := departments[i]  
88 - if err = models.GetRanksByDepartmentSelf(header.CompanyId, request.RankTypeId, request.RankRangeId, request.RankPeriodId, key, int64(d.Id), &selfRank); err != nil { 77 + if hasDepartmentInRank {
  78 + if departmentId > 0 {
  79 + if err = models.GetRanksByDepartmentSelf(header.CompanyId, request.RankTypeId, request.RankRangeId, request.RankPeriodId, key, departmentId, &selfRank); err != nil {
89 log.Error(err) 80 log.Error(err)
90 return 81 return
91 } 82 }
92 - if selfRank != nil {  
93 - departmentId = int64(d.Id)  
94 - break 83 + } else if hasDepartmentInRank {
  84 + for i := range departments {
  85 + d := departments[i]
  86 + if err = models.GetRanksByDepartmentSelf(header.CompanyId, request.RankTypeId, request.RankRangeId, request.RankPeriodId, key, int64(d.Id), &selfRank); err != nil {
  87 + log.Error(err)
  88 + return
  89 + }
  90 + if selfRank != nil {
  91 + departmentId = int64(d.Id)
  92 + break
  93 + }
  94 + }
  95 + if departmentId == 0 {
  96 + hasDepartmentInRank = false
95 } 97 }
96 - }  
97 - if departmentId == 0 {  
98 - hasDepartmentInRank = false  
99 } 98 }
100 } 99 }
101 } else if rankRange.Type == protocol.RankRangeTypeAllCompanyUser || rankRange.Type == protocol.RankRangeTypeSpecifyUser { 100 } else if rankRange.Type == protocol.RankRangeTypeAllCompanyUser || rankRange.Type == protocol.RankRangeTypeSpecifyUser {