作者 yangfu

机会池 成果池按部门统计修改

... ... @@ -32,6 +32,7 @@ func (this *AchievementController) AchievementPool() {
return
}
header := controllers.GetRequestHeader(this.Ctx)
request.IncludeSubDepartment = false
msg = protocol.NewReturnResponse(chance.AchievementPool(header, request))
}
... ...
... ... @@ -611,7 +611,7 @@ func (this *ChanceController) ChancePool() {
msg = m
return
}
request.IncludeSubDepartment = true
request.IncludeSubDepartment = false
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}
... ...
... ... @@ -85,9 +85,9 @@ func GetRankRanges(companyId int, rankTypeId int) (v []*RankRange, err error) {
if companyId > 0 {
sql.Where(fmt.Sprintf("company_id=%v", companyId))
}
if rankTypeId > 0 {
sql.Where(fmt.Sprintf("rank_type_id=%v", rankTypeId))
}
//if rankTypeId > 0 {
sql.Where(fmt.Sprintf("rank_type_id=%v", rankTypeId))
//}
sql.Order("sort_num")
_, err = sql.Querys(&v)
return
... ...
... ... @@ -47,11 +47,12 @@ type AchievementCommonListItem struct {
/*AchievementPool 成果池*/
type AchievementPoolRequest struct {
UserId int64 `json:"userId"`
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会
DepartmentId int `json:"departmentId"`
UserId int64 `json:"userId"`
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会
DepartmentId int `json:"departmentId"`
IncludeSubDepartment bool
}
type AchievementPoolResponse struct {
List []*AchievementCommonListItem `json:"list"`
... ...
... ... @@ -53,7 +53,7 @@ type RankType struct {
/*GetRankRange */
type GetRankRangeRequest struct {
RankTypeId int `json:"rankTypeId" valid:"Required"`
RankTypeId int `json:"rankTypeId"` // valid:"Required"
}
type GetRankRangeResponse struct {
List []RankRange `json:"rankRanges"`
... ... @@ -66,7 +66,7 @@ type RankRange struct {
/*GetRankPeriods 获取榜单竞争范围列表*/
type GetRankPeriodsRequest struct {
RankTypeId int `json:"rankTypeId" valid:"Required"`
RankTypeId int `json:"rankTypeId"`
}
type GetRankPeriodsResponse struct {
List []RankPeriod `json:"rankPeriods"`
... ... @@ -88,7 +88,7 @@ type ComputeRankScoreResponse struct {
/*GetRankSortItems */
type GetRankSortItemsRequest struct {
RankTypeId int `json:"rankTypeId" valid:"Required"`
RankTypeId int `json:"rankTypeId"`
}
type GetRankSortItemsResponse struct {
RankSortItems []RankSortItem `json:"rankSortItems"`
... ...
... ... @@ -19,7 +19,7 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme
)
rsp = &protocol.AchievementPoolResponse{}
rsp.List = make([]*protocol.AchievementCommonListItem, 0)
if request.DepartmentId > 0 {
if request.DepartmentId > 0 && request.IncludeSubDepartment {
if d, e := models.GetDepartmentById(request.DepartmentId); e != nil {
log.Error(err)
err = e
... ... @@ -30,6 +30,10 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme
return
}
}
} else {
if request.DepartmentId > 0 {
departmentIds = []int{request.DepartmentId}
}
}
if total, err = models.GetAchievementAll(request.UserId, header.CompanyId, request.ChanceTypeId, request.LastId, departmentIds, request.PageSize, &ormItems); err != nil {
if err == orm.ErrNoRows {
... ...
... ... @@ -125,6 +125,9 @@ func GetRankType(header *protocol.RequestHeader, request *protocol.GetRankTypeRe
var (
lists []*models.RankType
)
rsp = &protocol.GetRankTypeResponse{
List: make([]protocol.NameItem, 0),
}
if lists, err = models.GetRankTypes(header.CompanyId); err != nil {
if err == orm.ErrNoRows {
err = nil
... ... @@ -133,7 +136,7 @@ func GetRankType(header *protocol.RequestHeader, request *protocol.GetRankTypeRe
log.Error(err)
return
}
rsp = &protocol.GetRankTypeResponse{}
for i := range lists {
rsp.List = append(rsp.List, protocol.NameItem{Id: lists[i].Id, Name: lists[i].Name})
}
... ... @@ -148,6 +151,9 @@ func GetRankRange(header *protocol.RequestHeader, request *protocol.GetRankRange
rsp = &protocol.GetRankRangeResponse{
List: make([]protocol.RankRange, 0),
}
if request.RankTypeId == 0 {
return
}
if lists, err = models.GetRankRanges(int(header.CompanyId), request.RankTypeId); err != nil {
if err == orm.ErrNoRows {
err = nil
... ... @@ -177,6 +183,9 @@ func GetRankPeriods(header *protocol.RequestHeader, request *protocol.GetRankPer
lists []*models.RankPeriod
)
rsp = &protocol.GetRankPeriodsResponse{List: make([]protocol.RankPeriod, 0)}
if request.RankTypeId == 0 {
return
}
if lists, err = models.GetRankPeriods(int(header.CompanyId), request.RankTypeId, []int{protocol.RankPeriodBegin, protocol.RankPeriodEnd}); err != nil {
if err == orm.ErrNoRows {
err = nil
... ... @@ -205,6 +214,9 @@ func GetRankSortItems(header *protocol.RequestHeader, request *protocol.GetRankS
rsp = &protocol.GetRankSortItemsResponse{
RankSortItems: make([]protocol.RankSortItem, 0),
}
if request.RankTypeId == 0 {
return
}
if err = models.GetRankItems(header.CompanyId, request.RankTypeId, &sortItems); err != nil {
if err == orm.ErrNoRows {
err = nil
... ...