...
|
...
|
@@ -2,6 +2,7 @@ package models |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"opp/internal/utils"
|
|
|
"time"
|
|
|
|
|
|
"github.com/astaxie/beego/orm"
|
...
|
...
|
@@ -77,32 +78,33 @@ func GetRank(companyId, rankTypeId, rankRangeId, rankPeriodId int, relationId in |
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
//func GetRanksByUser(companyId, rankTypeId, rankRangeId, rankPeriodId int, relationId int64,v interface{})(total int, err error) {
|
|
|
// //var filterDepartment string = getFilterSqlByDIds(dIds)
|
|
|
// sql := fmt.Sprintf(`select a.*,b.nick_name name from (
|
|
|
//select ranking,score,relation_id,user_id from(
|
|
|
//select a.discovery_score score,a.relation_id,(@rowno:=@rowno+1) as ranking,user_id from rank a inner join user_company c on a.relation_id=c.id,(select (@rowno:=0)) b
|
|
|
//where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v
|
|
|
//order by a.discovery_score desc,c.create_at asc
|
|
|
//) a
|
|
|
//#where relation_id=?
|
|
|
//limit %v,%v
|
|
|
//)a inner join user b on a.user_id = b.id
|
|
|
//`, companyId,rankTypeId,rankRangeId,rankPeriodId,)
|
|
|
//
|
|
|
// //if public==protocol.pu
|
|
|
//
|
|
|
// sqlCount := fmt.Sprintf(`select count(0) from (
|
|
|
//select id from chance
|
|
|
//where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1 and status=1 %v
|
|
|
//) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId, filterDepartment)
|
|
|
// if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
|
|
|
// return
|
|
|
// }
|
|
|
// if v != nil {
|
|
|
// if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
|
|
|
// return
|
|
|
// }
|
|
|
// }
|
|
|
// return
|
|
|
//} |
|
|
func GetRanksByUser(companyId int64, rankTypeId, rankRangeId, rankPeriodId int, pageIndex, pageSize int, v interface{}) (total int, err error) {
|
|
|
//var filterDepartment string = getFilterSqlByDIds(dIds)
|
|
|
pageIndex, pageSize = utils.GetPageInfo(pageIndex, pageSize)
|
|
|
sql := fmt.Sprintf(`select a.*,b.nick_name name from (
|
|
|
select ranking,score,relation_id,user_id from(
|
|
|
select a.discovery_score score,a.relation_id,(@rowno:=@rowno+1) as ranking,user_id from rank a inner join user_company c on a.relation_id=c.id,(select (@rowno:=0)) b
|
|
|
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v
|
|
|
order by a.discovery_score desc,c.create_at asc
|
|
|
) a
|
|
|
#where relation_id=?
|
|
|
limit %v,%v
|
|
|
)a inner join user b on a.user_id = b.id
|
|
|
`, companyId, rankTypeId, rankRangeId, rankPeriodId, pageIndex, pageSize)
|
|
|
|
|
|
//if public==protocol.pu
|
|
|
|
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from rank
|
|
|
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v
|
|
|
`, companyId, rankTypeId, rankRangeId, rankPeriodId)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
|
|
}
|
|
|
if v != nil {
|
|
|
if err = utils.ExecuteQueryAll(v, sql); err != nil {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|