module Audit{
  export function getDoipAction(){
    return [
            { value: 0, name: '0.DOIP/Op.Hello' },niz
            { value: 1, name: '0.DOIP/Op.ListOperations' },
            { value: 2, name: '0.DOIP/Op.Retrieve' },
            { value: 3, name: '0.DOIP/Op.Create' },
            { value: 4, name: '0.DOIP/Op.Update' },
            { value: 5, name: '0.DOIP/Op.Delete' },
            { value: 6, name: '0.DOIP/Op.Search' },
            { value: 7, name: '0.DOIP/Op.Extension' },
            { value: 8, name: '0.DOIP/Op.Unknown' }
          ]
  }

  export function getAuditRule(arg){
    // {"repoId":"xxx"}
    var ret = [];
    ret.push({"displayName":"原始数据存证","desc":"原始数据存证到指定数据库，哈希数据存证","type":2});
    ret.push({"displayName":"哈希数据存证","desc":"仅哈希数据存证","type":1});
    ret.push({"displayName":"不存证","desc":"不存证","type":0 });
    return ret;
  }

  //@wyq TODO TODO
  // 这个通过DOIPUtil，去调用
  // DOIP的接口。
  @Description("{\"doId\":\"macjw.ab/repofile\"}");
  export function getDoAuditRule(arg){
    arg = convertArgToJson(arg);
    if(arg.count==undefined) arg.count=10;
    if(arg.offset==undefined) arg.offset=0;
    return org.bdware.sc.controlproxy.RepoProxy.getDoAuditRule(arg);
  }
  //@wyq
  export function setDoAuditRule(arg){
    ///arg={"doIdList":["dd","ddd.xx/xxx",...],"type":1}
    arg =  convertArgToJson(arg);
    if(arg.count==undefined) arg.count=10;
    if(arg.offset==undefined) arg.offset=0;
    return {"msg":"success","code":0};
  }

  //通过AuditProxy实现 @董瑞 需实现支持多标签索引的put接口。
  //======在全领监管->总体情况概览
  //使用以下参数获取DO数量变化趋势
  // interval=1周/1月/1年。。 eventPrefix的数组里为"irp_register"
  //使用以下参数获取操作数量统计
  // interavl= endTime-startTime， eventPrefix的数组里为""
  // 使用以下参数数字对象操作统计
  //eventPrefix为["doip","irp"] 已完成√
  // 使用以下参数获取doip操作统计
  //exentPrefix为["doip_create","doip_update","doip_delete","doip_retrieve","doip_hello","doip_list_operations","doip_search"] 已完成√
  // 使用以下参数获取irp操作统计
  //exentPrefix为["irp_create","irp_delete","irp_update","irp_batch_create","irp_resolution"] 已完成√
  // 使用以下参数获取doip、irp的成功率
  //exentPrefix为["irp_op_success","irp_op_failed"]
  //exentPrefix为["doip_op_success","doip_op_failed"]
   //======在全领监管->总体情况概览
  @Description("{\"doId\":\"86.20.100/repo4/bcrs\",\"startTime\":1644390000000, \"endTime\":1644404400000,\"interval\":3600000, \"eventPrefix\":[\"doip_retrieve\", \"doip_update\", \"doip_search\", \"doip_delete\"]}")
  export function countRecordByDate(arg){
  	arg=convertArgToJson(arg);
   return executeContract("AutoAudit","countRecordByDate",arg).result;
  }

  export function queryByHash(arg){
  	arg=convertArgToJson(arg);
    var ret =  executeContract("AutoAudit","queryByHash",arg.hash).result;
    if (typeof(ret)=='string'){
      var ret2={};
      ret2.code = 1;
      ret2.msg = ret;
      ret = ret2;
    }  else {
      ret.code = 0;
    }
    return ret;
  }

  export function queryByHashOriginal(arg){
  	arg=convertArgToJson(arg);
   return executeContract("AutoAudit","queryByHashOriginal",arg.hash).result;
  }


}