package com.android.chmo.http.service;

import com.android.chmo.app.ChmoApplication;
import com.android.chmo.constant.Constants;
import com.android.chmo.http.HttpApi;
import com.android.chmo.http.RequestCallback;
import com.android.chmo.model.ActivitiesInfo;
import com.android.chmo.model.LoginUser;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;

/**
 * Created by Administrator on 2018/8/2.
 */

public class ActivitiesService {

    private static RequestParams getRequestParams() {
        RequestParams params = new RequestParams(HttpApi.BASE_URL + "activity");
        return params;
    }

    /**
     *  活动列表
     */
    public static Callback.Cancelable getActivityList(int pageNo, RequestCallback callback) {
        LoginUser user = ChmoApplication.getApp().getLoginUser();
        RequestParams params = getRequestParams();
        params.addQueryStringParameter("action", "dogetpartty");
        params.addQueryStringParameter("memberpk", user.pk);
        params.addQueryStringParameter("index", pageNo+"");
        params.addQueryStringParameter("size", Constants.PAGE_SIZE+"");

        return HttpApi.GET(params, callback);
    }

    public static  Callback.Cancelable signIn(ActivitiesInfo info, String member, String contact, String count, String price, RequestCallback callback) {
        RequestParams params = getRequestParams();
        params.addQueryStringParameter("action", "doEnroll");
        params.addQueryStringParameter("PK", ChmoApplication.getApp().getLoginUser().pk);
        params.addQueryStringParameter("ParttyPK", info.pk);
        params.addQueryStringParameter("people", member);
        params.addQueryStringParameter("Tel", contact);
        params.addQueryStringParameter("pCount", count);
        params.addQueryStringParameter("Fee", price);

        return HttpApi.GET(params, callback);
    }

    /**
     *  我参加的活动列表
     */
    public static Callback.Cancelable getMyActivities(int pageNo, RequestCallback callback) {
        LoginUser user = ChmoApplication.getApp().getLoginUser();
        RequestParams params = getRequestParams();
        params.addQueryStringParameter("action", "doqrypartty");
        params.addQueryStringParameter("PK", user.pk);
        params.addQueryStringParameter("index", pageNo+"");
        params.addQueryStringParameter("size", Constants.PAGE_SIZE+"");
        return HttpApi.GET(params, callback);
    }


    /**
     *  我参加的活动列表
     */
    public static Callback.Cancelable getBanner(RequestCallback callback) {
        LoginUser user = ChmoApplication.getApp().getLoginUser();
        RequestParams params = getRequestParams();
        params.addQueryStringParameter("action", "doGetBanner");
        return HttpApi.GET(params, callback);
    }
}
