作者 tangxvhui

赛季列表调整

... ... @@ -89,15 +89,18 @@ func (c RankController) RankSeasonList() {
defer func() {
c.ResposeJson(msg)
}()
var param protocol.RequestPageInfo
type Parameter struct {
protocol.RequestPageInfo
RankTypeId int64 `json:"rank_type_id"`
}
var param Parameter
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
log.Error("json 解析失败 err:%s", err)
msg = protocol.BadRequestParam("1")
return
}
companyid := c.GetCompanyId()
rspData, err := serverank.RankSeasonList(param.PageIndex, param.PageSize, companyid)
rspData, err := serverank.RankSeasonList(param.PageIndex, param.PageSize, param.RankTypeId, companyid)
msg = protocol.NewReturnResponse(rspData, err)
return
}
... ...
... ... @@ -144,7 +144,7 @@ func AllowRank(id int64, companyid int64) error {
}
//RankSeasonList ..获取赛季列表
func RankSeasonList(pageindex int, pagesize int, companyid int64) (protocol.ResponseRankSeasonList, error) {
func RankSeasonList(pageindex int, pagesize int, rankTypeId int64, companyid int64) (protocol.ResponseRankSeasonList, error) {
var (
err error
listdata []protocol.RankSeasonItem
... ... @@ -157,10 +157,10 @@ func RankSeasonList(pageindex int, pagesize int, companyid int64) (protocol.Resp
List: make([]protocol.RankSeasonItem, 0),
}
pageStart := (pageindex - 1) * pagesize
datasql := `SELECT id,season_name,begin_time,end_time,status FROM rank_period WHERE company_id = ?`
datasql := `SELECT id,season_name,begin_time,end_time,status FROM rank_period WHERE company_id = ? AND rank_type_id=? `
datasql = fmt.Sprintf("%s ORDER BY begin_time DESC limit %d,%d", datasql, pageStart, pagesize)
countsql := `SELECT COUNT(*) FROM rank_period WHERE company_id = ?`
err = utils.ExecuteQueryOne(&cnt, countsql, companyid)
countsql := `SELECT COUNT(*) FROM rank_period WHERE company_id = ? AND rank_type_id=? `
err = utils.ExecuteQueryOne(&cnt, countsql, companyid, rankTypeId)
if err != nil {
log.Error("EXCUTE SQL ERR:%s", err)
return rspData, nil
... ... @@ -168,7 +168,7 @@ func RankSeasonList(pageindex int, pagesize int, companyid int64) (protocol.Resp
if cnt <= 0 {
return rspData, nil
}
err = utils.ExecuteQueryAll(&listdata, datasql, companyid)
err = utils.ExecuteQueryAll(&listdata, datasql, companyid, rankTypeId)
if err != nil {
log.Error("EXCUTE SQL ERR:%s", err)
return rspData, nil
... ...