import { IContext, IParam, EntityService } from '@core';

/**
 * {{appEntity.logicName}}服务对象基类
 *
 * @export
 * @class {{pascalCase appEntity.codeName}}
 * @extends {EntityBaseService}
 */
export class {{pascalCase appEntity.codeName}}ServiceBase extends EntityService {
  
  /**
  * Creates an instance of {{pascalCase appEntity.codeName}}ServiceBase.
  *
  * @param {*} [opts={}]
  * @memberof {{pascalCase appEntity.codeName}}ServiceBase
  */
  constructor(opts: IParam = {}) {
      super(opts,'{{pascalCase appEntity.codeName}}');
  }

  /**
   * 初始化基础数据
   *
   * @protected
   * @memberof ChartDataServiceBase
   */
  protected initBasicData() {
    this.appEntityCodeName = '{{lowerCase appEntity.codeName}}';
    this.appEntityCodeNames = '{{pluralize appEntity.codeName}}';
    {{#if appEntity.keyPSAppDEField}}
    this.appEntityKeyCodeName = '{{lowerCase appEntity.keyPSAppDEField.codeName}}';
    {{/if}}
    {{#if appEntity.majorPSAppDEField}}
      this.appEntityTextCodeName = '{{lowerCase appEntity.majorPSAppDEField.codeName}}';
    {{/if}}
    // 初始化关系实体路径集合
    this.deResPaths = [
      {{#each appEntity.appEntityResources as |appEntityResource| }}
        {{appEntityResource.deResPaths}}{{#unless @last}},{{/unless}}
      {{/each}}
    ]
  }

{{#each appEntity.allPSAppDEMethods as |singleAppMethod| }}
  {{! 非内置行为才输出 }}
  {{#if (eq isBuiltinMethod false)}}
  {{! 存在接口方法才输出 }}
  {{#if singleAppMethod.psDEServiceAPIMethod}}
  {{! 远端接口 }}

  {{> @macro/front-end/entity/service-remote-method.hbs singleAppMethod=singleAppMethod}}
  {{/if}}
  {{/if}}
{{/each}}
}