作者 yangfu

排行榜排名项修改

@@ -28,10 +28,10 @@ type GetRankListRequest struct { @@ -28,10 +28,10 @@ type GetRankListRequest struct {
28 PageSize int `json:"pageSize" valid:"Required"` //每页数量 28 PageSize int `json:"pageSize" valid:"Required"` //每页数量
29 } 29 }
30 type GetRankListResponse struct { 30 type GetRankListResponse struct {
31 - SortItems []string `json:"sortItems"` //评比项  
32 - Self []RankItem `json:"self"` //自己或所在部门的排名分数  
33 - Lists [][]RankItem `json:"lists"` //排名列表  
34 - Total int `json:"total"` //总数 31 + //SortItems []string `json:"sortItems"` //评比项
  32 + Self []RankItem `json:"self"` //自己或所在部门的排名分数
  33 + Lists [][]RankItem `json:"lists"` //排名列表
  34 + Total int `json:"total"` //总数
35 } 35 }
36 36
37 type RankItem struct { 37 type RankItem struct {
@@ -11,32 +11,35 @@ import ( @@ -11,32 +11,35 @@ import (
11 //排行榜 11 //排行榜
12 func GetRankList(header *protocol.RequestHeader, request *protocol.GetRankListRequest) (rsp *protocol.GetRankListResponse, err error) { 12 func GetRankList(header *protocol.RequestHeader, request *protocol.GetRankListRequest) (rsp *protocol.GetRankListResponse, err error) {
13 var ( 13 var (
14 - ranks []protocol.RankItem  
15 - selfRank *protocol.RankItem  
16 - rankRange *models.RankRange  
17 - itemKeys []string  
18 - itemNames []string 14 + ranks []protocol.RankItem
  15 + selfRank *protocol.RankItem
  16 + rankRange *models.RankRange
  17 + itemKeys []string
  18 + //itemNames []string
19 departments []*models.Department 19 departments []*models.Department
20 departmentId int64 20 departmentId int64
21 hasDepartmentInRank bool = true 21 hasDepartmentInRank bool = true
22 currentTotal int 22 currentTotal int
23 ) 23 )
  24 + rsp = &protocol.GetRankListResponse{
  25 + Self: make([]protocol.RankItem, 0),
  26 + Lists: make([][]protocol.RankItem, 0),
  27 + }
24 if rankRange, err = models.GetRankRangeById(request.RankRangeId); err != nil { 28 if rankRange, err = models.GetRankRangeById(request.RankRangeId); err != nil {
25 log.Error(err) 29 log.Error(err)
26 return 30 return
27 } 31 }
28 itemKeys = request.SortItemKeys 32 itemKeys = request.SortItemKeys
29 if len(itemKeys) == 0 { 33 if len(itemKeys) == 0 {
30 - if itemKeys, itemNames, err = models.GetRankItemKeys(header.CompanyId, request.RankTypeId); err != nil && err != orm.ErrNoRows { 34 + if itemKeys, _, err = models.GetRankItemKeys(header.CompanyId, request.RankTypeId); err != nil && err != orm.ErrNoRows {
31 log.Error(err) 35 log.Error(err)
32 return 36 return
33 } 37 }
34 } 38 }
35 - rsp = &protocol.GetRankListResponse{  
36 - Self: make([]protocol.RankItem, 0),  
37 - Lists: make([][]protocol.RankItem, 0), 39 + if len(itemKeys) == 0 {
  40 + return
38 } 41 }
39 - rsp.SortItems = itemNames 42 + //rsp.SortItems = itemNames
40 if rankRange.Type == protocol.RankRangeTypeAllCompanyDepartment || rankRange.Type == protocol.RankRangeTypeAllSpecifyDepartment { 43 if rankRange.Type == protocol.RankRangeTypeAllCompanyDepartment || rankRange.Type == protocol.RankRangeTypeAllSpecifyDepartment {
41 if departments, err = models.GetDepartmentByUser(header.UserId); err != nil { 44 if departments, err = models.GetDepartmentByUser(header.UserId); err != nil {
42 log.Error(err) 45 log.Error(err)