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.LoginUser;

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

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

public class FindService {

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

    /**
     *  发现列表
     */
    public static Callback.Cancelable getFindList(String pk, int pageNo, RequestCallback callback) {
        RequestParams params = getRequestParams();
        params.addQueryStringParameter("action", "findmodel");
        params.addQueryStringParameter("MemberPk", pk);
        params.addQueryStringParameter("index", pageNo+"");
        params.addQueryStringParameter("size", Constants.PAGE_SIZE+"");
        return HttpApi.GET(params, callback);
    }

    public static  Callback.Cancelable getCommentList(String pk, int pageNo, RequestCallback callback) {
        RequestParams params = getRequestParams();
        params.addQueryStringParameter("action", "findmodelprivatelimit");
        params.addQueryStringParameter("privatePk", pk);
        params.addQueryStringParameter("index", pageNo+"");
        params.addQueryStringParameter("size", Constants.PAGE_SIZE+"");
        return HttpApi.GET(params, callback);
    }

    public static  Callback.Cancelable sendComment(String pk, String content, RequestCallback callback) {
        LoginUser user = ChmoApplication.getApp().getLoginUser();
        RequestParams params = getRequestParams();
        params.addQueryStringParameter("action", "doAddPrivateRecord");
        params.addQueryStringParameter("PrivatePK", pk);
        params.addQueryStringParameter("PK", user.pk);
        params.addQueryStringParameter("RecordInfoPK", "0");
        params.addQueryStringParameter("Intro", content);
        return HttpApi.GET(params, callback);
    }

    public static  Callback.Cancelable setGood(String pk,int type, RequestCallback callback) {
        LoginUser user = ChmoApplication.getApp().getLoginUser();
        RequestParams params = getRequestParams();
        params.addQueryStringParameter("action", "likes");
        params.addQueryStringParameter("privatePk", pk);
        params.addQueryStringParameter("memberPk", user.pk);
        params.addQueryStringParameter("type", type+"");
        return HttpApi.GET(params, callback);
    }
}
