const system=require("../../../system");
const fs=require("fs");
const settings=require("../../../../config/settings");
var glob = require("glob");
class APIDocManager{
   constructor(){
     this.doc={};
     this.buildAPIDocMap();
  }
  async buildAPIDocMap(){
     var self=this;
     //订阅任务频道
     var apiPath=settings.basepath+"/app/base/api/impl";
     var rs = glob.sync(apiPath + "/**/*.js");
     if(rs){
        for(let r of rs){
          // var ps=r.split("/");
          // var nl=ps.length;
          // var pkname=ps[nl-2];
          // var fname=ps[nl-1].split(".")[0];
          // var obj=system.getObject("api."+pkname+"."+fname);
        
          var ClassObj=require(r);
          var obj=new ClassObj();
          var gk=obj.apiDoc.group+"|"+obj.apiDoc.groupDesc
          if(!this.doc[gk]){
            this.doc[gk]=[];
            this.doc[gk].push(obj.apiDoc);
          }else{
            this.doc[gk].push(obj.apiDoc);
          }
        }
    }
  }
}
module.exports=APIDocManager;
