package com.kamco.cd.kamcoback.postgres.repository.scene;

import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx50kEntity.mapInkx50kEntity;

import com.kamco.cd.kamcoback.postgres.entity.MapInkx50kEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;

public class MapInkx50kRepositoryImpl extends QuerydslRepositorySupport
    implements MapInkx50kRepositoryCustom {

  private final JPAQueryFactory queryFactory;

  public MapInkx50kRepositoryImpl(JPAQueryFactory queryFactory) {
    super(MapInkx5kEntity.class);
    this.queryFactory = queryFactory;
  }

  @Override
  public MapInkx50kEntity findByMapidCdParentNo(String mapidcdNo) {
    String parentCd = mapidcdNo.substring(0, 5);
    return queryFactory
        .selectFrom(mapInkx50kEntity)
        .where(mapInkx50kEntity.mapidcdNo.eq(parentCd))
        .fetchOne();
  }
}
