2021-06-24 18:19:28 +08:00
using Assets.Scripts.Apis.Models ;
using Newtonsoft.Json ;
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
2021-09-07 16:11:15 +08:00
using UnityEngine ;
2021-06-24 18:19:28 +08:00
namespace Assets.Scripts.Apis
{
internal class MapCompetitionApi : ApiBase
{
/// <summary>
/// 比赛实体
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public JsonResult < MapCompetition > GetById ( int id )
{
return Get < JsonResult < MapCompetition > > ( "/MapCompetition/GetDetail?id=" + id ) ;
}
/// <summary>
/// 获取当前比赛排名
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
2021-09-07 16:11:15 +08:00
public JsonResult < List < CompetitionRankingResultModel > > GetRankingListAsync ( int id )
2021-06-24 18:19:28 +08:00
{
2021-09-07 16:11:15 +08:00
var list = Get < JsonResult < CompetitionRankingResultListModel > > ( $"/MapRecord/GetCompetitionRanking?id={ id }&pageIndex=0&pageSize=999" ) ;
2021-06-24 18:19:28 +08:00
return new JsonResult < List < CompetitionRankingResultModel > >
{
result = list . result ,
errMsg = list . errMsg ,
data = Newtonsoft . Json . JsonConvert . DeserializeObject < List < CompetitionRankingResultModel > > ( JsonConvert . SerializeObject ( list . data . list ) )
} ;
}
//查询我参与的比赛列表
2021-07-23 18:07:12 +08:00
public JsonResult < List < JoinedCompetitionModel > > GetMyCompetitionList ( )
2021-06-24 18:19:28 +08:00
{
2021-09-07 16:11:15 +08:00
var list = Get < JsonResult < List < JoinedCompetitionModel > > > ( $"/MapCompetition/v0/GetMyList" ) ;
2021-06-24 18:19:28 +08:00
return new JsonResult < List < JoinedCompetitionModel > >
{
result = list . result ,
errMsg = list . errMsg ,
data = Newtonsoft . Json . JsonConvert . DeserializeObject < List < JoinedCompetitionModel > > ( JsonConvert . SerializeObject ( list . data ) )
} ;
}
//查询比赛列表
public JsonResult < List < MapCompetitionModel > > GetCompetitionList ( string name , int pageIndex , int pageSize , int status = 0 )
{
2021-09-07 16:11:15 +08:00
var list = Get < JsonResult < List < MapCompetitionModel > > > ( $"/MapCompetition/v1/GetList?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&status={ status }" ) ;
2021-06-24 18:19:28 +08:00
return new JsonResult < List < MapCompetitionModel > >
{
result = list . result ,
errMsg = list . errMsg ,
data = Newtonsoft . Json . JsonConvert . DeserializeObject < List < MapCompetitionModel > > ( JsonConvert . SerializeObject ( list . data ) )
} ;
}
2021-07-23 15:04:29 +08:00
public async Task < JsonResult < List < MapCompetition > > > GetCompetitionListV2 ( string name , int pageIndex , int pageSize , string status = "" , int order = 1 , bool self = false , int activity = 0 )
2021-07-20 09:58:01 +08:00
{
2021-09-07 16:11:15 +08:00
var list = await GetAsync < JsonResult < List < MapCompetition > > > ( $"/MapCompetition/v2/GetList?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&status={ status }&order={order}&self={self}&activity={activity}" ) ;
Debug . Log ( "67" ) ;
2021-07-20 09:58:01 +08:00
return new JsonResult < List < MapCompetition > >
{
result = list . result ,
errMsg = list . errMsg ,
data = Newtonsoft . Json . JsonConvert . DeserializeObject < List < MapCompetition > > ( JsonConvert . SerializeObject ( list . data ) )
} ;
}
2021-06-24 18:19:28 +08:00
//查询比赛详情
public JsonResult < MapCompetitionDetailModel > GetCompetitionDetail ( int id )
{
2021-09-07 16:11:15 +08:00
var list = Get < JsonResult < MapCompetitionDetailModel > > ( $"/MapRouteGlobalCycling/Get?id={ id }" ) ;
2021-06-24 18:19:28 +08:00
return new JsonResult < MapCompetitionDetailModel >
{
result = list . result ,
errMsg = list . errMsg ,
data = Newtonsoft . Json . JsonConvert . DeserializeObject < MapCompetitionDetailModel > ( JsonConvert . SerializeObject ( list . data ) )
} ;
}
2021-06-29 18:03:20 +08:00
//报名比赛
2021-07-23 09:04:56 +08:00
public JsonResult ApplyMapCompetition ( int id )
2021-06-24 18:19:28 +08:00
{
2021-06-29 18:03:20 +08:00
var param = new
{
id = id ,
} ;
2021-07-23 09:04:56 +08:00
return Post < JsonResult > ( $"/MapCompetition/ApplyMapCompetition" , param ) ;
}
//取消报名比赛
public JsonResult CancelMapCompetition ( int id )
{
var param = new
{
id = id ,
} ;
return Post < JsonResult > ( $"/MapCompetition/CancelMapCompetition" , param ) ;
2021-06-24 18:19:28 +08:00
}
2021-07-26 14:09:21 +08:00
2021-06-24 18:19:28 +08:00
}
}