package logic import ( "HttpServer/redishandler" "common/logger" "common/redis" "encoding/json" "net/http" "sort" "strconv" "strings" "time" ) func SetHeader(w http.ResponseWriter) { w.Header().Set("Access-Control-Allow-Origin", "*") //允许访问所有域 w.Header().Set("Content-Type", "application/json") w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid") } func (tinfo *TeamInfo) DoAddBuffTimee(btype int,muti int,resp *AddTeamBuffResp) { addtime := 1800*muti index := 0 for k,val := range tinfo.BInfo.Buff { if val.Type == btype { index = k } } for i:=0;i= nowtime { tinfo.BInfo.Buff[index].BuffInfo[len(tinfo.BInfo.Buff[index].BuffInfo)-1].EndTime += addTime } else { var tmp TeamBuffInfo tmp.BeginTime = nowtime tmp.EndTime = nowtime + addTime tinfo.BInfo.Buff[index].BuffInfo = append(tinfo.BInfo.Buff[index].BuffInfo,tmp) } }else { tinfo.BInfo.Buff[index].BuffInfo[len(tinfo.BInfo.Buff[index].BuffInfo)-1].EndTime += 86399 } //删除掉无用的 yestime := nowtime-86400 for i:=0;i sumlen{ begin = sumlen - 10 } if end > sumlen { end = sumlen - 1 } return rtslice[begin:end],nil,sumlen } func GetTeamListByNameCond(shopnum int,page int, name string) (TeamSlice,error,int) { if page < 0 { logger.Error("GetTeamListByCond invalid page=%v",page) page = 1 } var rtslice TeamSlice vv,err := redishandler.GetRedisClient().HGetAllValues(redis.TEAM_INFO) if err != nil { logger.Error("GetTeamListByCond err") return nil,err,0 } for _,val := range vv { one := new(TeamInfo) bytestr := val.([]byte) err = json.Unmarshal(bytestr, one) if err == nil { if one.BaseInfo.Num <= shopnum && strings.Index(one.BaseInfo.Name,name) != -1{ rtslice = append(rtslice,one) } } } //排序 sort.Sort(rtslice) begin := (page-1) * 10 end := begin + 9 sumlen := len(rtslice) if begin > sumlen{ begin = sumlen - 10 } if end > sumlen { end = sumlen - 1 } return rtslice[begin:end],nil,sumlen }