Skip to content

Commit

Permalink
Merge pull request #18 from Staketab/dev
Browse files Browse the repository at this point in the history
implement isNameReserved ednpoint
  • Loading branch information
sineDtS authored Feb 27, 2024
2 parents 3bee3f4 + 7cf9204 commit 09cba0e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,9 @@ public ResponseEntity<DomainEntity> update(@RequestBody DomainUpdateDTO domainUp
return notFound().build();
}
}

@GetMapping("/{domainName}/reserved")
public ResponseEntity<Boolean> isDomainNameReserved(@PathVariable String domainName) {
return ok(domainService.isNameReserved(domainName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Optional;


@Repository
public interface DomainRepository extends JpaRepository<DomainEntity, String> {

Expand All @@ -23,4 +26,6 @@ public interface DomainRepository extends JpaRepository<DomainEntity, String> {
from domains
where owner_address = :accountAddress and (:searchStr is null or name = :searchStr)""")
Page<DomainEntity> findAllDomainsByAccount(String searchStr, String accountAddress, Pageable buildPageable);

Optional<DomainEntity> findDomainEntityByDomainName(String domainName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public interface DomainService {
DomainEntity create(DomainReservationDTO domainRequest);
Optional<DomainEntity> retrieve(String id);
DomainEntity update(DomainUpdateDTO domainUpdateDTO);
Boolean isNameReserved(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ public Optional<DomainEntity> retrieve(String id) {
public DomainEntity update(DomainUpdateDTO domainUpdateDTO) {
return null;
}

@Override
public Boolean isNameReserved(String name) {
return domainRepository.findDomainEntityByDomainName(name).isPresent();
}
}

0 comments on commit 09cba0e

Please sign in to comment.