package com.tofly.ghrq_route.module.sign.service;

import android.content.Context;

import com.tofly.ghrq_route.base.URLResponseCode.ErrorCode;
import com.tofly.ghrq_route.module.deviceInfo.domain.DeviceInfoBean;
import com.tofly.ghrq_route.module.sign.controller.SignCallBack;
import com.tofly.ghrq_route.module.sign.domain.SignHistoryDataBean;
import com.tofly.ghrq_route.module.sqlite.DBDaoHelper;
import com.tofly.ghrq_route.common.ui.activity.UiSign;

import java.util.List;

/**
 * Created by Amu on 2017/3/14.
 */

public class SignServiceImplOffline implements ISignService {
    private Context mContext;
    private DBDaoHelper dbDaoHelper;

    public SignServiceImplOffline(Context context){
        mContext = context;
        dbDaoHelper = DBDaoHelper.getInstance();
    }

    @Override
    public void getSignStatusToday(Context context, String userid, final SignCallBack signCallBack) {
        int signState = UiSign.SIGN_UNCHECKED_TYPE;
        SignHistoryDataBean signHistoryData = dbDaoHelper.getLastSignHistory(userid);
        if (signHistoryData != null)
            signState = signHistoryData.getSignType();

        signCallBack.onGetSignStatusToday(true, ErrorCode.SUCCESS_OFFLINE, "", signState, 0);
    }

    @Override
    public void getSignListToday(Context context, String userid, final int pageindex, final int pagesize, final SignCallBack signCallBack) {
        int total = 0;
        List<SignHistoryDataBean> signHistoryDatas = dbDaoHelper.getSignHistorysToday(userid);
        if (signHistoryDatas != null) {
            total = signHistoryDatas.size();
        }
        signCallBack.onGetSignListToday(true, ErrorCode.SUCCESS_OFFLINE, "", signHistoryDatas, total);
    }

    @Override
    public void signToday(Context context, String userid, final SignHistoryDataBean signHistory, final DeviceInfoBean deviceInfo, final List<String> localPlanIds, final SignCallBack signCallBack) {
        signCallBack.onSignToday(true, ErrorCode.SUCCESS_OFFLINE, "", 0, 0, null);
    }

    @Override
    public void getDailyPlanAttened(Context context, String userid, final String date, final SignCallBack signCallBack) {
        int err_code = ErrorCode.LOGIN_OFFLINE;
        signCallBack.onGetDailyPlanAttened(false, err_code, ErrorCode.getErrorMessage(err_code), null);
    }
}
