'use strict';
/*global require, module, Buffer, ccs*/

/*
    convertID(id);
    getArticlesIndex(date, limit, callback);
    getLatestId(callback);
    getArticle(_id, callback);
    setArticle(articleObj, callback);
    setFavor(articleObj);
    setOppose(articleObj);
    setMark(articleObj);
    setComment(articleObj, callback);
    setNewArticle(articleObj, callback);
    delArticle(_idArray, callback);
 */
var union = ccs.lib.tools.union,
    intersect = ccs.lib.tools.intersect,
    IDString = ccs.lib.json.IDString,
    //defautMyCust = ccs.lib.json.mycust,
    globalConfig = ccs.lib.json.GlobalConfig,
    callbackFn = ccs.lib.tools.callbackFn,
    wrapCallback = ccs.lib.tools.wrapCallback,
    converter = ccs.lib.converter;

var that = ccs.dao.db.bind('tempdata', {

    //获取全部机构数据
    getjgCountReport: function (role,khjg,callback) {
        if(role>3)
        {
            that.find({}, {
                sort: {
                    KHJG: -1
                }
            }, wrapCallback(callback));
        }else if(role == 3)
        {
            that.find({KHJG:+khjg}, {
                sort: {
                    KHJG: -1
                }
            }, wrapCallback(callback));
        }



    },//获取全部机构数据

    //查询某支行首页数据
    gettotalzhyezhgl: function (ssjg, callback) {
        that.findOne({
            KHJG: +ssjg
        }, {
            sort: {
                _id: -1
            }
        }, wrapCallback(callback));
    },//查询某支行首页数据

    //获取分行首页数据
    gettotalzhyefhglzh: function (callback) {
        that.findOne({
            KHJG: 11111
        }, {
            sort: {
                _id: -1
            }
        }, wrapCallback(callback));
    }//获取分行首页数据
});



module.exports = {
    gettotalzhyefhglzh:that.gettotalzhyefhglzh,//获取分行首页数据
    gettotalzhyezhgl:that.gettotalzhyezhgl,//查询某支行首页数据
    getjgCountReport:that.getjgCountReport//获取全部机构数据

};