const system=require("../../system");
const ServiceBase=require("../sve.base");
class AppService extends ServiceBase{
  constructor(){
     super(ServiceBase.getDaoName(AppService));
     //this.appDao=system.getObject("db.appDao");
  }
  getApp(appkey){
    return   this.cacheManager["AppCache"].cacheApp(appkey);
  }
  async findAndCountAll(obj){
     var self=this;
     const apps=await super.findAndCountAll(obj);
     for(let i=0;i<apps.rows.length;i++){
       var  a=apps.rows[i];
       var appkey=a.appid;
       var apicallAccu= await this.cacheManager["ApiAccuCache"].getApiCallAccu(appkey);
       a.apiCallCount=apicallAccu.callcount;
       a.amount=apicallAccu.amount;

     }
     return apps;
  }
}
module.exports=AppService;
