<%#
 Copyright 2013-2021 the original author or authors from the BegCode project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      https://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
<%_
    const superCall = [];
    // const beans = [];
    // 通过Service一般controller中使用
  if (viaService) {
    beans.push({class: `${entityClass}Service`, instance: `${entityInstance}Service`});
    beans.push({class: `${entityClass}Repository`, instance: `${entityInstance}Repository`});
    if (entityClass !== 'CommonCondition' && databaseTypeSql) {
       // beans.push({class: `CommonConditionQueryService`, instance: `commonConditionQueryService`});
    }
    if (queryService) {
      beans.push({class: `${entityClass}QueryService`, instance: `${entityInstance}QueryService`});
    }
    if (isUsingMapsId && !isController) {
      const mapsIdEntity = mapsIdAssoc.otherEntityNameCapitalized;
      const mapsIdEntityInstance = mapsIdEntity.charAt(0).toLowerCase() + mapsIdEntity.slice(1);
      const mapsIdRepoInstance = `${mapsIdEntityInstance}Repository`;
      beans.push({class: `${mapsIdEntity}Repository`, instance: mapsIdRepoInstance});
    }
  } else {
    beans.push({class: `${entityClass}Repository`, instance: `${entityInstance}Repository`});
    if (constructorName.endsWith('QueryService')) {
      beans.push({class: 'EntityManager', instance: 'em'});
      if (entityClass !== 'CommonTable' && useCommonTable) {
        beans.push({class: 'CommonTableRepository', instance: 'commonTableRepository'});
      }
    }
    if (!constructorName.endsWith('QueryService') && !isController && !cacheProviderNo) {
      beans.push({class: 'CacheManager', instance: 'cacheManager'})
    }
    if (dtoMapstruct) {
      beans.push({class: `${entityClass}Mapper`, instance: `${entityInstance}Mapper`});
    }
    if (searchEngineElasticsearch) {
      beans.push({class: `${entityClass}SearchRepository`, instance: `${entityInstance}SearchRepository`});
    }
    if (isUsingMapsId) {
      const mapsIdEntity = mapsIdAssoc.otherEntityNameCapitalized;
      const mapsIdEntityInstance = mapsIdEntity.charAt(0).toLowerCase() + mapsIdEntity.slice(1);
      const mapsIdRepoInstance = `${mapsIdEntityInstance}Repository`;
      beans.push({class: `${mapsIdEntity}Repository`, instance: mapsIdRepoInstance});
    }
    // add by wangxin start
    if (!isController) {
      if (!(constructorName.endsWith('QueryService') || constructorName.endsWith('QueryServiceImpl'))) {
        // if (entityClass === 'UploadFile' || entityClass === 'UploadImage') {
          // beans.push({class: 'OssProperties', instance: 'ossProperties'});
        // }
        if (extendData && ormTool !== 'mybatis') {
          beans.push({class: 'CommonExtDataService', instance: 'commonExtDataService'});
        }
        if (entityClass === 'ApiPermission') {
          beans.push({class: 'RequestMappingHandlerMapping', instance: 'requestMappingHandlerMapping'});
        }
      }
    }
    // add by wangxin end
  }
  if (saveUserSnapshot && (viaService || constructorName.endsWith('Resource'))) {
    if (!beans.find(bean => (bean.class === 'UserRepository' && bean.instance === 'userRepository'))) { // add by wangxin
      if (!constructorName.endsWith('QueryService')) { // add by wangxin
        beans.push({class: 'UserRepository', instance: 'userRepository'});  // add by wangxin
      }
    } // add by wangxin
  }
_%>

    public <%= constructorName %>(<%= beans.map(bean => `${bean.class} ${bean.instance}`).join(', ') %>) {
        super(<%= beans.map(bean => `${bean.instance}`).join(', ') %>);
    }
