var APIBase = require("../../api.base");
var system = require("../../../system");
const os = require("os")
class ProductAPI extends APIBase {
  constructor() {
    super();
    this.productSve = system.getObject("service.product.productSve")
  }

  async etag (pobj, qobj, req) {
    if (!pobj.actionType) {
      return system.getResult(null, "actionType参数不能为空")
    }
    let result
    switch (pobj.actionType) {
      case 'getPage':
        result = await this.productSve.getPage(pobj.actionBody.page, pobj.actionBody.offset, pobj.actionBody.type)
        return result
      case 'createOrUpdate':
        break
      case 'getAll':
        result = await this.productSve.getAllDic(pobj.actionBody.type)
        return result
      case 'getByIds':
        result = await this.productSve.getByIds(pobj.actionBody.ids)
        break
      case 'getItems':
        break
      default:
        break
    }
  }

  exam () {
    return `<pre><pre/>`;
  }
  classDesc () {
    return {
      groupName: "product",
      groupDesc: "产品引擎",
      name: "ProductApi",
      desc: "产品相关接口",
      exam: "",
    };
  }
  methodDescs () {
    return [
      {
        methodDesc: `<pre><pre/>`,
        methodName: "product",
        paramdescs: [
          {
            paramDesc: "请求的行为，传递如：sjb",
            paramName: "action_process",
            paramType: "string",
            defaultValue: null,
          },
          {
            paramDesc: "业务操作类型，详情见方法中的描述",
            paramName: "action_type",
            paramType: "string",
            defaultValue: null,
          },
          {
            paramDesc: "业务操作类型的参数，action_body必须传递的参数有，times_tamp（时间戳，类型int）、sign(签名,类型string)，其余的为业务需要的参数",
            paramName: "action_body",
            paramType: "json",
            defaultValue: null,
          }
        ],
        rtnTypeDesc: `<pre><pre/>`,
        rtnType: `<pre><pre/>`
      }
    ];
  }
}
module.exports = ProductAPI;