package com.kfzs.duanduan.datashare.provider.session;

// @formatter:off
import android.net.Uri;
import android.provider.BaseColumns;

import com.kfzs.duanduan.datashare.provider.KFZSDDProvider;
import com.kfzs.duanduan.datashare.provider.base.AbstractSelection;
import com.kfzs.duanduan.datashare.provider.downloadtask.DownloadtaskColumns;
import com.kfzs.duanduan.datashare.provider.records.RecordsColumns;
import com.kfzs.duanduan.datashare.provider.session.SessionColumns;

/**
 * A session info which is part of a team.
 */
@SuppressWarnings("unused")
public class SessionColumns implements BaseColumns {
    public static final String TABLE_NAME = "session";
    public static final Uri CONTENT_URI = Uri.parse(KFZSDDProvider.CONTENT_URI_BASE + "/" + TABLE_NAME);

    /**
     * Primary key.
     */
    public static final String _ID = BaseColumns._ID;

    /**
     * account of this session. For instance, John.
     */
    public static final String ACCOUNT = "account";

    /**
     * open_id of this session. For instance, John.
     */
    public static final String OPEN_ID = "open_id";

    /**
     * update time of this session.
     */
    public static final String UPDATE_TIME = "update_time";

    /**
     * token of this session.
     */
    public static final String TOKEN = "token";

    /**
     * uid at user of this session.
     */
    public static final String UID = "uid";

    /**
     * data hash save of this session.
     */
    public static final String HASH = "hash";


    public static final String DEFAULT_ORDER = TABLE_NAME + "." + ACCOUNT + AbstractSelection.DESC;

    public static final String[] ALL_COLUMNS = new String[] {
            _ID,
            ACCOUNT,
            OPEN_ID,
            UPDATE_TIME,
            TOKEN,
            UID,
            HASH
    };

    public static boolean hasColumns(String[] projection) {
        if (projection == null) return true;
        for (String c : projection) {
            if (c.equals(ACCOUNT) || c.contains("." + ACCOUNT)) return true;
            if (c.equals(OPEN_ID) || c.contains("." + OPEN_ID)) return true;
            if (c.equals(UPDATE_TIME) || c.contains("." + UPDATE_TIME)) return true;
            if (c.equals(TOKEN) || c.contains("." + TOKEN)) return true;
            if (c.equals(UID) || c.contains("." + UID)) return true;
            if (c.equals(HASH) || c.contains("." + HASH)) return true;
        }
        return false;
    }

}
