package com.cnd3b.restcontroller.singleagent.appclient;

import com.cnd3b.common.Controller;
import com.cnd3b.common.data.Rows;
import com.cnd3b.common.data.SQLFactory;

import com.alibaba.fastjson.JSONObject;
public class mainpage extends Controller {
    public mainpage(JSONObject content) {
        super(content);
    }

    /**
     * 首页简报
     *
     * @return
     */
    public String query_briefreport() {
        StringBuffer where = new StringBuffer(" 1=1 ");
        if (!fisadministrator) {
            where.append(" and (t1.tenterprise_userid is null or t1.tenterprise_userid='").append(userid).append("' or t1.tenterprise_userid in ( select fsubid from tenterprise_userdetail where siteid='").append(siteid).append("' and fparentid='").append(userid).append("' )) ");
        }
        SQLFactory factory = new SQLFactory(this, "首页简报");
        factory.addParameter("siteid", siteid);
        factory.addParameter("tagentsid", tagentsid);
        factory.addParameter_SQL("where", where);
        Rows rows = dbConnect.runSqlQuery(factory.getSQL());
        return getSucReturnObject().setData(rows.get(0)).saveToDataPool(1).toString();
    }

    /**
     * 今日动态,一周内开单记录
     *
     * @return
     */
    public String query_newcustmsg() {
        StringBuffer where = new StringBuffer(" 1=1 ");
        if (!fisadministrator) {
            where.append(" and (t1.tenterprise_userid is null or t1.tenterprise_userid='").append(userid).append("' or t1.tenterprise_userid in ( select fsubid from tenterprise_userdetail where siteid='").append(siteid).append("' and fparentid='").append(userid).append("' )) ");
        }
        SQLFactory factory = new SQLFactory(this, "今日动态");
        factory.addParameter("siteid", siteid);
        factory.addParameter("tagentsid", tagentsid);
        factory.addParameter_SQL("where", where);
        Rows rows = dbConnect.runSqlQuery(factory.getSQL());
        return getSucReturnObject().setData(rows).saveToDataPool().toString();
    }
}
