var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class LoopplayCtl extends CtlBase{
   constructor(){
     super(CtlBase.getServiceName(LoopplayCtl));
     //this.appS=system.getObject("service.appSve");
   }

   async  findById(q,oid){
      return super.findById(Number(oid.id));
   }
   async findByChannelcode(qobj,obj,req){
     if(obj.channelcode==null||obj.channelcode==""||obj.channelcode=="undefined"){
       return {code:-1,msg:"参数channelcode错误"};
     }
     var result=await this.service.findByChannelcode(obj);
     return {code:1,msg:"success",data:result};
   }

   async findAll(queryobj,obj,req){
    var lst= await this.service.findAll();
    return system.getResult2(lst,null);
  }
   async findAndCountAll(queryobj,obj,req){
     obj.codepath=req.codepath;

     if(req.session.user){
       obj.uid=req.session.user.id;
       obj.appid=req.session.user.app_id;
       obj.onlyCode=req.session.user.unionId;
       obj.account_id=req.session.user.account_id;
       obj.ukstr=req.session.user.app_id+"￥"+req.session.user.id+"￥"+req.session.user.nickName+"￥"+req.session.user.headUrl;
     }

     var apps=await this.service.findAndCountAll(obj);
     return system.getResult2(apps,null);
   }

  //  async  findAll(q,oid){
  //    var rd=await this.service.findAll();
  //    return system.getResult2(rd,null);
  //     return super.findById(Number(oid.id));
  //  }
}
module.exports=LoopplayCtl;
