From 8c6914fabfd7eb19b49db3ec5be7c1162426c459 Mon Sep 17 00:00:00 2001 From: ruibaby Date: Sat, 23 Feb 2019 09:08:57 +0800 Subject: [PATCH] :art: add java doc for AbstractCrudService.java and BaseRepositoryImpl.java --- .../repository/base/BaseRepositoryImpl.java | 13 ++ .../service/base/AbstractCrudService.java | 122 +++++++++++++++++- 2 files changed, 134 insertions(+), 1 deletion(-) diff --git a/src/main/java/cc/ryanc/halo/repository/base/BaseRepositoryImpl.java b/src/main/java/cc/ryanc/halo/repository/base/BaseRepositoryImpl.java index 1e6f57bdc..a7e379ec5 100644 --- a/src/main/java/cc/ryanc/halo/repository/base/BaseRepositoryImpl.java +++ b/src/main/java/cc/ryanc/halo/repository/base/BaseRepositoryImpl.java @@ -36,6 +36,13 @@ public class BaseRepositoryImpl extends SimpleJpaRepository findAllByIdIn(Iterable ids, Sort sort) { Assert.notNull(ids, "The given Iterable of Id's must not be null!"); @@ -58,6 +65,12 @@ public class BaseRepositoryImpl extends SimpleJpaRepository ids) { diff --git a/src/main/java/cc/ryanc/halo/service/base/AbstractCrudService.java b/src/main/java/cc/ryanc/halo/service/base/AbstractCrudService.java index 42076339e..645c23cc9 100644 --- a/src/main/java/cc/ryanc/halo/service/base/AbstractCrudService.java +++ b/src/main/java/cc/ryanc/halo/service/base/AbstractCrudService.java @@ -21,7 +21,6 @@ import java.util.Optional; * * @param domain type * @param id type - * * @author johnniang */ public abstract class AbstractCrudService implements CrudService { @@ -52,11 +51,22 @@ public abstract class AbstractCrudService implements CrudService listAll() { return repository.findAll(); } + /** + * List all by sort + * + * @param sort sort + * @return List + */ @Override public List listAll(Sort sort) { Assert.notNull(sort, "Sort info must not be null"); @@ -64,6 +74,12 @@ public abstract class AbstractCrudService implements CrudService listAll(Pageable pageable) { Assert.notNull(pageable, "Pageable info must not be null"); @@ -71,11 +87,24 @@ public abstract class AbstractCrudService implements CrudService listAllByIds(Collection ids) { return CollectionUtils.isEmpty(ids) ? Collections.emptyList() : repository.findAllById(ids); } + /** + * List all by ids and sort + * + * @param ids ids + * @param sort sort + * @return List + */ @Override public List listAllByIds(Collection ids, Sort sort) { Assert.notNull(sort, "Sort info must not be null"); @@ -83,6 +112,12 @@ public abstract class AbstractCrudService implements CrudService fetchById(ID id) { Assert.notNull(id, domainName + " id must not be null"); @@ -90,16 +125,35 @@ public abstract class AbstractCrudService implements CrudService new NotFoundException(domainName + " was not found")); } + /** + * Gets domain of nullable by id. + * + * @param id id + * @return DOMAIN + */ @Override public DOMAIN getByIdOfNullable(ID id) { return fetchById(id).orElse(null); } + /** + * Exists by id. + * + * @param id id + * @return boolean + */ @Override public boolean existsById(ID id) { Assert.notNull(id, domainName + " id must not be null"); @@ -107,6 +161,12 @@ public abstract class AbstractCrudService implements CrudService implements CrudService implements CrudService createInBatch(Collection domains) { return CollectionUtils.isEmpty(domains) ? Collections.emptyList() : repository.saveAll(domains); } + /** + * Updates by domain + * + * @param domain domain + * @return DOMAIN + */ @Override public DOMAIN update(DOMAIN domain) { Assert.notNull(domain, domainName + " data must not be null"); @@ -138,11 +221,24 @@ public abstract class AbstractCrudService implements CrudService updateInBatch(Collection domains) { return CollectionUtils.isEmpty(domains) ? Collections.emptyList() : repository.saveAll(domains); } + /** + * Removes by id + * + * @param id id + * @return DOMAIN + * @throws NotFoundException If the specified id does not exist + */ @Override public DOMAIN removeById(ID id) { // Get non null domain by id @@ -155,6 +251,12 @@ public abstract class AbstractCrudService implements CrudService { @@ -163,6 +265,11 @@ public abstract class AbstractCrudService implements CrudService implements CrudService ids) { if (CollectionUtils.isEmpty(ids)) { @@ -180,6 +292,11 @@ public abstract class AbstractCrudService implements CrudService domains) { if (CollectionUtils.isEmpty(domains)) { @@ -189,6 +306,9 @@ public abstract class AbstractCrudService implements CrudService