#ifndef SCONSUMER
#define SCONSUMER
#include "sservice.h"
#include "sfilteralgorithm.h"
#include <QDate>
class SConsumer:public SService
{
public:
    struct stReal
    {
        QSet<QString> m_setRealAllUrl;
        QSet<QString> m_setRealBodyUrl;
        QMap<QString, int> m_mapRealReplyUniqueUrl; //multiple
    };
    struct stBodyConsumerMap
    {
        int num;
        int body_num;
        int category_num;
        int realin;
        int platformname_num;
        int platformform_num;
        QString body_date;
        int body_replycount;
        int body_view;
        int body_id_num;
        stBodyConsumerMap():num(0), body_num(0), category_num(0), realin(0), platformname_num(0), platformform_num(0), body_replycount(0), body_view(0), body_id_num(0){}
    };
    struct stReplyConsumerMap
    {
        int num;
        int reply_num;
        int body_num;
        int id_num;
        int category_num;
        int realin;
        stReplyConsumerMap():num(0), reply_num(0), body_num(0), id_num(0), category_num(0), realin(0) {}
    };
    struct stStatsConUserBuzzybyday
    {
        int category[11];
        QDate date;
        QString subject;
        int company_num;
        stStatsConUserBuzzybyday():company_num(0)
        {
            for (int i = 0; i < 11; i++)
                category[i] = 0;
        }
    };
    struct stBuzzy
    {
        int m_nCategory;
        QMap<QDate, int> m_mapBodyBuzz;
        QMap<QDate, int> m_mapReplyBuzz;
    };

    class SBodyConsumerMap
    {
    private:
        SInitializer *m_pSInitializer;
        QList<stBodyConsumerMap> m_listMap;
    public:
        void setInitiaizer(SInitializer &_SInitializer) { m_pSInitializer = &_SInitializer; }
        void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
        bool changeTable(QSqlDatabase& _db, const int &_nCompany);
        bool uploadData(QSqlDatabase& _db, const int &_nCompany);
        void clear() { m_listMap.clear(); }
    };
    class SReplyConsumerMap // Why did you define this?
    {
    private:
        SInitializer *m_pSInitializer;
        QList<stReplyConsumerMap> m_listMap;
    public:
        void setInitiaizer(SInitializer &_SInitializer) { m_pSInitializer = &_SInitializer; }
        void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
        bool changeTable(QSqlDatabase& _db, const int &_nCompany);
        bool uploadData(QSqlDatabase& _db, const int &_nCompany);
        void clear(){ m_listMap.clear(); }

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

private:
    SFilterAlgorithm m_SFilterAlgorithm;
    QMap<int, stReal> m_mapCategory;
    SBodyConsumerMap m_SBodyConsumerMap;
    SStatsConUserBuzzybyday m_SStatsConUserBuzzybyday;

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 _nCategory);
    virtual bool makeTable(SDatagroup &_datagroup);
};





#endif // SCONSUMER

