#ifndef SINFLUENCER
#define SINFLUENCER
#include "sservice.h"
#include "sfilteralgorithm.h"
#include "sinitializer.h"
#include <QVector>
class QString;
class QStringList;
class SInfluencer:public SService
{
public:
    struct stReal
    {
        QSet<QString> m_setRealAllUrl;
        QSet<QString> m_setRealBodyUrl;
        QMap<QString, int> m_mapRealReplyUniqueUrl; //multiple
    };
    struct stInfluencer
    {
        int id_num;
        int nickname_num;
        int community_num;
        int category_num;
        QString id_id;
        QString profile;
        QString profileurl;
        int bodycount;
        int replycount;
        double influencervalue;
        int rank;
        QString community_title;
        QString community_url;
        QString community_id;
        QString nickname_nickname;
        QString nickname_exnickname;
        QString platformname_name;
        int platformname_num;

        stInfluencer():id_num(0),nickname_num(0),community_num(0),category_num(0),bodycount(0),replycount(0),rank(0),influencervalue(0.0),platformname_num(0){}

    };
    struct stStatsInfBloggerRank
    {
        QString id_id;
        QString nickname_nickname;
        int bodycount;
        int replycount;
        double influencevalue;
        QString subject;
        int company_num;
        int rank;
        stStatsInfBloggerRank():bodycount(0),replycount(0),rank(0),influencevalue(0.0){}
        stStatsInfBloggerRank(const QString &_id_id, const QString &_nickname_nickname):id_id(_id_id),nickname_nickname(_nickname_nickname),
            bodycount(0), replycount(0), rank(0), influencevalue(0.0) {}
    };

    struct stStatsInfBloggerBuzzbyday
    {
        QString date;
        int formateddate;
        int idcount;
        int bodycount;
        int replycount;
        int company_num;
        stStatsInfBloggerBuzzbyday():formateddate(0), idcount(0), bodycount(0), replycount(0), company_num(0){}
    };

    struct stBodyInfluencerMap
    {
        int num;
        int body_num;
        int id_num;
        int category_num;
        int realin;
        int community_num;
        QString body_date;
        stBodyInfluencerMap():num(0),body_num(0), id_num(0), category_num(0), realin(0), community_num(0){}
    };
    struct stReplyInfluencerMap
    {
        int num;
        int reply_num;
        int body_num;
        int id_num;
        int category_num;
        int realin;
        int community_num;
        QString body_date;
        stReplyInfluencerMap():num(0),reply_num(0),body_num(0),id_num(0),category_num(0),realin(0),community_num(0){}
    };
    class STInfluencer
    {
    private:
        SInitializer *m_pSInitializer;
        QList<stInfluencer> m_listMap;
    public:
        void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
        void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
        bool uploadData(QSqlDatabase &_db, const int &_nCompany);
        bool changeTable(QSqlDatabase &_db, const int &_nCompany);
        void clear(){ m_listMap.clear(); }
    };

    class SStatsInfBloggerRank
    {
    private:
        SInitializer *m_pSInitializer;
        QList<stStatsInfBloggerRank> m_listMap;
    public:
        void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
        void clear(){ m_listMap.clear(); }
        void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
        bool uploadData(QSqlDatabase &_db, const int &_nCompany);
    };

    class SStatsInfBloggerBuzzbyday
    {
    private:
        SInitializer *m_pSInitializer;
        QList<stStatsInfBloggerBuzzbyday> m_listMap;
    public:
        void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
        void clear(){ m_listMap.clear(); }
        void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
        bool uploadData(QSqlDatabase &_db, const int &_nCompany);
    };

    class SBodyInfluencerMap
    {
    private:
        SInitializer *m_pSInitializer;
        QList<stBodyInfluencerMap> m_listMap;
    public:
        void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
        void clear(){ m_listMap.clear(); }
        void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
        bool uploadData(QSqlDatabase &_db, const int &_nCompany);
        bool changeTable(QSqlDatabase &_db, const int &_nCompany);
    };

    class SReplyInfluencerMap
    {
    private:
        SInitializer *m_pSInitializer;
        QList<stReplyInfluencerMap> m_listMap;
    public:
        void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
        void clear(){ m_listMap.clear(); }
        void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
        bool uploadData(QSqlDatabase &_db, const int &_nCompany);
        bool changeTable(QSqlDatabase &_db, const int &_nCompany);
    };

    struct isGreaterInfluencerValue
    {
        bool operator()(const stInfluencer& first,  const stInfluencer& second)
        {
            return first.influencervalue > second.influencervalue;
        }
        bool operator()(const stStatsInfBloggerRank& first, const stStatsInfBloggerRank& second)
        {
            return first.influencevalue > second.influencevalue;
        }
    };

    struct isGreaterBodyCount
    {
        bool operator()(const stStatsInfBloggerRank& first, const stStatsInfBloggerRank& second)
        {
            return first.bodycount > second.bodycount;
        }
        bool operator()(const stInfluencer& first,  const stInfluencer& second)
        {
            return first.bodycount > second.bodycount;
        }
    };

    struct isGreaterReplyCount
    {
        bool operator()(const stStatsInfBloggerRank& first, const stStatsInfBloggerRank& second)
        {
            return first.replycount > second.replycount;
        }
        bool operator()(const stInfluencer& first,  const stInfluencer& second)
        {
            return first.replycount > second.replycount;
        }
    };
    struct stInfluenceBuzz
    {
        int bodycount;
        int replycount;
        QSet<QString> idcount;
        stInfluenceBuzz():bodycount(0), replycount(0) {}
    };

private:
    SFilterAlgorithm m_SFilterAlgorithm;
    QMap<int, stReal> m_mapCategory;
    SBodyInfluencerMap m_SBodyInfluencerMap;
    SReplyInfluencerMap m_SReplyInfluencerMap;
    SStatsInfBloggerBuzzbyday m_SStatsInfBloggerBuzzbyday;
    SStatsInfBloggerRank m_SStatsInfBloggerRank;
    STInfluencer m_STInfluencer;

public:
    virtual void setInitiaizer(SInitializer &_initializer);
    virtual bool uploadData(int _companyNum);
    virtual bool changeTable(int _companyNum);
    virtual bool makeCategory(SDatagroup &_datagroup, int _nCategory, const QList<SInitializer::stFilter> &_listFilter);
    virtual bool makeOverallCategory(int _categoryNum);
    virtual bool makeTable(SDatagroup &_datagroup);

};


#endif // SINFLUENCER

