作者 yangfu

排行榜排名项修改

... ... @@ -28,10 +28,10 @@ type GetRankListRequest struct {
PageSize int `json:"pageSize" valid:"Required"` //每页数量
}
type GetRankListResponse struct {
SortItems []string `json:"sortItems"` //评比项
Self []RankItem `json:"self"` //自己或所在部门的排名分数
Lists [][]RankItem `json:"lists"` //排名列表
Total int `json:"total"` //总数
//SortItems []string `json:"sortItems"` //评比项
Self []RankItem `json:"self"` //自己或所在部门的排名分数
Lists [][]RankItem `json:"lists"` //排名列表
Total int `json:"total"` //总数
}
type RankItem struct {
... ...
... ... @@ -11,32 +11,35 @@ import (
//排行榜
func GetRankList(header *protocol.RequestHeader, request *protocol.GetRankListRequest) (rsp *protocol.GetRankListResponse, err error) {
var (
ranks []protocol.RankItem
selfRank *protocol.RankItem
rankRange *models.RankRange
itemKeys []string
itemNames []string
ranks []protocol.RankItem
selfRank *protocol.RankItem
rankRange *models.RankRange
itemKeys []string
//itemNames []string
departments []*models.Department
departmentId int64
hasDepartmentInRank bool = true
currentTotal int
)
rsp = &protocol.GetRankListResponse{
Self: make([]protocol.RankItem, 0),
Lists: make([][]protocol.RankItem, 0),
}
if rankRange, err = models.GetRankRangeById(request.RankRangeId); err != nil {
log.Error(err)
return
}
itemKeys = request.SortItemKeys
if len(itemKeys) == 0 {
if itemKeys, itemNames, err = models.GetRankItemKeys(header.CompanyId, request.RankTypeId); err != nil && err != orm.ErrNoRows {
if itemKeys, _, err = models.GetRankItemKeys(header.CompanyId, request.RankTypeId); err != nil && err != orm.ErrNoRows {
log.Error(err)
return
}
}
rsp = &protocol.GetRankListResponse{
Self: make([]protocol.RankItem, 0),
Lists: make([][]protocol.RankItem, 0),
if len(itemKeys) == 0 {
return
}
rsp.SortItems = itemNames
//rsp.SortItems = itemNames
if rankRange.Type == protocol.RankRangeTypeAllCompanyDepartment || rankRange.Type == protocol.RankRangeTypeAllSpecifyDepartment {
if departments, err = models.GetDepartmentByUser(header.UserId); err != nil {
log.Error(err)
... ...